|
| 1 | +From b7bd0b097586fbd492b0dc61346b89efb1a7b420 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Donald Sharp < [email protected]> |
| 3 | +Date: Sat, 18 Oct 2025 10:22:56 -0400 |
| 4 | +Subject: [PATCH] bgpd: Prevent unnecessary re-install of routes |
| 5 | + |
| 6 | +There is this sequence of events that is happening: |
| 7 | + |
| 8 | +a) BGP registers for a nexthop resolution for address A |
| 9 | +b) <time passes and BGP comes fully up> |
| 10 | +c) Something else in the system requests for the same |
| 11 | +nexthop resolution tracking for A |
| 12 | +d) Zebra wakes up and decides to send a update to BGP |
| 13 | +about the nexthop, even when nothing has happened. |
| 14 | +e) BGP decides that the nexthop has not changed but goes |
| 15 | +ahead and reinstalls everything again anyways. |
| 16 | + |
| 17 | +Let's modify BGP to be a bit smarter here. It already |
| 18 | +knows that the nexthop hasn't changed, there is no need |
| 19 | +to run bgp_process on each route that is using the BNC. |
| 20 | +Let's stop this from happening. |
| 21 | + |
| 22 | +This is only 1/2 the fix. I want to protect BGP from zebra |
| 23 | +but I also want zebra to not send the update to BGP in this case. |
| 24 | +That change is going to come in a different set of commits because |
| 25 | +it's a bit larger of a problem and will need a bit more work. |
| 26 | + |
| 27 | +Signed-off-by: Donald Sharp < [email protected]> |
| 28 | +--- |
| 29 | + bgpd/bgp_nht.c | 4 +++- |
| 30 | + 1 file changed, 3 insertions(+), 1 deletion(-) |
| 31 | + |
| 32 | +diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c |
| 33 | +index 330af64379..b720e37bb4 100644 |
| 34 | +--- a/bgpd/bgp_nht.c |
| 35 | ++++ b/bgpd/bgp_nht.c |
| 36 | +@@ -1472,7 +1472,9 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc) |
| 37 | + if (path_valid != bnc_is_valid_nexthop) |
| 38 | + hook_call(bgp_nht_path_update, bgp_path, path, bnc_is_valid_nexthop); |
| 39 | + |
| 40 | +- bgp_process(bgp_path, dest, path, afi, safi); |
| 41 | ++ if (CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_METRIC_CHANGED) || |
| 42 | ++ CHECK_FLAG(bnc->change_flags, BGP_NEXTHOP_CHANGED)) |
| 43 | ++ bgp_process(bgp_path, dest, path, afi, safi); |
| 44 | + } |
| 45 | + |
| 46 | + if (peer) { |
| 47 | +-- |
| 48 | +2.48.1 |
| 49 | + |
0 commit comments