diff options
| author | vivek <vivek@cumulusnetworks.com> | 2017-05-23 23:08:09 -0700 |
|---|---|---|
| committer | vivek <vivek@cumulusnetworks.com> | 2017-05-25 10:20:04 -0700 |
| commit | 64396cba7358b597d2e8093f71092d08bbf0021d (patch) | |
| tree | af258c601d85878e0bcebc4d140bf160cc316bc7 | |
| parent | ea2e48899bb921dac10da1d8273a167f4a63678e (diff) | |
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>
| -rw-r--r-- | bgpd/bgpd.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 92a0cd6acc..9d404b16dc 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -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]) |
