summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2024-05-08 17:26:58 +0200
committerGitHub <noreply@github.com>2024-05-08 17:26:58 +0200
commit1b7a2d19cb8671391b541ffec610f36d1832bab7 (patch)
treeebbeb9378a11b51ce1b64fc8b9e12bc98aabb9c0
parentd7907cc7011459ecc99afe162490c4c571c0d9bb (diff)
parenta9700bd9bc3600416e7ec809754dd13cc09729fb (diff)
downloadvyos-1x-1b7a2d19cb8671391b541ffec610f36d1832bab7.tar.gz
vyos-1x-1b7a2d19cb8671391b541ffec610f36d1832bab7.zip
Merge pull request #3427 from vyos/mergify/bp/sagitta/pr-3422
bgp: T6082: Allow the same local-as and remote-as in one peer group (backport #3422)
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_bgp.py21
-rwxr-xr-xsrc/conf_mode/protocols_bgp.py2
2 files changed, 22 insertions, 1 deletions
diff --git a/smoketest/scripts/cli/test_protocols_bgp.py b/smoketest/scripts/cli/test_protocols_bgp.py
index 03daa34aa..ea2f561a4 100755
--- a/smoketest/scripts/cli/test_protocols_bgp.py
+++ b/smoketest/scripts/cli/test_protocols_bgp.py
@@ -1330,6 +1330,27 @@ class TestProtocolsBGP(VyOSUnitTestSHIM.TestCase):
self.assertIn(f'neighbor {ext_neighbors[1]} remote-as external', conf)
self.assertIn(f'neighbor {ext_neighbors[1]} peer-group {ext_pg_name}', conf)
+ def test_bgp_29_peer_group_remote_as_equal_local_as(self):
+ self.cli_set(base_path + ['system-as', ASN])
+ self.cli_set(base_path + ['peer-group', 'OVERLAY', 'local-as', f'{int(ASN) + 1}'])
+ self.cli_set(base_path + ['peer-group', 'OVERLAY', 'remote-as', f'{int(ASN) + 1}'])
+ self.cli_set(base_path + ['peer-group', 'OVERLAY', 'address-family', 'l2vpn-evpn'])
+
+ self.cli_set(base_path + ['peer-group', 'UNDERLAY', 'address-family', 'ipv4-unicast'])
+
+ self.cli_set(base_path + ['neighbor', '10.177.70.62', 'peer-group', 'UNDERLAY'])
+ self.cli_set(base_path + ['neighbor', '10.177.70.62', 'remote-as', 'external'])
+
+ self.cli_set(base_path + ['neighbor', '10.177.75.1', 'peer-group', 'OVERLAY'])
+ self.cli_set(base_path + ['neighbor', '10.177.75.2', 'peer-group', 'OVERLAY'])
+
+ self.cli_commit()
+
+ conf = self.getFRRconfig(f'router bgp {ASN}')
+
+ self.assertIn(f'neighbor OVERLAY remote-as {int(ASN) + 1}', conf)
+ self.assertIn(f'neighbor OVERLAY local-as {int(ASN) + 1}', conf)
+
def test_bgp_99_bmp(self):
target_name = 'instance-bmp'
target_address = '127.0.0.1'
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py
index 44409c0e3..22f020099 100755
--- a/src/conf_mode/protocols_bgp.py
+++ b/src/conf_mode/protocols_bgp.py
@@ -333,7 +333,7 @@ def verify(bgp):
raise ConfigError('Cannot have local-as same as system-as number')
# Neighbor AS specified for local-as and remote-as can not be the same
- if dict_search('remote_as', peer_config) == asn:
+ if dict_search('remote_as', peer_config) == asn and neighbor != 'peer_group':
raise ConfigError(f'Neighbor "{peer}" has local-as specified which is '\
'the same as remote-as, this is not allowed!')