Modify

Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#9503 closed defect (fixed)

wide-dhcpv6-client: bad DUID generated for virtual devices

Reported by: pp+wrt0611@… Owned by: jow
Priority: normal Milestone: Barrier Breaker 14.07
Component: packages Version: Trunk
Keywords: Cc:

Description

When the device dhcp6c listens on is virtual (e.g. pppoe-wan), then the DUID generated by dhcp6c_write_duid in /etc/init.d/dhcp6c is always (big-endian variant)

# hexdump -C /var/dhcp6c_duid
00000000  00 0a 00 03 00 06 5c 78  5c 78 5c 78 5c 78 5c 78 |......\x\x\x\x\x|
00000010  5c 78                                            |\x|

which is anything but unique.

The reason for this is, that ifconfig's output does not have a line with 'HWaddr' for a virtual device, which results in an empty $mac variable.

The attached patch fixes the problem for pppoe-wan, but might need more work to be generally usefull.

Attachments (1)

dhcp6c_write_duid-get_mac_for_virt_dev.diff (499 bytes) - added by anonymous 7 years ago.

Download all attachments as: .zip

Change History (9)

Changed 7 years ago by anonymous

comment:1 Changed 7 years ago by jow

  • Owner changed from developers to jow
  • Status changed from new to accepted

comment:2 follow-up: Changed 7 years ago by jow

Please try this patch instead:

--- files/dhcp6c.init	(revision 26993)
+++ files/dhcp6c.init	(working copy)
@@ -11,9 +11,20 @@
 	return 0
 }
 
+get_device() {
+	local interface=$1
+	local ifname=$2
+	local device
+	config_get device "$interface" device
+	grep -qE "^ *$device:" /proc/net/dev && \
+		printf '%s\n' "$device" || \
+		printf '%s\n' "$ifname"
+	return 0
+}
+
 dhcp6c_write_duid() {
 	local ifname="$1"
-	local mac=$(ifconfig "$client_ifname" | sed -ne 's/.*HWaddr //p')
+	local mac=$(ifconfig "$client_device" | sed -ne 's/.*HWaddr //p')
 	local oIFS="$IFS"; IFS=":"; set -- $mac; IFS="$oIFS"
 
 	# low endian
@@ -123,6 +134,7 @@
 	local client_interface
 	config_get client_interface basic 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 duid_file="/var/dhcp6c_duid"

comment:3 in reply to: ↑ 2 ; follow-up: Changed 7 years ago by pp+wrt0611@…

Replying to jow:

This does not work. With

--- a/etc/init.d/dhcp6c Sun Jun 05 12:50:12 2011 +0200
+++ b/etc/init.d/dhcp6c Sun Jun 05 12:51:11 2011 +0200
@@ -19,6 +19,7 @@
        grep -qE "^ *$device:" /proc/net/dev && \
                printf '%s\n' "$device" || \
                printf '%s\n' "$ifname"
+       set > /tmp/set-get_device.txt
        return 0
 }

I get

cat /tmp/set-get_device.txt 
ALL_COMMANDS='start stop reload restart boot shutdown enable disable enabled depends '
CONFIG_APPEND=''
CONFIG_LIST_STATE=''
CONFIG_NUM_SECTIONS='4'
CONFIG_SECTION='state'
CONFIG_SECTIONS='basic loopback lan state'
CONFIG_basic_TYPE='dhcp6c'
CONFIG_basic_bcmcs_server_address='0'
CONFIG_basic_bcmcs_server_domain_name='0'
CONFIG_basic_debug='1'
CONFIG_basic_dns='dnsmasq'
CONFIG_basic_domain_name='0'
CONFIG_basic_domain_name_servers='1'
CONFIG_basic_enabled='1'
CONFIG_basic_interface='wan'
CONFIG_basic_na='0'
CONFIG_basic_nis_domain_name='0'
CONFIG_basic_nis_server_address='0'
CONFIG_basic_nisp_domain_name='0'
CONFIG_basic_nisp_server_address='0'
CONFIG_basic_ntp_servers='0'
CONFIG_basic_pd='1'
CONFIG_basic_rapid_commit='1'
CONFIG_basic_script='/usr/bin/dhcp6c-state'
CONFIG_basic_sip_server_address='0'
CONFIG_basic_sip_server_domain_name='0'
CONFIG_lan_TYPE='interface'
CONFIG_lan_enabled='1'
CONFIG_lan_sla_id='1'
CONFIG_lan_sla_len='8'
CONFIG_loopback_TYPE='interface'
CONFIG_loopback_enabled='1'
CONFIG_loopback_sla_id='0'
CONFIG_loopback_sla_len='8'
CONFIG_state_TYPE='dhcp6c_state'
DHCP6C_REQUEST_OPTIONS='domain_name_servers domain_name ntp_servers sip_server_address sip_domain_name nis_server_address nis_domain_name nisp_server_address nisp_domain_name bcmcs_server_address bcmcs_domain_name'
HOME='/root'
IFS=' 
'
LIST_SEP=' '
LOAD_STATE='1'
LOGNAME='root'
N='
'
NO_EXPORT='1'
OPTIND='1'
PATH='/bin:/sbin:/usr/bin:/usr/sbin'
PPID='1951'
PS1='\u@\h:\w\$ '
PS2='> '
PS4='+ '
PWD='/root'
SHELL='/bin/ash'
SSH_CONNECTION='::ffff:192.168.1.2 46022 ::ffff:192.168.1.1 22'
SSH_TTY='/dev/pts/0'
TERM='xterm'
USER='root'
_C='0'
action='restart'
client_ifname='pppoe-wan'
client_interface='wan'
device=''
enabled='1'
ifname='pppoe-wan'
initscript='/etc/init.d/dhcp6c'
interface='wan'

As you can see, $device is empty, therefore the fallback non-solution is used with the same bad result.
This is the reason, why I used

CONFIG_APPEND=1 config_load network

in my original patch.

comment:4 in reply to: ↑ 3 ; follow-up: Changed 7 years ago by Peter Pöschl <pp+wrt0611@…>

Replying to pp+wrt0611@…:
Perhaps it is useful to know

cat /etc/config/dhcp6c 

config 'dhcp6c' 'basic'
        option 'interface' 'wan'
        option 'dns' 'dnsmasq'
        option 'pd' '1'
        option 'na' '0'
        option 'rapid_commit' '1'
        option 'domain_name_servers' '1'
        option 'domain_name' '0'
        option 'ntp_servers' '0'
        option 'sip_server_address' '0'
        option 'sip_server_domain_name' '0'
        option 'nis_server_address' '0'
        option 'nis_domain_name' '0'
        option 'nisp_server_address' '0'
        option 'nisp_domain_name' '0'
        option 'bcmcs_server_address' '0'
        option 'bcmcs_server_domain_name' '0'
        option 'script' '/usr/bin/dhcp6c-state'
        option 'enabled' '1'
        option 'debug' '1'

config 'interface' 'loopback'
        option 'enabled' '1'
        option 'sla_id' '0'
        option 'sla_len' '8'

config 'interface' 'lan'
        option 'enabled' '1'
        option 'sla_id' '1'
        option 'sla_len' '8'

comment:5 in reply to: ↑ 4 Changed 7 years ago by pp+wrt0611@…

Replying to Peter Pöschl <pp+wrt0611@…>:

Note (to make this bug more visible via Google etc.):

If an ISP offers native IPv6 via DHCPv6 prefix delegation
and a customer runs an unpatched wide-dhcp6v-client on his router
then the lucky router, which has successfully acquired a lease, DOSes all the other OpenWRT routers with the same configuration, because due to the identical DUID they will get no answer to their SOLICIT messages.

comment:6 Changed 7 years ago by jow

The proposed patch missed a "scan_interfaces" invocation in the get_device() procedure, otherwise it works as expected:

root@OpenWrt:/# ifconfig eth0.1; ifconfig pppoe-wan
eth0.1    Link encap:Ethernet  HWaddr D8:5D:4C:A5:03:F2  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:78 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4553 (4.4 KiB)  TX bytes:1602 (1.5 KiB)

pppoe-wan Link encap:Point-to-Point Protocol  
          inet addr:10.67.7.3  P-t-P:10.0.0.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:27 errors:0 dropped:0 overruns:0 frame:0
          TX packets:37 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:4213 (4.1 KiB)  TX bytes:6388 (6.2 KiB)

root@OpenWrt:/# logread | grep DUID
Jun  8 23:17:17 OpenWrt user.notice dhcp6c: Using DUID 00:03:00:06:D8:5D:4C:A5:03:F2  
root@OpenWrt:/# 

comment:7 Changed 7 years ago by jow

  • Resolution set to fixed
  • Status changed from accepted to closed

Should be fixed with r27140.

comment:8 Changed 4 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.