mirror of
https://github.com/openwrt/openwrt.git
synced 2026-07-17 16:41:56 +04:00
scripts: dhcpv6: harmonize IAID between IA_NA and IA_PD requests
For DHCPv6 address requests (IA_NA), odhcp6c currently uses the first eight digits of the i/f name's MD5 hash as IAID. In case of DHCPv6-PD, however, odhcp6c expects the IAID to be specified explicitly for the IA_PD(s) requested, otherwise it will start counting the IAID from "1" up for each "-P" argument. As OpenWrt only requests a single IA_PD per interface, make sure to pass the identical IAID for IA_PD as is used for IA_NA, unless a custom IAID was explicitly specified in the i/f configuration. This prevents regressions with ISPs that expect an IA_PD request to come from the same IAID+DUID combination as the IA_NA request. In addition, add some validation of the "reqprefix" value, in order to catch most cases that would otherwise result in netifd or odhcp6c malfunction. Signed-off-by: Shine <4c.fce2@proton.me> Link: https://github.com/openwrt/openwrt/pull/23758 Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/functions/network.sh
|
||||
. ../netifd-proto.sh
|
||||
. /lib/config/uci.sh
|
||||
init_proto "$@"
|
||||
@@ -9,7 +10,7 @@ proto_dhcpv6_init_config() {
|
||||
renew_handler=1
|
||||
|
||||
proto_config_add_string 'reqaddress:or("try","force","none")'
|
||||
proto_config_add_string 'reqprefix:or("auto","no",range(0, 64))'
|
||||
proto_config_add_string reqprefix
|
||||
proto_config_add_string clientid
|
||||
proto_config_add_string 'reqopts:list(uinteger)'
|
||||
proto_config_add_string 'defaultreqopts:bool'
|
||||
@@ -85,7 +86,25 @@ proto_dhcpv6_setup() {
|
||||
[ -n "$reqaddress" ] && append opts "-N$reqaddress"
|
||||
|
||||
[ -z "$reqprefix" -o "$reqprefix" = "auto" ] && reqprefix=0
|
||||
[ "$reqprefix" != "no" ] && append opts "-P$reqprefix"
|
||||
[ "$reqprefix" != "no" ] && {
|
||||
# append interface IAID if none specified
|
||||
local iaid=$(echo -n $reqprefix | sed -nr 's/^.*:([0-9A-Fa-f]{1,8})$/\1/p')
|
||||
[ -z "$iaid" ] && {
|
||||
network_generate_iface_iaid iaid "$iface"
|
||||
reqprefix="$reqprefix:$iaid"
|
||||
}
|
||||
# validate prefix/length hint
|
||||
local hint=${reqprefix%:$iaid}
|
||||
[ "${hint#/}" -le "128" ] 2>/dev/null && {
|
||||
reqprefix=${reqprefix#/}
|
||||
} || {
|
||||
validate_data cidr6 "$hint" 2>/dev/null || {
|
||||
reqprefix="0:$iaid"
|
||||
logger -p warn -t dhcpv6 "$iface: ignoring invalid prefix hint"
|
||||
}
|
||||
}
|
||||
append opts "-P$reqprefix"
|
||||
}
|
||||
|
||||
[ -n "$clientid" ] && {
|
||||
clientid="$(hexdump_2hex "$clientid")"
|
||||
|
||||
Reference in New Issue
Block a user