bgpd: Fix route handling for 2-level routing tables

For certain (sub) address families such as EVPN or L3VPN, the routing
table is organized as a 2-level tree. Ensure that code walking the
routing table does the correct handling in such cases.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
This commit is contained in:
vivek 2017-05-23 23:08:09 -07:00
parent ea2e48899b
commit 64396cba73

View File

@ -1477,17 +1477,28 @@ bgp_recalculate_all_bestpaths (struct bgp *bgp)
{
afi_t afi;
safi_t safi;
struct bgp_node *rn;
struct bgp_node *rn, *nrn;
for (afi = AFI_IP; afi < AFI_MAX; afi++)
{
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
for (rn = bgp_table_top (bgp->rib[afi][safi]); rn; rn = bgp_route_next (rn))
for (rn = bgp_table_top (bgp->rib[afi][safi]); rn;
rn = bgp_route_next (rn))
{
if (rn->info != NULL)
{
bgp_process (bgp, rn, afi, safi);
/* Special handling for 2-level routing tables. */
if (safi == SAFI_MPLS_VPN ||
safi == SAFI_ENCAP ||
safi == SAFI_EVPN)
{
for (nrn = bgp_table_top((struct bgp_table *)(rn->info));
nrn; nrn = bgp_route_next (nrn))
bgp_process (bgp, nrn, afi, safi);
}
else
bgp_process (bgp, rn, afi, safi);
}
}
}
@ -3289,6 +3300,8 @@ bgp_free (struct bgp *bgp)
{
afi_t afi;
safi_t safi;
struct bgp_table *table;
struct bgp_node *rn;
QOBJ_UNREG (bgp);
@ -3304,6 +3317,18 @@ bgp_free (struct bgp *bgp)
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++)
{
/* Special handling for 2-level routing tables. */
if (safi == SAFI_MPLS_VPN ||
safi == SAFI_ENCAP ||
safi == SAFI_EVPN)
{
for (rn = bgp_table_top(bgp->rib[afi][safi]); rn;
rn = bgp_route_next (rn))
{
table = (struct bgp_table *) rn->info;
bgp_table_finish(&table);
}
}
if (bgp->route[afi][safi])
bgp_table_finish (&bgp->route[afi][safi]);
if (bgp->aggregate[afi][safi])