From d922f888dc822cc4e3b7ce70a4402ece7eef6e41 Mon Sep 17 00:00:00 2001 From: Nataliia Solomko Date: Mon, 23 Mar 2026 13:36:00 +0200 Subject: vpp: T8355: Set MTU for vpp interfaces --- python/vyos/ifconfig/vpp/bond.py | 3 +++ python/vyos/ifconfig/vpp/gre.py | 5 ++++- python/vyos/ifconfig/vpp/interface.py | 17 +++++++++++++++++ python/vyos/ifconfig/vpp/ipip.py | 3 +++ python/vyos/ifconfig/vpp/loopback.py | 2 ++ python/vyos/ifconfig/vpp/vxlan.py | 2 ++ python/vyos/utils/network.py | 25 +++++++++++++++++++++++++ python/vyos/vpp/control_vpp.py | 7 +++++-- 8 files changed, 61 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/vyos/ifconfig/vpp/bond.py b/python/vyos/ifconfig/vpp/bond.py index 75849a620..a1c6f2ef3 100644 --- a/python/vyos/ifconfig/vpp/bond.py +++ b/python/vyos/ifconfig/vpp/bond.py @@ -148,5 +148,8 @@ class VPPBondInterface(Interface, VPPInterface): if rx_mode: self.set_rx_mode(rx_mode) + # Apply VPP-specific interface settings + VPPInterface.update(self, config) + # Apply all settings to the lcp pair (kernel) interface super().update(config) diff --git a/python/vyos/ifconfig/vpp/gre.py b/python/vyos/ifconfig/vpp/gre.py index 0cec5e3c9..074977500 100644 --- a/python/vyos/ifconfig/vpp/gre.py +++ b/python/vyos/ifconfig/vpp/gre.py @@ -141,4 +141,7 @@ class VPPGREInterface(Interface, VPPInterface): if rx_mode: self.set_rx_mode(rx_mode) - super().update(config) + # Apply VPP-specific interface settings + VPPInterface.update(self, config) + + super().update(config) \ No newline at end of file diff --git a/python/vyos/ifconfig/vpp/interface.py b/python/vyos/ifconfig/vpp/interface.py index 1b87af4d2..17a897f74 100644 --- a/python/vyos/ifconfig/vpp/interface.py +++ b/python/vyos/ifconfig/vpp/interface.py @@ -54,3 +54,20 @@ class VPPInterface: lcp_name = lcp_pair.get('vpp_name_kernel') if lcp_name: self.vpp.iface_rxmode(lcp_name, rx_mode) + + def set_mtu_vpp(self, mtu): + # Set MTU for the VPP interface + self.vpp.set_iface_mtu(self.vpp_ifname, mtu) + + # Set MTU for the LCP pair interface + lcp_pair = self.vpp.lcp_pair_find(vpp_name_hw=self.vpp_ifname) + if lcp_pair: + lcp_name = lcp_pair.get('vpp_name_kernel') + if lcp_name: + self.vpp.set_iface_mtu(lcp_name, mtu) + + def update(self, config): + # Set MTU + if 'mtu' in config: + mtu = int(config['mtu']) + self.set_mtu_vpp(mtu) diff --git a/python/vyos/ifconfig/vpp/ipip.py b/python/vyos/ifconfig/vpp/ipip.py index fff79fd43..baec9f1c7 100644 --- a/python/vyos/ifconfig/vpp/ipip.py +++ b/python/vyos/ifconfig/vpp/ipip.py @@ -105,5 +105,8 @@ class VPPIPIPInterface(Interface, VPPInterface): if rx_mode: self.set_rx_mode(rx_mode) + # Apply VPP-specific interface settings + VPPInterface.update(self, config) + # Apply all settings to the lcp pair (kernel) interface super().update(config) diff --git a/python/vyos/ifconfig/vpp/loopback.py b/python/vyos/ifconfig/vpp/loopback.py index 36a30cb58..5ef7ead23 100644 --- a/python/vyos/ifconfig/vpp/loopback.py +++ b/python/vyos/ifconfig/vpp/loopback.py @@ -101,5 +101,7 @@ class VPPLoopbackInterface(Interface, VPPInterface): if rx_mode: self.set_rx_mode(rx_mode) + VPPInterface.update(self, config) + # Apply all settings to the lcp pair (kernel) interface super().update(config) diff --git a/python/vyos/ifconfig/vpp/vxlan.py b/python/vyos/ifconfig/vpp/vxlan.py index 8ca9bee70..da4e7ed50 100644 --- a/python/vyos/ifconfig/vpp/vxlan.py +++ b/python/vyos/ifconfig/vpp/vxlan.py @@ -122,4 +122,6 @@ class VPPVXLANInterface(Interface, VPPInterface): if rx_mode: self.set_rx_mode(rx_mode) + VPPInterface.update(self, config) + super().update(config) diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py index 217428a21..de283e546 100644 --- a/python/vyos/utils/network.py +++ b/python/vyos/utils/network.py @@ -696,3 +696,28 @@ def is_valid_ipv6_address_or_range(addr: str) -> bool: return ip_network(addr).version == 6 except: return False + + +def get_interfaces_by_ip(ip_address: str) -> list: + """ + Return a list of all interface names assigned the given IP address. + Args: + ip_address (str): The IP address to search for. + Returns: + list: List of interface names (str) that have the given IP address assigned. + Returns an empty list if no interface has the IP assigned. + """ + import netifaces + from vyos.template import is_ipv6 + + addr_type = AF_INET + if is_ipv6(ip_address): + addr_type = AF_INET6 + + ifaces = [] + for interface in netifaces.interfaces(): + addresses = netifaces.ifaddresses(interface) + for addr_info in addresses.get(addr_type, []): + if addr_info.get('addr') == ip_address: + ifaces.append(interface) + return ifaces diff --git a/python/vyos/vpp/control_vpp.py b/python/vyos/vpp/control_vpp.py index 2daaed423..5f3a18848 100644 --- a/python/vyos/vpp/control_vpp.py +++ b/python/vyos/vpp/control_vpp.py @@ -422,8 +422,11 @@ class VPPControl: mtu (int): MTU """ iface_index = self.get_sw_if_index(iface_name_vpp) - api_call_args: dict[str, str | int] = {'sw_if_index': iface_index, 'mtu': mtu} - return self.__vpp_api_client.api.hw_interface_set_mtu(**api_call_args) + api_call_args: dict[str, int | list[int]] = { + 'sw_if_index': iface_index, + 'mtu': [mtu, 0, 0, 0], + } + return self.__vpp_api_client.api.sw_interface_set_mtu(**api_call_args) @_Decorators.api_call def get_sw_if_dev_type(self, ifname: str) -> int | None: -- cgit v1.2.3