[package] wide-dhcpv6:
- fix DUID calculation for virtual interfaces like pppoe-wan (#9503) - add a config option "duid" to allow users to override the DUID - use service_kill to cleanly terminate dhcp6c - bump package revision git-svn-id: svn://svn.openwrt.org/openwrt/packages@27140 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
fa3e65e97a
commit
baa794848a
@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=wide-dhcpv6
|
PKG_NAME:=wide-dhcpv6
|
||||||
PKG_VERSION:=20080615
|
PKG_VERSION:=20080615
|
||||||
PKG_RELEASE:=5
|
PKG_RELEASE:=6
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
PKG_SOURCE_URL:=@SF/$(PKG_NAME)
|
PKG_SOURCE_URL:=@SF/$(PKG_NAME)
|
||||||
|
@ -22,6 +22,10 @@ config 'dhcp6c' 'basic'
|
|||||||
option 'bcmcs_server_address' '0'
|
option 'bcmcs_server_address' '0'
|
||||||
option 'bcmcs_server_domain_name' '0'
|
option 'bcmcs_server_domain_name' '0'
|
||||||
|
|
||||||
|
# Override the used DUID, by default it is derived from the interface MAC
|
||||||
|
# The given value must be uppercase and globally unique!
|
||||||
|
#option 'duid' '00:03:00:06:D8:5D:4C:A5:03:F2'
|
||||||
|
|
||||||
# Script to run when a reply is received
|
# Script to run when a reply is received
|
||||||
option 'script' '/usr/bin/dhcp6c-state'
|
option 'script' '/usr/bin/dhcp6c-state'
|
||||||
|
|
||||||
|
@ -11,23 +11,46 @@ get_ifname() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_device() {
|
||||||
|
local interface=$1
|
||||||
|
local ifname=$2
|
||||||
|
local device
|
||||||
|
scan_interfaces
|
||||||
|
config_get device "$interface" device
|
||||||
|
grep -qE "^ *$device:" /proc/net/dev && \
|
||||||
|
printf '%s\n' "$device" || \
|
||||||
|
printf '%s\n' "$ifname"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
dhcp6c_write_duid() {
|
dhcp6c_write_duid() {
|
||||||
local ifname="$1"
|
local mac="${1:-$(ifconfig "$client_device" | sed -ne 's/[[:space:]]*$//; s/.*HWaddr //p')}"
|
||||||
local mac=$(ifconfig "$client_ifname" | sed -ne 's/.*HWaddr //p')
|
local pat="[0-9A-F][0-9A-F]"
|
||||||
local oIFS="$IFS"; IFS=":"; set -- $mac; IFS="$oIFS"
|
|
||||||
|
|
||||||
# low endian
|
case "$mac" in
|
||||||
if [ "$(printf \\1 | hexdump -n1 -ve '8/2 "%04x"')" = "0001" ]; then
|
$pat:$pat:$pat:$pat:$pat:$pat:$pat:$pat:$pat:$pat)
|
||||||
printf \\x0a\\x00
|
printf $(echo "$mac" | sed -e 's/^/\\x/; s/:/\\x/g')
|
||||||
|
logger -t dhcp6c "Using user provided DUID $mac"
|
||||||
|
;;
|
||||||
|
$pat:$pat:$pat:$pat:$pat:$pat)
|
||||||
|
local oIFS="$IFS"; IFS=":"; set -- $mac; IFS="$oIFS"
|
||||||
|
|
||||||
# big endian
|
# low endian
|
||||||
else
|
if [ "$(printf \\1 | hexdump -n1 -ve '8/2 "%04x"')" = "0001" ]; then
|
||||||
printf \\x00\\x0a
|
printf \\x0a\\x00
|
||||||
fi
|
|
||||||
|
|
||||||
printf \\x00\\x03\\x00\\x06\\x$1\\x$2\\x$3\\x$4\\x$5\\x$6
|
# big endian
|
||||||
|
else
|
||||||
|
printf \\x00\\x0a
|
||||||
|
fi
|
||||||
|
|
||||||
logger -t dhcp6c "Using DUID 00:03:00:06:$1:$2:$3:$4:$5:$6"
|
printf \\x00\\x03\\x00\\x06\\x$1\\x$2\\x$3\\x$4\\x$5\\x$6
|
||||||
|
logger -t dhcp6c "Using MAC address DUID 00:03:00:06:$1:$2:$3:$4:$5:$6"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
logger -t dhcp6c "Unable to derive DUID from interface '$client_device' and no valid user DUID given"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
dhcp6c_write_interface() {
|
dhcp6c_write_interface() {
|
||||||
@ -117,18 +140,22 @@ start() {
|
|||||||
local enabled
|
local enabled
|
||||||
config_get_bool enabled basic enabled 0
|
config_get_bool enabled basic enabled 0
|
||||||
[ $enabled -eq 0 ] && return 0
|
[ $enabled -eq 0 ] && return 0
|
||||||
|
|
||||||
|
local user_duid
|
||||||
|
config_get user_duid basic duid
|
||||||
|
|
||||||
logger -t dhcp6c starting dhcp6c
|
logger -t dhcp6c starting dhcp6c
|
||||||
|
|
||||||
local client_interface
|
local client_interface
|
||||||
config_get client_interface basic interface
|
config_get client_interface basic interface
|
||||||
local client_ifname=$(get_ifname "$client_interface")
|
local client_ifname=$(get_ifname "$client_interface")
|
||||||
|
local client_device=$(get_device "$client_interface" "$client_ifname")
|
||||||
|
|
||||||
local config_file="/var/etc/dhcp6c.conf"
|
local config_file="/var/etc/dhcp6c.conf"
|
||||||
local duid_file="/var/dhcp6c_duid"
|
local duid_file="/var/dhcp6c_duid"
|
||||||
mkdir -m 755 -p /var/etc
|
mkdir -m 755 -p /var/etc
|
||||||
dhcp6c_write_config > $config_file
|
dhcp6c_write_config > $config_file
|
||||||
dhcp6c_write_duid > $duid_file
|
dhcp6c_write_duid "$user_duid" > $duid_file
|
||||||
|
|
||||||
local debug
|
local debug
|
||||||
local debug_option
|
local debug_option
|
||||||
@ -146,8 +173,8 @@ start() {
|
|||||||
stop() {
|
stop() {
|
||||||
|
|
||||||
logger -t dhcp6c stopping dhcp6c
|
logger -t dhcp6c stopping dhcp6c
|
||||||
rm -f /var/etc/dhcp6c.conf
|
service_kill dhcp6c /var/run/dhcp6c.pid
|
||||||
kill -TERM `cat /var/run/dhcp6c.pid`
|
rm -f /var/etc/dhcp6c.conf /var/run/dhcp6c.pid
|
||||||
ACTION=stop /sbin/hotplug-call dhcp6c
|
ACTION=stop /sbin/hotplug-call dhcp6c
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user