NetBSD Problem Report #49196

From www@NetBSD.org  Fri Sep 12 08:31:38 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 5C5A7CD631
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 12 Sep 2014 08:31:17 +0000 (UTC)
Message-Id: <20140912083111.F1381CD638@mollari.NetBSD.org>
Date: Fri, 12 Sep 2014 08:31:10 +0000 (UTC)
From: ozaki-r@netbsd.org
Reply-To: ozaki-r@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: ifconfig -vlanif with IFF_PROMISC on doesn't work correctly
X-Send-Pr-Version: www-1.0

>Number:         49196
>Category:       kern
>Synopsis:       ifconfig -vlanif with IFF_PROMISC on doesn't work correctly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 12 08:35:00 +0000 2014
>Closed-Date:    Tue Nov 04 09:41:15 +0000 2014
>Last-Modified:  Wed Jul 14 06:40:01 +0000 2021
>Originator:     Ryota Ozaki
>Release:        current
>Organization:
>Environment:
NetBSD rangeley 7.99.1 NetBSD 7.99.1 (RANGELEY) #181: Fri Sep 12 13:09:35 JST 2014  ozaki-r@(hidden):(hidden) amd64
>Description:
Detaching a parent interface from a VLAN interface in promiscuous mode causes an unexpected result: both interfaces still remain in promiscuous mode.

At least, the parent interface should leave promiscuous mode. I think the VLAN interface should leave as well. Actually there is no chance to turn promiscuous mode off once it's is unconfigured by vlan_unconfig.
>How-To-Repeat:
ifconfig wm1 10.0.0.2/24 up
ifconfig vlan0 create
ifconfig vlan0 up
ifconfig vlan0 vlan 10 vlanif wm1

# Setting vlan0 and wm1 promiscuous mode
tcpdump -i vlan0 &
ifconfig vlan0
ifconfig wm1

# Detaching vlan0 from wm1
ifconfig vlan0 -vlanif wm1
ifconfig wm1  # wm1 is still in promiscuous mode (unexpected)

ifconfig vlan0  # vlan0 is still in promiscuous mode (expected)

# Unsetting promiscuous mode
pkill tcpdump
sleep 1
ifconfig vlan0 # vlan0 is still in promiscuous mode (unexpected)

>Fix:
Index: sys/net/if_vlan.c
===================================================================
RCS file: /cvs/cvsroot/src/sys/net/if_vlan.c,v
retrieving revision 1.72
diff -u -p -r1.72 if_vlan.c
--- sys/net/if_vlan.c	12 Sep 2014 04:10:24 -0000	1.72
+++ sys/net/if_vlan.c	12 Sep 2014 08:21:18 -0000
@@ -400,6 +400,8 @@ vlan_unconfig(struct ifnet *ifp)
 	ifv->ifv_if.if_mtu = 0;
 	ifv->ifv_flags = 0;

+	if ((ifp->if_flags & IFF_PROMISC) != 0)
+		ifpromisc(ifp, 0);
 	if_down(ifp);
 	ifp->if_flags &= ~(IFF_UP|IFF_RUNNING);
 	ifp->if_capabilities = 0;
@@ -484,6 +486,10 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd
 		if ((error = copyin(ifr->ifr_data, &vlr, sizeof(vlr))) != 0)
 			break;
 		if (vlr.vlr_parent[0] == '\0') {
+			if (ifv->ifv_p != NULL) {
+				if ((ifp->if_flags & IFF_PROMISC) != 0)
+					error = ifpromisc(ifv->ifv_p, 0);
+			}
 			vlan_unconfig(ifp);
 			break;
 		}

>Release-Note:

>Audit-Trail:
From: "Ryota Ozaki" <ozaki-r@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49196 CVS commit: src/sys/net
Date: Mon, 15 Sep 2014 05:54:02 +0000

 Module Name:	src
 Committed By:	ozaki-r
 Date:		Mon Sep 15 05:54:02 UTC 2014

 Modified Files:
 	src/sys/net: if_vlan.c

 Log Message:
 Leave promiscuous mode when detaching a parent (ifconfig -vlanif)

 We have to call ifpromisc(ifp, 0) for both a VLAN interface
 and its parent when they are in promiscuous mode.

 PR 49196


 To generate a diff of this commit:
 cvs rdiff -u -r1.72 -r1.73 src/sys/net/if_vlan.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->pending-pullups
State-Changed-By: ozaki-r@NetBSD.org
State-Changed-When: Tue, 16 Sep 2014 03:03:13 +0000
State-Changed-Why:
pullup-6 and pullup-7


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49196 CVS commit: [netbsd-7] src
Date: Mon, 22 Sep 2014 10:44:37 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Sep 22 10:44:37 UTC 2014

 Modified Files:
 	src/sbin/ifconfig [netbsd-7]: ifconfig.8 vlan.c
 	src/sys/net [netbsd-7]: if_vlan.c

 Log Message:
 Pull up following revision(s) (requested by ozaki-r in ticket #108):
 	sbin/ifconfig/vlan.c: revision 1.14
 	sbin/ifconfig/ifconfig.8: revision 1.108
 	sys/net/if_vlan.c: revision 1.71-1.74

 Document -vlanif in ifconfig.8 and in usage measseg (PR 49114).
 Leave promiscuous mode when detaching a parent (PR 49196) and
 delete link local addresses (49197).
 Restore vlan_ioctl overwritten by ether_ifdetach in vlan_unconfig
 (PR 49112).
 Call if_input of vlan interface itself, not parent one.
 This allows bridging vlan interfaces again.


 To generate a diff of this commit:
 cvs rdiff -u -r1.106 -r1.106.4.1 src/sbin/ifconfig/ifconfig.8
 cvs rdiff -u -r1.13 -r1.13.24.1 src/sbin/ifconfig/vlan.c
 cvs rdiff -u -r1.70 -r1.70.2.1 src/sys/net/if_vlan.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "SAITOH Masanobu" <msaitoh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49196 CVS commit: [netbsd-6] src
Date: Mon, 3 Nov 2014 20:38:09 +0000

 Module Name:	src
 Committed By:	msaitoh
 Date:		Mon Nov  3 20:38:09 UTC 2014

 Modified Files:
 	src/sbin/ifconfig [netbsd-6]: ifconfig.8 vlan.c
 	src/sys/net [netbsd-6]: if_vlan.c

 Log Message:
 Pull up following revision(s) (requested by ozaki-r in ticket #1156):
 	sbin/ifconfig/vlan.c: revision 1.14
 	sbin/ifconfig/ifconfig.8: revision 1.108
 	sys/net/if_vlan.c: revision 1.71
 	sys/net/if_vlan.c: revision 1.73
 	sys/net/if_vlan.c: revision 1.74
 - PR#49114: Write about -vlanif in ifconfig.8.
   Add -vlanif to the help message of ifconfig.
 - PR#49196: Leave promiscuous mode when detaching a parent (ifconfig -vlanif)
   We have to call ifpromisc(ifp, 0) for both a VLAN interface
   and its parent when they are in promiscuous mode.
 - PR#49197: Delete link local addresses of a vlan interface when detaching its
   parent.
 - PR#49112: Restore vlan_ioctl overwritten by ether_ifdetach in vlan_unconfig


 To generate a diff of this commit:
 cvs rdiff -u -r1.104 -r1.104.2.1 src/sbin/ifconfig/ifconfig.8
 cvs rdiff -u -r1.13 -r1.13.8.1 src/sbin/ifconfig/vlan.c
 cvs rdiff -u -r1.69.8.1 -r1.69.8.2 src/sys/net/if_vlan.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: msaitoh@NetBSD.org
State-Changed-When: Tue, 04 Nov 2014 09:41:15 +0000
State-Changed-Why:
Pulled up. Thanks.


From: "Shoichi YAMAGUCHI" <yamaguchi@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49196 CVS commit: src/tests/net/if_vlan
Date: Wed, 14 Jul 2021 06:36:00 +0000

 Module Name:	src
 Committed By:	yamaguchi
 Date:		Wed Jul 14 06:36:00 UTC 2021

 Modified Files:
 	src/tests/net/if_vlan: t_vlan.sh

 Log Message:
 Added a test about clearing IFF_PROMISC at vlan_unconfig

 This test is related to PR/49196


 To generate a diff of this commit:
 cvs rdiff -u -r1.20 -r1.21 src/tests/net/if_vlan/t_vlan.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.