summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-12-04 07:23:14 +0100
committerChristian Poessinger <christian@poessinger.com>2021-12-04 07:37:55 +0100
commit63cadf52a4b8d8aa31a868c4b19e44a9eff12d37 (patch)
treec24a00cc6822eab7fe3c27f412533037b0e9448c
parent86df16c3b3055b82f3e0a9e705794302fa2df257 (diff)
downloadvyos-1x-63cadf52a4b8d8aa31a868c4b19e44a9eff12d37.tar.gz
vyos-1x-63cadf52a4b8d8aa31a868c4b19e44a9eff12d37.zip
bfd: T4044: add VRF support for peers
-rw-r--r--interface-definitions/protocols-bfd.xml.in1
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_bfd.py11
-rwxr-xr-xsrc/conf_mode/protocols_bfd.py4
3 files changed, 15 insertions, 1 deletions
diff --git a/interface-definitions/protocols-bfd.xml.in b/interface-definitions/protocols-bfd.xml.in
index 7b22b8125..d5a968001 100644
--- a/interface-definitions/protocols-bfd.xml.in
+++ b/interface-definitions/protocols-bfd.xml.in
@@ -73,6 +73,7 @@
<valueless/>
</properties>
</leafNode>
+ #include <include/interface/vrf.xml.i>
</children>
</tagNode>
<tagNode name="profile">
diff --git a/smoketest/scripts/cli/test_protocols_bfd.py b/smoketest/scripts/cli/test_protocols_bfd.py
index 46a019dfc..532814ef3 100755
--- a/smoketest/scripts/cli/test_protocols_bfd.py
+++ b/smoketest/scripts/cli/test_protocols_bfd.py
@@ -24,6 +24,7 @@ PROCESS_NAME = 'bfdd'
base_path = ['protocols', 'bfd']
dum_if = 'dum1001'
+vrf_name = 'red'
peers = {
'192.0.2.10' : {
'intv_rx' : '500',
@@ -42,7 +43,7 @@ peers = {
},
'2001:db8::a' : {
'source_addr': '2001:db8::1',
- 'source_intf': dum_if,
+ 'vrf' : vrf_name,
},
'2001:db8::b' : {
'source_addr': '2001:db8::1',
@@ -73,6 +74,8 @@ class TestProtocolsBFD(VyOSUnitTestSHIM.TestCase):
self.assertTrue(process_named_running(PROCESS_NAME))
def test_bfd_peer(self):
+ self.cli_set(['vrf', 'name', vrf_name, 'table', '1000'])
+
for peer, peer_config in peers.items():
if 'echo_mode' in peer_config:
self.cli_set(base_path + ['peer', peer, 'echo-mode'])
@@ -92,6 +95,8 @@ class TestProtocolsBFD(VyOSUnitTestSHIM.TestCase):
self.cli_set(base_path + ['peer', peer, 'source', 'address', peer_config["source_addr"]])
if 'source_intf' in peer_config:
self.cli_set(base_path + ['peer', peer, 'source', 'interface', peer_config["source_intf"]])
+ if 'vrf' in peer_config:
+ self.cli_set(base_path + ['peer', peer, 'vrf', peer_config["vrf"]])
# commit changes
self.cli_commit()
@@ -106,6 +111,8 @@ class TestProtocolsBFD(VyOSUnitTestSHIM.TestCase):
tmp += f' local-address {peer_config["source_addr"]}'
if 'source_intf' in peer_config:
tmp += f' interface {peer_config["source_intf"]}'
+ if 'vrf' in peer_config:
+ tmp += f' vrf {peer_config["vrf"]}'
self.assertIn(tmp, frrconfig)
peerconfig = self.getFRRconfig(f' peer {peer}', end='')
@@ -126,6 +133,8 @@ class TestProtocolsBFD(VyOSUnitTestSHIM.TestCase):
else:
self.assertNotIn(f'shutdown', peerconfig)
+ self.cli_delete(['vrf', 'name', vrf_name])
+
def test_bfd_profile(self):
peer = '192.0.2.10'
diff --git a/src/conf_mode/protocols_bfd.py b/src/conf_mode/protocols_bfd.py
index 1f8e4ddc6..6981d0db1 100755
--- a/src/conf_mode/protocols_bfd.py
+++ b/src/conf_mode/protocols_bfd.py
@@ -18,6 +18,7 @@ import os
from vyos.config import Config
from vyos.configdict import dict_merge
+from vyos.configverify import verify_vrf
from vyos.template import is_ipv6
from vyos.template import render_to_string
from vyos.validate import is_ipv6_link_local
@@ -83,6 +84,9 @@ def verify(bfd):
if 'source' in peer_config and 'interface' in peer_config['source']:
raise ConfigError('Multihop and source interface cannot be used together')
+ if 'vrf' in peer_config:
+ verify_vrf(peer_config)
+
return None
def generate(bfd):