diff options
author | sobomax <sobomax@FreeBSD.org> | 2002-08-19 15:16:38 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2002-08-19 15:16:38 +0000 |
commit | e50e3b03ec109b238fb7d960a5be0b08961b41d4 (patch) | |
tree | 2e1436eccf89dbd4a420091b15a0d5dd78911874 /sys/net/if.c | |
parent | be3fb716390064e92134d98e272ab35537b33ce9 (diff) | |
download | FreeBSD-src-e50e3b03ec109b238fb7d960a5be0b08961b41d4.zip FreeBSD-src-e50e3b03ec109b238fb7d960a5be0b08961b41d4.tar.gz |
Implement user-setable promiscuous mode (a new `promisc' flag for ifconfig(8)).
Also, for all interfaces in this mode pass all ethernet frames to upper layer,
even those not addressed to our own MAC, which allows packets encapsulated
in those frames be processed with packet filters (ipfw(8) et al).
Emphatically requested by: Anton Turygin <pa3op@ukr-link.net>
Valuable suggestions by: fenner
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 969963d..a551148 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1291,6 +1291,12 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) } ifp->if_flags = (ifp->if_flags & IFF_CANTCHANGE) | (new_flags &~ IFF_CANTCHANGE); + if (new_flags & IFF_PPROMISC) { + /* Permanently promiscuous mode requested */ + ifp->if_flags |= IFF_PROMISC; + } else if (ifp->if_pcount == 0) { + ifp->if_flags &= ~IFF_PROMISC; + } if (ifp->if_ioctl) (void) (*ifp->if_ioctl)(ifp, cmd, data); getmicrotime(&ifp->if_lastchange); @@ -1561,6 +1567,11 @@ ifpromisc(ifp, pswitch) oldpcount = ifp->if_pcount; oldflags = ifp->if_flags; + if (ifp->if_flags & IFF_PPROMISC) { + /* Do nothing if device is in permanently promiscuous mode */ + ifp->if_pcount += pswitch ? 1 : -1; + return (0); + } if (pswitch) { /* * If the device is not configured up, we cannot put it in |