Date: Thu, 29 Aug 2002 05:43:36 +0200 From: Julien Benoist <julienbenoist@altern.org> To: freebsd-hackers@freebsd.org Subject: toggling promiscuous mode logging on NICs Message-ID: <200208290542.09749.julienbenoist@altern.org>
next in thread | raw e-mail | index | archive | help
--------------Boundary-00=_OC6LUAAAEE0BFS69RKOB Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable This is a patch allowing to control kernel logging of promiscuous mode ch= anges=20 on network interfaces through sysctl (enabled by default) : kern.log_promisc=3D1 I dont know if this mib should be placed somewhere else, nor if the featu= re=20 itself could interest anyone... Patch attached anyway. --=20 Julien Benoist --------------Boundary-00=_OC6LUAAAEE0BFS69RKOB Content-Type: text/x-diff; charset="us-ascii"; name="log_promisc_hook.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="log_promisc_hook.patch" --- /usr/src.old/sys/net/if.c Sun Apr 28 07:40:25 2002 +++ /usr/src/sys/net/if.c Thu Aug 29 03:52:06 2002 @@ -80,6 +80,10 @@ static void if_slowtimo __P((void *)); static void link_rtrequest __P((int, struct rtentry *, struct rt_addrinfo *)); static int if_rtdel __P((struct radix_node *, void *)); +static int log_promisc = 1; + +SYSCTL_INT(_kern, OID_AUTO, log_promisc, CTLFLAG_RW, + &log_promisc, 0 , "toggle promiscuity mode"); SYSINIT(interfaces, SI_SUB_PROTO_IF, SI_ORDER_FIRST, ifinit, NULL) @@ -1245,14 +1249,18 @@ if (ifp->if_pcount++ != 0) return (0); ifp->if_flags |= IFF_PROMISC; - log(LOG_INFO, "%s%d: promiscuous mode enabled\n", - ifp->if_name, ifp->if_unit); + if (log_promisc==1) { + log(LOG_INFO, "%s%d: promiscuous mode enabled\n", + ifp->if_name, ifp->if_unit); + } } else { if (--ifp->if_pcount > 0) return (0); ifp->if_flags &= ~IFF_PROMISC; - log(LOG_INFO, "%s%d: promiscuous mode disabled\n", - ifp->if_name, ifp->if_unit); + if (log_promisc==1) { + log(LOG_INFO, "%s%d: promiscuous mode disabled\n", + ifp->if_name, ifp->if_unit); + } } ifr.ifr_flags = ifp->if_flags; error = (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr); --------------Boundary-00=_OC6LUAAAEE0BFS69RKOB-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208290542.09749.julienbenoist>