[openwrt/openwrt] netifd: use the global DHCP DUID for DHCPv4
LEDE Commits
lede-commits at lists.infradead.org
Sun Oct 19 10:46:26 PDT 2025
robimarko pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/9151c7015ed2116b92a82b27c122310f1a91a426
commit 9151c7015ed2116b92a82b27c122310f1a91a426
Author: David Härdeman <david at hardeman.nu>
AuthorDate: Fri Oct 10 11:38:36 2025 +0200
netifd: use the global DHCP DUID for DHCPv4
This makes the DHCPv4 client use the global DHCP DUID to generate a
RFC4361-style client identifier.
Signed-off-by: David Härdeman <david at hardeman.nu>
Link: https://github.com/openwrt/openwrt/pull/20359
Signed-off-by: Robert Marko <robimarko at gmail.com>
---
.../network/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"
More information about the lede-commits
mailing list