summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/ChangeLog79
-rw-r--r--bgpd/IMPLEMENTATION.txt2
-rw-r--r--bgpd/bgp_advertise.c16
-rw-r--r--bgpd/bgp_aspath.c20
-rw-r--r--bgpd/bgp_aspath.h4
-rw-r--r--bgpd/bgp_attr.c93
-rw-r--r--bgpd/bgp_attr.h7
-rw-r--r--bgpd/bgp_clist.c12
-rw-r--r--bgpd/bgp_community.c7
-rw-r--r--bgpd/bgp_damp.c41
-rw-r--r--bgpd/bgp_damp.h2
-rw-r--r--bgpd/bgp_debug.c2
-rw-r--r--bgpd/bgp_dump.c2
-rw-r--r--bgpd/bgp_ecommunity.c8
-rw-r--r--bgpd/bgp_ecommunity.h2
-rw-r--r--bgpd/bgp_filter.c14
-rw-r--r--bgpd/bgp_main.c10
-rw-r--r--bgpd/bgp_network.c158
-rw-r--r--bgpd/bgp_network.h6
-rw-r--r--bgpd/bgp_nexthop.c6
-rw-r--r--bgpd/bgp_packet.c26
-rw-r--r--bgpd/bgp_route.c71
-rw-r--r--bgpd/bgp_route.h21
-rw-r--r--bgpd/bgp_routemap.c5
-rw-r--r--bgpd/bgp_table.c36
-rw-r--r--bgpd/bgp_table.h17
-rw-r--r--bgpd/bgp_vty.c146
-rw-r--r--bgpd/bgp_zebra.c2
-rw-r--r--bgpd/bgpd.c232
-rw-r--r--bgpd/bgpd.conf.sample2
-rw-r--r--bgpd/bgpd.h87
31 files changed, 531 insertions, 605 deletions
diff --git a/bgpd/ChangeLog b/bgpd/ChangeLog
index 4630ab97..6fe2b0f5 100644
--- a/bgpd/ChangeLog
+++ b/bgpd/ChangeLog
@@ -1,3 +1,82 @@
+2008-07-22 Paul Jakma <paul.jakma@sun.com>
+
+ * bgp_{packet,route,advertise}.c: change to compiler testing of
+ DISABLE_BGP_ANNOUNCE, rather than cpp.
+
+2008-07-22 MIYAJIMA Mitsuharu <miyajima.mitsuharu@anchor.jp>
+
+ * bgp_packet.c: (bgp_update_packet_eor) Fix crash triggerable
+ if a bgpd was compiled with --disable-bgp-announce and if GR is
+ advertised by peer.
+
+2008-07-22 Paul Jakma <paul.jakma@sun.com>
+
+ * bgp_community.c: (community_str2com) assigns defaults to local
+ vars
+ * bgp_attr.c: (bgp_attr_parse) match format specifier to arg
+ * bgp_table.{c,h}: (bgp_table_top) can take a * to a const, quelling
+ warning in bgp_route.c
+
+2008-07-21 Paul Jakma <paul.jakma@sun.com>
+
+
+ * bgp_packet.c: (bgp_open_receive) fix warning in a zlog call
+ * bgp_vty.c: (bgp_vty_return) add return code
+ * bgpd.c: (bgp_master_init) setup the socket list.
+ * bgp_network.c: Remove the dual IPv4/6 socket thing for now, which
+ was implemented by Michael, until such time as its clear its
+ required for Linux (see sockopt comments). IPv6 support, including
+ IPv4 sessions on AF_INET6 sockets, therefore is broken, and the
+ '-l 0.0.0.0' arguments would need to be given to bgpd to make
+ things work here.
+
+2008-07-21 Michael H. Warfield <mhw@wittsend.com>
+ YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
+ Tomohiko Kusuda <kusuda@inetcore.com>
+ Leigh Brown <leigh@solinno.co.uk>
+
+ * bgp_network.c: (bgp_md5_set_one) shim between libzebra tcp-md5
+ sockopt and bgpd.
+ (bgp_md5_set_socket) Helper for bgp_connect
+ (bgp_md5_set) setup TCP-MD5SIG for the given peer.
+ (bgp_connect) call out to bgp_md5_set_socket for the outgoing
+ connect socket.
+ (bgp_socket) save references to the listen sockets, needed if
+ TCP-MD5SIG is applied later or changed.
+ * bgp_vty.c: (*neighbor_password_cmd) New 'neighbor ... password'
+ commands.
+ * bgpd.c: (peer_{new,delete) manage TCP-MD5 password
+ (peer_group2peer_config_copy) inherit TCP-MD5 password
+ (peer_password_{un,}set) orchestrate the whole add/remove of TCP-MD5
+ passwords: applying checks, stopping peers, and trying to return
+ errors to UI, etc.
+ (bgp_config_write_peer) save password.
+ Fix missing newline in writeout of neighbor ... port.
+
+2008-07-02 MIYAJIMA Mitsuharu <miyajima.mitsuharu@anchor.jp>
+
+ * *.c: CMD_AS_RANGE was being used inside command strings, and thus
+ not being expanded, fix by dequoting.
+
+2008-07-02 Stephen Hemminger <stephen.hemminger@vyatta.com>
+
+ * bgp_table.{c,h}: (bgp_table_finish) Take a double pointer and
+ scrub pointer in caller, so fixing double-free crashes seen
+ with route-server-client configuration.
+ * *.c: Adjust all callers of bgp_table_finish
+
+2008-07-02 Paul Jakma <paul.jakma@sun.com>
+
+ * bgp_table.{c,h}: (bgp_node_delete, bgp_table_free) shouldn't be
+ exported.
+
+2008-06-07 Paul Jakma <paul@jakma.org>
+
+ * bgp_attr.{c,h}: (bgp_mp_{un,}reach_parse) export, for unit tests.
+ * bgp_attr.c: (bgp_mp_reach_parse) Add logging. Tighten length test
+ to bounds check against the attribute length rather than the
+ stream length..
+
2008-06-01 jfletche@gmail.com
* bgp_attr.c: (bgp_attr_aspathlimit) fix silly bug in flags check
diff --git a/bgpd/IMPLEMENTATION.txt b/bgpd/IMPLEMENTATION.txt
index ac087a38..fff360ab 100644
--- a/bgpd/IMPLEMENTATION.txt
+++ b/bgpd/IMPLEMENTATION.txt
@@ -1,4 +1,4 @@
-$Id$
+$Id: IMPLEMENTATION.txt,v 1.2 2005/02/15 17:10:03 gdt Exp $
This file contains notes about the internals of the BGP
implementation. The initial impetus is understanding the memory usage
diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c
index 73b868a8..b9f4a85b 100644
--- a/bgpd/bgp_advertise.c
+++ b/bgpd/bgp_advertise.c
@@ -72,10 +72,10 @@ baa_hash_key (void *p)
}
static int
-baa_hash_cmp (void *p1, void *p2)
+baa_hash_cmp (const void *p1, const void *p2)
{
- struct bgp_advertise_attr * baa1 = (struct bgp_advertise_attr *) p1;
- struct bgp_advertise_attr * baa2 = (struct bgp_advertise_attr *) p2;
+ const struct bgp_advertise_attr * baa1 = p1;
+ const struct bgp_advertise_attr * baa2 = p2;
return attrhash_cmp (baa1->attr, baa2->attr);
}
@@ -220,9 +220,8 @@ bgp_adj_out_set (struct bgp_node *rn, struct peer *peer, struct prefix *p,
struct bgp_adj_out *adj = NULL;
struct bgp_advertise *adv;
-#ifdef DISABLE_BGP_ANNOUNCE
- return;
-#endif /* DISABLE_BGP_ANNOUNCE */
+ if (DISABLE_BGP_ANNOUNCE)
+ return;
/* Look for adjacency information. */
if (rn)
@@ -274,9 +273,8 @@ bgp_adj_out_unset (struct bgp_node *rn, struct peer *peer, struct prefix *p,
struct bgp_adj_out *adj;
struct bgp_advertise *adv;
-#ifdef DISABLE_BGP_ANNOUNCE
- return;
-#endif /* DISABLE_BGP_ANNOUNCE */
+ if (DISABLE_BGP_ANNOUNCE)
+ return;
/* Lookup existing adjacency, if it is not there return immediately. */
for (adj = rn->adj_out; adj; adj = adj->next)
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index 38c9caa6..242bd8ee 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -322,11 +322,7 @@ assegment_normalise (struct assegment *head)
static struct aspath *
aspath_new (void)
{
- struct aspath *aspath;
-
- aspath = XMALLOC (MTYPE_AS_PATH, sizeof (struct aspath));
- memset (aspath, 0, sizeof (struct aspath));
- return aspath;
+ return XCALLOC (MTYPE_AS_PATH, sizeof (struct aspath));
}
/* Free AS path structure. */
@@ -1347,10 +1343,10 @@ aspath_add_seq (struct aspath *aspath, as_t asno)
/* Compare leftmost AS value for MED check. If as1's leftmost AS and
as2's leftmost AS is same return 1. */
int
-aspath_cmp_left (struct aspath *aspath1, struct aspath *aspath2)
+aspath_cmp_left (const struct aspath *aspath1, const struct aspath *aspath2)
{
- struct assegment *seg1 = NULL;
- struct assegment *seg2 = NULL;
+ const struct assegment *seg1 = NULL;
+ const struct assegment *seg2 = NULL;
if (!(aspath1 && aspath2))
return 0;
@@ -1484,7 +1480,7 @@ aspath_reconcile_as4 ( struct aspath *aspath, struct aspath *as4path)
as2's leftmost AS is same return 1. (confederation as-path
only). */
int
-aspath_cmp_left_confed (struct aspath *aspath1, struct aspath *aspath2)
+aspath_cmp_left_confed (const struct aspath *aspath1, const struct aspath *aspath2)
{
if (! (aspath1 && aspath2) )
return 0;
@@ -1769,10 +1765,10 @@ aspath_key_make (void *p)
/* If two aspath have same value then return 1 else return 0 */
static int
-aspath_cmp (void *arg1, void *arg2)
+aspath_cmp (const void *arg1, const void *arg2)
{
- struct assegment *seg1 = ((struct aspath *)arg1)->segments;
- struct assegment *seg2 = ((struct aspath *)arg2)->segments;
+ const struct assegment *seg1 = ((struct aspath *)arg1)->segments;
+ const struct assegment *seg2 = ((struct aspath *)arg2)->segments;
while (seg1 || seg2)
{
diff --git a/bgpd/bgp_aspath.h b/bgpd/bgp_aspath.h
index d8b41fa9..2b4625c8 100644
--- a/bgpd/bgp_aspath.h
+++ b/bgpd/bgp_aspath.h
@@ -72,8 +72,8 @@ extern struct aspath *aspath_prepend (struct aspath *, struct aspath *);
extern struct aspath *aspath_filter_exclude (struct aspath *, struct aspath *);
extern struct aspath *aspath_add_seq (struct aspath *, as_t);
extern struct aspath *aspath_add_confed_seq (struct aspath *, as_t);
-extern int aspath_cmp_left (struct aspath *, struct aspath *);
-extern int aspath_cmp_left_confed (struct aspath *, struct aspath *);
+extern int aspath_cmp_left (const struct aspath *, const struct aspath *);
+extern int aspath_cmp_left_confed (const struct aspath *, const struct aspath *);
extern struct aspath *aspath_delete_confed_seq (struct aspath *);
extern struct aspath *aspath_empty (void);
extern struct aspath *aspath_empty_get (void);
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index d58ad418..c52c776e 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -131,15 +131,13 @@ cluster_hash_key_make (void *p)
}
static int
-cluster_hash_cmp (void *p1, void *p2)
+cluster_hash_cmp (const void *p1, const void *p2)
{
- struct cluster_list * cluster1 = (struct cluster_list *) p1;
- struct cluster_list * cluster2 = (struct cluster_list *) p2;
+ const struct cluster_list * cluster1 = p1;
+ const struct cluster_list * cluster2 = p2;
- if (cluster1->length == cluster2->length &&
- memcmp (cluster1->list, cluster2->list, cluster1->length) == 0)
- return 1;
- return 0;
+ return (cluster1->length == cluster2->length &&
+ memcmp (cluster1->list, cluster2->list, cluster1->length) == 0);
}
static void
@@ -150,13 +148,13 @@ cluster_free (struct cluster_list *cluster)
XFREE (MTYPE_CLUSTER, cluster);
}
+#if 0
static struct cluster_list *
cluster_dup (struct cluster_list *cluster)
{
struct cluster_list *new;
- new = XMALLOC (MTYPE_CLUSTER, sizeof (struct cluster_list));
- memset (new, 0, sizeof (struct cluster_list));
+ new = XCALLOC (MTYPE_CLUSTER, sizeof (struct cluster_list));
new->length = cluster->length;
if (cluster->length)
@@ -169,6 +167,7 @@ cluster_dup (struct cluster_list *cluster)
return new;
}
+#endif
static struct cluster_list *
cluster_intern (struct cluster_list *cluster)
@@ -267,15 +266,13 @@ transit_hash_key_make (void *p)
}
static int
-transit_hash_cmp (void *p1, void *p2)
+transit_hash_cmp (const void *p1, const void *p2)
{
- struct transit * transit1 = (struct transit *) p1;
- struct transit * transit2 = (struct transit *) p2;
+ const struct transit * transit1 = p1;
+ const struct transit * transit2 = p2;
- if (transit1->length == transit2->length &&
- memcmp (transit1->val, transit2->val, transit1->length) == 0)
- return 1;
- return 0;
+ return (transit1->length == transit2->length &&
+ memcmp (transit1->val, transit2->val, transit1->length) == 0);
}
static void
@@ -393,10 +390,10 @@ attrhash_key_make (void *p)
}
int
-attrhash_cmp (void *p1, void *p2)
+attrhash_cmp (const void *p1, const void *p2)
{
- struct attr * attr1 = (struct attr *) p1;
- struct attr * attr2 = (struct attr *) p2;
+ const struct attr * attr1 = p1;
+ const struct attr * attr2 = p2;
if (attr1->flag == attr2->flag
&& attr1->origin == attr2->origin
@@ -408,8 +405,8 @@ attrhash_cmp (void *p1, void *p2)
&& attr1->pathlimit.ttl == attr2->pathlimit.ttl
&& attr1->pathlimit.as == attr2->pathlimit.as)
{
- struct attr_extra *ae1 = attr1->extra;
- struct attr_extra *ae2 = attr2->extra;
+ const struct attr_extra *ae1 = attr1->extra;
+ const struct attr_extra *ae2 = attr2->extra;
if (ae1 && ae2
&& ae1->aggregator_as == ae2->aggregator_as
@@ -435,7 +432,7 @@ attrhash_cmp (void *p1, void *p2)
}
static void
-attrhash_init ()
+attrhash_init (void)
{
attrhash = hash_create (attrhash_key_make, attrhash_cmp);
}
@@ -1259,7 +1256,7 @@ bgp_attr_cluster_list (struct peer *peer, bgp_size_t length,
}
/* Multiprotocol reachability information parse. */
-static int
+int
bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr,
struct bgp_nlri *mp_update)
{
@@ -1277,8 +1274,13 @@ bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr,
/* safe to read statically sized header? */
#define BGP_MP_REACH_MIN_SIZE 5
+#define LEN_LEFT (length - (stream_get_getp(s) - start))
if ((length > STREAM_READABLE(s)) || (length < BGP_MP_REACH_MIN_SIZE))
- return -1;
+ {
+ zlog_info ("%s: %s sent invalid length, %lu",
+ __func__, peer->host, (unsigned long)length);
+ return -1;
+ }
/* Load AFI, SAFI. */
afi = stream_getw (s);
@@ -1287,8 +1289,12 @@ bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr,
/* Get nexthop length. */
attre->mp_nexthop_len = stream_getc (s);
- if (STREAM_READABLE(s) < attre->mp_nexthop_len)
- return -1;
+ if (LEN_LEFT < attre->mp_nexthop_len)
+ {
+ zlog_info ("%s: %s, MP nexthop length, %u, goes past end of attribute",
+ __func__, peer->host, attre->mp_nexthop_len);
+ return -1;
+ }
/* Nexthop length check. */
switch (attre->mp_nexthop_len)
@@ -1330,13 +1336,17 @@ bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr,
break;
#endif /* HAVE_IPV6 */
default:
- zlog_info ("Wrong multiprotocol next hop length: %d",
- attre->mp_nexthop_len);
+ zlog_info ("%s: (%s) Wrong multiprotocol next hop length: %d",
+ __func__, peer->host, attre->mp_nexthop_len);
return -1;
}
- if (!STREAM_READABLE(s))
- return -1;
+ if (!LEN_LEFT)
+ {
+ zlog_info ("%s: (%s) Failed to read SNPA and NLRI(s)",
+ __func__, peer->host);
+ return -1;
+ }
{
u_char val;
@@ -1346,15 +1356,23 @@ bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr,
}
/* must have nrli_len, what is left of the attribute */
- nlri_len = length - (stream_get_getp(s) - start);
+ nlri_len = LEN_LEFT;
if ((!nlri_len) || (nlri_len > STREAM_READABLE(s)))
- return -1;
+ {
+ zlog_info ("%s: (%s) Failed to read NLRI",
+ __func__, peer->host);
+ return -1;
+ }
if (safi != BGP_SAFI_VPNV4)
{
ret = bgp_nlri_sanity_check (peer, afi, stream_pnt (s), nlri_len);
- if (ret < 0)
- return -1;
+ if (ret < 0)
+ {
+ zlog_info ("%s: (%s) NLRI doesn't pass sanity check",
+ __func__, peer->host);
+ return -1;
+ }
}
mp_update->afi = afi;
@@ -1365,10 +1383,11 @@ bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr,
stream_forward_getp (s, nlri_len);
return 0;
+#undef LEN_LEFT
}
/* Multiprotocol unreachable parse */
-static int
+int
bgp_mp_unreach_parse (struct peer *peer, bgp_size_t length,
struct bgp_nlri *mp_withdraw)
{
@@ -1549,9 +1568,9 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
&& ((endp - startp) < (BGP_ATTR_MIN_LEN + 1)))
{
zlog (peer->log, LOG_WARNING,
- "%s Extended length set, but just %tu bytes of attr header",
+ "%s Extended length set, but just %lu bytes of attr header",
peer->host,
- endp - STREAM_PNT (BGP_INPUT (peer)));
+ (unsigned long) (endp - STREAM_PNT (BGP_INPUT (peer))));
bgp_notify_send (peer,
BGP_NOTIFY_UPDATE_ERR,
diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h
index e152b9f4..12149a17 100644
--- a/bgpd/bgp_attr.h
+++ b/bgpd/bgp_attr.h
@@ -163,7 +163,7 @@ extern bgp_size_t bgp_packet_withdraw (struct peer *peer, struct stream *s,
struct prefix_rd *, u_char *);
extern void bgp_dump_routes_attr (struct stream *, struct attr *,
struct prefix *);
-extern int attrhash_cmp (void *, void *);
+extern int attrhash_cmp (const void *, const void *);
extern unsigned int attrhash_key_make (void *);
extern void attr_show_all (struct vty *);
extern unsigned long int attr_count (void);
@@ -176,4 +176,9 @@ extern void cluster_unintern (struct cluster_list *);
/* Transit attribute prototypes. */
void transit_unintern (struct transit *);
+/* Exported for unit-test purposes only */
+extern int bgp_mp_reach_parse (struct peer *, bgp_size_t, struct attr *,
+ struct bgp_nlri *);
+extern int bgp_mp_unreach_parse (struct peer *, bgp_size_t, struct bgp_nlri *);
+
#endif /* _QUAGGA_BGP_ATTR_H */
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index a6ca1a46..6bf3b64a 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -51,11 +51,7 @@ community_list_master_lookup (struct community_list_handler *ch, int master)
static struct community_entry *
community_entry_new ()
{
- struct community_entry *new;
-
- new = XMALLOC (MTYPE_COMMUNITY_LIST_ENTRY, sizeof (struct community_entry));
- memset (new, 0, sizeof (struct community_entry));
- return new;
+ return XCALLOC (MTYPE_COMMUNITY_LIST_ENTRY, sizeof (struct community_entry));
}
/* Free community list entry. */
@@ -92,11 +88,7 @@ community_entry_free (struct community_entry *entry)
static struct community_list *
community_list_new ()
{
- struct community_list *new;
-
- new = XMALLOC (MTYPE_COMMUNITY_LIST, sizeof (struct community_list));
- memset (new, 0, sizeof (struct community_list));
- return new;
+ return XCALLOC (MTYPE_COMMUNITY_LIST, sizeof (struct community_list));
}
/* Free community-list. */
diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c
index d5e9821b..1cafdb3e 100644
--- a/bgpd/bgp_community.c
+++ b/bgpd/bgp_community.c
@@ -581,8 +581,8 @@ community_str2com (const char *str)
{
struct community *com = NULL;
struct community *com_sort = NULL;
- u_int32_t val;
- enum community_token token;
+ u_int32_t val = 0;
+ enum community_token token = community_token_unknown;
do
{
@@ -633,5 +633,6 @@ community_hash (void)
void
community_init (void)
{
- comhash = hash_create (community_hash_make, community_cmp);
+ comhash = hash_create ((unsigned int (*) (void *))community_hash_make,
+ (int (*) (const void *, const void *))community_cmp);
}
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c
index a0a8557d..ba25f4d1 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -517,29 +517,28 @@ bgp_damp_disable (struct bgp *bgp, afi_t afi, safi_t safi)
return 0;
}
-int
+void
bgp_config_write_damp (struct vty *vty)
{
- if (bgp_damp_cfg.half_life == DEFAULT_HALF_LIFE*60
- && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE
- && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS
- && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4)
- vty_out (vty, " bgp dampening%s", VTY_NEWLINE);
- else if (bgp_damp_cfg.half_life != DEFAULT_HALF_LIFE*60
- && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE
- && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS
- && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4)
- vty_out (vty, " bgp dampening %ld%s",
- bgp_damp_cfg.half_life/60,
- VTY_NEWLINE);
- else
- vty_out (vty, " bgp dampening %ld %d %d %ld%s",
- bgp_damp_cfg.half_life/60,
- bgp_damp_cfg.reuse_limit,
- bgp_damp_cfg.suppress_value,
- bgp_damp_cfg.max_suppress_time/60,
- VTY_NEWLINE);
- return 1;
+ if (bgp_damp_cfg.half_life == DEFAULT_HALF_LIFE*60
+ && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE
+ && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS
+ && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4)
+ vty_out (vty, " bgp dampening%s", VTY_NEWLINE);
+ else if (bgp_damp_cfg.half_life != DEFAULT_HALF_LIFE*60
+ && bgp_damp_cfg.reuse_limit == DEFAULT_REUSE
+ && bgp_damp_cfg.suppress_value == DEFAULT_SUPPRESS
+ && bgp_damp_cfg.max_suppress_time == bgp_damp_cfg.half_life*4)
+ vty_out (vty, " bgp dampening %ld%s",
+ bgp_damp_cfg.half_life/60,
+ VTY_NEWLINE);
+ else
+ vty_out (vty, " bgp dampening %ld %d %d %ld%s",
+ bgp_damp_cfg.half_life/60,
+ bgp_damp_cfg.reuse_limit,
+ bgp_damp_cfg.suppress_value,
+ bgp_damp_cfg.max_suppress_time/60,
+ VTY_NEWLINE);
}
#define BGP_UPTIME_LEN 25
diff --git a/bgpd/bgp_damp.h b/bgpd/bgp_damp.h
index 37ed90bc..17c31cb9 100644
--- a/bgpd/bgp_damp.h
+++ b/bgpd/bgp_damp.h
@@ -140,7 +140,7 @@ extern void bgp_damp_info_free (struct bgp_damp_info *, int);
extern void bgp_damp_info_clean (void);
extern char * bgp_get_reuse_time (unsigned int, char*, size_t);
extern int bgp_damp_decay (time_t, int);
-extern int bgp_config_write_damp (struct vty *);
+extern void bgp_config_write_damp (struct vty *);
extern void bgp_damp_info_vty (struct vty *, struct bgp_info *);
extern char * bgp_damp_reuse_time_vty (struct vty *, struct bgp_info *);
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index 757b9cf8..b7280d93 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -856,7 +856,7 @@ bgp_config_write_debug (struct vty *vty)
return write;
}
-struct cmd_node debug_node =
+static struct cmd_node debug_node =
{
DEBUG_NODE,
"",
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index e815ea3c..53dea805 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -773,7 +773,7 @@ DEFUN (no_dump_bgp_routes,
}
/* BGP node structure. */
-struct cmd_node bgp_dump_node =
+static struct cmd_node bgp_dump_node =
{
DUMP_NODE,
"",
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c
index 9e7ae1b3..c08673ce 100644
--- a/bgpd/bgp_ecommunity.c
+++ b/bgpd/bgp_ecommunity.c
@@ -247,15 +247,13 @@ ecommunity_hash_make (void *arg)
/* Compare two Extended Communities Attribute structure. */
int
-ecommunity_cmp (void *arg1, void *arg2)
+ecommunity_cmp (const void *arg1, const void *arg2)
{
const struct ecommunity *ecom1 = arg1;
const struct ecommunity *ecom2 = arg2;
- if (ecom1->size == ecom2->size
- && memcmp (ecom1->val, ecom2->val, ecom1->size * ECOMMUNITY_SIZE) == 0)
- return 1;
- return 0;
+ return (ecom1->size == ecom2->size
+ && memcmp (ecom1->val, ecom2->val, ecom1->size * ECOMMUNITY_SIZE) == 0);
}
/* Initialize Extended Comminities related hash. */
diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h
index 69014237..278721c8 100644
--- a/bgpd/bgp_ecommunity.h
+++ b/bgpd/bgp_ecommunity.h
@@ -72,7 +72,7 @@ extern struct ecommunity *ecommunity_parse (u_int8_t *, u_short);
extern struct ecommunity *ecommunity_dup (struct ecommunity *);
extern struct ecommunity *ecommunity_merge (struct ecommunity *, struct ecommunity *);
extern struct ecommunity *ecommunity_intern (struct ecommunity *);
-extern int ecommunity_cmp (void *, void *);
+extern int ecommunity_cmp (const void *, const void *);
extern void ecommunity_unintern (struct ecommunity *);
extern unsigned int ecommunity_hash_make (void *);
extern struct ecommunity *ecommunity_str2com (const char *, int, int);
diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c
index ab7f0703..e4cf91af 100644
--- a/bgpd/bgp_filter.c
+++ b/bgpd/bgp_filter.c
@@ -99,11 +99,7 @@ static struct as_list_master as_list_master =
static struct as_filter *
as_filter_new ()
{
- struct as_filter *new;
-
- new = XMALLOC (MTYPE_AS_FILTER, sizeof (struct as_filter));
- memset (new, 0, sizeof (struct as_filter));
- return new;
+ return XCALLOC (MTYPE_AS_FILTER, sizeof (struct as_filter));
}
/* Free allocated AS filter. */
@@ -179,11 +175,7 @@ as_list_lookup (const char *name)
static struct as_list *
as_list_new ()
{
- struct as_list *new;
-
- new = XMALLOC (MTYPE_AS_LIST, sizeof (struct as_list));
- memset (new, 0, sizeof (struct as_list));
- return new;
+ return XCALLOC (MTYPE_AS_LIST, sizeof (struct as_list));
}
static void
@@ -679,7 +671,7 @@ config_write_as_list (struct vty *vty)
return write;
}
-struct cmd_node as_list_node =
+static struct cmd_node as_list_node =
{
AS_LIST_NODE,
"",
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index e6d34afc..2089c6b5 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -203,6 +203,7 @@ main (int argc, char **argv)
int dryrun = 0;
char *progname;
struct thread thread;
+ int tmp_port;
/* Set umask before anything for security */
umask (0027);
@@ -238,7 +239,11 @@ main (int argc, char **argv)
pid_file = optarg;
break;
case 'p':
- bm->port = atoi (optarg);
+ tmp_port = atoi (optarg);
+ if (tmp_port <= 0 || tmp_port > 0xffff)
+ bm->port = BGP_PORT_DEFAULT;
+ else
+ bm->port = tmp_port;
break;
case 'A':
vty_addr = optarg;
@@ -252,7 +257,8 @@ main (int argc, char **argv)
break;
}
vty_port = atoi (optarg);
- vty_port = (vty_port ? vty_port : BGP_VTY_PORT);
+ if (vty_port <= 0 || vty_port > 0xffff)
+ vty_port = BGP_VTY_PORT;
break;
case 'r':
retain_mode = 1;
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index e981e718..87f7f7b6 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -29,6 +29,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "prefix.h"
#include "command.h"
#include "privs.h"
+#include "linklist.h"
#include "bgpd/bgpd.h"
#include "bgpd/bgp_fsm.h"
@@ -39,33 +40,70 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
extern struct zebra_privs_t bgpd_privs;
-#if defined(HAVE_TCP_MD5SIG)
/*
* Set MD5 key for the socket, for the given IPv4 peer address.
* If the password is NULL or zero-length, the option will be disabled.
*/
-int
-bgp_md5_set (int sock, struct sockaddr_in *sin, const char *password)
+static int
+bgp_md5_set_socket (int socket, union sockunion *su, const char *password)
{
- int ret, en;
-
- if ( bgpd_privs.change (ZPRIVS_RAISE) )
- zlog_err ("bgp_md5_set: could not raise privs");
-
- ret = sockopt_tcp_signature (sock, sin, password);
+ int ret = -1;
+ int en = ENOSYS;
+
+ assert (socket >= 0);
+
+#if HAVE_DECL_TCP_MD5SIG
+ ret = sockopt_tcp_signature (socket, su, password);
en = errno;
-
- if (bgpd_privs.change (ZPRIVS_LOWER) )
- zlog_err ("bgp_md5_set: could not lower privs");
-
+#endif /* HAVE_TCP_MD5SIG */
+
if (ret < 0)
zlog (NULL, LOG_WARNING, "can't set TCP_MD5SIG option on socket %d: %s",
- sock, safe_strerror (en));
+ socket, safe_strerror (en));
return ret;
}
+/* Helper for bgp_connect */
+static int
+bgp_md5_set_connect (int socket, union sockunion *su, const char *password)
+{
+ int ret = -1;
+
+#if HAVE_DECL_TCP_MD5SIG
+ if ( bgpd_privs.change (ZPRIVS_RAISE) )
+ {
+ zlog_err ("%s: could not raise privs", __func__);
+ return ret;
+ }
+
+ ret = bgp_md5_set_socket (socket, su, password);
+
+ if (bgpd_privs.change (ZPRIVS_LOWER) )
+ zlog_err ("%s: could not lower privs", __func__);
#endif /* HAVE_TCP_MD5SIG */
+
+ return ret;
+}
+
+int
+bgp_md5_set (struct peer *peer)
+{
+ struct listnode *node;
+ int fret = 0, ret;
+ int *socket;
+
+ /* Just set the password on the listen socket(s). Outbound connections
+ * are taken care of in bgp_connect() below.
+ */
+ for (ALL_LIST_ELEMENTS_RO(bm->listen_sockets, node, socket))
+ {
+ ret = bgp_md5_set_socket ((int )socket, &peer->su, peer->password);
+ if (ret < 0)
+ fret = ret;
+ }
+ return fret;
+}
/* Accept bgp connection. */
static int
@@ -266,17 +304,14 @@ bgp_connect (struct peer *peer)
sockopt_reuseaddr (peer->fd);
sockopt_reuseport (peer->fd);
-
+
#ifdef IPTOS_PREC_INTERNETCONTROL
if (sockunion_family (&peer->su) == AF_INET)
setsockopt_ipv4_tos (peer->fd, IPTOS_PREC_INTERNETCONTROL);
#endif
-#ifdef HAVE_TCP_MD5SIG
- if (CHECK_FLAG (peer->flags, PEER_FLAG_PASSWORD))
- if (sockunion_family (&peer->su) == AF_INET)
- bgp_md5_set (peer->fd, &peer->su.sin, peer->password);
-#endif /* HAVE_TCP_MD5SIG */
+ if (peer->password)
+ bgp_md5_set_connect (peer->fd, &peer->su, peer->password);
/* Bind socket. */
bgp_bind (peer);
@@ -328,10 +363,6 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address)
struct addrinfo req;
struct addrinfo *ainfo;
struct addrinfo *ainfo_save;
-#if defined(HAVE_TCP_MD5SIG) && defined(IPV6_V6ONLY)
- struct sockaddr_in sin;
- int socklen, on = 1;
-#endif
int sock = 0;
char port_str[BUFSIZ];
@@ -372,18 +403,12 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address)
setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL);
#endif
-#if defined(HAVE_TCP_MD5SIG) && defined(IPV6_V6ONLY)
-/* We can not apply MD5SIG to an IPv6 socket. If this is an AF_INET6
- socket, we'll have to create another socket for IPv4*/
-
+#ifdef IPV6_V6ONLY
+ /* Want only IPV6 on ipv6 socket (not mapped addresses) */
if (ainfo->ai_family == AF_INET6) {
-/* Mark this one for IPv6 only */
- ret = setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY,
+ int on = 1;
+ setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY,
(void *) &on, sizeof (on));
- if( ret < 0 ) {
- en = errno;
- zlog_err ("setsockopt V6ONLY: %s", safe_strerror (en));
- }
}
#endif
@@ -409,67 +434,9 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address)
close (sock);
continue;
}
-
-#if defined(HAVE_TCP_MD5SIG) && defined(IPV6_V6ONLY)
- thread_add_read (master, bgp_accept, bgp, sock);
-
- if (ainfo->ai_family != AF_INET6)
- continue;
-
- /* If first socket was an IPv6 socket, we need to create an IPv4
- socket for use by the TCP_MD5SIG logic. This code is blatently
- copied and modified from the alternate IPv4 only code from below... */
-
- sock = socket (AF_INET, SOCK_STREAM, 0);
- if (sock < 0)
- {
- zlog_err ("socket: %s", safe_strerror (errno));
- continue;
- }
-
- sockopt_reuseaddr (sock);
- sockopt_reuseport (sock);
- setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL);
-
- memset (&sin, 0, sizeof (struct sockaddr_in));
-
- sin.sin_family = AF_INET;
- sin.sin_port = htons (port);
- socklen = sizeof (struct sockaddr_in);
-#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
- sin.sin_len = socklen;
-#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */
-
- if ( bgpd_privs.change (ZPRIVS_RAISE) )
- zlog_err ("bgp_socket: could not raise privs");
-
- ret = bind (sock, (struct sockaddr *) &sin, socklen);
- en = errno;
- if (bgpd_privs.change (ZPRIVS_LOWER) )
- zlog_err ("bgp_bind_address: could not lower privs");
-
- if (ret < 0)
- {
- zlog_err ("bind: %s", safe_strerror (en));
- close(sock);
- continue;
- }
-
- ret = listen (sock, 3);
- if (ret < 0)
- {
- zlog_err ("listen: %s", safe_strerror (errno));
- close (sock);
- continue;
- }
-#endif
-
-#ifdef HAVE_TCP_MD5SIG
- bm->sock = sock;
-#endif /* HAVE_TCP_MD5SIG */
-
+
+ listnode_add (bm->listen_sockets, (void *)sock);
thread_add_read (master, bgp_accept, bgp, sock);
-
}
while ((ainfo = ainfo->ai_next) != NULL);
@@ -540,9 +507,6 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address)
close (sock);
return ret;
}
-#ifdef HAVE_TCP_MD5SIG
- bm->sock = sock;
-#endif /* HAVE_TCP_MD5SIG */
thread_add_read (bm->master, bgp_accept, bgp, sock);
diff --git a/bgpd/bgp_network.h b/bgpd/bgp_network.h
index e7119414..618d8dbb 100644
--- a/bgpd/bgp_network.h
+++ b/bgpd/bgp_network.h
@@ -21,12 +21,10 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#ifndef _QUAGGA_BGP_NETWORK_H
#define _QUAGGA_BGP_NETWORK_H
-#if defined(HAVE_TCP_MD5SIG)
-extern int bgp_md5_set (int, struct sockaddr_in *, const char *);
-#endif /* HAVE_TCP_MD5SIG */
-
extern int bgp_socket (struct bgp *, unsigned short, char *);
extern int bgp_connect (struct peer *);
extern void bgp_getsockname (struct peer *);
+extern int bgp_md5_set (struct peer *);
+
#endif /* _QUAGGA_BGP_NETWORK_H */
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 4dd5d946..a184dd4a 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -98,11 +98,7 @@ bnc_nexthop_free (struct bgp_nexthop_cache *bnc)
static struct bgp_nexthop_cache *
bnc_new ()
{
- struct bgp_nexthop_cache *new;
-
- new = XMALLOC (MTYPE_BGP_NEXTHOP_CACHE, sizeof (struct bgp_nexthop_cache));
- memset (new, 0, sizeof (struct bgp_nexthop_cache));
- return new;
+ return XCALLOC (MTYPE_BGP_NEXTHOP_CACHE, sizeof (struct bgp_nexthop_cache));
}
static void
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index f92a88ad..19375ef9 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -235,9 +235,8 @@ bgp_update_packet_eor (struct peer *peer, afi_t afi, safi_t safi)
struct stream *s;
struct stream *packet;
-#ifdef DISABLE_BGP_ANNOUNCE
- return;
-#endif /* DISABLE_BGP_ANNOUNCE */
+ if (DISABLE_BGP_ANNOUNCE)
+ return NULL;
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("send End-of-RIB for %s to %s", afi_safi_print (afi, safi), peer->host);
@@ -369,9 +368,8 @@ bgp_default_update_send (struct peer *peer, struct attr *attr,
char attrstr[BUFSIZ];
char buf[BUFSIZ];
-#ifdef DISABLE_BGP_ANNOUNCE
- return;
-#endif /* DISABLE_BGP_ANNOUNCE */
+ if (DISABLE_BGP_ANNOUNCE)
+ return;
if (afi == AFI_IP)
str2prefix ("0.0.0.0/0", &p);
@@ -438,9 +436,8 @@ bgp_default_withdraw_send (struct peer *peer, afi_t afi, safi_t safi)
bgp_size_t total_attr_len;
char buf[BUFSIZ];
-#ifdef DISABLE_BGP_ANNOUNCE
- return;
-#endif /* DISABLE_BGP_ANNOUNCE */
+ if (DISABLE_BGP_ANNOUNCE)
+ return;
if (afi == AFI_IP)
str2prefix ("0.0.0.0/0", &p);
@@ -960,9 +957,8 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi,
struct bgp_filter *filter;
int orf_refresh = 0;
-#ifdef DISABLE_BGP_ANNOUNCE
- return;
-#endif /* DISABLE_BGP_ANNOUNCE */
+ if (DISABLE_BGP_ANNOUNCE)
+ return;
filter = &peer->filter[afi][safi];
@@ -1190,9 +1186,9 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
/* Receive OPEN message log */
if (BGP_DEBUG (normal, NORMAL))
- zlog_debug ("%s rcv OPEN, version %d, remote-as (in open) %u,"
+ zlog_debug ("%s rcv OPEN, version %d, remote-as (in open) %d,"
" holdtime %d, id %s",
- peer->host, version, (unsigned)remote_as, holdtime,
+ peer->host, version, remote_as, holdtime,
inet_ntoa (remote_id));
/* BEGIN to read the capability here, but dont do it yet */
@@ -1237,7 +1233,7 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
zlog_debug ("%s [AS4] OPEN remote_as is AS_TRANS, but no AS4."
" Odd, but proceeding.", peer->host);
else if (as4 < BGP_AS_MAX && BGP_DEBUG (as4, AS4))
- zlog_debug ("%s [AS4] OPEN remote_as is AS_TRANS, but AS4 %u fits "
+ zlog_debug ("%s [AS4] OPEN remote_as is AS_TRANS, but AS4 (%u) fits "
"in 2-bytes, very odd peer.", peer->host, as4);
if (as4)
remote_as = as4;
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index f8eb7f7f..db8e36d5 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -129,16 +129,11 @@ bgp_info_extra_get (struct bgp_info *ri)
static struct bgp_info *
bgp_info_new ()
{
- struct bgp_info *new;
-
- new = XMALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
- memset (new, 0, sizeof (struct bgp_info));
-
- return new;
+ return XCALLOC (MTYPE_BGP_ROUTE, sizeof (struct bgp_info));
}
/* Free bgp route information. */
-static void
+void
bgp_info_free (struct bgp_info *binfo)
{
if (binfo->attr)
@@ -151,39 +146,6 @@ bgp_info_free (struct bgp_info *binfo)
XFREE (MTYPE_BGP_ROUTE, binfo);
}
-struct bgp_info *
-bgp_info_lock (struct bgp_info *binfo)
-{
- binfo->lock++;
- return binfo;
-}
-
-struct bgp_info *
-bgp_info_unlock (struct bgp_info *binfo)
-{
- assert (binfo && binfo->lock > 0);
- binfo->lock--;
-
- if (binfo->lock == 0)
- {
-#if 0
- zlog_debug ("%s: unlocked and freeing", __func__);
- zlog_backtrace (LOG_DEBUG);
-#endif
- bgp_info_free (binfo);
- return NULL;
- }
-
-#if 0
- if (binfo->lock == 1)
- {
- zlog_debug ("%s: unlocked to 1", __func__);
- zlog_backtrace (LOG_DEBUG);
- }
-#endif
-
- return binfo;
-}
void
bgp_info_add (struct bgp_node *rn, struct bgp_info *ri)
@@ -742,9 +704,8 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
filter = &peer->filter[afi][safi];
bgp = peer->bgp;
-#ifdef DISABLE_BGP_ANNOUNCE
- return 0;
-#endif
+ if (DISABLE_BGP_ANNOUNCE)
+ return 0;
/* Do not send announces to RS-clients from the 'normal' bgp_table. */
if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT))
@@ -1095,9 +1056,8 @@ bgp_announce_check_rsclient (struct bgp_info *ri, struct peer *rsclient,
filter = &rsclient->filter[afi][safi];
bgp = rsclient->bgp;
-#ifdef DISABLE_BGP_ANNOUNCE
- return 0;
-#endif
+ if (DISABLE_BGP_ANNOUNCE)
+ return 0;
/* Do not send back route to sender. */
if (from == rsclient)
@@ -2680,10 +2640,10 @@ bgp_clear_node_complete (struct work_queue *wq)
{
struct peer *peer = wq->spec.data;
- peer_unlock (peer); /* bgp_clear_node_complete */
-
/* Tickle FSM to start moving again */
BGP_EVENT_ADD (peer, Clearing_Completed);
+
+ peer_unlock (peer); /* bgp_clear_node_complete */
}
static void
@@ -3123,10 +3083,7 @@ bgp_nlri_sanity_check (struct peer *peer, int afi, u_char *pnt,
static struct bgp_static *
bgp_static_new ()
{
- struct bgp_static *new;
- new = XMALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
- memset (new, 0, sizeof (struct bgp_static));
- return new;
+ return XCALLOC (MTYPE_BGP_STATIC, sizeof (struct bgp_static));
}
static void
@@ -4511,10 +4468,7 @@ struct bgp_aggregate
static struct bgp_aggregate *
bgp_aggregate_new ()
{
- struct bgp_aggregate *new;
- new = XMALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
- memset (new, 0, sizeof (struct bgp_aggregate));
- return new;
+ return XCALLOC (MTYPE_BGP_AGGREGATE, sizeof (struct bgp_aggregate));
}
static void
@@ -10861,10 +10815,7 @@ struct bgp_distance
static struct bgp_distance *
bgp_distance_new ()
{
- struct bgp_distance *new;
- new = XMALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
- memset (new, 0, sizeof (struct bgp_distance));
- return new;
+ return XCALLOC (MTYPE_BGP_DISTANCE, sizeof (struct bgp_distance));
}
static void
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index e5987972..3e65bb10 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -174,8 +174,25 @@ extern void bgp_clear_route_all (struct peer *);
extern void bgp_clear_adj_in (struct peer *, afi_t, safi_t);
extern void bgp_clear_stale_route (struct peer *, afi_t, safi_t);
-extern struct bgp_info *bgp_info_lock (struct bgp_info *);
-extern struct bgp_info *bgp_info_unlock (struct bgp_info *);
+extern void bgp_info_free (struct bgp_info *);
+
+static inline struct bgp_info *
+bgp_info_lock (struct bgp_info *binfo)
+{
+ binfo->lock++;
+ return binfo;
+}
+
+static inline void
+bgp_info_unlock (struct bgp_info *binfo)
+{
+ assert (binfo && binfo->lock > 0);
+ binfo->lock--;
+
+ if (binfo->lock == 0)
+ bgp_info_free (binfo);
+}
+
extern void bgp_info_add (struct bgp_node *rn, struct bgp_info *ri);
extern void bgp_info_delete (struct bgp_node *rn, struct bgp_info *ri);
extern struct bgp_info_extra *bgp_info_extra_get (struct bgp_info *);
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index b93b2682..78ad3f08 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -47,6 +47,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "bgpd/bgp_filter.h"
#include "bgpd/bgp_mplsvpn.h"
#include "bgpd/bgp_ecommunity.h"
+#include "bgpd/bgp_vty.h"
/* Memo of route-map commands.
@@ -3451,7 +3452,7 @@ DEFUN (no_set_atomic_aggregate,
DEFUN (set_aggregator_as,
set_aggregator_as_cmd,
- "set aggregator as CMD_AS_RANGE A.B.C.D",
+ "set aggregator as " CMD_AS_RANGE " A.B.C.D",
SET_STR
"BGP aggregator attribute\n"
"AS number of aggregator\n"
@@ -3523,7 +3524,7 @@ DEFUN (no_set_aggregator_as,
ALIAS (no_set_aggregator_as,
no_set_aggregator_as_val_cmd,
- "no set aggregator as CMD_AS_RANGE A.B.C.D",
+ "no set aggregator as " CMD_AS_RANGE " A.B.C.D",
NO_STR
SET_STR
"BGP aggregator attribute\n"
diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c
index 5faf5856..15630a24 100644
--- a/bgpd/bgp_table.c
+++ b/bgpd/bgp_table.c
@@ -28,16 +28,15 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h"
-void bgp_node_delete (struct bgp_node *);
-void bgp_table_free (struct bgp_table *);
+static void bgp_node_delete (struct bgp_node *);
+static void bgp_table_free (struct bgp_table *);
struct bgp_table *
bgp_table_init (afi_t afi, safi_t safi)
{
struct bgp_table *rt;
- rt = XMALLOC (MTYPE_BGP_TABLE, sizeof (struct bgp_table));
- memset (rt, 0, sizeof (struct bgp_table));
+ rt = XCALLOC (MTYPE_BGP_TABLE, sizeof (struct bgp_table));
rt->type = BGP_TABLE_MAIN;
rt->afi = afi;
@@ -47,19 +46,16 @@ bgp_table_init (afi_t afi, safi_t safi)
}
void
-bgp_table_finish (struct bgp_table *rt)
+bgp_table_finish (struct bgp_table **rt)
{
- bgp_table_free (rt);
+ bgp_table_free (*rt);
+ *rt = NULL;
}
static struct bgp_node *
bgp_node_create ()
{
- struct bgp_node *rn;
-
- rn = (struct bgp_node *) XMALLOC (MTYPE_BGP_NODE, sizeof (struct bgp_node));
- memset (rn, 0, sizeof (struct bgp_node));
- return rn;
+ return XCALLOC (MTYPE_BGP_NODE, sizeof (struct bgp_node));
}
/* Allocate new route node with prefix set. */
@@ -84,7 +80,7 @@ bgp_node_free (struct bgp_node *node)
}
/* Free route table. */
-void
+static void
bgp_table_free (struct bgp_table *rt)
{
struct bgp_node *tmp_node;
@@ -229,7 +225,7 @@ bgp_unlock_node (struct bgp_node *node)
/* Find matched prefix. */
struct bgp_node *
-bgp_node_match (struct bgp_table *table, struct prefix *p)
+bgp_node_match (const struct bgp_table *table, struct prefix *p)
{
struct bgp_node *node;
struct bgp_node *matched;
@@ -255,7 +251,7 @@ bgp_node_match (struct bgp_table *table, struct prefix *p)
}
struct bgp_node *
-bgp_node_match_ipv4 (struct bgp_table *table, struct in_addr *addr)
+bgp_node_match_ipv4 (const struct bgp_table *table, struct in_addr *addr)
{
struct prefix_ipv4 p;
@@ -269,7 +265,7 @@ bgp_node_match_ipv4 (struct bgp_table *table, struct in_addr *addr)
#ifdef HAVE_IPV6
struct bgp_node *
-bgp_node_match_ipv6 (struct bgp_table *table, struct in6_addr *addr)
+bgp_node_match_ipv6 (const struct bgp_table *table, struct in6_addr *addr)
{
struct prefix_ipv6 p;
@@ -284,7 +280,7 @@ bgp_node_match_ipv6 (struct bgp_table *table, struct in6_addr *addr)
/* Lookup same prefix node. Return NULL when we can't find route. */
struct bgp_node *
-bgp_node_lookup (struct bgp_table *table, struct prefix *p)
+bgp_node_lookup (const struct bgp_table *table, struct prefix *p)
{
struct bgp_node *node;
@@ -304,7 +300,7 @@ bgp_node_lookup (struct bgp_table *table, struct prefix *p)
/* Add node to routing table. */
struct bgp_node *
-bgp_node_get (struct bgp_table *table, struct prefix *p)
+bgp_node_get (struct bgp_table *const table, struct prefix *p)
{
struct bgp_node *new;
struct bgp_node *node;
@@ -360,7 +356,7 @@ bgp_node_get (struct bgp_table *table, struct prefix *p)
}
/* Delete node from the routing table. */
-void
+static void
bgp_node_delete (struct bgp_node *node)
{
struct bgp_node *child;
@@ -405,7 +401,7 @@ bgp_node_delete (struct bgp_node *node)
/* Get fist node and lock it. This function is useful when one want
to lookup all the node exist in the routing table. */
struct bgp_node *
-bgp_table_top (struct bgp_table *table)
+bgp_table_top (const struct bgp_table *const table)
{
/* If there is no node in the routing table return NULL. */
if (table->top == NULL)
@@ -499,7 +495,7 @@ bgp_route_next_until (struct bgp_node *node, struct bgp_node *limit)
}
unsigned long
-bgp_table_count (struct bgp_table *table)
+bgp_table_count (const struct bgp_table *table)
{
return table->count;
}
diff --git a/bgpd/bgp_table.h b/bgpd/bgp_table.h
index 62421e71..dfa7e1f3 100644
--- a/bgpd/bgp_table.h
+++ b/bgpd/bgp_table.h
@@ -68,21 +68,20 @@ struct bgp_node
};
extern struct bgp_table *bgp_table_init (afi_t, safi_t);
-extern void bgp_table_finish (struct bgp_table *);
+extern void bgp_table_finish (struct bgp_table **);
extern void bgp_unlock_node (struct bgp_node *node);
-extern void bgp_node_delete (struct bgp_node *node);
-extern struct bgp_node *bgp_table_top (struct bgp_table *);
+extern struct bgp_node *bgp_table_top (const struct bgp_table *const);
extern struct bgp_node *bgp_route_next (struct bgp_node *);
extern struct bgp_node *bgp_route_next_until (struct bgp_node *, struct bgp_node *);
-extern struct bgp_node *bgp_node_get (struct bgp_table *, struct prefix *);
-extern struct bgp_node *bgp_node_lookup (struct bgp_table *, struct prefix *);
+extern struct bgp_node *bgp_node_get (struct bgp_table *const, struct prefix *);
+extern struct bgp_node *bgp_node_lookup (const struct bgp_table *const, struct prefix *);
extern struct bgp_node *bgp_lock_node (struct bgp_node *node);
-extern struct bgp_node *bgp_node_match (struct bgp_table *, struct prefix *);
-extern struct bgp_node *bgp_node_match_ipv4 (struct bgp_table *,
+extern struct bgp_node *bgp_node_match (const struct bgp_table *, struct prefix *);
+extern struct bgp_node *bgp_node_match_ipv4 (const struct bgp_table *,
struct in_addr *);
#ifdef HAVE_IPV6
-extern struct bgp_node *bgp_node_match_ipv6 (struct bgp_table *,
+extern struct bgp_node *bgp_node_match_ipv6 (const struct bgp_table *,
struct in6_addr *);
#endif /* HAVE_IPV6 */
-extern unsigned long bgp_table_count (struct bgp_table *);
+extern unsigned long bgp_table_count (const struct bgp_table *const);
#endif /* _QUAGGA_BGP_TABLE_H */
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 0e689359..fc560d17 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -210,6 +210,9 @@ bgp_vty_return (struct vty *vty, int ret)
case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS:
str = "Cannot have local-as same as BGP AS number";
break;
+ case BGP_ERR_TCPSIG_FAILED:
+ str = "Error while applying TCP-Sig to session(s)";
+ break;
}
if (str)
{
@@ -308,7 +311,7 @@ DEFUN_DEPRECATED (neighbor_version,
/* "router bgp" commands. */
DEFUN (router_bgp,
router_bgp_cmd,
- "router bgp CMD_AS_RANGE",
+ "router bgp " CMD_AS_RANGE,
ROUTER_STR
BGP_STR
AS_STR)
@@ -331,12 +334,12 @@ DEFUN (router_bgp,
VTY_NEWLINE);
return CMD_WARNING;
case BGP_ERR_AS_MISMATCH:
- vty_out (vty, "BGP is already running; AS is %u%s", (unsigned)as, VTY_NEWLINE);
+ vty_out (vty, "BGP is already running; AS is %d%s", as, VTY_NEWLINE);
return CMD_WARNING;
case BGP_ERR_INSTANCE_MISMATCH:
vty_out (vty, "BGP view name and AS number mismatch%s", VTY_NEWLINE);
- vty_out (vty, "BGP instance is already running; AS is %u%s",
- (unsigned)as, VTY_NEWLINE);
+ vty_out (vty, "BGP instance is already running; AS is %d%s",
+ as, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -348,7 +351,7 @@ DEFUN (router_bgp,
ALIAS (router_bgp,
router_bgp_view_cmd,
- "router bgp CMD_AS_RANGE view WORD",
+ "router bgp " CMD_AS_RANGE " view WORD",
ROUTER_STR
BGP_STR
AS_STR
@@ -358,7 +361,7 @@ ALIAS (router_bgp,
/* "no router bgp" commands. */
DEFUN (no_router_bgp,
no_router_bgp_cmd,
- "no router bgp CMD_AS_RANGE",
+ "no router bgp " CMD_AS_RANGE,
NO_STR
ROUTER_STR
BGP_STR
@@ -388,7 +391,7 @@ DEFUN (no_router_bgp,
ALIAS (no_router_bgp,
no_router_bgp_view_cmd,
- "no router bgp CMD_AS_RANGE view WORD",
+ "no router bgp " CMD_AS_RANGE " view WORD",
NO_STR
ROUTER_STR
BGP_STR
@@ -539,7 +542,7 @@ ALIAS (no_bgp_cluster_id,
DEFUN (bgp_confederation_identifier,
bgp_confederation_identifier_cmd,
- "bgp confederation identifier CMD_AS_RANGE",
+ "bgp confederation identifier " CMD_AS_RANGE,
"BGP specific commands\n"
"AS confederation parameters\n"
"AS number\n"
@@ -580,7 +583,7 @@ DEFUN (no_bgp_confederation_identifier,
ALIAS (no_bgp_confederation_identifier,
no_bgp_confederation_identifier_arg_cmd,
- "no bgp confederation identifier CMD_AS_RANGE",
+ "no bgp confederation identifier " CMD_AS_RANGE,
NO_STR
"BGP specific commands\n"
"AS confederation parameters\n"
@@ -589,7 +592,7 @@ ALIAS (no_bgp_confederation_identifier,
DEFUN (bgp_confederation_peers,
bgp_confederation_peers_cmd,
- "bgp confederation peers .CMD_AS_RANGE",
+ "bgp confederation peers ." CMD_AS_RANGE,
"BGP specific commands\n"
"AS confederation parameters\n"
"Peer ASs in BGP confederation\n"
@@ -619,7 +622,7 @@ DEFUN (bgp_confederation_peers,
DEFUN (no_bgp_confederation_peers,
no_bgp_confederation_peers_cmd,
- "no bgp confederation peers .CMD_AS_RANGE",
+ "no bgp confederation peers ." CMD_AS_RANGE,
NO_STR
"BGP specific commands\n"
"AS confederation parameters\n"
@@ -1277,10 +1280,10 @@ peer_remote_as_vty (struct vty *vty, const char *peer_str,
switch (ret)
{
case BGP_ERR_PEER_GROUP_MEMBER:
- vty_out (vty, "%% Peer-group AS %u. Cannot configure remote-as for member%s", (unsigned)as, VTY_NEWLINE);
+ vty_out (vty, "%% Peer-group AS %d. Cannot configure remote-as for member%s", as, VTY_NEWLINE);
return CMD_WARNING;
case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT:
- vty_out (vty, "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external%s", (unsigned)as, as_str, VTY_NEWLINE);
+ vty_out (vty, "%% The AS# can not be changed from %d to %s, peer-group members must be all internal or all external%s", as, as_str, VTY_NEWLINE);
return CMD_WARNING;
}
return bgp_vty_return (vty, ret);
@@ -1288,7 +1291,7 @@ peer_remote_as_vty (struct vty *vty, const char *peer_str,
DEFUN (neighbor_remote_as,
neighbor_remote_as_cmd,
- NEIGHBOR_CMD2 "remote-as CMD_AS_RANGE",
+ NEIGHBOR_CMD2 "remote-as " CMD_AS_RANGE,
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Specify a BGP neighbor\n"
@@ -1352,7 +1355,7 @@ DEFUN (no_neighbor,
ALIAS (no_neighbor,
no_neighbor_remote_as_cmd,
- NO_NEIGHBOR_CMD "remote-as CMD_AS_RANGE",
+ NO_NEIGHBOR_CMD "remote-as " CMD_AS_RANGE,
NO_STR
NEIGHBOR_STR
NEIGHBOR_ADDR_STR
@@ -1382,7 +1385,7 @@ DEFUN (no_neighbor_peer_group,
DEFUN (no_neighbor_peer_group_remote_as,
no_neighbor_peer_group_remote_as_cmd,
- "no neighbor WORD remote-as CMD_AS_RANGE",
+ "no neighbor WORD remote-as " CMD_AS_RANGE,
NO_STR
NEIGHBOR_STR
"Neighbor tag\n"
@@ -1404,7 +1407,7 @@ DEFUN (no_neighbor_peer_group_remote_as,
DEFUN (neighbor_local_as,
neighbor_local_as_cmd,
- NEIGHBOR_CMD2 "local-as CMD_AS_RANGE",
+ NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Specify a local-as number\n"
@@ -1423,7 +1426,7 @@ DEFUN (neighbor_local_as,
DEFUN (neighbor_local_as_no_prepend,
neighbor_local_as_no_prepend_cmd,
- NEIGHBOR_CMD2 "local-as CMD_AS_RANGE no-prepend",
+ NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Specify a local-as number\n"
@@ -1462,7 +1465,7 @@ DEFUN (no_neighbor_local_as,
ALIAS (no_neighbor_local_as,
no_neighbor_local_as_val_cmd,
- NO_NEIGHBOR_CMD2 "local-as CMD_AS_RANGE",
+ NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE,
NO_STR
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
@@ -1471,7 +1474,7 @@ ALIAS (no_neighbor_local_as,
ALIAS (no_neighbor_local_as,
no_neighbor_local_as_val2_cmd,
- NO_NEIGHBOR_CMD2 "local-as CMD_AS_RANGE no-prepend",
+ NO_NEIGHBOR_CMD2 "local-as " CMD_AS_RANGE " no-prepend",
NO_STR
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
@@ -1479,7 +1482,6 @@ ALIAS (no_neighbor_local_as,
"AS number used as local AS\n"
"Do not prepend local-as to updates from ebgp peers\n")
-#ifdef HAVE_TCP_MD5SIG
DEFUN (neighbor_password,
neighbor_password_cmd,
NEIGHBOR_CMD2 "password LINE",
@@ -1517,7 +1519,6 @@ DEFUN (no_neighbor_password,
ret = peer_password_unset (peer);
return bgp_vty_return (vty, ret);
}
-#endif /* HAVE_TCP_MD5SIG */
DEFUN (neighbor_activate,
neighbor_activate_cmd,
@@ -1600,7 +1601,7 @@ DEFUN (neighbor_set_peer_group,
if (ret == BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT)
{
- vty_out (vty, "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external%s", (unsigned)as, VTY_NEWLINE);
+ vty_out (vty, "%% Peer with AS %d cannot be in this peer-group, members must be all internal or all external%s", as, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -2193,8 +2194,7 @@ peer_rsclient_unset_vty (struct vty *vty, const char *peer_str,
listnode_delete (bgp->rsclient, peer);
}
- bgp_table_finish (peer->rib[afi][safi]);
- peer->rib[afi][safi] = NULL;
+ bgp_table_finish (&peer->rib[bgp_node_afi(vty)][bgp_node_safi(vty)]);
return CMD_SUCCESS;
}
@@ -4363,7 +4363,7 @@ ALIAS (clear_ip_bgp_external,
DEFUN (clear_ip_bgp_as,
clear_ip_bgp_as_cmd,
- "clear ip bgp CMD_AS_RANGE",
+ "clear ip bgp " CMD_AS_RANGE,
CLEAR_STR
IP_STR
BGP_STR
@@ -4374,14 +4374,14 @@ DEFUN (clear_ip_bgp_as,
ALIAS (clear_ip_bgp_as,
clear_bgp_as_cmd,
- "clear bgp CMD_AS_RANGE",
+ "clear bgp " CMD_AS_RANGE,
CLEAR_STR
BGP_STR
"Clear peers with the AS number\n")
ALIAS (clear_ip_bgp_as,
clear_bgp_ipv6_as_cmd,
- "clear bgp ipv6 CMD_AS_RANGE",
+ "clear bgp ipv6 " CMD_AS_RANGE,
CLEAR_STR
BGP_STR
"Address family\n"
@@ -4893,7 +4893,7 @@ ALIAS (clear_bgp_external_soft_out,
DEFUN (clear_ip_bgp_as_soft_out,
clear_ip_bgp_as_soft_out_cmd,
- "clear ip bgp CMD_AS_RANGE soft out",
+ "clear ip bgp " CMD_AS_RANGE " soft out",
CLEAR_STR
IP_STR
BGP_STR
@@ -4907,7 +4907,7 @@ DEFUN (clear_ip_bgp_as_soft_out,
ALIAS (clear_ip_bgp_as_soft_out,
clear_ip_bgp_as_out_cmd,
- "clear ip bgp CMD_AS_RANGE out",
+ "clear ip bgp " CMD_AS_RANGE " out",
CLEAR_STR
IP_STR
BGP_STR
@@ -4916,7 +4916,7 @@ ALIAS (clear_ip_bgp_as_soft_out,
DEFUN (clear_ip_bgp_as_ipv4_soft_out,
clear_ip_bgp_as_ipv4_soft_out_cmd,
- "clear ip bgp CMD_AS_RANGE ipv4 (unicast|multicast) soft out",
+ "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out",
CLEAR_STR
IP_STR
BGP_STR
@@ -4937,7 +4937,7 @@ DEFUN (clear_ip_bgp_as_ipv4_soft_out,
ALIAS (clear_ip_bgp_as_ipv4_soft_out,
clear_ip_bgp_as_ipv4_out_cmd,
- "clear ip bgp CMD_AS_RANGE ipv4 (unicast|multicast) out",
+ "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out",
CLEAR_STR
IP_STR
BGP_STR
@@ -4949,7 +4949,7 @@ ALIAS (clear_ip_bgp_as_ipv4_soft_out,
DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
clear_ip_bgp_as_vpnv4_soft_out_cmd,
- "clear ip bgp CMD_AS_RANGE vpnv4 unicast soft out",
+ "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out",
CLEAR_STR
IP_STR
BGP_STR
@@ -4965,7 +4965,7 @@ DEFUN (clear_ip_bgp_as_vpnv4_soft_out,
ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
clear_ip_bgp_as_vpnv4_out_cmd,
- "clear ip bgp CMD_AS_RANGE vpnv4 unicast out",
+ "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out",
CLEAR_STR
IP_STR
BGP_STR
@@ -4976,7 +4976,7 @@ ALIAS (clear_ip_bgp_as_vpnv4_soft_out,
DEFUN (clear_bgp_as_soft_out,
clear_bgp_as_soft_out_cmd,
- "clear bgp CMD_AS_RANGE soft out",
+ "clear bgp " CMD_AS_RANGE " soft out",
CLEAR_STR
BGP_STR
"Clear peers with the AS number\n"
@@ -4989,7 +4989,7 @@ DEFUN (clear_bgp_as_soft_out,
ALIAS (clear_bgp_as_soft_out,
clear_bgp_ipv6_as_soft_out_cmd,
- "clear bgp ipv6 CMD_AS_RANGE soft out",
+ "clear bgp ipv6 " CMD_AS_RANGE " soft out",
CLEAR_STR
BGP_STR
"Address family\n"
@@ -4999,7 +4999,7 @@ ALIAS (clear_bgp_as_soft_out,
ALIAS (clear_bgp_as_soft_out,
clear_bgp_as_out_cmd,
- "clear bgp CMD_AS_RANGE out",
+ "clear bgp " CMD_AS_RANGE " out",
CLEAR_STR
BGP_STR
"Clear peers with the AS number\n"
@@ -5007,7 +5007,7 @@ ALIAS (clear_bgp_as_soft_out,
ALIAS (clear_bgp_as_soft_out,
clear_bgp_ipv6_as_out_cmd,
- "clear bgp ipv6 CMD_AS_RANGE out",
+ "clear bgp ipv6 " CMD_AS_RANGE " out",
CLEAR_STR
BGP_STR
"Address family\n"
@@ -5797,7 +5797,7 @@ ALIAS (clear_bgp_external_in_prefix_filter,
DEFUN (clear_ip_bgp_as_soft_in,
clear_ip_bgp_as_soft_in_cmd,
- "clear ip bgp CMD_AS_RANGE soft in",
+ "clear ip bgp " CMD_AS_RANGE " soft in",
CLEAR_STR
IP_STR
BGP_STR
@@ -5811,7 +5811,7 @@ DEFUN (clear_ip_bgp_as_soft_in,
ALIAS (clear_ip_bgp_as_soft_in,
clear_ip_bgp_as_in_cmd,
- "clear ip bgp CMD_AS_RANGE in",
+ "clear ip bgp " CMD_AS_RANGE " in",
CLEAR_STR
IP_STR
BGP_STR
@@ -5820,7 +5820,7 @@ ALIAS (clear_ip_bgp_as_soft_in,
DEFUN (clear_ip_bgp_as_in_prefix_filter,
clear_ip_bgp_as_in_prefix_filter_cmd,
- "clear ip bgp CMD_AS_RANGE in prefix-filter",
+ "clear ip bgp " CMD_AS_RANGE " in prefix-filter",
CLEAR_STR
IP_STR
BGP_STR
@@ -5834,7 +5834,7 @@ DEFUN (clear_ip_bgp_as_in_prefix_filter,
DEFUN (clear_ip_bgp_as_ipv4_soft_in,
clear_ip_bgp_as_ipv4_soft_in_cmd,
- "clear ip bgp CMD_AS_RANGE ipv4 (unicast|multicast) soft in",
+ "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in",
CLEAR_STR
IP_STR
BGP_STR
@@ -5855,7 +5855,7 @@ DEFUN (clear_ip_bgp_as_ipv4_soft_in,
ALIAS (clear_ip_bgp_as_ipv4_soft_in,
clear_ip_bgp_as_ipv4_in_cmd,
- "clear ip bgp CMD_AS_RANGE ipv4 (unicast|multicast) in",
+ "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in",
CLEAR_STR
IP_STR
BGP_STR
@@ -5867,7 +5867,7 @@ ALIAS (clear_ip_bgp_as_ipv4_soft_in,
DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
clear_ip_bgp_as_ipv4_in_prefix_filter_cmd,
- "clear ip bgp CMD_AS_RANGE ipv4 (unicast|multicast) in prefix-filter",
+ "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter",
CLEAR_STR
IP_STR
BGP_STR
@@ -5888,7 +5888,7 @@ DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter,
DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
clear_ip_bgp_as_vpnv4_soft_in_cmd,
- "clear ip bgp CMD_AS_RANGE vpnv4 unicast soft in",
+ "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in",
CLEAR_STR
IP_STR
BGP_STR
@@ -5904,7 +5904,7 @@ DEFUN (clear_ip_bgp_as_vpnv4_soft_in,
ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
clear_ip_bgp_as_vpnv4_in_cmd,
- "clear ip bgp CMD_AS_RANGE vpnv4 unicast in",
+ "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in",
CLEAR_STR
IP_STR
BGP_STR
@@ -5915,7 +5915,7 @@ ALIAS (clear_ip_bgp_as_vpnv4_soft_in,
DEFUN (clear_bgp_as_soft_in,
clear_bgp_as_soft_in_cmd,
- "clear bgp CMD_AS_RANGE soft in",
+ "clear bgp " CMD_AS_RANGE " soft in",
CLEAR_STR
BGP_STR
"Clear peers with the AS number\n"
@@ -5928,7 +5928,7 @@ DEFUN (clear_bgp_as_soft_in,
ALIAS (clear_bgp_as_soft_in,
clear_bgp_ipv6_as_soft_in_cmd,
- "clear bgp ipv6 CMD_AS_RANGE soft in",
+ "clear bgp ipv6 " CMD_AS_RANGE " soft in",
CLEAR_STR
BGP_STR
"Address family\n"
@@ -5938,7 +5938,7 @@ ALIAS (clear_bgp_as_soft_in,
ALIAS (clear_bgp_as_soft_in,
clear_bgp_as_in_cmd,
- "clear bgp CMD_AS_RANGE in",
+ "clear bgp " CMD_AS_RANGE " in",
CLEAR_STR
BGP_STR
"Clear peers with the AS number\n"
@@ -5946,7 +5946,7 @@ ALIAS (clear_bgp_as_soft_in,
ALIAS (clear_bgp_as_soft_in,
clear_bgp_ipv6_as_in_cmd,
- "clear bgp ipv6 CMD_AS_RANGE in",
+ "clear bgp ipv6 " CMD_AS_RANGE " in",
CLEAR_STR
BGP_STR
"Address family\n"
@@ -5955,7 +5955,7 @@ ALIAS (clear_bgp_as_soft_in,
DEFUN (clear_bgp_as_in_prefix_filter,
clear_bgp_as_in_prefix_filter_cmd,
- "clear bgp CMD_AS_RANGE in prefix-filter",
+ "clear bgp " CMD_AS_RANGE " in prefix-filter",
CLEAR_STR
BGP_STR
"Clear peers with the AS number\n"
@@ -5968,7 +5968,7 @@ DEFUN (clear_bgp_as_in_prefix_filter,
ALIAS (clear_bgp_as_in_prefix_filter,
clear_bgp_ipv6_as_in_prefix_filter_cmd,
- "clear bgp ipv6 CMD_AS_RANGE in prefix-filter",
+ "clear bgp ipv6 " CMD_AS_RANGE " in prefix-filter",
CLEAR_STR
BGP_STR
"Address family\n"
@@ -6283,7 +6283,7 @@ ALIAS (clear_bgp_external_soft,
DEFUN (clear_ip_bgp_as_soft,
clear_ip_bgp_as_soft_cmd,
- "clear ip bgp CMD_AS_RANGE soft",
+ "clear ip bgp " CMD_AS_RANGE " soft",
CLEAR_STR
IP_STR
BGP_STR
@@ -6296,7 +6296,7 @@ DEFUN (clear_ip_bgp_as_soft,
DEFUN (clear_ip_bgp_as_ipv4_soft,
clear_ip_bgp_as_ipv4_soft_cmd,
- "clear ip bgp CMD_AS_RANGE ipv4 (unicast|multicast) soft",
+ "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft",
CLEAR_STR
IP_STR
BGP_STR
@@ -6316,7 +6316,7 @@ DEFUN (clear_ip_bgp_as_ipv4_soft,
DEFUN (clear_ip_bgp_as_vpnv4_soft,
clear_ip_bgp_as_vpnv4_soft_cmd,
- "clear ip bgp CMD_AS_RANGE vpnv4 unicast soft",
+ "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft",
CLEAR_STR
IP_STR
BGP_STR
@@ -6331,7 +6331,7 @@ DEFUN (clear_ip_bgp_as_vpnv4_soft,
DEFUN (clear_bgp_as_soft,
clear_bgp_as_soft_cmd,
- "clear bgp CMD_AS_RANGE soft",
+ "clear bgp " CMD_AS_RANGE " soft",
CLEAR_STR
BGP_STR
"Clear peers with the AS number\n"
@@ -6343,7 +6343,7 @@ DEFUN (clear_bgp_as_soft,
ALIAS (clear_bgp_as_soft,
clear_bgp_ipv6_as_soft_cmd,
- "clear bgp ipv6 CMD_AS_RANGE soft",
+ "clear bgp ipv6 " CMD_AS_RANGE " soft",
CLEAR_STR
BGP_STR
"Address family\n"
@@ -6669,8 +6669,8 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
/* Usage summary and header */
vty_out (vty,
- "BGP router identifier %s, local AS number %u%s",
- inet_ntoa (bgp->router_id), (unsigned)bgp->as, VTY_NEWLINE);
+ "BGP router identifier %s, local AS number %d%s",
+ inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE);
ents = bgp_table_count (bgp->rib[afi][safi]);
vty_out (vty, "RIB entries %ld, using %s of memory%s", ents,
@@ -6716,8 +6716,8 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi)
vty_out (vty, "4 ");
- vty_out (vty, "%5u %7d %7d %8d %4d %4lu ",
- (unsigned)peer->as,
+ vty_out (vty, "%5d %7d %7d %8d %4d %4lu ",
+ peer->as,
peer->open_in + peer->update_in + peer->keepalive_in
+ peer->notify_in + peer->refresh_in + peer->dynamic_cap_in,
peer->open_out + peer->update_out + peer->keepalive_out
@@ -7226,9 +7226,9 @@ bgp_show_peer (struct vty *vty, struct peer *p)
/* Configured IP address. */
vty_out (vty, "BGP neighbor is %s, ", p->host);
- vty_out (vty, "remote AS %u, ", (unsigned)p->as);
- vty_out (vty, "local AS %u%s, ",
- p->change_local_as ? (unsigned)p->change_local_as : (unsigned)p->local_as,
+ vty_out (vty, "remote AS %d, ", p->as);
+ vty_out (vty, "local AS %d%s, ",
+ p->change_local_as ? p->change_local_as : p->local_as,
CHECK_FLAG (p->flags, PEER_FLAG_LOCAL_AS_NO_PREPEND) ?
" no-prepend" : "");
vty_out (vty, "%s link%s",
@@ -8009,7 +8009,7 @@ bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp,
"Route Server's BGP router identifier %s%s",
inet_ntoa (bgp->router_id), VTY_NEWLINE);
vty_out (vty,
- "Route Server's local AS number %u%s", (unsigned)bgp->as,
+ "Route Server's local AS number %d%s", bgp->as,
VTY_NEWLINE);
vty_out (vty, "%s", VTY_NEWLINE);
@@ -8749,42 +8749,42 @@ bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi,
}
/* BGP node structure. */
-struct cmd_node bgp_node =
+static struct cmd_node bgp_node =
{
BGP_NODE,
"%s(config-router)# ",
1,
};
-struct cmd_node bgp_ipv4_unicast_node =
+static struct cmd_node bgp_ipv4_unicast_node =
{
BGP_IPV4_NODE,
"%s(config-router-af)# ",
1,
};
-struct cmd_node bgp_ipv4_multicast_node =
+static struct cmd_node bgp_ipv4_multicast_node =
{
BGP_IPV4M_NODE,
"%s(config-router-af)# ",
1,
};
-struct cmd_node bgp_ipv6_unicast_node =
+static struct cmd_node bgp_ipv6_unicast_node =
{
BGP_IPV6_NODE,
"%s(config-router-af)# ",
1,
};
-struct cmd_node bgp_ipv6_multicast_node =
+static struct cmd_node bgp_ipv6_multicast_node =
{
BGP_IPV6M_NODE,
"%s(config-router-af)# ",
1,
};
-struct cmd_node bgp_vpnv4_node =
+static struct cmd_node bgp_vpnv4_node =
{
BGP_VPNV4_NODE,
"%s(config-router-af)# ",
@@ -8938,11 +8938,9 @@ bgp_vty_init (void)
install_element (BGP_NODE, &no_neighbor_local_as_val_cmd);
install_element (BGP_NODE, &no_neighbor_local_as_val2_cmd);
-#ifdef HAVE_TCP_MD5SIG
/* "neighbor password" commands. */
install_element (BGP_NODE, &neighbor_password_cmd);
install_element (BGP_NODE, &no_neighbor_password_cmd);
-#endif /* HAVE_TCP_MD5SIG */
/* "neighbor activate" commands. */
install_element (BGP_NODE, &neighbor_activate_cmd);
@@ -10675,7 +10673,7 @@ community_list_config_write (struct vty *vty)
return write;
}
-struct cmd_node community_list_node =
+static struct cmd_node community_list_node =
{
COMMUNITY_LIST_NODE,
"",
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index ec1143af..943b1777 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -640,7 +640,6 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote,
}
#if 0
-#ifdef HAVE_IPV6
static unsigned int
bgp_ifindex_by_nexthop (struct in6_addr *addr)
{
@@ -671,7 +670,6 @@ bgp_ifindex_by_nexthop (struct in6_addr *addr)
}
return 0;
}
-#endif /* HAVE_IPV6 */
#endif
void
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index b37e577d..7f6ca168 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -114,46 +114,6 @@ bgp_option_check (int flag)
return CHECK_FLAG (bm->options, flag);
}
-/* BGP flag manipulation. */
-int
-bgp_flag_set (struct bgp *bgp, int flag)
-{
- SET_FLAG (bgp->flags, flag);
- return 0;
-}
-
-int
-bgp_flag_unset (struct bgp *bgp, int flag)
-{
- UNSET_FLAG (bgp->flags, flag);
- return 0;
-}
-
-int
-bgp_flag_check (struct bgp *bgp, int flag)
-{
- return CHECK_FLAG (bgp->flags, flag);
-}
-
-/* Internal function to set BGP structure configureation flag. */
-static void
-bgp_config_set (struct bgp *bgp, int config)
-{
- SET_FLAG (bgp->config, config);
-}
-
-static void
-bgp_config_unset (struct bgp *bgp, int config)
-{
- UNSET_FLAG (bgp->config, config);
-}
-
-static int
-bgp_config_check (struct bgp *bgp, int config)
-{
- return CHECK_FLAG (bgp->config, config);
-}
-
/* Set BGP router identifier. */
int
bgp_router_id_set (struct bgp *bgp, struct in_addr *id)
@@ -684,7 +644,7 @@ peer_sort (struct peer *peer)
}
}
-static inline void
+void
peer_free (struct peer *peer)
{
assert (peer->status == Deleted);
@@ -719,49 +679,6 @@ peer_free (struct peer *peer)
XFREE (MTYPE_BGP_PEER, peer);
}
-
-/* increase reference count on a struct peer */
-struct peer *
-peer_lock (struct peer *peer)
-{
- assert (peer && (peer->lock >= 0));
- assert (peer->status != Deleted);
-
- peer->lock++;
-
- return peer;
-}
-
-/* decrease reference count on a struct peer
- * struct peer is freed and NULL returned if last reference
- */
-struct peer *
-peer_unlock (struct peer *peer)
-{
- assert (peer && (peer->lock > 0));
-
- peer->lock--;
-
- if (peer->lock == 0)
- {
-#if 0
- zlog_debug ("unlocked and freeing");
- zlog_backtrace (LOG_DEBUG);
-#endif
- peer_free (peer);
- return NULL;
- }
-
-#if 0
- if (peer->lock == 1)
- {
- zlog_debug ("unlocked to 1");
- zlog_backtrace (LOG_DEBUG);
- }
-#endif
-
- return peer;
-}
/* Allocate new peer object, implicitely locked. */
static struct peer *
@@ -1190,7 +1107,7 @@ peer_delete (struct peer *peer)
if ((pn = listnode_lookup (peer->group->peer, peer)))
{
- peer = peer_unlock (peer); /* group->peer list reference */
+ peer_unlock (peer); /* group->peer list reference */
list_delete_node (peer->group->peer, pn);
}
peer->group = NULL;
@@ -1204,19 +1121,16 @@ peer_delete (struct peer *peer)
bgp_stop (peer);
bgp_fsm_change_status (peer, Deleted);
-#ifdef HAVE_TCP_MD5SIG
/* Password configuration */
if (peer->password)
{
- free (peer->password);
+ XFREE (MTYPE_PEER_PASSWORD, peer->password);
peer->password = NULL;
- if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)
- && sockunion_family (&peer->su) == AF_INET)
- bgp_md5_set (bm->sock, &peer->su.sin, NULL);
+ if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
+ bgp_md5_set (peer);
}
-#endif /* HAVE_TCP_MD5SIG */
-
+
bgp_timer_set (peer); /* stops all timers for Deleted */
/* Delete from all peer list. */
@@ -1243,10 +1157,7 @@ peer_delete (struct peer *peer)
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
if (peer->rib[afi][safi] && ! peer->af_group[afi][safi])
- {
- bgp_table_finish (peer->rib[afi][safi]);
- peer->rib[afi][safi] = NULL;
- }
+ bgp_table_finish (&peer->rib[afi][safi]);
/* Buffers. */
if (peer->ibuf)
@@ -1435,26 +1346,16 @@ peer_group2peer_config_copy (struct peer_group *group, struct peer *peer,
else
peer->v_routeadv = BGP_DEFAULT_EBGP_ROUTEADV;
-#ifdef HAVE_TCP_MD5SIG
/* password apply */
- if (CHECK_FLAG (conf->flags, PEER_FLAG_PASSWORD))
- {
- if (peer->password)
- free (peer->password);
- peer->password = strdup (conf->password);
+ if (peer->password)
+ XFREE (MTYPE_PEER_PASSWORD, peer->password);
- if (sockunion_family (&peer->su) == AF_INET)
- bgp_md5_set (bm->sock, &peer->su.sin, peer->password);
- }
- else if (peer->password)
- {
- free (peer->password);
- peer->password = NULL;
+ if (conf->password)
+ peer->password = XSTRDUP (MTYPE_PEER_PASSWORD, conf->password);
+ else
+ peer->password = NULL;
- if (sockunion_family (&peer->su) == AF_INET)
- bgp_md5_set (bm->sock, &peer->su.sin, NULL);
- }
-#endif /* HAVE_TCP_MD5SIG */
+ bgp_md5_set (peer);
/* maximum-prefix */
peer->pmax[afi][safi] = conf->pmax[afi][safi];
@@ -1837,8 +1738,7 @@ peer_group_bind (struct bgp *bgp, union sockunion *su,
list_delete_node (bgp->rsclient, pn);
}
- bgp_table_finish (peer->rib[afi][safi]);
- peer->rib[afi][safi] = NULL;
+ bgp_table_finish (&peer->rib[afi][safi]);
/* Import policy. */
if (peer->filter[afi][safi].map[RMAP_IMPORT].name)
@@ -2054,7 +1954,7 @@ bgp_get (struct bgp **bgp_val, as_t *as, const char *name)
}
/* Delete BGP instance. */
-int
+void
bgp_delete (struct bgp *bgp)
{
struct peer *peer;
@@ -2102,8 +2002,6 @@ bgp_delete (struct bgp *bgp)
XFREE (MTYPE_ROUTE_TABLE,bgp->rib[afi][safi]);
}
XFREE (MTYPE_BGP, bgp);
-
- return 0;
}
struct peer *
@@ -3419,26 +3317,25 @@ peer_local_as_unset (struct peer *peer)
return 0;
}
-#ifdef HAVE_TCP_MD5SIG
/* Set password for authenticating with the peer. */
int
peer_password_set (struct peer *peer, const char *password)
{
- struct peer_group *group;
struct listnode *nn, *nnode;
int len = password ? strlen(password) : 0;
+ int ret = BGP_SUCCESS;
if ((len < PEER_PASSWORD_MINLEN) || (len > PEER_PASSWORD_MAXLEN))
return BGP_ERR_INVALID_VALUE;
if (peer->password && strcmp (peer->password, password) == 0
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
- return 0;
+ return 0;
- SET_FLAG (peer->flags, PEER_FLAG_PASSWORD);
if (peer->password)
- free (peer->password);
- peer->password = strdup (password);
+ XFREE (MTYPE_PEER_PASSWORD, peer->password);
+
+ peer->password = XSTRDUP (MTYPE_PEER_PASSWORD, password);
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
@@ -3446,50 +3343,46 @@ peer_password_set (struct peer *peer, const char *password)
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
BGP_EVENT_ADD (peer, BGP_Stop);
-
- if (sockunion_family (&peer->su) == AF_INET)
- bgp_md5_set (bm->sock, &peer->su.sin, peer->password);
- return 0;
+
+ return (bgp_md5_set (peer) >= 0) ? BGP_SUCCESS : BGP_ERR_TCPSIG_FAILED;
}
- group = peer->group;
- /* #42# LIST_LOOP (group->peer, peer, nn) */
- for (ALL_LIST_ELEMENTS (group->peer, nn, nnode, peer))
+ for (ALL_LIST_ELEMENTS (peer->group->peer, nn, nnode, peer))
{
if (peer->password && strcmp (peer->password, password) == 0)
continue;
-
- SET_FLAG (peer->flags, PEER_FLAG_PASSWORD);
+
if (peer->password)
- free (peer->password);
- peer->password = strdup (password);
+ XFREE (MTYPE_PEER_PASSWORD, peer->password);
+
+ peer->password = XSTRDUP(MTYPE_PEER_PASSWORD, password);
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
BGP_EVENT_ADD (peer, BGP_Stop);
-
- if (sockunion_family (&peer->su) == AF_INET)
- bgp_md5_set (bm->sock, &peer->su.sin, peer->password);
+
+ if (bgp_md5_set (peer) < 0)
+ ret = BGP_ERR_TCPSIG_FAILED;
}
- return 0;
+ return ret;
}
int
peer_password_unset (struct peer *peer)
{
- struct peer_group *group;
struct listnode *nn, *nnode;
- if (! CHECK_FLAG (peer->flags, PEER_FLAG_PASSWORD)
- && ! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
+ if (!peer->password
+ && !CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
return 0;
- if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
+ if (!CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP))
{
if (peer_group_active (peer)
- && CHECK_FLAG (peer->group->conf->flags, PEER_FLAG_PASSWORD))
+ && peer->group->conf->password
+ && strcmp (peer->group->conf->password, peer->password) == 0)
return BGP_ERR_PEER_GROUP_HAS_THE_FLAG;
if (peer->status == Established)
@@ -3497,46 +3390,37 @@ peer_password_unset (struct peer *peer)
else
BGP_EVENT_ADD (peer, BGP_Stop);
- if (sockunion_family (&peer->su) == AF_INET)
- bgp_md5_set (bm->sock, &peer->su.sin, NULL);
-
- UNSET_FLAG (peer->flags, PEER_FLAG_PASSWORD);
if (peer->password)
- free (peer->password);
+ XFREE (MTYPE_PEER_PASSWORD, peer->password);
+
peer->password = NULL;
+
+ bgp_md5_set (peer);
return 0;
}
- UNSET_FLAG (peer->flags, PEER_FLAG_PASSWORD);
- if (peer->password)
- free (peer->password);
+ XFREE (MTYPE_PEER_PASSWORD, peer->password);
peer->password = NULL;
- group = peer->group;
- /* #42# LIST_LOOP (group->peer, peer, nn) */
- for (ALL_LIST_ELEMENTS (group->peer, nn, nnode, peer))
+ for (ALL_LIST_ELEMENTS (peer->group->peer, nn, nnode, peer))
{
- if (! CHECK_FLAG (peer->flags, PEER_FLAG_PASSWORD))
+ if (!peer->password)
continue;
if (peer->status == Established)
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE);
else
BGP_EVENT_ADD (peer, BGP_Stop);
-
- if (sockunion_family (&peer->su) == AF_INET)
- bgp_md5_set (bm->sock, &peer->su.sin, NULL);
-
- UNSET_FLAG (peer->flags, PEER_FLAG_PASSWORD);
- if (peer->password)
- free (peer->password);
+
+ XFREE (MTYPE_PEER_PASSWORD, peer->password);
peer->password = NULL;
+
+ bgp_md5_set (peer);
}
return 0;
}
-#endif /* HAVE_TCP_MD5SIG */
/* Set distribute list to the peer. */
int
@@ -4543,13 +4427,13 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
vty_out (vty, " neighbor %s peer-group%s", addr,
VTY_NEWLINE);
if (peer->as)
- vty_out (vty, " neighbor %s remote-as %u%s", addr, (unsigned)peer->as,
+ vty_out (vty, " neighbor %s remote-as %d%s", addr, peer->as,
VTY_NEWLINE);
}
else
{
if (! g_peer->as)
- vty_out (vty, " neighbor %s remote-as %u%s", addr, (unsigned)peer->as,
+ vty_out (vty, " neighbor %s remote-as %d%s", addr, peer->as,
VTY_NEWLINE);
if (peer->af_group[AFI_IP][SAFI_UNICAST])
vty_out (vty, " neighbor %s peer-group %s%s", addr,
@@ -4575,19 +4459,17 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
! CHECK_FLAG (g_peer->flags, PEER_FLAG_SHUTDOWN))
vty_out (vty, " neighbor %s shutdown%s", addr, VTY_NEWLINE);
-#ifdef HAVE_TCP_MD5SIG
/* Password. */
- if (CHECK_FLAG (peer->flags, PEER_FLAG_PASSWORD))
- if (! peer_group_active (peer)
- || ! CHECK_FLAG (g_peer->flags, PEER_FLAG_PASSWORD)
+ if (peer->password)
+ if (!peer_group_active (peer)
+ || ! g_peer->password
|| strcmp (peer->password, g_peer->password) != 0)
vty_out (vty, " neighbor %s password %s%s", addr, peer->password,
VTY_NEWLINE);
-#endif /* HAVE_TCP_MD5SIG */
/* BGP port. */
if (peer->port != BGP_PORT_DEFAULT)
- vty_out (vty, " neighbor %s port %d%s", addr, peer->port,
+ vty_out (vty, " neighbor %s port %d%s", addr, peer->port,
VTY_NEWLINE);
/* Local interface name. */
@@ -4950,7 +4832,7 @@ bgp_config_write (struct vty *vty)
vty_out (vty, "!%s", VTY_NEWLINE);
/* Router bgp ASN */
- vty_out (vty, "router bgp %u", (unsigned)bgp->as);
+ vty_out (vty, "router bgp %d", bgp->as);
if (bgp_option_check (BGP_OPT_MULTIPLE_INSTANCE))
{
@@ -5117,12 +4999,10 @@ bgp_master_init (void)
bm = &bgp_master;
bm->bgp = list_new ();
+ bm->listen_sockets = list_new ();
bm->port = BGP_PORT_DEFAULT;
bm->master = thread_master_create ();
bm->start_time = time (NULL);
-#ifdef HAVE_TCP_MD5SIG
- bm->sock = -1;
-#endif /* HAVE_TCP_MD5SIG */
}
diff --git a/bgpd/bgpd.conf.sample b/bgpd/bgpd.conf.sample
index 62cacc85..b6a8b6f1 100644
--- a/bgpd/bgpd.conf.sample
+++ b/bgpd/bgpd.conf.sample
@@ -2,7 +2,7 @@
!
! BGPd sample configuratin file
!
-! $Id$
+! $Id: bgpd.conf.sample,v 1.1 2002/12/13 20:15:29 paul Exp $
!
hostname bgpd
password zebra
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index ef1f860b..f699dc35 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -42,6 +42,9 @@ struct bgp_master
struct work_queue *process_main_queue;
struct work_queue *process_rsclient_queue;
+ /* Listening sockets */
+ struct list *listen_sockets;
+
/* BGP port number. */
u_int16_t port;
@@ -56,11 +59,6 @@ struct bgp_master
#define BGP_OPT_NO_FIB (1 << 0)
#define BGP_OPT_MULTIPLE_INSTANCE (1 << 1)
#define BGP_OPT_CONFIG_CISCO (1 << 2)
-
-#ifdef HAVE_TCP_MD5SIG
- /* bgp receive socket */
- int sock;
-#endif /* HAVE_TCP_MD5SIG */
};
/* BGP instance structure. */
@@ -363,7 +361,6 @@ struct peer
/* NSF mode (graceful restart) */
u_char nsf[AFI_MAX][SAFI_MAX];
-#define PEER_FLAG_PASSWORD (1 << 9) /* password */
/* Per AF configuration flags. */
u_int32_t af_flags[AFI_MAX][SAFI_MAX];
@@ -383,7 +380,7 @@ struct peer
#define PEER_FLAG_ORF_PREFIX_RM (1 << 13) /* orf capability receive-mode */
#define PEER_FLAG_MAX_PREFIX (1 << 14) /* maximum prefix */
#define PEER_FLAG_MAX_PREFIX_WARNING (1 << 15) /* maximum prefix warning-only */
-#define PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED (1 << 16) /* leave link-local nexthop unchanged */
+#define PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED (1 << 16) /* leave link-local nexthop unchanged */
/* MD5 password */
char *password;
@@ -543,13 +540,9 @@ struct peer
#define PEER_RMAP_TYPE_EXPORT (1 << 7) /* neighbor route-map export */
};
-#if defined(HAVE_TCP_MD5SIG)
-
#define PEER_PASSWORD_MINLEN (1)
#define PEER_PASSWORD_MAXLEN (80)
-#endif /* HAVE_TCP_MD5SIG */
-
/* This structure's member directly points incoming packet data
stream. */
struct bgp_nlri
@@ -803,7 +796,8 @@ enum bgp_clear_type
#define BGP_ERR_INSTANCE_MISMATCH -26
#define BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP -27
#define BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS -28
-#define BGP_ERR_MAX -29
+#define BGP_ERR_TCPSIG_FAILED -29
+#define BGP_ERR_MAX -30
extern struct bgp_master *bm;
@@ -823,13 +817,32 @@ extern struct peer_group *peer_group_lookup (struct bgp *, const char *);
extern struct peer_group *peer_group_get (struct bgp *, const char *);
extern struct peer *peer_lookup_with_open (union sockunion *, as_t, struct in_addr *,
int *);
-extern struct peer *peer_lock (struct peer *);
-extern struct peer *peer_unlock (struct peer *);
+extern void peer_free (struct peer *peer);
extern int peer_sort (struct peer *peer);
extern int peer_active (struct peer *);
extern int peer_active_nego (struct peer *);
extern struct peer *peer_create_accept (struct bgp *);
extern char *peer_uptime (time_t, char *, size_t);
+
+static inline struct peer *
+peer_lock (struct peer *peer)
+{
+ assert (peer && (peer->lock >= 0));
+ assert (peer->status != Deleted);
+
+ peer->lock++;
+ return peer;
+}
+
+static inline void
+peer_unlock (struct peer *peer)
+{
+ assert (peer && (peer->lock > 0));
+
+ if (--peer->lock == 0)
+ peer_free (peer);
+}
+
extern int bgp_config_write (struct vty *);
extern void bgp_config_write_family_header (struct vty *, afi_t, safi_t, int *);
@@ -843,11 +856,46 @@ extern int bgp_option_unset (int);
extern int bgp_option_check (int);
extern int bgp_get (struct bgp **, as_t *, const char *);
-extern int bgp_delete (struct bgp *);
+extern void bgp_delete (struct bgp *);
+extern void bgp_free (struct bgp *);
-extern int bgp_flag_set (struct bgp *, int);
-extern int bgp_flag_unset (struct bgp *, int);
-extern int bgp_flag_check (struct bgp *, int);
+/* BGP flag manipulation. */
+static inline void
+bgp_flag_set (struct bgp *bgp, int flag)
+{
+ SET_FLAG (bgp->flags, flag);
+}
+
+static inline void
+bgp_flag_unset (struct bgp *bgp, int flag)
+{
+ UNSET_FLAG (bgp->flags, flag);
+}
+
+static inline int
+bgp_flag_check (const struct bgp *bgp, int flag)
+{
+ return CHECK_FLAG (bgp->flags, flag);
+}
+
+/* Internal function to set BGP structure configureation flag. */
+static inline void
+bgp_config_set (struct bgp *bgp, int config)
+{
+ SET_FLAG (bgp->config, config);
+}
+
+static inline void
+bgp_config_unset (struct bgp *bgp, int config)
+{
+ UNSET_FLAG (bgp->config, config);
+}
+
+static inline int
+bgp_config_check (const struct bgp *bgp, int config)
+{
+ return CHECK_FLAG (bgp->config, config);
+}
extern int bgp_router_id_set (struct bgp *, struct in_addr *);
@@ -940,10 +988,9 @@ extern int peer_route_map_set (struct peer *, afi_t, safi_t, int, const char *);
extern int peer_route_map_unset (struct peer *, afi_t, safi_t, int);
extern int peer_unsuppress_map_set (struct peer *, afi_t, safi_t, const char *);
-#ifdef HAVE_TCP_MD5SIG
+
extern int peer_password_set (struct peer *, const char *);
extern int peer_password_unset (struct peer *);
-#endif /* HAVE_TCP_MD5SIG */
extern int peer_unsuppress_map_unset (struct peer *, afi_t, safi_t);