Blame SOURCES/0006-graceful-restart.patch

8eca10
From 12f9f8472d0f8cfc026352906b8e5342df2846cc Mon Sep 17 00:00:00 2001
8eca10
From: Donatas Abraitis <donatas@opensourcerouting.org>
8eca10
Date: Tue, 27 Sep 2022 17:30:16 +0300
8eca10
Subject: [PATCH] bgpd: Do not send Deconfig/Shutdown message when restarting
8eca10
8eca10
We might disable sending unconfig/shutdown notifications when
8eca10
Graceful-Restart is enabled and negotiated.
8eca10
8eca10
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
8eca10
---
8eca10
 bgpd/bgpd.c | 35 ++++++++++++++++++++++++++---------
8eca10
 1 file changed, 26 insertions(+), 9 deletions(-)
8eca10
8eca10
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
8eca10
index 749e46ebe9d..ae1308db423 100644
8eca10
--- a/bgpd/bgpd.c
8eca10
+++ b/bgpd/bgpd.c
8eca10
@@ -2755,11 +2755,34 @@ int peer_group_remote_as(struct bgp *bgp, const char *group_name, as_t *as,
8eca10
 
8eca10
 void peer_notify_unconfig(struct peer *peer)
8eca10
 {
8eca10
+	if (BGP_PEER_GRACEFUL_RESTART_CAPABLE(peer)) {
8eca10
+		if (bgp_debug_neighbor_events(peer))
8eca10
+			zlog_debug(
8eca10
+				"%pBP configured Graceful-Restart, skipping unconfig notification",
8eca10
+				peer);
8eca10
+		return;
8eca10
+	}
8eca10
+
8eca10
 	if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
8eca10
 		bgp_notify_send(peer, BGP_NOTIFY_CEASE,
8eca10
 				BGP_NOTIFY_CEASE_PEER_UNCONFIG);
8eca10
 }
8eca10
 
8eca10
+static void peer_notify_shutdown(struct peer *peer)
8eca10
+{
8eca10
+	if (BGP_PEER_GRACEFUL_RESTART_CAPABLE(peer)) {
8eca10
+		if (bgp_debug_neighbor_events(peer))
8eca10
+			zlog_debug(
8eca10
+				"%pBP configured Graceful-Restart, skipping shutdown notification",
8eca10
+				peer);
8eca10
+		return;
8eca10
+	}
8eca10
+
8eca10
+	if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
8eca10
+		bgp_notify_send(peer, BGP_NOTIFY_CEASE,
8eca10
+				BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN);
8eca10
+}
8eca10
+
8eca10
 void peer_group_notify_unconfig(struct peer_group *group)
8eca10
 {
8eca10
 	struct peer *peer, *other;
8eca10
@@ -3676,11 +3699,8 @@ int bgp_delete(struct bgp *bgp)
8eca10
 	}
8eca10
 
8eca10
 	/* Inform peers we're going down. */
8eca10
-	for (ALL_LIST_ELEMENTS(bgp->peer, node, next, peer)) {
8eca10
-		if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
8eca10
-			bgp_notify_send(peer, BGP_NOTIFY_CEASE,
8eca10
-					BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN);
8eca10
-	}
8eca10
+	for (ALL_LIST_ELEMENTS(bgp->peer, node, next, peer))
8eca10
+		peer_notify_shutdown(peer);
8eca10
 
8eca10
 	/* Delete static routes (networks). */
8eca10
 	bgp_static_delete(bgp);
8eca10
@@ -8252,10 +8272,7 @@ void bgp_terminate(void)
8eca10
 
8eca10
 	for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp))
8eca10
 		for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer))
8eca10
-			if (peer_established(peer) || peer->status == OpenSent
8eca10
-			    || peer->status == OpenConfirm)
8eca10
-				bgp_notify_send(peer, BGP_NOTIFY_CEASE,
8eca10
-						BGP_NOTIFY_CEASE_PEER_UNCONFIG);
8eca10
+			peer_notify_unconfig(peer);
8eca10
 
8eca10
 	BGP_TIMER_OFF(bm->t_rmap_update);
8eca10