Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated BBR to use peer group name as prefix. #6515

Merged
merged 2 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/sonic-bgpcfgd/bgpcfgd/managers_bbr.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ def __set_prepare_config(self, status):
for af in ["ipv4", "ipv6"]:
cmds.append(" address-family %s" % af)
for pg_name in sorted(self.bbr_enabled_pgs.keys()):
if pg_name in available_peer_groups and af in self.bbr_enabled_pgs[pg_name]:
cmds.append(" %sneighbor %s allowas-in 1" % (prefix_of_commands, pg_name))
peer_groups_to_restart.add(pg_name)
for peer_group_name in available_peer_groups:
if peer_group_name.startswith(pg_name) and af in self.bbr_enabled_pgs[pg_name]:
cmds.append(" %sneighbor %s allowas-in 1" % (prefix_of_commands, peer_group_name))
peer_groups_to_restart.add(peer_group_name)
return cmds, list(peer_groups_to_restart)

def __get_available_peer_groups(self):
Expand Down
40 changes: 37 additions & 3 deletions src/sonic-bgpcfgd/tests/test_bbr.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def test___set_validation_4():
def test___set_validation_5():
__set_validation_common("all", {"status": "disabled"}, None, True)

def __set_prepare_config_common(status, bbr_enabled_pgs, available_pgs, expected_cmds):
def __set_prepare_config_common(status, bbr_enabled_pgs, available_pgs, expected_cmds, bbr_applied_pgs=None):
cfg_mgr = MagicMock()
common_objs = {
'directory': Directory(),
Expand All @@ -269,10 +269,10 @@ def __set_prepare_config_common(status, bbr_enabled_pgs, available_pgs, expected
}
}
m.bbr_enabled_pgs = bbr_enabled_pgs
m._BBRMgr__get_available_peer_groups = MagicMock(return_value = available_pgs)
m._BBRMgr__get_available_peer_groups = MagicMock(return_value = sorted(available_pgs))
cmds, peer_groups = m._BBRMgr__set_prepare_config(status)
assert cmds == expected_cmds
assert set(peer_groups) == available_pgs
assert set(peer_groups) == (available_pgs if not bbr_applied_pgs else bbr_applied_pgs)

def test___set_prepare_config_enabled():
__set_prepare_config_common("enabled", {
Expand Down Expand Up @@ -327,7 +327,41 @@ def test___set_prepare_config_disabled_part():
' no neighbor PEER_V4 allowas-in 1',
' no neighbor PEER_V6 allowas-in 1',
])
def test___set_prepare_config_enabled_multiple_peers():
__set_prepare_config_common("enabled", {
"PEER_V4": ["ipv4"],
"PEER_V6": ["ipv6"],
}, {"PEER_V4", "PEER_V4_DEPLOYMENT_ID_0", "PEER_V4_DEPLOYMENT_ID_1", "PEER_V6", "PEER_V6_DEPLOYMENT_ID_0", "PEER_V6_DEPLOYMENT_ID_1", "PEER_INVALID"},
[
'router bgp 65500',
' address-family ipv4',
' neighbor PEER_V4 allowas-in 1',
' neighbor PEER_V4_DEPLOYMENT_ID_0 allowas-in 1',
' neighbor PEER_V4_DEPLOYMENT_ID_1 allowas-in 1',
' address-family ipv6',
' neighbor PEER_V6 allowas-in 1',
' neighbor PEER_V6_DEPLOYMENT_ID_0 allowas-in 1',
' neighbor PEER_V6_DEPLOYMENT_ID_1 allowas-in 1',
],
{"PEER_V4", "PEER_V4_DEPLOYMENT_ID_0", "PEER_V4_DEPLOYMENT_ID_1", "PEER_V6", "PEER_V6_DEPLOYMENT_ID_0", "PEER_V6_DEPLOYMENT_ID_1"})

def test___set_prepare_config_disabled_multiple_peers():
__set_prepare_config_common("disabled", {
"PEER_V4": ["ipv4"],
"PEER_V6": ["ipv6"],
}, {"PEER_V4", "PEER_V4_DEPLOYMENT_ID_0", "PEER_V4_DEPLOYMENT_ID_1", "PEER_V6", "PEER_V6_DEPLOYMENT_ID_0", "PEER_V6_DEPLOYMENT_ID_1", "PEER_INVALID"},
[
'router bgp 65500',
' address-family ipv4',
' no neighbor PEER_V4 allowas-in 1',
' no neighbor PEER_V4_DEPLOYMENT_ID_0 allowas-in 1',
' no neighbor PEER_V4_DEPLOYMENT_ID_1 allowas-in 1',
' address-family ipv6',
' no neighbor PEER_V6 allowas-in 1',
' no neighbor PEER_V6_DEPLOYMENT_ID_0 allowas-in 1',
' no neighbor PEER_V6_DEPLOYMENT_ID_1 allowas-in 1',
],
{"PEER_V4", "PEER_V4_DEPLOYMENT_ID_0", "PEER_V4_DEPLOYMENT_ID_1", "PEER_V6", "PEER_V6_DEPLOYMENT_ID_0", "PEER_V6_DEPLOYMENT_ID_1"})

def test__get_available_peer_groups():
cfg_mgr = MagicMock()
Expand Down