From bdrewery@FreeBSD.org  Tue Aug  7 17:31:38 2012
Return-Path: <bdrewery@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 2BC95106564A
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  7 Aug 2012 17:31:37 +0000 (UTC)
	(envelope-from bdrewery@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28])
	by mx1.freebsd.org (Postfix) with ESMTP id B1C908FC14
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  7 Aug 2012 17:31:37 +0000 (UTC)
Received: from freefall.freebsd.org (localhost [127.0.0.1])
	by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q77HVbhq095957
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 7 Aug 2012 17:31:37 GMT
	(envelope-from bdrewery@freefall.freebsd.org)
Received: (from bdrewery@localhost)
	by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q77HVbsB095956
	for FreeBSD-gnats-submit@freebsd.org; Tue, 7 Aug 2012 17:31:37 GMT
	(envelope-from bdrewery)
Received: (qmail 86285 invoked from network); 7 Aug 2012 12:31:33 -0500
Received: from unknown (HELO test8.xzibition.com) (10.10.0.34)
  by sweb.xzibition.com with SMTP; 7 Aug 2012 12:31:33 -0500
Received: by test8.xzibition.com (sSMTP sendmail emulation); Tue, 07 Aug 2012 12:30:46 -0500
Message-Id: <201208071731.q77HVbsB095956@freefall.freebsd.org>
Date: Tue, 07 Aug 2012 12:30:46 -0500
From: Bryan Drewery <bdrewery@freebsd.org>
Reply-To: Bryan Drewery <bdrewery@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [kern] uuidgen(2) uses ipfw0 interface for MAC address resulting in zeros
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         170460
>Category:       kern
>Synopsis:       [kernel] [patch] uuidgen(2) uses ipfw0 interface for MAC address resulting in zeros
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    eadler
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 07 17:40:01 UTC 2012
>Closed-Date:    Sun Oct 21 03:31:49 UTC 2012
>Last-Modified:  Sun Oct 21 03:31:49 UTC 2012
>Originator:     Bryan Drewery
>Release:        FreeBSD 8.3-RELEASE i386
>Organization:
>Environment:

	
>Description:
	uuidgen(2) reads the first MAC address it finds. This can result in the ipfw0 interace address being used, which is 0.

	# ifconfig
	ipfw0: flags=8801<UP,SIMPLEX,MULTICAST> metric 0 mtu 65536
		nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
	lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
		options=3<RXCSUM,TXCSUM>
		inet6 ::1 prefixlen 128 
		inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 
		inet 127.0.0.1 netmask 0xff000000 
		nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
	xn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
		options=503<RXCSUM,TXCSUM,TSO4,LRO>
		ether 08:00:27:a2:7d:bf
		inet6 fe80::a00:27ff:fea2:7dbf%xn0 prefixlen 64 scopeid 0x3 
		inet 10.10.0.35 netmask 0xffff0000 broadcast 10.10.255.255
		inet6 2001:470:1f11:262:a00:27ff:fea2:7dbf prefixlen 64 autoconf 
		nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
		media: Ethernet manual
		status: active

	# uuidgen
	102beb5c-e0b5-11e1-9304-000000000000


>How-To-Repeat:
	Compile with IPFIREWALL.
	I'm also using XEN domU.

	Somehow the ipfw0 interface is coming first.
>Fix:

	Ignore interfaces with no link address.
	With patch, it properly ignores ipfw0:
	# uuidgen
	7ba3705f-e0b5-11e1-9bf7-080027a27dbf
	# uuidgen
	7bf8778f-e0b5-11e1-9bf7-080027a27dbf


--- patch-kern_uuid_ipfw0.txt begins here ---
Index: sys/kern/kern_uuid.c
===================================================================
--- sys/kern/kern_uuid.c	(revision 239130)
+++ sys/kern/kern_uuid.c	(working copy)
@@ -102,7 +102,7 @@
 		TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
 			sdl = (struct sockaddr_dl*)ifa->ifa_addr;
 			if (sdl != NULL && sdl->sdl_family == AF_LINK &&
-			    sdl->sdl_type == IFT_ETHER) {
+			    sdl->sdl_type == IFT_ETHER && sdl->sdl_alen > 0) {
 				/* Got a MAC address. */
 				bcopy(LLADDR(sdl), node, UUID_NODE_LEN);
 				IF_ADDR_RUNLOCK(ifp);
--- patch-kern_uuid_ipfw0.txt ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->eadler 
Responsible-Changed-By: bdrewery 
Responsible-Changed-When: Tue Aug 7 17:46:24 UTC 2012 
Responsible-Changed-Why:  
eadler wants this 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/170460: commit references a PR
Date: Sat,  1 Sep 2012 23:34:26 +0000 (UTC)

 Author: eadler
 Date: Sat Sep  1 23:33:49 2012
 New Revision: 239997
 URL: http://svn.freebsd.org/changeset/base/239997
 
 Log:
       Mark the ipfw interface type as not being ether. This fixes an issue
       where uuidgen tried to obtain a ipfw device's mac address which was
       always zero.
   
       PR:		170460
       Submitted by:	wxs
       Reviewed by:	bdrewery
       Reviewed by:	delphij
       Approved by:	cperciva
       MFC after:	1 week
 
 Modified:
   head/sys/netinet/ipfw/ip_fw_log.c
 
 Modified: head/sys/netinet/ipfw/ip_fw_log.c
 ==============================================================================
 --- head/sys/netinet/ipfw/ip_fw_log.c	Sat Sep  1 15:59:09 2012	(r239996)
 +++ head/sys/netinet/ipfw/ip_fw_log.c	Sat Sep  1 23:33:49 2012	(r239997)
 @@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$");
  #include <net/if.h>
  #include <net/if_clone.h>
  #include <net/vnet.h>
 -#include <net/if_types.h>	/* for IFT_ETHER */
 +#include <net/if_types.h>	/* for IFT_PFLOG */
  #include <net/bpf.h>		/* for BPF */
  
  #include <netinet/in.h>
 @@ -151,7 +151,7 @@ ipfw_log_clone_create(struct if_clone *i
  	if (error)
  		return (error);
  
 -	ifp = if_alloc(IFT_ETHER);
 +	ifp = if_alloc(IFT_PFLOG);
  	if (ifp == NULL) {
  		ifc_free_unit(ifc, unit);
  		return (ENOSPC);
 _______________________________________________
 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: eadler 
State-Changed-When: Sat Sep 1 23:40:47 UTC 2012 
State-Changed-Why:  
committed in r239997 

http://www.freebsd.org/cgi/query-pr.cgi?pr=170460 
State-Changed-From-To: patched->closed 
State-Changed-By: eadler 
State-Changed-When: Sun Oct 21 03:31:48 UTC 2012 
State-Changed-Why:  
Committed. Thanks! 

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