summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorPavel Shirshov <pavelsh@microsoft.com>2022-05-05 20:16:27 +0200
committerDonald Sharp <sharpd@pinkbelly.org>2022-05-13 20:14:35 +0200
commit425bd64be847f1f8dd3c4c24b5a6d8f2fe05fb30 (patch)
treedb71ae18cda7dee3b4f0f8628c783464976c2f96 /bgpd
parentMerge pull request #11195 from anlancs/fix/lib-qsort (diff)
downloadfrr-425bd64be847f1f8dd3c4c24b5a6d8f2fe05fb30.tar.xz
frr-425bd64be847f1f8dd3c4c24b5a6d8f2fe05fb30.zip
bgpd: Allow bgp to control the DSCP session TOS value
Allow BGP to control the TOS DSCP value in the tcp header via a new command at the bgp global level `bgp session-dscp <0-63>` Signed-off-by: Donald Sharp <sharpd@nvidia.com> Signed-off-by: Pavel Shirhov <pavelsh@microsoft.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_network.c11
-rw-r--r--bgpd/bgp_vty.c34
-rw-r--r--bgpd/bgpd.c2
-rw-r--r--bgpd/bgpd.h4
4 files changed, 43 insertions, 8 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index e702ee4fd..77e2a0f53 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -741,11 +741,9 @@ int bgp_connect(struct peer *peer)
#ifdef IPTOS_PREC_INTERNETCONTROL
frr_with_privs(&bgpd_privs) {
if (sockunion_family(&peer->su) == AF_INET)
- setsockopt_ipv4_tos(peer->fd,
- IPTOS_PREC_INTERNETCONTROL);
+ setsockopt_ipv4_tos(peer->fd, bm->tcp_dscp);
else if (sockunion_family(&peer->su) == AF_INET6)
- setsockopt_ipv6_tclass(peer->fd,
- IPTOS_PREC_INTERNETCONTROL);
+ setsockopt_ipv6_tclass(peer->fd, bm->tcp_dscp);
}
#endif
@@ -822,10 +820,9 @@ static int bgp_listener(int sock, struct sockaddr *sa, socklen_t salen,
#ifdef IPTOS_PREC_INTERNETCONTROL
if (sa->sa_family == AF_INET)
- setsockopt_ipv4_tos(sock, IPTOS_PREC_INTERNETCONTROL);
+ setsockopt_ipv4_tos(sock, bm->tcp_dscp);
else if (sa->sa_family == AF_INET6)
- setsockopt_ipv6_tclass(sock,
- IPTOS_PREC_INTERNETCONTROL);
+ setsockopt_ipv6_tclass(sock, bm->tcp_dscp);
#endif
sockopt_v6only(sa->sa_family, sock);
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 4a3688be2..9e22c6cdb 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -1568,6 +1568,32 @@ DEFUN (no_router_bgp,
return CMD_SUCCESS;
}
+/* bgp session-dscp */
+
+DEFPY (bgp_session_dscp,
+ bgp_session_dscp_cmd,
+ "bgp session-dscp (0-63)$dscp",
+ BGP_STR
+ "Override default (C6) bgp TCP session DSCP value\n"
+ "Manually configured dscp parameter\n")
+{
+ bm->tcp_dscp = dscp << 2;
+
+ return CMD_SUCCESS;
+}
+
+DEFPY (no_bgp_session_dscp,
+ no_bgp_session_dscp_cmd,
+ "no bgp session-dscp [(0-63)]",
+ NO_STR
+ BGP_STR
+ "Override default (C6) bgp TCP session DSCP value\n"
+ "Manually configured dscp parameter\n")
+{
+ bm->tcp_dscp = IPTOS_PREC_INTERNETCONTROL;
+
+ return CMD_SUCCESS;
+}
/* BGP router-id. */
@@ -17126,6 +17152,10 @@ int bgp_config_write(struct vty *vty)
if (CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA))
vty_out(vty, "bgp send-extra-data zebra\n");
+ /* BGP session DSCP value */
+ if (bm->tcp_dscp != IPTOS_PREC_INTERNETCONTROL)
+ vty_out(vty, "bgp session-dscp %u\n", bm->tcp_dscp >> 2);
+
/* BGP configuration. */
for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) {
@@ -17829,6 +17859,10 @@ void bgp_vty_init(void)
/* "no router bgp" commands. */
install_element(CONFIG_NODE, &no_router_bgp_cmd);
+ /* "bgp session-dscp command */
+ install_element(CONFIG_NODE, &bgp_session_dscp_cmd);
+ install_element(CONFIG_NODE, &no_bgp_session_dscp_cmd);
+
/* "bgp router-id" commands. */
install_element(BGP_NODE, &bgp_router_id_cmd);
install_element(BGP_NODE, &no_bgp_router_id_cmd);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 779540772..7d284f28b 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -3259,7 +3259,6 @@ static struct bgp *bgp_create(as_t *as, const char *name,
bgp->evpn_info = XCALLOC(MTYPE_BGP_EVPN_INFO,
sizeof(struct bgp_evpn_info));
-
bgp_evpn_init(bgp);
bgp_evpn_vrf_es_init(bgp);
bgp_pbr_init(bgp);
@@ -7854,6 +7853,7 @@ void bgp_master_init(struct thread_master *master, const int buffer_size,
bm->terminating = false;
bm->socket_buffer = buffer_size;
bm->wait_for_fib = false;
+ bm->tcp_dscp = IPTOS_PREC_INTERNETCONTROL;
bgp_mac_init();
/* init the rd id space.
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index af07cb4c1..6b58c101a 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -171,6 +171,10 @@ struct bgp_master {
#define BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA (1 << 1)
bool terminating; /* global flag that sigint terminate seen */
+
+ /* DSCP value for TCP sessions */
+ uint8_t tcp_dscp;
+
QOBJ_FIELDS;
};
DECLARE_QOBJ_TYPE(bgp_master);