From nobody@FreeBSD.org  Sat Jun 12 06:13:25 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0F0BA16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 12 Jun 2004 06:13:25 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 08D1243D41
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 12 Jun 2004 06:13:25 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i5C6DN6q094348
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 12 Jun 2004 06:13:23 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.11/8.12.11/Submit) id i5C6DNXn094336;
	Sat, 12 Jun 2004 06:13:23 GMT
	(envelope-from nobody)
Message-Id: <200406120613.i5C6DNXn094336@www.freebsd.org>
Date: Sat, 12 Jun 2004 06:13:23 GMT
From: Shingo WATANABE <nabe@nabechan.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: if_udav  failed to set the promiscuous mode
X-Send-Pr-Version: www-2.3

>Number:         67862
>Category:       kern
>Synopsis:       if_udav  failed to set the promiscuous mode
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    sanpei
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jun 12 06:20:10 GMT 2004
>Closed-Date:    Sun Jun 13 11:23:39 GMT 2004
>Last-Modified:  Sun Jun 13 11:23:39 GMT 2004
>Originator:     Shingo WATANABE
>Release:        FreeBSD 5.2-CURRENT
>Organization:
personal
>Environment:
FreeBSD hack.nabechan.org 5.2-CURRENT FreeBSD 5.2-CURRENT #0: Wed Jun  9 01:28:25 JST 2004     nabe@hack.nabechan.org:/usr/obj/usr/src/sys/HACK  i386

>Description:
The udav(4) driver was ported from NetBSD.  This driver works well except for the promiscuous mode.  To support the promiscuous mode udav(4) driver needs to handle the SIOCSIFFLAGS ioctl.  This problem is caused by the difference of ether_ioctl() function between FreeBSD and NetBSD.

I attached the patch to fix this problem, please commit this if it has not any problem.
regards
>How-To-Repeat:
try to launch tcpdump using udav(4) interface.
>Fix:
apply the following patch.

--- if_udav.c.org	2004-06-04 11:32:33.000000000 +0900
+++ if_udav.c	2004-06-04 11:51:24.000000000 +0900
@@ -1562,6 +1562,35 @@
 #endif
 
 	switch (cmd) {
+#if defined(__FreeBSD__)
+	case SIOCSIFFLAGS:
+		if (ifp->if_flags & IFF_UP) {
+			if (ifp->if_flags & IFF_RUNNING &&
+			    ifp->if_flags & IFF_PROMISC) {
+				UDAV_SETBIT(sc, UDAV_RCR,
+					    UDAV_RCR_ALL|UDAV_RCR_PRMSC);
+			} else if (ifp->if_flags & IFF_RUNNING &&
+				   !(ifp->if_flags & IFF_PROMISC)) {
+				if (ifp->if_flags & IFF_ALLMULTI)
+					UDAV_CLRBIT(sc, UDAV_RCR,
+						    UDAV_RCR_PRMSC);
+				else
+					UDAV_CLRBIT(sc, UDAV_RCR,
+						    UDAV_RCR_ALL|UDAV_RCR_PRMSC);
+			} else if (!(ifp->if_flags & IFF_RUNNING))
+				udav_init(sc);
+		} else {
+			if (ifp->if_flags & IFF_RUNNING)
+				udav_stop(ifp, 1);
+		}
+		error = 0;
+		break;
+	case SIOCADDMULTI:
+	case SIOCDELMULTI:
+		udav_setmulti(sc);
+		error = 0;
+		break;
+#endif
 	case SIOCGIFMEDIA:
 	case SIOCSIFMEDIA:
 		mii = GET_MII(sc);
@@ -1570,10 +1599,12 @@
 
 	default:
 		error = ether_ioctl(ifp, cmd, data);
+#if defined(__NetBSD__)
 		if (error == ENETRESET) {
 			udav_setmulti(sc);
 			error = 0;
 		}
+#endif
 		break;
 	}
 

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: sanpei 
State-Changed-When: Sun Jun 13 07:54:29 GMT 2004 
State-Changed-Why:  
I handled this PR. 


Responsible-Changed-From-To: freebsd-bugs->sanpei 
Responsible-Changed-By: sanpei 
Responsible-Changed-When: Sun Jun 13 07:54:29 GMT 2004 
Responsible-Changed-Why:  
I handled this PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=67862 
State-Changed-From-To: analyzed->closed 
State-Changed-By: sanpei 
State-Changed-When: Sun Jun 13 11:23:17 GMT 2004 
State-Changed-Why:  
Committed if_udav.c 1.6, thanks 

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