From dm@home3.dinoex.sub.de  Sun Nov 15 15:45:41 2009
Return-Path: <dm@home3.dinoex.sub.de>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id DF76C106566B
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 15 Nov 2009 15:45:40 +0000 (UTC)
	(envelope-from dm@home3.dinoex.sub.de)
Received: from uucp.dinoex.sub.de (uucp.dinoex.sub.de [194.45.71.2])
	by mx1.freebsd.org (Postfix) with ESMTP id 5F30E8FC1C
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 15 Nov 2009 15:45:38 +0000 (UTC)
Received: from home3.dinoex.sub.de (home3.dinoex.sub.de [194.45.71.20])
	by uucp.dinoex.sub.de (8.14.3/8.14.2) with ESMTP id nAFFj0OR043200
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 15 Nov 2009 16:45:16 +0100 (CET)
	(envelope-from dm@home3.dinoex.sub.de)
Received: (from dm@localhost)
	by home3.dinoex.sub.de (8.14.3/8.14.3/Submit) id nAFFj1C8017176;
	Sun, 15 Nov 2009 16:45:01 +0100 (CET)
	(envelope-from dm)
Message-Id: <200911151545.nAFFj1C8017176@home3.dinoex.sub.de>
Date: Sun, 15 Nov 2009 16:45:01 +0100 (CET)
From: dirk.meyer@dinoex.sub.org
Reply-To: dirk.meyer@dinoex.sub.org
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: ifconfig does not set country DE
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         140571
>Category:       bin
>Synopsis:       [patch] ifconfig(8) does not set country DE
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    gavin
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 15 15:50:01 UTC 2009
>Closed-Date:    Sat Jan 16 15:28:12 UTC 2010
>Last-Modified:  Sat Jan 16 15:28:12 UTC 2010
>Originator:     Dirk Meyer
>Release:        FreeBSD 8.0-PRERELEASE
>Organization:
privat
>Environment:

	FreeBSD 8.0-PRERELEASE #1: Sun Nov 15 13:01:02 CET 2009

>Description:

	ifconfig is unable to set country DE
	as DE" will match short for "DEBUG" instead of exact country "DE".

>How-To-Repeat:

$ ifconfig wlan0 list countries
Country codes:
DEBUG Debug           ZW Zimbabwe        YE Yemen           VN Viet Nam       
VE Venezuela       UZ Uzbekistan      UY Uruguay         US United States  
GB United Kingdom  AE United Arab Emi UA Ukraine         TR Turkey         
TN Tunisia         TT Tobago          TH Thailand        TW Taiwan         
SY Syria           CH Switzerland     SE Sweden          LK Sri Lanka      
ES Spain           ZA South Africa    SI Slovenia        SK Slovak Republic
SG Singapore       SA Saudi Arabia    RU Rusia           RO Romania        
QA Quatar          PR Puerto Rico     PT Portugal        PL Poland         
PH Phillipines     PE Peru            PA Panama          PK Pakistan       
OM Oman            NO Norway          NZ New Zealand     NL Netherlands    
NP Nepal           MA Morocco         MC Monaco          MX Mexico         
MT Malta           MY Malaysia        MK Macedonia       MO Macau          
LU Luxemborg       LT Lithuania       LI Liechtenstein   LB Lebanon        
LV Latvia          KW Kuwait          K2 Korea Republic2 KR Korea Republic 
KP North Korea     KZ Kazakhstan      JO Jordan          J5 Japan5         
J4 Japan4          J3 Japan3          J2 Japan2          J1 Japan1         
JP Japan           JM Jamaica         IT Italy           IL Israel         
IE Ireland         IR Iran            ID Indonesia       IN India          
IS Iceland         HU Hungary         HK Hong Kong       HN Honduras       
GT Guatemala       GR Greece          DE Germany         GE Georgia        
F2 France2         FR France          FI Finland         EE Estonia        
SV El Salvador     EG Egypt           EC Ecuador         DO Dominican Repub
DK Denmark         CZ Czech Republic  CY Cyprus          HR Croatia        
CR Costa Rica      CO Colombia        CN China           CL Chile          
CA Canada          BG Bulgaria        BN Brunei          BR Brazil         
BO Bolivia         BZ Belize          BE Belgium         BY Belarus        
BD Bangladesh      BH Bahrain         AZ Azerbaijan      AT Austria        
AU Australia       AM Armenia         AR Argentina       DZ Algeria        
AL Albania         
Regulatory domains:
GZ901           XR9             SR9             NONE           
ROW             KOREA           APAC3           APAC2          
APAC            ETSI3           ETSI2           ETSI           
JAPAN           FCC4            FCC3            FCC            
DEBUG           

$ ifconfig wlan0 country DE
$ ifconfig wlan0
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:21:6b:a9:e4:22
        inet6 fe80::221:6bff:fea9:e422%wlan0 prefixlen 64 scopeid 0x6 
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: no carrier
        ssid "" channel 1 (2412 Mhz 11b)
        regdomain DEBUG authmode WPA1+WPA2/802.11i privacy ON deftxkey UNDEF
        txpower 30 bmiss 10 scanvalid 60 wme roaming MANUAL bintval 0

If the country DE is renamed to DEX in /etc/regdomain.xml
then ifconfig can set the correct regdomain.

$ ifconfig wlan0 
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:21:6b:a9:e4:22
        inet6 fe80::221:6bff:fea9:e422%wlan0 prefixlen 64 scopeid 0x6 
        media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
        status: no carrier
        ssid "" channel 1 (2412 Mhz 11b)
        regdomain ETSI country DEX authmode WPA1+WPA2/802.11i privacy ON
        deftxkey UNDEF txpower 30 bmiss 10 scanvalid 60 wme roaming MANUAL
        bintval 0

>Fix:

	The xml parser should not select the first "debug" entry
	when extact match is in the table.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: gavin 
State-Changed-When: Sun Nov 15 20:08:14 UTC 2009 
State-Changed-Why:  
To submitter: Can you test http://people.freebsd.org/~gavin/PRs/140571.diff 
and make sure it fixes things for you? 


Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Sun Nov 15 20:08:14 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s) 

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

From: dirk.meyer@dinoex.sub.org (Dirk Meyer)
To: FreeBSD-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/140571: [patch] ifconfig(8) does not set country
	DE
Date: Mon, 16 Nov 2009 08:54:35 +0100

 The patch at http://people.freebsd.org/~gavin/PRs/140571.diff
 does fix the problem.
 
 DEB does match DEBUG
 DE can now selected and metahces the country
 D does match the first entry found (DEBUG), which is okay.
 
 # ifconfig wlan0 country DEB
 # ifconfig wlan0
 wlan0: flags=8c02<BROADCAST,OACTIVE,SIMPLEX,MULTICAST> metric 0 mtu 1500
         ether 00:21:6b:a9:e4:22
         inet6 fe80::221:6bff:fea9:e422%wlan0 prefixlen 64 scopeid 0x6 
         media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
         status: no carrier
         ssid "" channel 1 (2412 Mhz 11b)
         regdomain DEBUG authmode WPA1+WPA2/802.11i privacy OFF txpower 30
         bmiss 10 scanvalid 60 wme
 # ifconfig wlan0 country DE
 # ifconfig wlan0
 wlan0: flags=8c02<BROADCAST,OACTIVE,SIMPLEX,MULTICAST> metric 0 mtu 1500
         ether 00:21:6b:a9:e4:22
         inet6 fe80::221:6bff:fea9:e422%wlan0 prefixlen 64 scopeid 0x6 
         media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
         status: no carrier
         ssid "" channel 1 (2412 Mhz 11b)
         regdomain ETSI country DE authmode WPA1+WPA2/802.11i privacy OFF
         txpower 30 bmiss 10 scanvalid 60 wme
 # ifconfig wlan0 country D
 # ifconfig wlan0
 wlan0: flags=8c02<BROADCAST,OACTIVE,SIMPLEX,MULTICAST> metric 0 mtu 1500
         ether 00:21:6b:a9:e4:22
         inet6 fe80::221:6bff:fea9:e422%wlan0 prefixlen 64 scopeid 0x6 
         media: IEEE 802.11 Wireless Ethernet autoselect (autoselect)
         status: no carrier
         ssid "" channel 1 (2412 Mhz 11b)
         regdomain DEBUG authmode WPA1+WPA2/802.11i privacy OFF txpower 30
         bmiss 10 scanvalid 60 wme
 
 Thanks for the quick response.
 
 kind regards
 
 - Dirk Meyer, Im Grund 4, 34317 Habichtswald, Germany
 - [dirk.meyer@dinoex.sub.org],[dirk.meyer@guug.de],[dinoex@FreeBSD.org]
State-Changed-From-To: feedback->open 
State-Changed-By: gavin 
State-Changed-When: Sun Dec 13 19:22:06 UTC 2009 
State-Changed-Why:  
Feedback was received 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/140571: commit references a PR
Date: Tue, 15 Dec 2009 20:44:26 +0000 (UTC)

 Author: gavin
 Date: Tue Dec 15 20:44:12 2009
 New Revision: 200587
 URL: http://svn.freebsd.org/changeset/base/200587
 
 Log:
   ifconfig(8) is documented to take a ISO 3166-1 country code to set the
   regulatory domain with the "country" parameter, but will also take a full
   country name.  The man page warns that only the ISO code is unambiguous.
   In reality, however, the first match on either would be accepted, leading
   to "DE" being interpreted as the "DEBUG" country rather than Germany, and
   "MO" selecting Morocco rather than the correct country, Macau.
   
   Fix this by always checking for an ISO CC match first, and only search on
   the full country name if that fails.
   
   PR:		bin/140571
   Tested by:	Dirk Meyer dirk.meyer dinoex.sub.org
   Reviewed by:	sam
   Approved by:	ed (mentor)
   MFC after:	1 month
 
 Modified:
   head/sbin/ifconfig/regdomain.c
 
 Modified: head/sbin/ifconfig/regdomain.c
 ==============================================================================
 --- head/sbin/ifconfig/regdomain.c	Tue Dec 15 20:20:05 2009	(r200586)
 +++ head/sbin/ifconfig/regdomain.c	Tue Dec 15 20:44:12 2009	(r200587)
 @@ -694,8 +694,11 @@ lib80211_country_findbyname(const struct
  
  	len = strlen(name);
  	LIST_FOREACH(cp, &rdp->countries, next) {
 -		if (strcasecmp(cp->isoname, name) == 0 ||
 -		    strncasecmp(cp->name, name, len) == 0)
 +		if (strcasecmp(cp->isoname, name) == 0)
 +			return cp;
 +	}
 +	LIST_FOREACH(cp, &rdp->countries, next) {
 +		if (strncasecmp(cp->name, name, len) == 0)
  			return cp;
  	}
  	return NULL;
 _______________________________________________
 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"
 
State-Changed-From-To: open->patched 
State-Changed-By: gavin 
State-Changed-When: Tue Dec 15 21:08:39 UTC 2009 
State-Changed-Why:  
Fixed in HEAD 


Responsible-Changed-From-To: freebsd-net->gavin 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Tue Dec 15 21:08:39 UTC 2009 
Responsible-Changed-Why:  
Mine 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/140571: commit references a PR
Date: Sat, 16 Jan 2010 15:00:48 +0000 (UTC)

 Author: gavin
 Date: Sat Jan 16 15:00:35 2010
 New Revision: 202446
 URL: http://svn.freebsd.org/changeset/base/202446
 
 Log:
   MFC r200587:
     ifconfig(8) is documented to take a ISO 3166-1 country code to set the
     regulatory domain with the "country" parameter, but will also take a full
     country name.  The man page warns that only the ISO code is unambiguous.
     In reality, however, the first match on either would be accepted, leading
     to "DE" being interpreted as the "DEBUG" country rather than Germany, and
     "MO" selecting Morocco rather than the correct country, Macau.
   
     Fix this by always checking for an ISO CC match first, and only search on
     the full country name if that fails.
   
   PR:		bin/140571
   Tested by:	Dirk Meyer dirk.meyer dinoex.sub.org
   Reviewed by:	sam
   Approved by:	ed (mentor, implicit)
 
 Modified:
   stable/8/sbin/ifconfig/regdomain.c
 Directory Properties:
   stable/8/sbin/ifconfig/   (props changed)
 
 Modified: stable/8/sbin/ifconfig/regdomain.c
 ==============================================================================
 --- stable/8/sbin/ifconfig/regdomain.c	Sat Jan 16 14:33:22 2010	(r202445)
 +++ stable/8/sbin/ifconfig/regdomain.c	Sat Jan 16 15:00:35 2010	(r202446)
 @@ -694,8 +694,11 @@ lib80211_country_findbyname(const struct
  
  	len = strlen(name);
  	LIST_FOREACH(cp, &rdp->countries, next) {
 -		if (strcasecmp(cp->isoname, name) == 0 ||
 -		    strncasecmp(cp->name, name, len) == 0)
 +		if (strcasecmp(cp->isoname, name) == 0)
 +			return cp;
 +	}
 +	LIST_FOREACH(cp, &rdp->countries, next) {
 +		if (strncasecmp(cp->name, name, len) == 0)
  			return cp;
  	}
  	return NULL;
 _______________________________________________
 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"
 
State-Changed-From-To: patched->closed 
State-Changed-By: gavin 
State-Changed-When: Sat Jan 16 15:27:25 UTC 2010 
State-Changed-Why:  
Fixed in HEAD and 8.x.  Thanks for your bug report! 

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