Blame SOURCES/0009-bgp-ttl-security.patch

caebb1
From 8a66632391db5f5181a4afef6aae41f48bee7fdb Mon Sep 17 00:00:00 2001
caebb1
From: Donald Sharp <sharpd@nvidia.com>
caebb1
Date: Fri, 15 Jan 2021 08:14:49 -0500
caebb1
Subject: [PATCH] bgpd: Allow peer-groups to have `ttl-security hops`
caebb1
 configured
caebb1
caebb1
The command `neighbor PGROUP ttl-security hops X` was being
caebb1
accepted but ignored.  Allow it to be stored.  I am still
caebb1
not sure that this is applied correctly, but that is another
caebb1
problem.
caebb1
caebb1
Fixes: #7848
caebb1
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
caebb1
---
caebb1
 bgpd/bgpd.c | 8 +++++---
caebb1
 1 file changed, 5 insertions(+), 3 deletions(-)
caebb1
caebb1
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
caebb1
index 9297ec4711c..4ebd3da0620 100644
caebb1
--- a/bgpd/bgpd.c
caebb1
+++ b/bgpd/bgpd.c
caebb1
@@ -7150,6 +7150,7 @@ int is_ebgp_multihop_configured(struct peer *peer)
caebb1
 int peer_ttl_security_hops_set(struct peer *peer, int gtsm_hops)
caebb1
 {
caebb1
 	struct peer_group *group;
caebb1
+	struct peer *gpeer;
caebb1
 	struct listnode *node, *nnode;
caebb1
 	int ret;
caebb1
 
caebb1
@@ -7186,9 +7187,10 @@ int peer_ttl_security_hops_set(struct peer *peer, int gtsm_hops)
caebb1
 				return ret;
caebb1
 		} else {
caebb1
 			group = peer->group;
caebb1
+			group->conf->gtsm_hops = gtsm_hops;
caebb1
 			for (ALL_LIST_ELEMENTS(group->peer, node, nnode,
caebb1
-					       peer)) {
caebb1
-				peer->gtsm_hops = group->conf->gtsm_hops;
caebb1
+					       gpeer)) {
caebb1
+				gpeer->gtsm_hops = group->conf->gtsm_hops;
caebb1
 
caebb1
 				/* Calling ebgp multihop also resets the
caebb1
 				 * session.
caebb1
@@ -7198,7 +7200,7 @@ int peer_ttl_security_hops_set(struct peer *peer, int gtsm_hops)
caebb1
 				 * value is
caebb1
 				 * irrelevant.
caebb1
 				 */
caebb1
-				peer_ebgp_multihop_set(peer, MAXTTL);
caebb1
+				peer_ebgp_multihop_set(gpeer, MAXTTL);
caebb1
 			}
caebb1
 		}
caebb1
 	} else {
caebb1
@@ -7219,9 +7221,10 @@ int peer_ttl_security_hops_set(struct peer *peer, int gtsm_hops)
caebb1
 					       MAXTTL + 1 - gtsm_hops);
caebb1
 		} else {
caebb1
 			group = peer->group;
caebb1
+			group->conf->gtsm_hops = gtsm_hops;
caebb1
 			for (ALL_LIST_ELEMENTS(group->peer, node, nnode,
caebb1
-					       peer)) {
caebb1
-				peer->gtsm_hops = group->conf->gtsm_hops;
caebb1
+					       gpeer)) {
caebb1
+				gpeer->gtsm_hops = group->conf->gtsm_hops;
caebb1
 
caebb1
 				/* Change setting of existing peer
caebb1
 				 *   established then change value (may break
caebb1
@@ -7231,17 +7234,18 @@ int peer_ttl_security_hops_set(struct peer *peer, int gtsm_hops)
caebb1
 				 *   no session then do nothing (will get
caebb1
 				 * handled by next connection)
caebb1
 				 */
caebb1
-				if (peer->fd >= 0
caebb1
-				    && peer->gtsm_hops
caebb1
+				if (gpeer->fd >= 0
caebb1
+				    && gpeer->gtsm_hops
caebb1
 					       != BGP_GTSM_HOPS_DISABLED)
caebb1
 					sockopt_minttl(
caebb1
-						peer->su.sa.sa_family, peer->fd,
caebb1
-						MAXTTL + 1 - peer->gtsm_hops);
caebb1
-				if ((peer->status < Established)
caebb1
-				    && peer->doppelganger
caebb1
-				    && (peer->doppelganger->fd >= 0))
caebb1
-					sockopt_minttl(peer->su.sa.sa_family,
caebb1
-						       peer->doppelganger->fd,
caebb1
+						gpeer->su.sa.sa_family,
caebb1
+						gpeer->fd,
caebb1
+						MAXTTL + 1 - gpeer->gtsm_hops);
caebb1
+				if ((gpeer->status < Established)
caebb1
+				    && gpeer->doppelganger
caebb1
+				    && (gpeer->doppelganger->fd >= 0))
caebb1
+					sockopt_minttl(gpeer->su.sa.sa_family,
caebb1
+						       gpeer->doppelganger->fd,
caebb1
 						       MAXTTL + 1 - gtsm_hops);
caebb1
 			}
caebb1
 		}