From nobody@FreeBSD.org  Mon Dec 12 14:50:04 2011
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 C5369106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 12 Dec 2011 14:50:04 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 9910F8FC15
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 12 Dec 2011 14:50:04 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id pBCEo37L028004
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 12 Dec 2011 14:50:03 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id pBCEo3qZ028003;
	Mon, 12 Dec 2011 14:50:03 GMT
	(envelope-from nobody)
Message-Id: <201112121450.pBCEo3qZ028003@red.freebsd.org>
Date: Mon, 12 Dec 2011 14:50:03 GMT
From: Ralf Wenk <IZ-FreeBSD0701@hs-karlsruhe.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: dhclient stopped working on wlan0 because of changes in CURRENT kernel between 2011-11-29 and 2011-12-12
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         163206
>Category:       kern
>Synopsis:       dhclient stopped working on wlan0 because of changes in CURRENT kernel between 2011-11-29 and 2011-12-12
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    glebius
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 12 15:00:03 UTC 2011
>Closed-Date:    Tue Dec 13 11:56:36 UTC 2011
>Last-Modified:  Tue Dec 13 15:20:08 UTC 2011
>Originator:     Ralf Wenk
>Release:        FreeBSD 10.0-CURRENT
>Organization:
Hochschule Karlsruhe, University of Applied Sciences
>Environment:
FreeBSD IZ-T193196065251a 10.0-CURRENT FreeBSD 10.0-CURRENT #4: Mon Dec 12 10:11:00 CET 2011     root@IZ-T193196065251a:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
After upgrading from a current world and kernel from 2011-11-29 to todays
version dhclient is now unable to aquire an IP address from an wlan0 interface.
It is working fine on an em0 interface with the same kernel.

The messages in /var/log/messages are

Dec 12 15:08:31 IZ-T193196065251a dhclient[1625]: wlan0: not found
Dec 12 15:08:31 IZ-T193196065251a dhclient[1625]: exiting.
Dec 12 15:08:31 IZ-T193196065251a dhclient[1626]: connection closed
Dec 12 15:08:31 IZ-T193196065251a dhclient[1626]: exiting.
Dec 12 15:08:31 IZ-T193196065251a root: /etc/rc.d/dhclient: WARNING: failed to start dhclient

Reverting the kernel to the old CURRENT version fixes the problem.
Because of successfully using world of today with an old kernel I think the
problem is caused by changes made to the kernel between the two dates.

Stopping the dhclient with "/etc/rc.d/dhclient stop wlan0" shows
  dhclient not running? (check /var/run/dhclient.wlan0.pid).
as expected. Starting with "/etc/rc.d/dhclient start wlan0" shows
  Starting dhclient.
  ifconfig: ioctl (SIOCAIFADDR): File exists
  wlan0: not found
  exiting.
  /etc/rc.d/dhclient: WARNING: failed to start dhclient

Adding "set -xv" to /sbin/dhclient-script leads to the 
  $IFCONFIG $interface inet alias 0.0.0.0 netmask 0.0.0.0 broadcast 255.255.255.255 up
line as the cause of the "ifconfig: ioctl (SIOCAIFADDR): File exists"
error message.

# ifconfig wlan0" 
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:22:5f:fa:85:0b
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: IEEE 802.11 Wireless Ethernet OFDM/6Mbps mode 11g
        status: associated
        ssid HsKA-8021x channel 1 (2412 MHz 11g) bssid 0a:0b:6b:2b:2e:c6
        regdomain ETSI country DE indoor ecm authmode WPA2/802.11i privacy ON
        deftxkey UNDEF TKIP 2:128-bit txpower 30 bmiss 7 scanvalid 450 bgscan
        bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
        wme burst roaming MANUAL
#
>How-To-Repeat:
Set up interfaces in /etc/rc.conf as
ifconfig_em0="DHCP"
wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP country Germany"

use a CURRENT kernel of today and than a CURRENT kernel at least of 2011-11-29.
>Fix:


>Release-Note:
>Audit-Trail:

From: Gleb Smirnoff <glebius@FreeBSD.org>
To: Ralf Wenk <IZ-FreeBSD0701@hs-karlsruhe.de>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/163206: dhclient stopped working on wlan0 because of
 changes in CURRENT kernel between 2011-11-29 and 2011-12-12
Date: Mon, 12 Dec 2011 19:25:11 +0400

 --ZwgA9U+XZDXt4+m+
 Content-Type: text/plain; charset=koi8-r
 Content-Disposition: inline
 
   Ralf,
 
   can you please perform two tests:
 
   1) Back out the r228313 revision and try again.
      http://svnweb.freebsd.org/base?view=revision&revision=228313
 
   2) Return the tree back to normal state (including r228313) and
      try the attached patch.
 
 -- 
 Totus tuus, Glebius.
 
 --ZwgA9U+XZDXt4+m+
 Content-Type: text/x-diff; charset=koi8-r
 Content-Disposition: attachment; filename="in.c.diff"
 
 Index: in.c
 ===================================================================
 --- in.c	(revision 228438)
 +++ in.c	(working copy)
 @@ -1072,7 +1072,7 @@
  in_scrubprefix(struct in_ifaddr *target, u_int flags)
  {
  	struct in_ifaddr *ia;
 -	struct in_addr prefix, mask, p;
 +	struct in_addr prefix, mask, p, m;
  	int error = 0;
  	struct sockaddr_in prefix0, mask0;
  
 @@ -1133,15 +1133,22 @@
  
  	IN_IFADDR_RLOCK();
  	TAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) {
 -		if (rtinitflags(ia))
 +		if (rtinitflags(ia)) {
  			p = ia->ia_dstaddr.sin_addr;
 -		else {
 +
 +			if (prefix.s_addr != p.s_addr)
 +				continue;
 +		} else {
  			p = ia->ia_addr.sin_addr;
 -			p.s_addr &= ia->ia_sockmask.sin_addr.s_addr;
 +			m = ia->ia_sockmask.sin_addr;
 +			p.s_addr &= m.s_addr;
 +
 +			if (prefix.s_addr != p.s_addr ||
 +			    mask.s_addr != m.s_addr)
 +				continue;
  		}
  
 -		if ((prefix.s_addr != p.s_addr) ||
 -		    !(ia->ia_ifp->if_flags & IFF_UP))
 +		if ((ia->ia_ifp->if_flags & IFF_UP) == 0)
  			continue;
  
  		/*
 
 --ZwgA9U+XZDXt4+m+--

From: Gleb Smirnoff <glebius@FreeBSD.org>
To: Ralf Wenk <IZ-FreeBSD0701@hs-karlsruhe.de>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/163206: dhclient stopped working on wlan0 because of
 changes in CURRENT kernel between 2011-11-29 and 2011-12-12
Date: Mon, 12 Dec 2011 19:28:55 +0400

   One more question: have you got any error messages in dmesg?
 
 -- 
 Totus tuus, Glebius.

From: Gleb Smirnoff <glebius@FreeBSD.org>
To: Ralf Wenk <IZ-FreeBSD0701@hs-karlsruhe.de>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/163206: dhclient stopped working on wlan0 because of
 changes in CURRENT kernel between 2011-11-29 and 2011-12-12
Date: Mon, 12 Dec 2011 19:45:13 +0400

 --YToU2i3Vx8H2dn7O
 Content-Type: text/plain; charset=koi8-r
 Content-Disposition: inline
 
   Ralf,
 
   a couple more questions:
 
   1) Can you please tell whether you have default route in kernel when
      dhclient fails? The default may be was received on em0.
 
   2) If you do, then please try the attached patch to dhclient-script.
 
 -- 
 Totus tuus, Glebius.
 
 --YToU2i3Vx8H2dn7O
 Content-Type: text/x-diff; charset=koi8-r
 Content-Disposition: attachment; filename="dhclient-script.diff"
 
 Index: dhclient-script
 ===================================================================
 --- dhclient-script	(revision 228438)
 +++ dhclient-script	(working copy)
 @@ -320,7 +320,7 @@
  
  PREINIT)
  	delete_old_alias
 -	$IFCONFIG $interface inet alias 0.0.0.0 netmask 0.0.0.0 broadcast 255.255.255.255 up
 +	$IFCONFIG $interface inet alias 0.0.0.0 netmask 255.0.0.0 broadcast 255.255.255.255 up
  	;;
  
  ARPCHECK|ARPSEND)
 
 --YToU2i3Vx8H2dn7O--

From: Ralf Wenk <IZ-FreeBSD0701@hs-karlsruhe.de>
To: Gleb Smirnoff <glebius@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/163206: dhclient stopped working on wlan0 because of changes 
 in CURRENT kernel between 2011-11-29 and 2011-12-12
Date: Tue, 13 Dec 2011 09:40:31 +0100

 Gleb,
 
 while the kernel with the r228313 revision is still compiling ...
  
 >   a couple more questions:
 > 
 >   1) Can you please tell whether you have default route in kernel when
 >      dhclient fails? The default may be was received on em0.
 
 definitely yes. em0 is the "default route interface".
 
 >   2) If you do, then please try the attached patch to dhclient-script.
 
 This patch fixes/works around the problem with yesterdays CURRENT kernel.
 
 
 Kind regards, Ralf
 
State-Changed-From-To: open->closed 
State-Changed-By: glebius 
State-Changed-When: Tue Dec 13 11:56:11 UTC 2011 
State-Changed-Why:  
Fixed in r228463. 


Responsible-Changed-From-To: freebsd-bugs->glebius 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Tue Dec 13 11:56:11 UTC 2011 
Responsible-Changed-Why:  
Fixed in r228463. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/163206: commit references a PR
Date: Tue, 13 Dec 2011 11:55:19 +0000 (UTC)

 Author: glebius
 Date: Tue Dec 13 11:54:51 2011
 New Revision: 228463
 URL: http://svn.freebsd.org/changeset/base/228463
 
 Log:
   dhclient-script relied on incorrect behavior of SIOCAIFADDR ioctl,
   that changed 0.0.0.0/0.0.0.0 prefix to 0.0.0.0/255.0.0.0.
   
   In the r228313 this behavior was fixed, and since dhclient-script
   got broken.
   
   I'm not sure this fix is a perfect one, it just changes
   dhclient-script to set 0.0.0.0/255.0.0.0 explicitly.
   
   PR:		kern/163206
 
 Modified:
   head/sbin/dhclient/dhclient-script
 
 Modified: head/sbin/dhclient/dhclient-script
 ==============================================================================
 --- head/sbin/dhclient/dhclient-script	Tue Dec 13 11:13:28 2011	(r228462)
 +++ head/sbin/dhclient/dhclient-script	Tue Dec 13 11:54:51 2011	(r228463)
 @@ -320,7 +320,7 @@ MEDIUM)
  
  PREINIT)
  	delete_old_alias
 -	$IFCONFIG $interface inet alias 0.0.0.0 netmask 0.0.0.0 broadcast 255.255.255.255 up
 +	$IFCONFIG $interface inet alias 0.0.0.0 netmask 255.0.0.0 broadcast 255.255.255.255 up
  	;;
  
  ARPCHECK|ARPSEND)
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: Ralf Wenk <IZ-FreeBSD0701@hs-karlsruhe.de>
To: Gleb Smirnoff <glebius@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/163206: dhclient stopped working on wlan0 because of changes 
 in CURRENT kernel between 2011-11-29 and 2011-12-12
Date: Tue, 13 Dec 2011 16:12:32 +0100

 Gleb,
 
 I am sorry it took a while.
 
 >   can you please perform two tests:
 > 
 >   1) Back out the r228313 revision and try again.
 >      http://svnweb.freebsd.org/base?view=revision&revision=228313
 
 With that change it worked again.
 
 >   2) Return the tree back to normal state (including r228313) and
 >      try the attached patch.
 
 Two tries to compile the patched kernel failed in objcopy while working on
 zlib.ko. The cause is currentyl unknown to me. Regardless of the closed
 state, if it is still interesting for you I will try with a complete newly
 checked out tree and revert the r228463 revision.
 
 Kind regards, Ralf
 
>Unformatted:
