summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2021-09-24 16:10:31 +0200
committerDonald Sharp <sharpd@nvidia.com>2021-09-27 18:38:08 +0200
commitb8210849b8ac1abe2d5d9a5ab2459abfde65efa5 (patch)
tree21578742ab61cca8751ef0a1e9b6cd2446dc1a91 /bgpd
parent*: Add resolve via default flag (diff)
downloadfrr-b8210849b8ac1abe2d5d9a5ab2459abfde65efa5.tar.xz
frr-b8210849b8ac1abe2d5d9a5ab2459abfde65efa5.zip
bgpd: Make bgp ready to remove distinction between 2 nh tracking types
Allow bgp to figure out if it cares about address resolution instead of having zebra care about it. This will allow the removal of the zapi type for import checking and just use nexthop resolution. Effectively we just look up the route being returned and if it is in either table we just handle it instead of looking for clues from the zapi message type. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_nht.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index 87d76489b..90fa90730 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -664,7 +664,7 @@ void bgp_nht_interface_events(struct peer *peer)
void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
{
struct bgp_nexthop_cache_head *tree = NULL;
- struct bgp_nexthop_cache *bnc;
+ struct bgp_nexthop_cache *bnc_nhc, *bnc_import;
struct bgp *bgp;
struct zapi_route nhr;
afi_t afi;
@@ -685,22 +685,38 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
}
afi = family2afi(nhr.prefix.family);
- if (command == ZEBRA_NEXTHOP_UPDATE)
- tree = &bgp->nexthop_cache_table[afi];
- else if (command == ZEBRA_IMPORT_CHECK_UPDATE)
- tree = &bgp->import_check_table[afi];
+ tree = &bgp->nexthop_cache_table[afi];
- bnc = bnc_find(tree, &nhr.prefix, nhr.srte_color);
- if (!bnc) {
+ bnc_nhc = bnc_find(tree, &nhr.prefix, nhr.srte_color);
+ if (!bnc_nhc) {
if (BGP_DEBUG(nht, NHT))
zlog_debug(
- "parse nexthop update(%pFX(%u)(%s)): bnc info not found",
+ "parse nexthop update(%pFX(%u)(%s)): bnc info not found for nexthop cache",
+ &nhr.prefix, nhr.srte_color, bgp->name_pretty);
+ } else
+ bgp_process_nexthop_update(bnc_nhc, &nhr);
+
+ tree = &bgp->import_check_table[afi];
+
+ bnc_import = bnc_find(tree, &nhr.prefix, nhr.srte_color);
+ if (!bnc_import) {
+ if (BGP_DEBUG(nht, NHT))
+ zlog_debug(
+ "parse nexthop update(%pFX(%u)(%s)): bnc info not found for import check",
&nhr.prefix, nhr.srte_color, bgp->name_pretty);
return;
+ } else {
+ if (nhr.type == ZEBRA_ROUTE_BGP
+ || !prefix_same(&bnc_import->prefix, &nhr.prefix)) {
+ if (BGP_DEBUG(nht, NHT))
+ zlog_debug(
+ "%s: Import Check does not resolve to the same prefix for %pFX received %pFX",
+ __func__, &bnc_import->prefix, &nhr.prefix);
+ return;
+ }
+ bgp_process_nexthop_update(bnc_import, &nhr);
}
- bgp_process_nexthop_update(bnc, &nhr);
-
/*
* HACK: if any BGP route is dependant on an SR-policy that doesn't
* exist, zebra will never send NH updates relative to that policy. In
@@ -712,12 +728,12 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
* which should provide a better infrastructure to solve this issue in
* a more efficient and elegant way.
*/
- if (nhr.srte_color == 0) {
+ if (nhr.srte_color == 0 && bnc_nhc) {
struct bgp_nexthop_cache *bnc_iter;
frr_each (bgp_nexthop_cache, &bgp->nexthop_cache_table[afi],
bnc_iter) {
- if (!prefix_same(&bnc->prefix, &bnc_iter->prefix)
+ if (!prefix_same(&bnc_import->prefix, &bnc_iter->prefix)
|| bnc_iter->srte_color == 0
|| CHECK_FLAG(bnc_iter->flags, BGP_NEXTHOP_VALID))
continue;