forked from Mirror/frr
Merge pull request #17341 from zice312963205/zly_tcpmss
bgpd:support tcp-mss for neighbor group
This commit is contained in:
commit
a85dce2c66
|
@ -18732,7 +18732,7 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TCP max segment size */
|
/* TCP max segment size */
|
||||||
if (CHECK_FLAG(peer->flags, PEER_FLAG_TCP_MSS))
|
if (peergroup_flag_check(peer, PEER_FLAG_TCP_MSS))
|
||||||
vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss);
|
vty_out(vty, " neighbor %s tcp-mss %d\n", addr, peer->tcp_mss);
|
||||||
|
|
||||||
/* passive */
|
/* passive */
|
||||||
|
|
62
bgpd/bgpd.c
62
bgpd/bgpd.c
|
@ -3031,6 +3031,9 @@ static void peer_group2peer_config_copy(struct peer_group *group,
|
||||||
bgp_peer_configure_bfd(peer, false);
|
bgp_peer_configure_bfd(peer, false);
|
||||||
bgp_peer_config_apply(peer, group);
|
bgp_peer_config_apply(peer, group);
|
||||||
}
|
}
|
||||||
|
/* peer tcp-mss */
|
||||||
|
if (!CHECK_FLAG(peer->flags_override, PEER_FLAG_TCP_MSS))
|
||||||
|
PEER_ATTR_INHERIT(peer, group, tcp_mss);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Peer group's remote AS configuration. */
|
/* Peer group's remote AS configuration. */
|
||||||
|
@ -4796,6 +4799,7 @@ static const struct peer_flag_action peer_flag_action_list[] = {
|
||||||
{PEER_FLAG_AS_LOOP_DETECTION, 0, peer_change_none},
|
{PEER_FLAG_AS_LOOP_DETECTION, 0, peer_change_none},
|
||||||
{PEER_FLAG_EXTENDED_LINK_BANDWIDTH, 0, peer_change_none},
|
{PEER_FLAG_EXTENDED_LINK_BANDWIDTH, 0, peer_change_none},
|
||||||
{PEER_FLAG_LONESOUL, 0, peer_change_reset_out},
|
{PEER_FLAG_LONESOUL, 0, peer_change_reset_out},
|
||||||
|
{PEER_FLAG_TCP_MSS, 0, peer_change_none},
|
||||||
{0, 0, 0}};
|
{0, 0, 0}};
|
||||||
|
|
||||||
static const struct peer_flag_action peer_af_flag_action_list[] = {
|
static const struct peer_flag_action peer_af_flag_action_list[] = {
|
||||||
|
@ -6097,9 +6101,27 @@ void peer_port_unset(struct peer *peer)
|
||||||
*/
|
*/
|
||||||
void peer_tcp_mss_set(struct peer *peer, uint32_t tcp_mss)
|
void peer_tcp_mss_set(struct peer *peer, uint32_t tcp_mss)
|
||||||
{
|
{
|
||||||
|
struct peer *member;
|
||||||
|
struct listnode *node, *nnode;
|
||||||
|
|
||||||
|
peer_flag_set(peer, PEER_FLAG_TCP_MSS);
|
||||||
peer->tcp_mss = tcp_mss;
|
peer->tcp_mss = tcp_mss;
|
||||||
SET_FLAG(peer->flags, PEER_FLAG_TCP_MSS);
|
|
||||||
bgp_tcp_mss_set(peer);
|
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
|
||||||
|
bgp_tcp_mss_set(peer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ALL_LIST_ELEMENTS(peer->group->peer, node, nnode, member)) {
|
||||||
|
/* Skip peers with overridden configuration. */
|
||||||
|
if (CHECK_FLAG(member->flags_override, PEER_FLAG_TCP_MSS))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Set flag and configuration on peer-group member. */
|
||||||
|
SET_FLAG(member->flags, PEER_FLAG_TCP_MSS);
|
||||||
|
PEER_ATTR_INHERIT(member, peer->group, tcp_mss);
|
||||||
|
bgp_tcp_mss_set(member);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset the TCP-MSS value in the peer structure,
|
/* Reset the TCP-MSS value in the peer structure,
|
||||||
|
@ -6108,9 +6130,39 @@ void peer_tcp_mss_set(struct peer *peer, uint32_t tcp_mss)
|
||||||
*/
|
*/
|
||||||
void peer_tcp_mss_unset(struct peer *peer)
|
void peer_tcp_mss_unset(struct peer *peer)
|
||||||
{
|
{
|
||||||
UNSET_FLAG(peer->flags, PEER_FLAG_TCP_MSS);
|
struct peer *member;
|
||||||
peer->tcp_mss = 0;
|
struct listnode *node, *nnode;
|
||||||
bgp_tcp_mss_set(peer);
|
|
||||||
|
/* Inherit configuration from peer-group if peer is member. */
|
||||||
|
if (peer_group_active(peer)) {
|
||||||
|
peer_flag_inherit(peer, PEER_FLAG_TCP_MSS);
|
||||||
|
PEER_ATTR_INHERIT(peer, peer->group, tcp_mss);
|
||||||
|
} else {
|
||||||
|
/* Otherwise remove flag and configuration from peer. */
|
||||||
|
peer_flag_unset(peer, PEER_FLAG_TCP_MSS);
|
||||||
|
peer->tcp_mss = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skip peer-group mechanics for regular peers. */
|
||||||
|
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
|
||||||
|
bgp_tcp_mss_set(peer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Remove flag and configuration from all peer-group members, unless
|
||||||
|
* they are explicitely overriding peer-group configuration.
|
||||||
|
*/
|
||||||
|
for (ALL_LIST_ELEMENTS(peer->group->peer, node, nnode, member)) {
|
||||||
|
/* Skip peers with overridden configuration. */
|
||||||
|
if (CHECK_FLAG(member->flags_override, PEER_FLAG_TCP_MSS))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Remove flag and configuration on peer-group member. */
|
||||||
|
UNSET_FLAG(member->flags, PEER_FLAG_TCP_MSS);
|
||||||
|
member->tcp_mss = 0;
|
||||||
|
bgp_tcp_mss_set(member);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
router bgp 65000
|
router bgp 65000
|
||||||
no bgp ebgp-requires-policy
|
no bgp ebgp-requires-policy
|
||||||
|
neighbor aaa peer-group
|
||||||
|
neighbor aaa remote-as 65001
|
||||||
|
neighbor 192.168.254.2 peer-group aaa
|
||||||
neighbor 192.168.255.2 remote-as 65001
|
neighbor 192.168.255.2 remote-as 65001
|
||||||
neighbor 192.168.255.2 timers 3 10
|
neighbor 192.168.255.2 timers 3 10
|
||||||
exit-address-family
|
exit-address-family
|
||||||
|
|
|
@ -2,5 +2,8 @@
|
||||||
interface r1-eth0
|
interface r1-eth0
|
||||||
ip address 192.168.255.1/24
|
ip address 192.168.255.1/24
|
||||||
!
|
!
|
||||||
|
interface r1-eth1
|
||||||
|
ip address 192.168.254.1/24
|
||||||
|
!
|
||||||
ip forwarding
|
ip forwarding
|
||||||
!
|
!
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
router bgp 65001
|
router bgp 65001
|
||||||
no bgp ebgp-requires-policy
|
no bgp ebgp-requires-policy
|
||||||
|
neighbor aaa peer-group
|
||||||
|
neighbor aaa remote-as 65000
|
||||||
|
neighbor 192.168.254.1 peer-group aaa
|
||||||
neighbor 192.168.255.1 remote-as 65000
|
neighbor 192.168.255.1 remote-as 65000
|
||||||
neighbor 192.168.255.1 timers 3 10
|
neighbor 192.168.255.1 timers 3 10
|
||||||
exit-address-family
|
exit-address-family
|
||||||
|
|
|
@ -2,5 +2,8 @@
|
||||||
interface r2-eth0
|
interface r2-eth0
|
||||||
ip address 192.168.255.2/24
|
ip address 192.168.255.2/24
|
||||||
!
|
!
|
||||||
|
interface r2-eth1
|
||||||
|
ip address 192.168.254.2/24
|
||||||
|
!
|
||||||
ip forwarding
|
ip forwarding
|
||||||
!
|
!
|
||||||
|
|
|
@ -45,6 +45,10 @@ def build_topo(tgen):
|
||||||
switch.add_link(tgen.gears["r1"])
|
switch.add_link(tgen.gears["r1"])
|
||||||
switch.add_link(tgen.gears["r2"])
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
|
switch = tgen.add_switch("s2")
|
||||||
|
switch.add_link(tgen.gears["r1"])
|
||||||
|
switch.add_link(tgen.gears["r2"])
|
||||||
|
|
||||||
|
|
||||||
def setup_module(mod):
|
def setup_module(mod):
|
||||||
tgen = Topogen(build_topo, mod.__name__)
|
tgen = Topogen(build_topo, mod.__name__)
|
||||||
|
@ -78,12 +82,16 @@ def test_bgp_tcp_mss():
|
||||||
router2 = tgen.gears["r2"]
|
router2 = tgen.gears["r2"]
|
||||||
|
|
||||||
def _bgp_converge(router):
|
def _bgp_converge(router):
|
||||||
output = json.loads(router.vtysh_cmd("show ip bgp neighbor 192.168.255.2 json"))
|
output = json.loads(router.vtysh_cmd("show ip bgp neighbor json"))
|
||||||
expected = {
|
expected = {
|
||||||
"192.168.255.2": {
|
"192.168.255.2": {
|
||||||
"bgpState": "Established",
|
"bgpState": "Established",
|
||||||
"addressFamilyInfo": {"ipv4Unicast": {"acceptedPrefixCounter": 0}},
|
"addressFamilyInfo": {"ipv4Unicast": {"acceptedPrefixCounter": 0}},
|
||||||
}
|
},
|
||||||
|
"192.168.254.2": {
|
||||||
|
"bgpState": "Established",
|
||||||
|
"addressFamilyInfo": {"ipv4Unicast": {"acceptedPrefixCounter": 0}},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return topotest.json_cmp(output, expected)
|
return topotest.json_cmp(output, expected)
|
||||||
|
|
||||||
|
@ -108,7 +116,7 @@ def test_bgp_tcp_mss():
|
||||||
|
|
||||||
logger.info("Check if neighbor sessions are up in {}".format(router1.name))
|
logger.info("Check if neighbor sessions are up in {}".format(router1.name))
|
||||||
test_func = functools.partial(_bgp_converge, router1)
|
test_func = functools.partial(_bgp_converge, router1)
|
||||||
_, result = topotest.run_and_expect(test_func, None, count=15, wait=0.5)
|
_, result = topotest.run_and_expect(test_func, None, count=15, wait=1)
|
||||||
assert result is None, 'Failed to see BGP convergence in "{}"'.format(router1.name)
|
assert result is None, 'Failed to see BGP convergence in "{}"'.format(router1.name)
|
||||||
|
|
||||||
logger.info("BGP neighbor session is up in {}".format(router1.name))
|
logger.info("BGP neighbor session is up in {}".format(router1.name))
|
||||||
|
@ -117,19 +125,21 @@ def test_bgp_tcp_mss():
|
||||||
"Configure tcp-mss 500 on {} and reset the session".format(router1.name)
|
"Configure tcp-mss 500 on {} and reset the session".format(router1.name)
|
||||||
)
|
)
|
||||||
_bgp_conf_tcp_mss(router1, "65000", "192.168.255.2")
|
_bgp_conf_tcp_mss(router1, "65000", "192.168.255.2")
|
||||||
|
_bgp_conf_tcp_mss(router1, "65000", "aaa")
|
||||||
_bgp_clear_session(router1)
|
_bgp_clear_session(router1)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Configure tcp-mss 500 on {} and reset the session".format(router2.name)
|
"Configure tcp-mss 500 on {} and reset the session".format(router2.name)
|
||||||
)
|
)
|
||||||
_bgp_conf_tcp_mss(router2, "65001", "192.168.255.1")
|
_bgp_conf_tcp_mss(router2, "65001", "192.168.255.1")
|
||||||
|
_bgp_conf_tcp_mss(router2, "65001", "aaa")
|
||||||
_bgp_clear_session(router2)
|
_bgp_clear_session(router2)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"Check if neighbor session is up after reset in {}".format(router1.name)
|
"Check if neighbor session is up after reset in {}".format(router1.name)
|
||||||
)
|
)
|
||||||
test_func = functools.partial(_bgp_converge, router1)
|
test_func = functools.partial(_bgp_converge, router1)
|
||||||
_, result = topotest.run_and_expect(test_func, None, count=15, wait=0.5)
|
_, result = topotest.run_and_expect(test_func, None, count=15, wait=1)
|
||||||
assert result is None, 'Failed to see BGP convergence after reset in "{}"'.format(
|
assert result is None, 'Failed to see BGP convergence after reset in "{}"'.format(
|
||||||
router1.name
|
router1.name
|
||||||
)
|
)
|
||||||
|
@ -138,7 +148,13 @@ def test_bgp_tcp_mss():
|
||||||
"Verify if TCP MSS value is synced with neighbor in {}".format(router1.name)
|
"Verify if TCP MSS value is synced with neighbor in {}".format(router1.name)
|
||||||
)
|
)
|
||||||
test_func = functools.partial(_bgp_check_neighbor_tcp_mss, router1, "192.168.255.2")
|
test_func = functools.partial(_bgp_check_neighbor_tcp_mss, router1, "192.168.255.2")
|
||||||
_, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
|
_, result = topotest.run_and_expect(test_func, None, count=15, wait=1)
|
||||||
|
assert (
|
||||||
|
result is None
|
||||||
|
), 'Failed to sync TCP MSS value over BGP session in "{}"'.format(router1.name)
|
||||||
|
|
||||||
|
test_func = functools.partial(_bgp_check_neighbor_tcp_mss, router1, "192.168.254.2")
|
||||||
|
success, result = topotest.run_and_expect(test_func, None, count=15, wait=1)
|
||||||
assert (
|
assert (
|
||||||
result is None
|
result is None
|
||||||
), 'Failed to sync TCP MSS value over BGP session in "{}"'.format(router1.name)
|
), 'Failed to sync TCP MSS value over BGP session in "{}"'.format(router1.name)
|
||||||
|
@ -148,7 +164,13 @@ def test_bgp_tcp_mss():
|
||||||
"Verify if TCP MSS value is synced with neighbor in {}".format(router2.name)
|
"Verify if TCP MSS value is synced with neighbor in {}".format(router2.name)
|
||||||
)
|
)
|
||||||
test_func = functools.partial(_bgp_check_neighbor_tcp_mss, router2, "192.168.255.1")
|
test_func = functools.partial(_bgp_check_neighbor_tcp_mss, router2, "192.168.255.1")
|
||||||
_, result = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
|
_, result = topotest.run_and_expect(test_func, None, count=15, wait=1)
|
||||||
|
assert (
|
||||||
|
result is None
|
||||||
|
), 'Failed to sync TCP MSS value over BGP session in "{}"'.format(router2.name)
|
||||||
|
|
||||||
|
test_func = functools.partial(_bgp_check_neighbor_tcp_mss, router2, "192.168.254.1")
|
||||||
|
success, result = topotest.run_and_expect(test_func, None, count=15, wait=1)
|
||||||
assert (
|
assert (
|
||||||
result is None
|
result is None
|
||||||
), 'Failed to sync TCP MSS value over BGP session in "{}"'.format(router2.name)
|
), 'Failed to sync TCP MSS value over BGP session in "{}"'.format(router2.name)
|
||||||
|
|
Loading…
Reference in a new issue