summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNataliia Solomko <natalirs1985@gmail.com>2026-01-12 16:37:13 +0200
committerNataliia Solomko <natalirs1985@gmail.com>2026-01-21 15:07:14 +0200
commitf8a68122f3b4738a2a1bd1526ed3c9b8961d050d (patch)
treeee495630f8b3f6687a546b7064f313b4c9f429f9
parent7fea6b6dbbd786bf6a32c496fc70ca9e9b5f8b1f (diff)
downloadvyos-1x-f8a68122f3b4738a2a1bd1526ed3c9b8961d050d.tar.gz
vyos-1x-f8a68122f3b4738a2a1bd1526ed3c9b8961d050d.zip
vpp: T8125: Enable ip4-dhcp-client-detect feature if interface address is configured as DHCP
DHCP address cannot be assigned on VPP interfaces without enabling the 'ip4-dhcp-client-detect' feature
-rw-r--r--data/templates/vpp/startup.conf.j22
-rw-r--r--python/vyos/vpp/control_vpp.py31
-rwxr-xr-xsmoketest/scripts/cli/test_vpp.py9
-rwxr-xr-xsrc/conf_mode/interfaces_ethernet.py30
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 1886ac615..b985a45d4 100755
--- a/smoketest/scripts/cli/test_vpp.py
+++ b/smoketest/scripts/cli/test_vpp.py
@@ -139,6 +139,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',
)
@@ -175,6 +176,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