diff options
| author | Daniil Baturin <daniil@vyos.io> | 2026-01-22 16:56:47 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-22 16:56:47 +0000 |
| commit | 0a619674e6ce46add5d1573399179c0d8e29456c (patch) | |
| tree | 9c5434910ace817cf4deb237ef0a7093541b6c20 | |
| parent | 41aa42fec49399a3cee7c772d2799b1c17490401 (diff) | |
| parent | f8a68122f3b4738a2a1bd1526ed3c9b8961d050d (diff) | |
| download | vyos-1x-0a619674e6ce46add5d1573399179c0d8e29456c.tar.gz vyos-1x-0a619674e6ce46add5d1573399179c0d8e29456c.zip | |
Merge pull request #4942 from natali-rs1985/T8125
vpp: T8125: Enable ip4-dhcp-client-detect feature if interface address is configured as DHCP
| -rw-r--r-- | data/templates/vpp/startup.conf.j2 | 2 | ||||
| -rw-r--r-- | python/vyos/vpp/control_vpp.py | 31 | ||||
| -rwxr-xr-x | smoketest/scripts/cli/test_vpp.py | 9 | ||||
| -rwxr-xr-x | src/conf_mode/interfaces_ethernet.py | 30 |
4 files changed, 62 insertions, 10 deletions
diff --git a/data/templates/vpp/startup.conf.j2 b/data/templates/vpp/startup.conf.j2 index b67251acc..b5b4853ce 100644 --- a/data/templates/vpp/startup.conf.j2 +++ b/data/templates/vpp/startup.conf.j2 @@ -114,6 +114,8 @@ plugins { # plugin wireguard_plugin.so { enable } # ACL plugin acl_plugin.so { enable } + # DHCP plugin + plugin dhcp_plugin.so { enable } } diff --git a/python/vyos/vpp/control_vpp.py b/python/vyos/vpp/control_vpp.py index 2ee253b45..18ec349bc 100644 --- a/python/vyos/vpp/control_vpp.py +++ b/python/vyos/vpp/control_vpp.py @@ -494,3 +494,34 @@ class VPPControl: cp_sw_if_index=self.get_sw_if_index(vpp_pair_name), is_add=is_add, ) + + @_Decorators.api_call + def enable_dhcp_client(self, ifname: str) -> None: + """Enable DHCP client detection on a given interface + + Args: + ifname (str): name of an interface in kernel + """ + iface_index = self.get_sw_if_index(ifname) + feature_is_enabled = self.__vpp_api_client.api.feature_is_enabled( + sw_if_index=iface_index, + feature_name='ip4-dhcp-client-detect', + arc_name='ip4-unicast', + ) + if not feature_is_enabled.is_enabled: + self.__vpp_api_client.api.dhcp_client_detect_enable_disable( + sw_if_index=iface_index, + enable=True, + ) + + @_Decorators.api_call + def disable_dhcp_client(self, ifname: str) -> None: + """Disable DHCP client detection on a given interface + + Args: + ifname (str): name of an interface in kernel + """ + self.__vpp_api_client.api.dhcp_client_detect_enable_disable( + sw_if_index=self.get_sw_if_index(ifname), + enable=False, + ) diff --git a/smoketest/scripts/cli/test_vpp.py b/smoketest/scripts/cli/test_vpp.py index a5c7ab873..16295a932 100755 --- a/smoketest/scripts/cli/test_vpp.py +++ b/smoketest/scripts/cli/test_vpp.py @@ -140,6 +140,7 @@ class TestVPP(VyOSUnitTestSHIM.TestCase): 'plugin default { disable }', 'plugin dpdk_plugin.so { enable }', 'plugin linux_cp_plugin.so { enable }', + 'plugin dhcp_plugin.so { enable }', 'dev 0000:00:00.0', 'uio-bind-force', ) @@ -176,6 +177,14 @@ class TestVPP(VyOSUnitTestSHIM.TestCase): self.cli_delete(['interfaces', 'ethernet', interface, 'mtu']) self.cli_commit() + # set interface address as dhcp + self.cli_set(['interfaces', 'ethernet', interface, 'address', 'dhcp']) + self.cli_commit() + + # check 'ip4-dhcp-client-detect' feature is enabled on interface + _, out = rc_cmd(f'sudo vppctl show interface features {interface}') + self.assertIn(f'ip4-dhcp-client-detect', out) + def test_02_vpp_vxlan(self): vni = '23' interface_vxlan = f'vxlan{vni}' diff --git a/src/conf_mode/interfaces_ethernet.py b/src/conf_mode/interfaces_ethernet.py index 599421c72..ffb59c89e 100755 --- a/src/conf_mode/interfaces_ethernet.py +++ b/src/conf_mode/interfaces_ethernet.py @@ -447,17 +447,27 @@ def apply(ethernet): if 'static_arp' in ethernet: call_dependents() - # If the interface is managed by the VPP DPDK driver, synchronize runtime - # parameters between Linux and the corresponding VPP LCP interface - if dict_search(f'vpp.settings.interface.{ifname}.driver', ethernet) == 'dpdk': + vpp_iface_config = dict_search(f'vpp.settings.interface.{ifname}', ethernet) + if vpp_iface_config and is_systemd_service_running('vpp.service'): vpp_api = VPPControl() - # Find LCP pair - lcp_pair = vpp_api.lcp_pair_find(vpp_name_hw=ifname) - lcp_name = lcp_pair.get('vpp_name_kernel') - # Sync MTU to VPP LCP pair interface - if lcp_name: - mtu = e.get_mtu() - vpp_api.set_iface_mtu(lcp_name, mtu) + + # Enable ip4-dhcp-client-detect feature for DHCP-configured interfaces. + # This feature is required for VPP to process DHCP packets and assign addresses. + if 'dhcp' in ethernet.get('address', []): + vpp_api.enable_dhcp_client(ifname) + else: + vpp_api.disable_dhcp_client(ifname) + + # If the interface is managed by the VPP DPDK driver, synchronize runtime + # parameters between Linux and the corresponding VPP LCP interface + if vpp_iface_config.get('driver') == 'dpdk': + # Find LCP pair + lcp_pair = vpp_api.lcp_pair_find(vpp_name_hw=ifname) + lcp_name = lcp_pair.get('vpp_name_kernel') + # Sync MTU to VPP LCP pair interface + if lcp_name: + mtu = e.get_mtu() + vpp_api.set_iface_mtu(lcp_name, mtu) return None |
