From owner-freebsd-net@FreeBSD.ORG Sat Sep 25 03:07:51 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D3A6D16A4CE for ; Sat, 25 Sep 2004 03:07:51 +0000 (GMT) Received: from outbound0.sv.meer.net (outbound0.sv.meer.net [205.217.152.13]) by mx1.FreeBSD.org (Postfix) with ESMTP id B65B243D54 for ; Sat, 25 Sep 2004 03:07:51 +0000 (GMT) (envelope-from gnn@neville-neil.com) Received: from mail.meer.net (mail.meer.net [209.157.152.14]) i8P374r2069224; Fri, 24 Sep 2004 20:07:05 -0700 (PDT) (envelope-from gnn@neville-neil.com) Received: from minion.local.neville-neil.com (pc1.oakwoodazabu1-unet.ocn.ne.jp [220.110.140.201]) by mail.meer.net (8.12.1/8.12.2/meer) with ESMTP id i8P372uZ083645; Fri, 24 Sep 2004 20:07:02 -0700 (PDT) (envelope-from gnn@neville-neil.com) Date: Sat, 25 Sep 2004 12:07:00 +0900 Message-ID: From: "George V. Neville-Neil" To: ming fu In-Reply-To: <41541355.50800@borderware.com> References: <41541355.50800@borderware.com> User-Agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.5 (Awara-Onsen) FLIM/1.14.5 (Demachiyanagi) APEL/10.5 Emacs/21.2 (powerpc-apple-darwin) MULE/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII cc: freebsd-net@freebsd.org Subject: Re: promisc coding question X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Sep 2004 03:07:52 -0000 At Fri, 24 Sep 2004 08:30:13 -0400, ming fu wrote: > > Hi, > > in if.h > #define IFF_PROMISC 0x100 /* receive all packets */ > #define IFF_PPROMISC 0x20000 /* user-requested promisc mode */ > > Do I have to set both on for the promisc to work? > If I only need one of them, then what is the difference? > The first flag (IFF_PROMISC) is the one that the kernel code uses and sets on an interface's ifp structure. The second one is the one that comes from user space programs and is sent to the routine ifhwioctl() to set the first flag. Having reviewed this flags usage I believe that there are at least two bugs in the kernel related to its handling: I beleieve it is only used correctly at: if.c[1160] if (new_flags & IFF_PPROMISC) { but that at: if.c[1478] if (ifp->if_flags & IFF_PPROMISC) { and if_ethersubr.c[664] && (ifp->if_flags & IFF_PPROMISC)== 0) { neither of those checks can ever succeed because I can find nowhere in the code that the IFF_PPROMISCx flag is set on an interface. I suggest two changes to remedy this: 1) Change IFF_PPROMISC to IFF_USERPROMISC to disambiguate the names. 2) Change if.c[1478] and if_ethersubr.c[664] to check for the correct flag, IFF_PROMISC. Or, someone can tell me that I'm wrong :-) I will send out a patch next. Later, George