Blame SOURCES/0012-graceful-restart.patch

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