diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-05-28 22:59:17 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2022-05-28 22:59:17 +0200 |
commit | f9e38622adc6edb66c84c397ef4d0ae9e49e008e (patch) | |
tree | ada22e119bedfe9badd22bf583a6958dfbb50be5 | |
parent | 8099770c1004d4dd756145050157f51f474ede95 (diff) | |
download | vyos-1x-f9e38622adc6edb66c84c397ef4d0ae9e49e008e.tar.gz vyos-1x-f9e38622adc6edb66c84c397ef4d0ae9e49e008e.zip |
rip: T4448: add support to set protocol version on an interface level
-rw-r--r-- | data/templates/frr/ripd.frr.j2 | 6 | ||||
-rw-r--r-- | interface-definitions/include/rip/version.xml.i | 19 | ||||
-rw-r--r-- | interface-definitions/protocols-rip.xml.in | 34 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_protocols_rip.py | 9 | ||||
-rwxr-xr-x | src/conf_mode/protocols_rip.py | 15 |
5 files changed, 66 insertions, 17 deletions
diff --git a/data/templates/frr/ripd.frr.j2 b/data/templates/frr/ripd.frr.j2 index e884ed85f..e9e484cc2 100644 --- a/data/templates/frr/ripd.frr.j2 +++ b/data/templates/frr/ripd.frr.j2 @@ -32,6 +32,12 @@ interface {{ iface }} {% if iface_config.split_horizon.poison_reverse is vyos_defined %} ip rip split-horizon poisoned-reverse {% endif %} +{% if iface_config.receive.version is vyos_defined %} + ip rip receive version {{ iface_config.receive.version }} +{% endif %} +{% if iface_config.send.version is vyos_defined %} + ip rip send version {{ iface_config.send.version }} +{% endif %} exit ! {% endfor %} diff --git a/interface-definitions/include/rip/version.xml.i b/interface-definitions/include/rip/version.xml.i new file mode 100644 index 000000000..f7d3eab0d --- /dev/null +++ b/interface-definitions/include/rip/version.xml.i @@ -0,0 +1,19 @@ +<!-- include start from rip/version.xml.i -->
+<leafNode name="version">
+ <properties>
+ <help>RIP protocol version</help>
+ <valueHelp>
+ <format>1</format>
+ <description>RIPv1</description>
+ </valueHelp>
+ <valueHelp>
+ <format>2</format>
+ <description>RIPv2</description>
+ </valueHelp>
+ <constraint>
+ <validator name="numeric" argument="--range 1-2"/>
+ </constraint>
+ </properties>
+ <defaultValue>2</defaultValue>
+</leafNode>
+<!-- include end -->
diff --git a/interface-definitions/protocols-rip.xml.in b/interface-definitions/protocols-rip.xml.in index 500af51e5..2195b0316 100644 --- a/interface-definitions/protocols-rip.xml.in +++ b/interface-definitions/protocols-rip.xml.in @@ -98,6 +98,22 @@ <constraintErrorMessage>Password must be 16 characters or less</constraintErrorMessage> </properties> </leafNode> + </children> + </node> + <node name="receive"> + <properties> + <help>Advertisement reception</help> + </properties> + <children> + #include <include/rip/version.xml.i> + </children> + </node> + <node name="send"> + <properties> + <help>Advertisement transmission</help> + </properties> + <children> + #include <include/rip/version.xml.i> </children> </node> </children> @@ -226,23 +242,7 @@ </leafNode> #include <include/rip/timers.xml.i> #include <include/route-map.xml.i> - <leafNode name="version"> - <properties> - <help>RIP protocol version</help> - <valueHelp> - <format>u32:1</format> - <description>RIPv1</description> - </valueHelp> - <valueHelp> - <format>u32:2</format> - <description>RIPv2</description> - </valueHelp> - <constraint> - <validator name="numeric" argument="--range 1-2"/> - </constraint> - </properties> - <defaultValue>2</defaultValue> - </leafNode> + #include <include/rip/version.xml.i> </children> </node> </children> diff --git a/smoketest/scripts/cli/test_protocols_rip.py b/smoketest/scripts/cli/test_protocols_rip.py index ee882943b..8c100d537 100755 --- a/smoketest/scripts/cli/test_protocols_rip.py +++ b/smoketest/scripts/cli/test_protocols_rip.py @@ -160,8 +160,12 @@ class TestProtocolsRIP(VyOSUnitTestSHIM.TestCase): def test_rip_03_version(self): version = '1' + interface = 'eth0' self.cli_set(base_path + ['version', version]) + self.cli_set(base_path + ['interface', interface, 'send', 'version', version]) + self.cli_set(base_path + ['interface', interface, 'receive', 'version', version]) + # commit changes self.cli_commit() @@ -169,5 +173,10 @@ class TestProtocolsRIP(VyOSUnitTestSHIM.TestCase): frrconfig = self.getFRRconfig('router rip') self.assertIn(f'version {version}', frrconfig) + frrconfig = self.getFRRconfig(f'interface {interface}') + self.assertIn(f' ip rip receive version {version}', frrconfig) + self.assertIn(f' ip rip send version {version}', frrconfig) + + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/src/conf_mode/protocols_rip.py b/src/conf_mode/protocols_rip.py index c78d90396..e29b23765 100755 --- a/src/conf_mode/protocols_rip.py +++ b/src/conf_mode/protocols_rip.py @@ -56,9 +56,24 @@ def get_config(config=None): # We have gathered the dict representation of the CLI, but there are default # options which we need to update into the dictionary retrived. default_values = defaults(base) + + # T2665: we can not blend in default values of tagNodes - delete and add + # individual values later on ... + if 'interface' in default_values: + del default_values['interface'] # merge in remaining default values rip = dict_merge(default_values, rip) + # T2665: add individual per interface defaults + + # T2665: blend in per interface defaults + if 'interface' in rip: + default_values = defaults(base + ['interface']) + for interface in rip['interface']: + # merge in default values + rip['interface'][interface] = dict_merge(default_values, + rip['interface'][interface]) + # We also need some additional information from the config, prefix-lists # and route-maps for instance. They will be used in verify(). # |