Subject: kern/929: BPF refuses to take SLIP/PPP/??? out of promisc. mode.
To: None <gnats-admin@NetBSD.ORG>
From: Rafal Boni <rafal@ruger-75.slip.uiuc.edu>
List: netbsd-bugs
Date: 03/30/1995 10:05:05
>Number:         929
>Category:       kern
>Synopsis:       BPF will set promisc mode, but cannot unset it...
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 30 10:05:02 1995
>Originator:     Rafal Boni
>Organization:
	Huh? Wazzat?
>Release:        March 27 -current
>Environment:

System: NetBSD ruger-75.slip.uiuc.edu 1.0A NetBSD 1.0A (RAFAL) #4: Mon Mar 27 13:14:15 CST 1995 rafal@rafal.slip.uiuc.edu:/usr/src/sys/arch/i386/compile/RAFAL i386
	Running either SLIP or PPP

>Description:
	For any interface that does not support SIOCSIFFLAGS ioctl, BPF will
	happily put it into promiscuous mode, but will not take it out.

	Currently such interfaces include SLIP, PPP, TUN and loopback [and
	possibly some others].

	From /sys/net/bpf.c, circa line 685:

	/*
	 * Put interface into promiscuous mode.
	 */
	case BIOCPROMISC:
		if (d->bd_bif == 0) {
			/*
			 * No interface attached yet.
			 */
			error = EINVAL;
			break;
		}
		s = splimp();
		if (d->bd_promisc == 0) {
			error = ifpromisc(d->bd_bif->bif_ifp, 1);
			if (error == 0)
				d->bd_promisc = 1;
		}
		splx(s);
		break;

	If the interface does not support SIOCSIFFLAGS, which is used by the
	ifpromisc() call, ifpromisc will return an error, and hence the
	bd_promisc field will not be set.  If bd_promisc is not set, BPF will
	rightfully not try to take the interface out of promiscuous mode on
	close.

>How-To-Repeat:
	tcpdump -i sl0

	On exit from tcpdump "ifconfig -a" then says:

	sl0: flags=d111<UP,POINTOPOINT,PROMISC,LINK0,LINK2,MULTICAST>
		inet 128.174.23.123 --> 128.174.107.1 netmask 0xffffff00 

>Fix:
	(1) implement SIOCSIFFLAGS handler in if_ppp, if_sl, if_loop and 
	if_tun.  

	(2) Have BPF ignore errors from the *ifp->if_ioctl function, as
	almost everthing else in the kernel does??  The flags are updated
	anyway, whether *ifp->if_ioctl succeeds or not...

	(3) <Insert better ideas here...>
>Audit-Trail:
>Unformatted: