diff options
-rw-r--r-- | op-mode-definitions/container.xml.in | 35 | ||||
-rw-r--r-- | python/vyos/ethtool.py | 24 | ||||
-rw-r--r-- | python/vyos/ifconfig/ethernet.py | 31 | ||||
-rw-r--r-- | python/vyos/ifconfig/vti.py | 8 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_interfaces_vti.py | 19 | ||||
-rwxr-xr-x | src/etc/ipsec.d/vti-up-down | 4 | ||||
-rwxr-xr-x | src/op_mode/dhcp.py | 3 | ||||
-rw-r--r-- | src/systemd/vyos-grub-update.service | 4 |
8 files changed, 62 insertions, 66 deletions
diff --git a/op-mode-definitions/container.xml.in b/op-mode-definitions/container.xml.in index 4aa13e913..bb6f97b02 100644 --- a/op-mode-definitions/container.xml.in +++ b/op-mode-definitions/container.xml.in @@ -103,12 +103,28 @@ </properties> <command>sudo ${vyos_op_scripts_dir}/container.py show_container</command> <children> - <leafNode name="image"> + <node name="json"> + <properties> + <help>Show containers in JSON format</help> + </properties> + <!-- no admin check --> + <command>sudo ${vyos_op_scripts_dir}/container.py show_container --raw</command> + </node> + <node name="image"> <properties> <help>Show container image</help> </properties> <command>sudo ${vyos_op_scripts_dir}/container.py show_image</command> - </leafNode> + <children> + <node name="json"> + <properties> + <help>Show container image in JSON format</help> + </properties> + <!-- no admin check --> + <command>sudo ${vyos_op_scripts_dir}/container.py show_image --raw</command> + </node> + </children> + </node> <tagNode name="log"> <properties> <help>Show logs from a given container</help> @@ -116,14 +132,25 @@ <path>container name</path> </completionHelp> </properties> + <!-- no admin check --> <command>sudo podman logs --names "$4"</command> </tagNode> - <leafNode name="network"> + <node name="network"> <properties> <help>Show available container networks</help> </properties> + <!-- no admin check --> <command>sudo ${vyos_op_scripts_dir}/container.py show_network</command> - </leafNode> + <children> + <node name="json"> + <properties> + <help>Show available container networks in JSON format</help> + </properties> + <!-- no admin check --> + <command>sudo ${vyos_op_scripts_dir}/container.py show_network --raw</command> + </node> + </children> + </node> </children> </node> <node name="log"> diff --git a/python/vyos/ethtool.py b/python/vyos/ethtool.py index 473c98d0c..5e241fc08 100644 --- a/python/vyos/ethtool.py +++ b/python/vyos/ethtool.py @@ -24,7 +24,6 @@ from vyos.utils.process import popen _drivers_without_speed_duplex_flow = ['vmxnet3', 'virtio_net', 'xen_netfront', 'iavf', 'ice', 'i40e', 'hv_netvsc', 'veth', 'ixgbevf', 'tun'] -_drivers_without_eee = ['vmxnet3', 'virtio_net', 'xen_netfront', 'hv_netvsc'] class Ethtool: """ @@ -63,8 +62,6 @@ class Ethtool: _auto_negotiation = False _auto_negotiation_supported = None _flow_control = None - _eee = False - _eee_enabled = None def __init__(self, ifname): # Get driver used for interface @@ -118,15 +115,6 @@ class Ethtool: if not bool(err): self._flow_control = loads(out) - # Get current Energy Efficient Ethernet (EEE) settings, but this is - # not supported by all NICs (e.g. vmxnet3 does not support is) - out, _ = popen(f'ethtool --show-eee {ifname}') - if len(out.splitlines()) > 1: - self._eee = True - # read current EEE setting, this returns: - # EEE status: disabled || EEE status: enabled - inactive || EEE status: enabled - active - self._eee_enabled = bool('enabled' in out.splitlines()[1]) - def check_auto_negotiation_supported(self): """ Check if the NIC supports changing auto-negotiation """ return self._auto_negotiation_supported @@ -211,15 +199,3 @@ class Ethtool: 'flow-control settings!') return 'on' if bool(self._flow_control[0]['autonegotiate']) else 'off' - - def check_eee(self): - """ Check if the NIC supports eee """ - if self.get_driver_name() in _drivers_without_eee: - return False - return self._eee - - def get_eee(self): - if self._eee_enabled == None: - raise ValueError('Interface does not support changing '\ - 'EEE settings!') - return self._eee_enabled diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py index c3f5bbf47..8d96c863f 100644 --- a/python/vyos/ifconfig/ethernet.py +++ b/python/vyos/ifconfig/ethernet.py @@ -404,34 +404,6 @@ class EthernetIf(Interface): print(f'could not set "{rx_tx}" ring-buffer for {ifname}') return output - def set_eee(self, enable): - """ - Enable/Disable Energy Efficient Ethernet (EEE) settings - - Example: - >>> from vyos.ifconfig import EthernetIf - >>> i = EthernetIf('eth0') - >>> i.set_eee(enable=False) - """ - if not isinstance(enable, bool): - raise ValueError('Value out of range') - - if not self.ethtool.check_eee(): - self._debug_msg(f'NIC driver does not support changing EEE settings!') - return False - - current = self.ethtool.get_eee() - if current != enable: - # Assemble command executed on system. Unfortunately there is no way - # to change this setting via sysfs - cmd = f'ethtool --set-eee {self.ifname} eee ' - cmd += 'on' if enable else 'off' - output, code = self._popen(cmd) - if code: - Warning(f'could not change "{self.ifname}" EEE setting!') - return output - return None - def update(self, config): """ General helper function which works on a dictionary retrived by get_config_dict(). It's main intention is to consolidate the scattered @@ -442,9 +414,6 @@ class EthernetIf(Interface): value = 'off' if 'disable_flow_control' in config else 'on' self.set_flow_control(value) - # Always disable Energy Efficient Ethernet - self.set_eee(False) - # GRO (generic receive offload) self.set_gro(dict_search('offload.gro', config) != None) diff --git a/python/vyos/ifconfig/vti.py b/python/vyos/ifconfig/vti.py index 9ebbeb9ed..9511386f4 100644 --- a/python/vyos/ifconfig/vti.py +++ b/python/vyos/ifconfig/vti.py @@ -1,4 +1,4 @@ -# Copyright 2021-2022 VyOS maintainers and contributors <maintainers@vyos.io> +# Copyright 2021-2024 VyOS maintainers and contributors <maintainers@vyos.io> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -52,8 +52,14 @@ class VTIIf(Interface): cmd += f' {iproute2_key} {tmp}' self._cmd(cmd.format(**self.config)) + + # interface is always A/D down. It needs to be enabled explicitly self.set_interface('admin_state', 'down') + def set_admin_state(self, state): + """ Handled outside by /etc/ipsec.d/vti-up-down """ + pass + def get_mac(self): """ Get a synthetic MAC address. """ return self.get_mac_synthetic() diff --git a/smoketest/scripts/cli/test_interfaces_vti.py b/smoketest/scripts/cli/test_interfaces_vti.py index 7f13575a3..871ac650b 100755 --- a/smoketest/scripts/cli/test_interfaces_vti.py +++ b/smoketest/scripts/cli/test_interfaces_vti.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2023 VyOS maintainers and contributors +# Copyright (C) 2023-2024 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -18,6 +18,9 @@ import unittest from base_interfaces_test import BasicInterfaceTest +from vyos.ifconfig import Interface +from vyos.utils.network import is_intf_addr_assigned + class VTIInterfaceTest(BasicInterfaceTest.TestCase): @classmethod def setUpClass(cls): @@ -27,5 +30,19 @@ class VTIInterfaceTest(BasicInterfaceTest.TestCase): # call base-classes classmethod super(VTIInterfaceTest, cls).setUpClass() + def test_add_single_ip_address(self): + addr = '192.0.2.0/31' + for intf in self._interfaces: + self.cli_set(self._base_path + [intf, 'address', addr]) + for option in self._options.get(intf, []): + self.cli_set(self._base_path + [intf] + option.split()) + + self.cli_commit() + + # VTI interface are always down and only brought up by IPSec + for intf in self._interfaces: + self.assertTrue(is_intf_addr_assigned(intf, addr)) + self.assertEqual(Interface(intf).get_admin_state(), 'down') + if __name__ == '__main__': unittest.main(verbosity=2) diff --git a/src/etc/ipsec.d/vti-up-down b/src/etc/ipsec.d/vti-up-down index 441b316c2..01e9543c9 100755 --- a/src/etc/ipsec.d/vti-up-down +++ b/src/etc/ipsec.d/vti-up-down @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2021-2023 VyOS maintainers and contributors +# Copyright (C) 2021-2024 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -57,7 +57,9 @@ if __name__ == '__main__': if 'disable' not in vti: tmp = VTIIf(interface) tmp.update(vti) + call(f'sudo ip link set {interface} up') else: + call(f'sudo ip link set {interface} down') syslog(f'Interface {interface} is admin down ...') elif verb in ['down-client', 'down-host']: if vti_link_up: diff --git a/src/op_mode/dhcp.py b/src/op_mode/dhcp.py index d6b8aa0b8..b1fa6b918 100755 --- a/src/op_mode/dhcp.py +++ b/src/op_mode/dhcp.py @@ -79,8 +79,7 @@ def _get_raw_server_leases(family='inet', pool=None, sorted=None, state=[], orig """ lease_file = '/config/dhcpdv6.leases' if family == 'inet6' else '/config/dhcpd.leases' data = [] - leases = IscDhcpLeases(lease_file).get() - + leases = IscDhcpLeases(lease_file).get(include_backups=True) if pool is None: pool = _get_dhcp_pools(family=family) aux = False diff --git a/src/systemd/vyos-grub-update.service b/src/systemd/vyos-grub-update.service index 522b13a33..7b67ae1b8 100644 --- a/src/systemd/vyos-grub-update.service +++ b/src/systemd/vyos-grub-update.service @@ -6,9 +6,9 @@ Before=vyos-router.service [Service] Type=oneshot ExecStart=/usr/libexec/vyos/system/grub_update.py -TimeoutSec=5 +TimeoutSec=60 KillMode=process StandardOutput=journal+console [Install] -WantedBy=vyos-router.service
\ No newline at end of file +WantedBy=vyos-router.service |