From owner-freebsd-hackers Wed Aug 28 20:48:38 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C2BBD37B400 for ; Wed, 28 Aug 2002 20:48:35 -0700 (PDT) Received: from mail.libertysurf.net (mail.libertysurf.net [213.36.80.91]) by mx1.FreeBSD.org (Postfix) with ESMTP id 195C943E42 for ; Wed, 28 Aug 2002 20:48:35 -0700 (PDT) (envelope-from julienbenoist@altern.org) Received: from manali (212.232.20.209) by mail.libertysurf.net (6.5.026) id 3D50909B00220532 for freebsd-hackers@freebsd.org; Thu, 29 Aug 2002 05:43:37 +0200 From: Julien Benoist To: freebsd-hackers@freebsd.org Subject: toggling promiscuous mode logging on NICs Date: Thu, 29 Aug 2002 05:43:36 +0200 User-Agent: KMail/1.4.2 MIME-Version: 1.0 Message-Id: <200208290542.09749.julienbenoist@altern.org> Content-Type: Multipart/Mixed; boundary="------------Boundary-00=_OC6LUAAAEE0BFS69RKOB" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --------------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