summaryrefslogtreecommitdiff
path: root/bgpd/bgp_nexthop.c
diff options
context:
space:
mode:
authorTrey Aspelund <taspelund@nvidia.com>2023-01-25 13:07:43 -0500
committerTrey Aspelund <taspelund@nvidia.com>2023-01-27 11:11:44 -0500
commit826c3f6db358e9bbc48848c5eadaab7916f5c3f9 (patch)
tree44a84dc46bb249727abf87045366f15e2d84a1eb /bgpd/bgp_nexthop.c
parent2d5928355c89130713660493e23430994b79a8ef (diff)
bgpd: only unimport routes if tunnel-ip changes
When processing a new local VNI, we were always walking the global EVPN table to look for routes that needed to be removed due to a martian nexthop change (specifically a tunnel-ip change). Since the martian TIP table is global (all VNIs) + the walk is also in the global table (all VNIs), we can trust that any new TIP from any VNI would result in routes getting removed from the global table and unimported from all live (L2)VNIs. i.e. The only time this update is actionable is if we are adding/removing an IP from the martian TIP table, and we do not need to walk the table for normal refcount adjustments. Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
Diffstat (limited to 'bgpd/bgp_nexthop.c')
-rw-r--r--bgpd/bgp_nexthop.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index d9822ee974..77e26037c0 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -188,15 +188,30 @@ void bgp_tip_hash_destroy(struct bgp *bgp)
bgp->tip_hash = NULL;
}
-void bgp_tip_add(struct bgp *bgp, struct in_addr *tip)
+/* Add/Update Tunnel-IP entry of bgp martian next-hop table.
+ *
+ * Returns true only if we add a _new_ TIP so the caller knows that an
+ * actionable change has occurred. If we find an existing TIP then we
+ * only need to update the refcnt, since the collection of known TIPs
+ * has not changed.
+ */
+bool bgp_tip_add(struct bgp *bgp, struct in_addr *tip)
{
struct tip_addr tmp;
struct tip_addr *addr;
+ bool tip_added = false;
tmp.addr = *tip;
- addr = hash_get(bgp->tip_hash, &tmp, bgp_tip_hash_alloc);
+ addr = hash_lookup(bgp->tip_hash, &tmp);
+ if (!addr) {
+ addr = hash_get(bgp->tip_hash, &tmp, bgp_tip_hash_alloc);
+ tip_added = true;
+ }
+
addr->refcnt++;
+
+ return tip_added;
}
void bgp_tip_del(struct bgp *bgp, struct in_addr *tip)