diff options
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_advertise.c | 9 | ||||
-rw-r--r-- | bgpd/bgp_aspath.c | 6 | ||||
-rw-r--r-- | bgpd/bgp_attr.c | 46 | ||||
-rw-r--r-- | bgpd/bgp_attr.h | 4 | ||||
-rw-r--r-- | bgpd/bgp_clist.c | 14 | ||||
-rw-r--r-- | bgpd/bgp_debug.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_dump.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_ecommunity.c | 11 | ||||
-rw-r--r-- | bgpd/bgp_ecommunity.h | 4 | ||||
-rw-r--r-- | bgpd/bgp_filter.c | 14 | ||||
-rw-r--r-- | bgpd/bgp_network.c | 21 | ||||
-rw-r--r-- | bgpd/bgp_nexthop.c | 6 | ||||
-rw-r--r-- | bgpd/bgp_open.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_packet.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 67 | ||||
-rw-r--r-- | bgpd/bgp_route.h | 21 | ||||
-rw-r--r-- | bgpd/bgp_snmp.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_table.c | 10 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 17 | ||||
-rw-r--r-- | bgpd/bgp_zebra.c | 4 | ||||
-rw-r--r-- | bgpd/bgpd.c | 91 | ||||
-rw-r--r-- | bgpd/bgpd.h | 66 |
22 files changed, 127 insertions, 294 deletions
diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c index ea3dfe03..b9f4a85b 100644 --- a/bgpd/bgp_advertise.c +++ b/bgpd/bgp_advertise.c @@ -72,19 +72,10 @@ baa_hash_key (void *p) } static int -<<<<<<< HEAD:bgpd/bgp_advertise.c -baa_hash_cmp (void *p1, void *p2) -======= baa_hash_cmp (const void *p1, const void *p2) ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_advertise.c { -<<<<<<< HEAD:bgpd/bgp_advertise.c - 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; ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_advertise.c return attrhash_cmp (baa1->attr, baa2->attr); } diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index 006fc917..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. */ diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 217e0cba..d116c30f 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -131,29 +131,13 @@ cluster_hash_key_make (void *p) } static int -<<<<<<< HEAD:bgpd/bgp_attr.c -cluster_hash_cmp (void *p1, void *p2) -======= cluster_hash_cmp (const void *p1, const void *p2) ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_attr.c { -<<<<<<< HEAD:bgpd/bgp_attr.c - 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; ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_attr.c -<<<<<<< HEAD:bgpd/bgp_attr.c - 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); ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_attr.c } static void @@ -281,29 +265,13 @@ transit_hash_key_make (void *p) } static int -<<<<<<< HEAD:bgpd/bgp_attr.c -transit_hash_cmp (void *p1, void *p2) -======= transit_hash_cmp (const void *p1, const void *p2) ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_attr.c { -<<<<<<< HEAD:bgpd/bgp_attr.c - struct transit * transit1 = (struct transit *) p1; - struct transit * transit2 = (struct transit *) p2; -======= const struct transit * transit1 = p1; const struct transit * transit2 = p2; ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_attr.c -<<<<<<< HEAD:bgpd/bgp_attr.c - 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); ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_attr.c } static void @@ -421,19 +389,10 @@ attrhash_key_make (void *p) } int -<<<<<<< HEAD:bgpd/bgp_attr.c -attrhash_cmp (void *p1, void *p2) -======= attrhash_cmp (const void *p1, const void *p2) ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_attr.c { -<<<<<<< HEAD:bgpd/bgp_attr.c - struct attr * attr1 = (struct attr *) p1; - struct attr * attr2 = (struct attr *) p2; -======= const struct attr * attr1 = p1; const struct attr * attr2 = p2; ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_attr.c if (attr1->flag == attr2->flag && attr1->origin == attr2->origin @@ -445,13 +404,8 @@ attrhash_cmp (const void *p1, const void *p2) && attr1->pathlimit.ttl == attr2->pathlimit.ttl && attr1->pathlimit.as == attr2->pathlimit.as) { -<<<<<<< HEAD:bgpd/bgp_attr.c - 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; ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_attr.c if (ae1 && ae2 && ae1->aggregator_as == ae2->aggregator_as diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index b0ff8234..12149a17 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -163,11 +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 *); -<<<<<<< HEAD:bgpd/bgp_attr.h -extern int attrhash_cmp (void *, void *); -======= extern int attrhash_cmp (const void *, const void *); ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_attr.h extern unsigned int attrhash_key_make (void *); extern void attr_show_all (struct vty *); extern unsigned long int attr_count (void); diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index f75fc55b..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. */ @@ -836,6 +828,7 @@ community_list_init (void) return ch; } +#if 0 /* Terminate community-list. */ static void community_list_terminate (struct community_list_handler *ch) @@ -857,3 +850,4 @@ community_list_terminate (struct community_list_handler *ch) XFREE (MTYPE_COMMUNITY_LIST_HANDLER, ch); } +#endif 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 6b79eec0..c08673ce 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -247,24 +247,13 @@ ecommunity_hash_make (void *arg) /* Compare two Extended Communities Attribute structure. */ int -<<<<<<< HEAD:bgpd/bgp_ecommunity.c -ecommunity_cmp (void *arg1, void *arg2) -======= ecommunity_cmp (const void *arg1, const void *arg2) ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_ecommunity.c { const struct ecommunity *ecom1 = arg1; const struct ecommunity *ecom2 = arg2; -<<<<<<< HEAD:bgpd/bgp_ecommunity.c - 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); ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_ecommunity.c } /* Initialize Extended Comminities related hash. */ diff --git a/bgpd/bgp_ecommunity.h b/bgpd/bgp_ecommunity.h index 0d1eb585..278721c8 100644 --- a/bgpd/bgp_ecommunity.h +++ b/bgpd/bgp_ecommunity.h @@ -72,11 +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 *); -<<<<<<< HEAD:bgpd/bgp_ecommunity.h -extern int ecommunity_cmp (void *, void *); -======= extern int ecommunity_cmp (const void *, const void *); ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_ecommunity.h 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_network.c b/bgpd/bgp_network.c index fb8a7dd3..87f7f7b6 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -92,12 +92,6 @@ bgp_md5_set (struct peer *peer) struct listnode *node; int fret = 0, ret; int *socket; - - if ( bgpd_privs.change (ZPRIVS_RAISE) ) - { - zlog_err ("%s: could not raise privs", __func__); - return -1; - } /* Just set the password on the listen socket(s). Outbound connections * are taken care of in bgp_connect() below. @@ -108,9 +102,6 @@ bgp_md5_set (struct peer *peer) if (ret < 0) fret = ret; } - if (bgpd_privs.change (ZPRIVS_LOWER) ) - zlog_err ("%s: could not lower privs", __func__); - return fret; } @@ -314,14 +305,11 @@ bgp_connect (struct peer *peer) sockopt_reuseaddr (peer->fd); sockopt_reuseport (peer->fd); -<<<<<<< HEAD:bgpd/bgp_network.c -======= #ifdef IPTOS_PREC_INTERNETCONTROL if (sockunion_family (&peer->su) == AF_INET) setsockopt_ipv4_tos (peer->fd, IPTOS_PREC_INTERNETCONTROL); #endif ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_network.c if (peer->password) bgp_md5_set_connect (peer->fd, &peer->su, peer->password); @@ -415,6 +403,15 @@ bgp_socket (struct bgp *bgp, unsigned short port, char *address) setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL); #endif +#ifdef IPV6_V6ONLY + /* Want only IPV6 on ipv6 socket (not mapped addresses) */ + if (ainfo->ai_family == AF_INET6) { + int on = 1; + setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, + (void *) &on, sizeof (on)); + } +#endif + if (bgpd_privs.change (ZPRIVS_RAISE) ) zlog_err ("bgp_socket: could not raise privs"); diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 22e48db0..d0d6aa18 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_open.c b/bgpd/bgp_open.c index 84d8191e..9ecfb16a 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -526,7 +526,7 @@ bgp_capability_parse (struct peer *peer, size_t length, u_char **error) if (caphdr.length < cap_minsizes[caphdr.code]) { zlog_info ("%s %s Capability length error: got %u," - " expected at least %u", + " expected at least %zu", peer->host, LOOKUP (capcode_str, caphdr.code), caphdr.length, cap_minsizes[caphdr.code]); diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 1422bad6..862f3413 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -920,6 +920,7 @@ bgp_notify_send (struct peer *peer, u_char code, u_char sub_code) bgp_notify_send_with_data (peer, code, sub_code, NULL, 0); } +#if 0 static const char * afi2str (afi_t afi) { @@ -943,6 +944,7 @@ safi2str (safi_t safi) else return "Unknown SAFI"; } +#endif /* Send route refresh message to the peer. */ void diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 9d149cbb..ff4e0ab4 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) @@ -2678,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 @@ -3121,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 @@ -4509,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 @@ -9176,11 +9132,7 @@ bgp_table_stats (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) vty_out (vty, "%12llu%s", ts.counts[i], VTY_NEWLINE); if (ts.counts[BGP_STATS_MAXBITLEN] < 9) break; -<<<<<<< HEAD:bgpd/bgp_route.c - vty_out (vty, "%30s: ", "\% announced "); -======= vty_out (vty, "%30s: ", "%% announced "); ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_route.c vty_out (vty, "%12.2f%s", 100 * (float)ts.counts[BGP_STATS_SPACE] / (float)((uint64_t)1UL << ts.counts[BGP_STATS_MAXBITLEN]), @@ -10863,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 @@ -10961,6 +10910,7 @@ bgp_distance_unset (struct vty *vty, const char *distance_str, return CMD_SUCCESS; } +#if 0 static void bgp_distance_reset () { @@ -10977,6 +10927,7 @@ bgp_distance_reset () bgp_unlock_node (rn); } } +#endif /* Apply BGP information to distance method. */ u_char 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_snmp.c b/bgpd/bgp_snmp.c index 576e3e09..09199017 100644 --- a/bgpd/bgp_snmp.c +++ b/bgpd/bgp_snmp.c @@ -383,7 +383,7 @@ write_bgpPeerTable (int action, u_char *var_val, struct in_addr addr; struct peer *peer; long intval; - int bigsize = SNMP_MAX_LEN; + size_t bigsize = SNMP_MAX_LEN; if (var_val_type != ASN_INTEGER) { diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c index c2120252..15630a24 100644 --- a/bgpd/bgp_table.c +++ b/bgpd/bgp_table.c @@ -36,8 +36,7 @@ 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; @@ -56,11 +55,7 @@ bgp_table_finish (struct bgp_table **rt) 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. */ @@ -369,6 +364,7 @@ bgp_node_delete (struct bgp_node *node) assert (node->lock == 0); assert (node->info == NULL); + assert (node->table->count > 0); if (node->l_left && node->l_right) return; diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index b2164503..b6e03cf4 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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)# ", @@ -9872,10 +9872,7 @@ bgp_vty_init (void) /* "show bgp memory" commands. */ install_element (VIEW_NODE, &show_bgp_memory_cmd); -<<<<<<< HEAD:bgpd/bgp_vty.c -======= install_element (RESTRICTED_NODE, &show_bgp_memory_cmd); ->>>>>>> 41dc3488cf127a1e23333459a0c316ded67f7ff3:bgpd/bgp_vty.c install_element (ENABLE_NODE, &show_bgp_memory_cmd); /* Community-list. */ @@ -10706,7 +10703,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 0b6ab45a..943b1777 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -639,7 +639,7 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote, return ret; } -#ifdef HAVE_IPV6 +#if 0 static unsigned int bgp_ifindex_by_nexthop (struct in6_addr *addr) { @@ -670,7 +670,7 @@ bgp_ifindex_by_nexthop (struct in6_addr *addr) } return 0; } -#endif /* HAVE_IPV6 */ +#endif void bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 8eb0d2e4..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; @@ -2037,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; @@ -2085,8 +2002,6 @@ bgp_delete (struct bgp *bgp) XFREE (MTYPE_ROUTE_TABLE,bgp->rib[afi][safi]); } XFREE (MTYPE_BGP, bgp); - - return 0; } struct peer * diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index afe06635..f699dc35 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -817,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 *); @@ -837,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 *); + +/* 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); +} -extern int bgp_flag_set (struct bgp *, int); -extern int bgp_flag_unset (struct bgp *, int); -extern int bgp_flag_check (struct bgp *, int); +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 *); |