toggling promiscuous mode logging on NICs

2002-08-28 Thread Julien Benoist

This is a patch allowing to control kernel logging of promiscuous mode changes 
on network interfaces through sysctl (enabled by default) :
kern.log_promisc=1

I dont know if this mib should be placed somewhere else, nor if the feature 
itself could interest anyone... Patch attached anyway.

-- 
Julien Benoist



--- /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);



Re: toggling promiscuous mode logging on NICs

2002-08-28 Thread Terry Lambert

Julien Benoist wrote:
 This is a patch allowing to control kernel logging of promiscuous mode changes
 on network interfaces through sysctl (enabled by default) :
 kern.log_promisc=1
 
 I dont know if this mib should be placed somewhere else, nor if the feature
 itself could interest anyone... Patch attached anyway.

In a general sense, it's probably abut time to add a class
parameter or two (one a bitmap, the other a bitmap within that
bitmap) to all of the kernel display data.

That would let you block all messages of a class, without the
need to introduce per-printf sysctl's.

This sort of goes with PHK's idea that the console code needs
a rethink.

-- Terry

To Unsubscribe: send mail to [EMAIL PROTECTED]
with unsubscribe freebsd-hackers in the body of the message