Date: Sat, 25 Sep 2004 12:07:00 +0900 From: "George V. Neville-Neil" <gnn@neville-neil.com> To: ming fu <fming@borderware.com> Cc: freebsd-net@freebsd.org Subject: Re: promisc coding question Message-ID: <m2hdpnf3mz.wl@minion.local.neville-neil.com> In-Reply-To: <41541355.50800@borderware.com> References: <41541355.50800@borderware.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?m2hdpnf3mz.wl>