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

fix(validation): add check for multiprotocol BGP sessions #236

Merged
merged 2 commits into from
Dec 20, 2024
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
1 change: 0 additions & 1 deletion routers/router.gru1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
ipv6: fe80::2608
multiprotocol: true
sessions:
- ipv4
- ipv6
wireguard:
remote_address: 64.181.170.30
Expand Down
6 changes: 6 additions & 0 deletions test_validate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ def test_validate_sessions(self):
for session in sessions_valid:
self.assertEqual(validate_sessions(**session), [])

session_ipv4_multiprotocol = {
'sessions': ['ipv4'],
'peer': {'multiprotocol': True, 'ipv4': '192.168.1.1'}
}
self.assertEqual(validate_sessions(**session_ipv4_multiprotocol), ["sessions: 'ipv4' cannot be used with multiprotocol"])

def test_validate_wireguard(self):
not_dict = []
self.assertEqual(validate_wireguard(not_dict), f"wireguard: '{not_dict}' must be type dictionary")
Expand Down
4 changes: 4 additions & 0 deletions validate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ def validate_sessions(sessions, peer):
if "ipv6" in sessions and "ipv6" not in peer:
errors.append("ipv6 required when sessions['ipv6']")

if "ipv4" in sessions and "multiprotocol" in peer:
if peer["multiprotocol"]:
errors.append("sessions: 'ipv4' cannot be used with multiprotocol")

return errors


Expand Down
Loading