From nobody@FreeBSD.org  Fri Feb 27 20:48:24 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0509E106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 27 Feb 2009 20:48:24 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id CD29B8FC15
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 27 Feb 2009 20:48:23 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n1RKmNSp052607
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 27 Feb 2009 20:48:23 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n1RKmNjD052606;
	Fri, 27 Feb 2009 20:48:23 GMT
	(envelope-from nobody)
Message-Id: <200902272048.n1RKmNjD052606@www.freebsd.org>
Date: Fri, 27 Feb 2009 20:48:23 GMT
From: David Horn <dhorn2000@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] /etc/network.subr: ipv6 rtsol on incorrect wlan interface
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         132179
>Category:       conf
>Synopsis:       [patch] /etc/network.subr: ipv6 rtsol on incorrect wlan interface
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    dougb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 27 20:50:01 UTC 2009
>Closed-Date:    Tue Sep 29 17:37:39 UTC 2009
>Last-Modified:  Tue Sep 29 17:37:39 UTC 2009
>Originator:     David Horn
>Release:        -current as of Feb 26 2009
>Organization:
>Environment:
FreeBSD top-bsd 8.0-CURRENT FreeBSD 8.0-CURRENT #2: Thu Feb 26 03:23:18 EST 2009     dhorn@top-bsd.private.nullcore.com:/usr/obj/usr/src/sys/DHORN  i386

>Description:
in /etc/network.subr, in function network6_interface_setup:

The incorrect wlan network interfaces will be eligible for rtsol.

If rtsol is called for a wireless hardware interface rather than the wlanX interface, it will fail to send a router solicitation, and will give spurious errors like:

get_llflag() failed, anyway I'll try
sendmsg on iwn0: Can't assign requested address
sendmsg on iwn0: Can't assign requested address
sendmsg on iwn0: Can't assign requested address

This is not just innocuous, as the way that rtsol is called, only the first interface is actually eligible, so wlan0 will never be initialized by rtsol, This may not be easily noticeable depending on ipv6 router advertisement timing.

My patch dynamically determines if an interface is 802.11, and NOT named wlanX to remove eligibility.

>How-To-Repeat:
Setup a machine with a wireless interface and ipv6 enabled and setup in rc.conf

e.g.
ipv6_enabled="YES"
wlans_iwn0=wlan0
ifconfig_wlan0="WPA DHCP"

with appropriate wpa_supplicant.conf configured

Watch for get_llflag() failed errors on boot
>Fix:
unified diff attached.

Patch attached with submission follows:

--- /usr/src/etc/network.subr	2009-02-04 13:20:27.000000000 -0500
+++ /etc/network.subr	2009-02-27 15:19:15.000000000 -0500
@@ -852,10 +852,28 @@
 			rtsol_available=no
 			rtsol_interface=no
 			ifconfig $i inet6 ${ipv6_ifconfig} alias
 		fi
 
+		# allow rtsol on wlan software interfaces e.g. wlan0,
+		# but not on wlan hardware interfaces e.g. iwn0
+		case "$i" in
+		wlan[0-9]*)
+			;;
+		*)
+			device=`ifconfig $i 2>/dev/null | while read line; do
+				case "$line" in
+				*media:?IEEE?802.11*)	
+					echo 802.11_hardware 	
+					;;
+				esac
+			done`
+			if [ "$device" = "802.11_hardware" ]; then
+				rtsol_interface=no
+			fi
+			;;
+		esac
 		if [ ${rtsol_available} = yes -a ${rtsol_interface} = yes ]
 		then
 			case ${i} in
 			lo0|gif[0-9]*|stf[0-9]*|faith[0-9]*|lp[0-9]*|sl[0-9]*|tun[0-9]*|pflog[0-9]*|pfsync[0-9]*)
 				;;


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Sat Feb 28 15:38:25 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s).  I think -net is probably the most 
appropriate list for this, rather than -rc. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132179 

From: David Horn <dhorn2000@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: conf/132179: [patch] /etc/network.subr: ipv6 rtsol on incorrect 
	wlan interface
Date: Tue, 29 Sep 2009 12:14:35 -0400

 Please close this bug (conf/132179) as fixed. SVN r195029
 
 This works now in -current and in 8/Stable
 
 Modified Fri Jun 26 01:27:16 2009 UTC (3 months ago) by dougb
 File length: 22019 byte(s)
 Diff to previous 193199
 
 rtsol should not be run on the wireless NIC interfaces directly,
 it will run on wlan0 instead.
 
 http://svn.freebsd.org/viewvc/base/head/etc/network.subr?r1=193199&r2=195029
 
 --Thanks!
 
 ---Dave H
State-Changed-From-To: open->closed 
State-Changed-By: dougb 
State-Changed-When: Tue Sep 29 17:36:31 UTC 2009 
State-Changed-Why:  

Originator reports that this problem was fixed by my change in r195029. 


Responsible-Changed-From-To: freebsd-net->dougb 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Tue Sep 29 17:36:31 UTC 2009 
Responsible-Changed-Why:  

I committed the update. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=132179 
>Unformatted:
