diff options
| author | Jafar Al-Gharaibeh <jafar@atcorp.com> | 2025-03-27 10:27:11 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-27 10:27:11 -0500 |
| commit | 2224879e54f4866334ba43be373928dab46f0012 (patch) | |
| tree | ae48a33f2cbb71b3b277fb8768850cc99cd9354c | |
| parent | 2f6fb565fc84b98ce1cd88c3b366f0ae18ac423b (diff) | |
| parent | 93ba3dd5477a1e6a60b1e35c2c16bc7a1ecd6aa8 (diff) | |
Merge pull request #18516 from opensourcerouting/fix/backport_18498_10.2
bgpd: Retain the routes if we do a clear with N-bit set for Graceful-Restart (backport)
| -rw-r--r-- | bgpd/bgp_packet.c | 7 | ||||
| -rw-r--r-- | tests/topotests/bgp_gr_notification/r1/bgpd.conf | 1 | ||||
| -rw-r--r-- | tests/topotests/bgp_gr_notification/r2/bgpd.conf | 1 | ||||
| -rw-r--r-- | tests/topotests/bgp_gr_notification/test_bgp_gr_notification.py | 43 |
4 files changed, 35 insertions, 17 deletions
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 2dbeb3cbde..1669a5c106 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -1035,6 +1035,13 @@ static void bgp_notify_send_internal(struct peer_connection *connection, /* Add packet to peer's output queue */ stream_fifo_push(connection->obuf, s); + /* If Graceful-Restart N-bit (Notification) is exchanged, + * and it's not a Hard Reset, let's retain the routes. + */ + if (bgp_has_graceful_restart_notification(peer) && !hard_reset && + CHECK_FLAG(peer->sflags, PEER_STATUS_NSF_MODE)) + SET_FLAG(peer->sflags, PEER_STATUS_NSF_WAIT); + bgp_peer_gr_flags_update(peer); BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(peer->bgp, peer->bgp->peer); diff --git a/tests/topotests/bgp_gr_notification/r1/bgpd.conf b/tests/topotests/bgp_gr_notification/r1/bgpd.conf index 0af042f6be..bca5c33bc3 100644 --- a/tests/topotests/bgp_gr_notification/r1/bgpd.conf +++ b/tests/topotests/bgp_gr_notification/r1/bgpd.conf @@ -3,7 +3,6 @@ router bgp 65001 bgp graceful-restart neighbor 192.168.255.2 remote-as external neighbor 192.168.255.2 timers 1 3 - neighbor 192.168.255.2 timers delayopen 10 address-family ipv4 redistribute connected exit-address-family diff --git a/tests/topotests/bgp_gr_notification/r2/bgpd.conf b/tests/topotests/bgp_gr_notification/r2/bgpd.conf index 8325e21d2c..5e47f9dee3 100644 --- a/tests/topotests/bgp_gr_notification/r2/bgpd.conf +++ b/tests/topotests/bgp_gr_notification/r2/bgpd.conf @@ -4,7 +4,6 @@ router bgp 65002 bgp graceful-restart neighbor 192.168.255.1 remote-as external neighbor 192.168.255.1 timers 1 3 - neighbor 192.168.255.1 timers delayopen 10 address-family ipv4 redistribute connected exit-address-family diff --git a/tests/topotests/bgp_gr_notification/test_bgp_gr_notification.py b/tests/topotests/bgp_gr_notification/test_bgp_gr_notification.py index 5d8338d6eb..45e8da94c3 100644 --- a/tests/topotests/bgp_gr_notification/test_bgp_gr_notification.py +++ b/tests/topotests/bgp_gr_notification/test_bgp_gr_notification.py @@ -165,8 +165,8 @@ def test_bgp_administrative_reset_gr(): } return topotest.json_cmp(output, expected) - def _bgp_check_gr_notification_stale(): - output = json.loads(r1.vtysh_cmd("show bgp ipv4 unicast 172.16.255.2/32 json")) + def _bgp_check_gr_notification_stale(router, prefix): + output = json.loads(router.vtysh_cmd(f"show bgp ipv4 unicast {prefix} json")) expected = { "paths": [ { @@ -177,29 +177,42 @@ def test_bgp_administrative_reset_gr(): } return topotest.json_cmp(output, expected) - def _bgp_clear_r1_and_shutdown(): - r2.vtysh_cmd( - """ - clear ip bgp 192.168.255.1 - configure terminal - router bgp - neighbor 192.168.255.1 shutdown - """ - ) - step("Initial BGP converge") test_func = functools.partial(_bgp_converge) _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) assert result is None, "Failed to see BGP convergence on R2" - step("Reset and shutdown R1") - _bgp_clear_r1_and_shutdown() + step("Reset and delay the session establishement for R1") + r1.vtysh_cmd( + """ + configure terminal" + router bgp + neighbor 192.168.255.2 timers delayopen 60 + """ + ) + r2.vtysh_cmd( + """ + configure terminal" + router bgp + neighbor 192.168.255.1 timers delayopen 60 + """ + ) + r2.vtysh_cmd("clear ip bgp 192.168.255.1") step("Check if stale routes are retained on R1") - test_func = functools.partial(_bgp_check_gr_notification_stale) + test_func = functools.partial( + _bgp_check_gr_notification_stale, r1, "172.16.255.2/32" + ) _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) assert result is None, "Failed to see retained stale routes on R1" + step("Check if stale routes are retained on R2") + test_func = functools.partial( + _bgp_check_gr_notification_stale, r2, "172.16.255.1/32" + ) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) + assert result is None, "Failed to see retained stale routes on R2" + step("Check if Hard Reset notification wasn't sent from R2") test_func = functools.partial(_bgp_check_hard_reset) _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) |
