From ru@ucb.crimea.ua  Thu Apr 30 09:20:56 1998
Received: from relay.ucb.crimea.ua (relay.ucb.crimea.ua [194.93.177.113])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA02128
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 30 Apr 1998 09:20:40 -0700 (PDT)
          (envelope-from ru@ucb.crimea.ua)
Received: (from ru@localhost)
	by relay.ucb.crimea.ua (8.8.8/8.8.8) id TAA16249;
	Thu, 30 Apr 1998 19:20:29 +0300 (EEST)
	(envelope-from ru)
Message-Id: <199804301620.TAA16249@relay.ucb.crimea.ua>
Date: Thu, 30 Apr 1998 19:20:29 +0300 (EEST)
From: Ruslan Ermilov <ru@ucb.crimea.ua>
Reply-To: ru@ucb.crimea.ua
To: FreeBSD-gnats-submit@freebsd.org
Subject: loopback interface has no SIOCSIFFLAGS handler, this causes bugs
X-Send-Pr-Version: 3.2

>Number:         6466
>Category:       kern
>Synopsis:       loopback interface has no SIOCSIFFLAGS handler, this causes bugs
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 30 09:30:01 PDT 1998
>Closed-Date:    Thu Apr 30 12:37:06 PDT 1998
>Last-Modified:  Thu Apr 30 12:37:17 PDT 1998
>Originator:     Ruslan Ermilov
>Release:        FreeBSD 2.2.6-STABLE i386
>Organization:
United Commercial Bank
>Environment:

	-stable and (I guess) -current.

>Description:

	Loopback network interface driver (net/if_loop.c) has no
	SIOCSIFFLAGS ioctl handler.

	This causes bugs.

	I noticed this after running tcpdump on lo0.
	Once set, IFF_PROMISC flag isn't cleared on lo0.

	Searching in the source code (net/if.c, net/if_loop.c, net/bpf.c)
	I found the problem:


	1. The IFF_PROMISC flag is cleared in ifpromisc(ifp,0).

	2. ifpromisc(ifp,0) is called from bpf_detach() only if
           (struct bpf_d).bd_promisc is set to non-zero.

	3. bd_promisc is set to 1 in bpfioctl() while handling BIOCPROMISC.
	   It is set to 1 only if ifpromisc(ifp,1) returns 0.

	4. ifpromisc(ifp,1) fails on if_ioctl(lo0, SIOCSIFFLAGS)
	   because if_loop.c has no handler for SIOCSIFFLAGS.

>How-To-Repeat:

	1. Run ``ifconfig lo0'':

	lo0: flags=8149<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
		inet 127.0.0.1 netmask 0xff000000 

	2. Run ``tcpdump -i lo0''

	3. Stop ``tcpdump -i lo0''

	4. Run ``ifconfig lo0'' again:

	lo0: flags=8149<UP,LOOPBACK,RUNNING,PROMISC,MULTICAST> mtu 16384
	                                    ^^^^^^^
		inet 127.0.0.1 netmask 0xff000000 

>Fix:

This patch for RELENG_2_2:

Index: if_loop.c
===================================================================
RCS file: /usr/FreeBSD-CVS/src/sys/net/if_loop.c,v
retrieving revision 1.22
diff -u -r1.22 if_loop.c
--- if_loop.c	1996/06/19 16:24:10	1.22
+++ if_loop.c	1998/04/30 16:09:16
@@ -293,6 +293,9 @@
 		ifp->if_mtu = ifr->ifr_mtu;
 		break;
 
+	case SIOCSIFFLAGS:
+		break;
+
 	default:
 		error = EINVAL;
 	}

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Thu Apr 30 12:37:06 PDT 1998 
State-Changed-Why:  
committed, thanks! 
>Unformatted:
