summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface-definitions/interfaces-tunnel.xml.in1
-rw-r--r--python/vyos/ifconfig/control.py4
-rw-r--r--python/vyos/ifconfig/interface.py9
-rwxr-xr-xsrc/conf_mode/interfaces-tunnel.py6
4 files changed, 14 insertions, 6 deletions
diff --git a/interface-definitions/interfaces-tunnel.xml.in b/interface-definitions/interfaces-tunnel.xml.in
index 848d6a1c7..c66628ec8 100644
--- a/interface-definitions/interfaces-tunnel.xml.in
+++ b/interface-definitions/interfaces-tunnel.xml.in
@@ -21,6 +21,7 @@
#include <include/address-ipv4-ipv6.xml.i>
#include <include/interface-disable.xml.i>
#include <include/interface-disable-link-detect.xml.i>
+ #include <include/interface-vrf.xml.i>
#include <include/interface-mtu-64-8024.xml.i>
<leafNode name="local-ip">
diff --git a/python/vyos/ifconfig/control.py b/python/vyos/ifconfig/control.py
index 635b626e8..89deba40a 100644
--- a/python/vyos/ifconfig/control.py
+++ b/python/vyos/ifconfig/control.py
@@ -48,7 +48,7 @@ class Control:
"""
Using the defined names, set data write to sysfs.
"""
- if not value:
+ if not value and not self._command_set[name].get('force', False):
return None
# the code can pass int as int
@@ -108,7 +108,7 @@ class Control:
"""
Using the defined names, set data write to sysfs.
"""
- if not value:
+ if not value and not self._sysfs_set[name].get('force', False):
return None
# the code can pass int as int
diff --git a/python/vyos/ifconfig/interface.py b/python/vyos/ifconfig/interface.py
index 21ffa88f6..9de24d729 100644
--- a/python/vyos/ifconfig/interface.py
+++ b/python/vyos/ifconfig/interface.py
@@ -89,7 +89,12 @@ class Interface(Control):
'shellcmd': 'ip link set dev {ifname} master {value}',
},
'del_vrf': {
- 'shellcmd': 'ip link set dev {ifname} nomaster {value}',
+ 'shellcmd': 'ip link set dev {ifname} nomaster',
+ },
+ 'vrf': {
+ 'force': True,
+ 'convert': lambda v: f'master {v}' if v else 'nomaster',
+ 'shellcmd': 'ip link set dev {ifname} {value}',
},
}
@@ -308,7 +313,7 @@ class Interface(Control):
"""
self.set_interface('add_vrf', vrf)
- def del_vrf(self, vrf):
+ def del_vrf(self, vrf=''):
"""
Remove interface from given VRF instance.
diff --git a/src/conf_mode/interfaces-tunnel.py b/src/conf_mode/interfaces-tunnel.py
index 67b58719b..3d4f26374 100755
--- a/src/conf_mode/interfaces-tunnel.py
+++ b/src/conf_mode/interfaces-tunnel.py
@@ -129,6 +129,7 @@ class ConfigurationState (Config):
default_config_data = {
# interface definition
+ 'vrf': '',
'addresses-add': [],
'addresses-del': [],
'state': 'up',
@@ -180,6 +181,7 @@ mapping = {
'dhcp-interface': ('dhcp-interface', False, None),
'state': ('disable', False, 'down'),
'link_detect': ('disable-link-detect', False, 2),
+ 'vrf': ('vrf', False, None),
'addresses-add': ('address', True, None),
}
@@ -326,7 +328,7 @@ def verify(conf):
# what are the tunnel options we can set / modified / deleted
kls = get_class(options)
- valid = kls.updates + ['alias', 'addresses-add', 'addresses-del']
+ valid = kls.updates + ['alias', 'addresses-add', 'addresses-del', 'vrf']
if changes['section'] == 'create':
valid.extend(['type',])
@@ -466,7 +468,7 @@ def apply(conf):
tunnel.set_interface(option, options[option])
# set other interface properties
- for option in ('alias', 'mtu', 'link_detect', 'multicast', 'allmulticast'):
+ for option in ('alias', 'mtu', 'link_detect', 'multicast', 'allmulticast', 'vrf'):
tunnel.set_interface(option, options[option])
# Configure interface address(es)