summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsdc <taras@vyos.io>2023-06-30 21:44:51 +0300
committerzsdc <taras@vyos.io>2023-07-03 18:18:53 +0300
commitf6036065083c76fa6ba0aed67ba7c07e5e53c07b (patch)
tree89f36fda3d87cd26986c31c0d90282a6cbbc257e
parent4599a9e35b8944a56e82d990957da27444b7814c (diff)
downloadvyos-1x-f6036065083c76fa6ba0aed67ba7c07e5e53c07b.tar.gz
vyos-1x-f6036065083c76fa6ba0aed67ba7c07e5e53c07b.zip
VPP: T1797: Added interfaces reinitialization
After an interface is added/removed from VPP, it will be reinitialized, which allows reconfiguring IP addresses on it. Also modified VPP load priority to start before interfaces, and avoid reconfiguration during boot.
-rw-r--r--data/config-mode-dependencies.json3
-rw-r--r--interface-definitions/netns.xml.in2
-rw-r--r--interface-definitions/vpp.xml.in2
-rwxr-xr-xsrc/conf_mode/vpp.py19
4 files changed, 16 insertions, 10 deletions
diff --git a/data/config-mode-dependencies.json b/data/config-mode-dependencies.json
index ccee359d1..91a757c16 100644
--- a/data/config-mode-dependencies.json
+++ b/data/config-mode-dependencies.json
@@ -28,5 +28,8 @@
"wireguard": ["interfaces-wireguard"],
"wireless": ["interfaces-wireless"],
"wwan": ["interfaces-wwan"]
+ },
+ "vpp": {
+ "ethernet": ["interfaces-ethernet"]
}
}
diff --git a/interface-definitions/netns.xml.in b/interface-definitions/netns.xml.in
index 87880e96a..5d958968f 100644
--- a/interface-definitions/netns.xml.in
+++ b/interface-definitions/netns.xml.in
@@ -3,7 +3,7 @@
<node name="netns" owner="${vyos_conf_scripts_dir}/netns.py">
<properties>
<help>Network namespace</help>
- <priority>299</priority>
+ <priority>291</priority>
</properties>
<children>
<tagNode name="name">
diff --git a/interface-definitions/vpp.xml.in b/interface-definitions/vpp.xml.in
index 51ab776c3..3f0758c0a 100644
--- a/interface-definitions/vpp.xml.in
+++ b/interface-definitions/vpp.xml.in
@@ -3,7 +3,7 @@
<node name="vpp" owner="${vyos_conf_scripts_dir}/vpp.py">
<properties>
<help>Accelerated data-plane</help>
- <priority>1280</priority>
+ <priority>295</priority>
</properties>
<children>
<node name="cpu">
diff --git a/src/conf_mode/vpp.py b/src/conf_mode/vpp.py
index 62ec4c162..dc13f4e60 100755
--- a/src/conf_mode/vpp.py
+++ b/src/conf_mode/vpp.py
@@ -21,13 +21,11 @@ from pathlib import Path
from re import search as re_search, MULTILINE as re_M
from vyos.config import Config
+from vyos.configdep import set_dependents, call_dependents
from vyos.configdict import dict_merge
from vyos.configdict import node_changed
from vyos.ifconfig import Section
-from vyos.ifconfig import EthernetIf
-from vyos.ifconfig import interface
-from vyos.util import call
-from vyos.util import rc_cmd
+from vyos.util import call, rc_cmd, boot_configuration_complete
from vyos.template import render
from vyos.xml import defaults
@@ -48,7 +46,6 @@ MIN_TOTAL_MEMORY = 6
def _get_pci_address_by_interface(iface) -> str:
- from vyos.util import rc_cmd
rc, out = rc_cmd(f'ethtool -i {iface}')
# if ethtool command was successful
if rc == 0 and out:
@@ -87,6 +84,9 @@ def get_config(config=None):
'iface_name': removed_iface,
'iface_pci_addr': pci_address
})
+ # add an interface to a list of interfaces that need
+ # to be reinitialized after the commit
+ set_dependents('ethernet', conf, removed_iface)
if not conf.exists(base):
return {'removed_ifaces': removed_ifaces}
@@ -107,6 +107,9 @@ def get_config(config=None):
for iface, iface_config in config['interface'].items():
default_values_iface = defaults(base + ['interface'])
config['interface'][iface] = dict_merge(default_values_iface, config['interface'][iface])
+ # add an interface to a list of interfaces that need
+ # to be reinitialized after the commit
+ set_dependents('ethernet', conf, iface)
# Get PCI address auto
for iface, iface_config in config['interface'].items():
@@ -186,9 +189,9 @@ def apply(config):
if iface not in Section.interfaces():
vpp_control.lcp_pair_add(iface, iface)
- # update interface config
- #e = EthernetIf(iface)
- #e.update(config['other_interfaces'][iface])
+ # reinitialize interfaces, but not during the first boot
+ if boot_configuration_complete():
+ call_dependents()
if __name__ == '__main__':