summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_nexthop.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2016-12-05 19:43:38 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2016-12-05 19:48:38 +0100
commit53dc2b05c76f4f5cd6a72373fb241afdcedb2ee1 (patch)
treed43e2f4f851f368dcc943a9b30e73ff603ea5bc1 /bgpd/bgp_nexthop.c
parentMerge branch 'stable/2.0' (diff)
parentbuild: number sections in COMMUNITY.md HTML (diff)
downloadfrr-53dc2b05c76f4f5cd6a72373fb241afdcedb2ee1.tar.xz
frr-53dc2b05c76f4f5cd6a72373fb241afdcedb2ee1.zip
Merge branch 'stable/2.0'
Conflicts: bgpd/bgp_route.c lib/if.c ripd/rip_interface.c zebra/interface.c zebra/zebra_vty.c
Diffstat (limited to 'bgpd/bgp_nexthop.c')
-rw-r--r--bgpd/bgp_nexthop.c59
1 files changed, 26 insertions, 33 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index 493655d7f..a77e92c17 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -113,6 +113,12 @@ bgp_address_hash_alloc (void *p)
return addr;
}
+static void
+bgp_address_hash_free (void *addr)
+{
+ XFREE (MTYPE_BGP_ADDR, addr);
+}
+
static unsigned int
bgp_address_hash_key_make (void *p)
{
@@ -142,7 +148,7 @@ bgp_address_destroy (struct bgp *bgp)
{
if (bgp->address_hash == NULL)
return;
- hash_clean(bgp->address_hash, NULL);
+ hash_clean(bgp->address_hash, bgp_address_hash_free);
hash_free(bgp->address_hash);
bgp->address_hash = NULL;
}
@@ -523,17 +529,14 @@ DEFUN (show_ip_bgp_instance_all_nexthop,
void
bgp_scan_init (struct bgp *bgp)
{
- bgp->nexthop_cache_table[AFI_IP] = bgp_table_init (AFI_IP, SAFI_UNICAST);
- bgp->connected_table[AFI_IP] = bgp_table_init (AFI_IP, SAFI_UNICAST);
- bgp->import_check_table[AFI_IP] = bgp_table_init (AFI_IP, SAFI_UNICAST);
-
- bgp->nexthop_cache_table[AFI_IP6] = bgp_table_init (AFI_IP6, SAFI_UNICAST);
- bgp->connected_table[AFI_IP6] = bgp_table_init (AFI_IP6, SAFI_UNICAST);
- bgp->import_check_table[AFI_IP6] = bgp_table_init (AFI_IP6, SAFI_UNICAST);
+ afi_t afi;
- bgp->nexthop_cache_table[AFI_ETHER] = bgp_table_init (AFI_ETHER, SAFI_UNICAST);
- bgp->connected_table[AFI_ETHER] = bgp_table_init (AFI_ETHER, SAFI_UNICAST);
- bgp->import_check_table[AFI_ETHER] = bgp_table_init (AFI_ETHER, SAFI_UNICAST);
+ for (afi = AFI_IP; afi < AFI_MAX; afi++)
+ {
+ bgp->nexthop_cache_table[afi] = bgp_table_init (afi, SAFI_UNICAST);
+ bgp->connected_table[afi] = bgp_table_init (afi, SAFI_UNICAST);
+ bgp->import_check_table[afi] = bgp_table_init (afi, SAFI_UNICAST);
+ }
}
void
@@ -546,29 +549,19 @@ bgp_scan_vty_init (void)
void
bgp_scan_finish (struct bgp *bgp)
{
- /* Only the current one needs to be reset. */
- bgp_nexthop_cache_reset (bgp->nexthop_cache_table[AFI_IP]);
-
- bgp_table_unlock (bgp->nexthop_cache_table[AFI_IP]);
- bgp->nexthop_cache_table[AFI_IP] = NULL;
-
- bgp_table_unlock (bgp->connected_table[AFI_IP]);
- bgp->connected_table[AFI_IP] = NULL;
-
- bgp_table_unlock (bgp->import_check_table[AFI_IP]);
- bgp->import_check_table[AFI_IP] = NULL;
-
-#ifdef HAVE_IPV6
- /* Only the current one needs to be reset. */
- bgp_nexthop_cache_reset (bgp->nexthop_cache_table[AFI_IP6]);
+ afi_t afi;
- bgp_table_unlock (bgp->nexthop_cache_table[AFI_IP6]);
- bgp->nexthop_cache_table[AFI_IP6] = NULL;
+ for (afi = AFI_IP; afi < AFI_MAX; afi++)
+ {
+ /* Only the current one needs to be reset. */
+ bgp_nexthop_cache_reset (bgp->nexthop_cache_table[afi]);
+ bgp_table_unlock (bgp->nexthop_cache_table[afi]);
+ bgp->nexthop_cache_table[afi] = NULL;
- bgp_table_unlock (bgp->connected_table[AFI_IP6]);
- bgp->connected_table[AFI_IP6] = NULL;
+ bgp_table_unlock (bgp->connected_table[afi]);
+ bgp->connected_table[afi] = NULL;
- bgp_table_unlock (bgp->import_check_table[AFI_IP6]);
- bgp->import_check_table[AFI_IP6] = NULL;
-#endif /* HAVE_IPV6 */
+ bgp_table_unlock (bgp->import_check_table[afi]);
+ bgp->import_check_table[afi] = NULL;
+ }
}