diff options
author | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-05-16 21:53:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-16 21:53:41 +0200 |
commit | b2ca7559b4caa282e56e5be9ba9e3731466939be (patch) | |
tree | ab2f2599126072678c1d1a7d90c4b1d6938b424b /bgpd | |
parent | Merge pull request #11207 from anlancs/fix/zebra-remove-check-l3vni (diff) | |
parent | bgpd: Allow bgp to control the DSCP session TOS value (diff) | |
download | frr-b2ca7559b4caa282e56e5be9ba9e3731466939be.tar.xz frr-b2ca7559b4caa282e56e5be9ba9e3731466939be.zip |
Merge pull request #11152 from donaldsharp/dscp
bgpd: Allow bgp to control the DSCP session TOS value
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_network.c | 11 | ||||
-rw-r--r-- | bgpd/bgp_vty.c | 34 | ||||
-rw-r--r-- | bgpd/bgpd.c | 2 | ||||
-rw-r--r-- | bgpd/bgpd.h | 4 |
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); |