Skip to content

Commit 89d982d

Browse files
ihipopNoltari
authored andcommitted
netifd: dhcp: suppress udhcpc default vendor class if specified in sendopts
When DHCP Option 60 is specified via sendopts (hex, decimal, or named formats), udhcpc sends its default "udhcp <version>" string alongside the custom value, which causes authentication failures with some ISPs. This fix detects Option 60 in sendopts and automatically passes -V "" to udhcpc to suppress the default version string while allowing multiple user-defined vendor classes. Supported formats: - Hexadecimal: 0x3c - Decimal: 60 - Named: vendor Fixes: openwrt#21242 Signed-off-by: JINLIANG GU <[email protected]> openwrt#21450 Signed-off-by: Álvaro Fernández Rojas <[email protected]>
1 parent 93e98b4 commit 89d982d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

package/network/config/netifd/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=netifd
4-
PKG_RELEASE:=1
4+
PKG_RELEASE:=2
55

66
PKG_SOURCE_PROTO:=git
77
PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git

package/network/config/netifd/files/lib/netifd/proto/dhcp.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ proto_dhcp_setup() {
6666
[ "$norelease" = 1 ] && norelease="" || norelease="-R"
6767
[ -z "$clientid" ] && clientid="$(proto_dhcp_get_default_clientid "$iface")"
6868
[ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}"
69+
[ -n "$vendorid" ] && append dhcpopts "-x 0x3c:$(echo -n "$vendorid" | hexdump -ve '1/1 "%02x"')"
6970
[ -n "$iface6rd" ] && proto_export "IFACE6RD=$iface6rd"
7071
[ "$iface6rd" != 0 -a -f /lib/netifd/proto/6rd.sh ] && append dhcpopts "-O 212"
7172
[ -n "$zone6rd" ] && proto_export "ZONE6RD=$zone6rd"
@@ -76,14 +77,24 @@ proto_dhcp_setup() {
7677
# Request classless route option (see RFC 3442) by default
7778
[ "$classlessroute" = "0" ] || append dhcpopts "-O 121"
7879

80+
# Avoid sending duplicate Option 60 values
81+
local emptyvendorid
82+
case "$dhcpopts" in
83+
*"-x 0"[xX]*"3"[cC]":"* |\
84+
*"-x 60:"* |\
85+
*"-x vendor:"*)
86+
emptyvendorid=1
87+
;;
88+
esac
89+
7990
proto_export "INTERFACE=$config"
8091
proto_run_command "$config" udhcpc \
8192
-p /var/run/udhcpc-$iface.pid \
8293
-s /lib/netifd/dhcp.script \
8394
-f -t 0 -i "$iface" \
8495
${ipaddr:+-r ${ipaddr/\/*/}} \
8596
${hostname:+-x "hostname:$hostname"} \
86-
${vendorid:+-V "$vendorid"} \
97+
${emptyvendorid:+-V ""} \
8798
$clientid $defaultreqopts $broadcast $norelease $dhcpopts
8899
}
89100

0 commit comments

Comments
 (0)