promisc coding question
George V. Neville-Neil
gnn at neville-neil.com
Fri Sep 24 20:07:52 PDT 2004
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
More information about the freebsd-net
mailing list