From 9151c7015ed2116b92a82b27c122310f1a91a426 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20H=C3=A4rdeman?= Date: Fri, 10 Oct 2025 11:38:36 +0200 Subject: [PATCH] netifd: use the global DHCP DUID for DHCPv4 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This makes the DHCPv4 client use the global DHCP DUID to generate a RFC4361-style client identifier. Signed-off-by: David Härdeman Link: https://github.com/openwrt/openwrt/pull/20359 Signed-off-by: Robert Marko --- .../config/netifd/files/lib/netifd/proto/dhcp.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh index 0bef6a1abb..f6e0690884 100755 --- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh +++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh @@ -4,6 +4,7 @@ . /lib/functions.sh . ../netifd-proto.sh +. /lib/config/uci.sh init_proto "$@" proto_dhcp_init_config() { @@ -31,6 +32,18 @@ proto_dhcp_add_sendopts() { [ -n "$1" ] && append "$3" "-x $1" } +proto_dhcp_get_default_clientid() { + [ -z "$1" ] && return + + local iface="$1" + local duid + local iaid="0" + + [ -e "/sys/class/net/$iface/ifindex" ] && iaid="$(cat "/sys/class/net/$iface/ifindex")" + duid="$(uci_get network @globals[0] dhcp_default_duid)" + [ -n "$duid" ] && printf "ff%08x%s" "$iaid" "$duid" +} + proto_dhcp_setup() { local config="$1" local iface="$2" @@ -51,6 +64,7 @@ proto_dhcp_setup() { [ "$defaultreqopts" = 0 ] && defaultreqopts="-o" || defaultreqopts= [ "$broadcast" = 1 ] && broadcast="-B" || broadcast= [ "$norelease" = 1 ] && norelease="" || norelease="-R" + [ -z "$clientid" ] && clientid="$(proto_dhcp_get_default_clientid "$iface")" [ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" [ -n "$iface6rd" ] && proto_export "IFACE6RD=$iface6rd" [ "$iface6rd" != 0 -a -f /lib/netifd/proto/6rd.sh ] && append dhcpopts "-O 212" -- 2.30.2