mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2026-01-28 03:37:17 +01:00
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@hardeman.nu> Link: https://github.com/openwrt/openwrt/pull/20359 Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
parent
a660a076db
commit
9151c7015e
1 changed files with 14 additions and 0 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue