Blame SOURCES/0012-graceful-restart.patch

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