Wed Jul 14 06:50:22 2021 UTC ()
unset IFF_PROMISC at bpf_detach()

Doing "d->bd_promisc = 0" is that bpf_detach() does not call
ifpromisc(ifp, 0). Currently, there is no reason for
this behavior so that it is removed.
In addition to the change, the workaround for it in vlan(4)
is also removed.


(yamaguchi)
diff -r1.240 -r1.241 src/sys/net/bpf.c
diff -r1.158 -r1.159 src/sys/net/if_vlan.c

cvs diff -r1.240 -r1.241 src/sys/net/bpf.c (expand / switch to unified diff)

--- src/sys/net/bpf.c 2021/06/09 15:44:15 1.240
+++ src/sys/net/bpf.c 2021/07/14 06:50:22 1.241
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: bpf.c,v 1.240 2021/06/09 15:44:15 martin Exp $ */ 1/* $NetBSD: bpf.c,v 1.241 2021/07/14 06:50:22 yamaguchi Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1990, 1991, 1993 4 * Copyright (c) 1990, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from the Stanford/CMU enet packet filter, 7 * This code is derived from the Stanford/CMU enet packet filter,
8 * (net/enet.c) distributed as part of 4.3BSD, and code contributed 8 * (net/enet.c) distributed as part of 4.3BSD, and code contributed
9 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 9 * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
10 * Berkeley Laboratory. 10 * Berkeley Laboratory.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * @(#)bpf.c 8.4 (Berkeley) 1/9/95 36 * @(#)bpf.c 8.4 (Berkeley) 1/9/95
37 * static char rcsid[] = 37 * static char rcsid[] =
38 * "Header: bpf.c,v 1.67 96/09/26 22:00:52 leres Exp "; 38 * "Header: bpf.c,v 1.67 96/09/26 22:00:52 leres Exp ";
39 */ 39 */
40 40
41#include <sys/cdefs.h> 41#include <sys/cdefs.h>
42__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.240 2021/06/09 15:44:15 martin Exp $"); 42__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.241 2021/07/14 06:50:22 yamaguchi Exp $");
43 43
44#if defined(_KERNEL_OPT) 44#if defined(_KERNEL_OPT)
45#include "opt_bpf.h" 45#include "opt_bpf.h"
46#include "sl.h" 46#include "sl.h"
47#include "opt_net_mpsafe.h" 47#include "opt_net_mpsafe.h"
48#endif 48#endif
49 49
50#include <sys/param.h> 50#include <sys/param.h>
51#include <sys/systm.h> 51#include <sys/systm.h>
52#include <sys/mbuf.h> 52#include <sys/mbuf.h>
53#include <sys/buf.h> 53#include <sys/buf.h>
54#include <sys/time.h> 54#include <sys/time.h>
55#include <sys/proc.h> 55#include <sys/proc.h>
@@ -2184,27 +2184,26 @@ _bpfdetach(struct ifnet *ifp) @@ -2184,27 +2184,26 @@ _bpfdetach(struct ifnet *ifp)
2184 struct bpf_d *d; 2184 struct bpf_d *d;
2185 int s; 2185 int s;
2186 2186
2187 mutex_enter(&bpf_mtx); 2187 mutex_enter(&bpf_mtx);
2188 /* Nuke the vnodes for any open instances */ 2188 /* Nuke the vnodes for any open instances */
2189 again_d: 2189 again_d:
2190 BPF_DLIST_WRITER_FOREACH(d) { 2190 BPF_DLIST_WRITER_FOREACH(d) {
2191 mutex_enter(d->bd_mtx); 2191 mutex_enter(d->bd_mtx);
2192 if (d->bd_bif != NULL && d->bd_bif->bif_ifp == ifp) { 2192 if (d->bd_bif != NULL && d->bd_bif->bif_ifp == ifp) {
2193 /* 2193 /*
2194 * Detach the descriptor from an interface now. 2194 * Detach the descriptor from an interface now.
2195 * It will be free'ed later by close routine. 2195 * It will be free'ed later by close routine.
2196 */ 2196 */
2197 d->bd_promisc = 0; /* we can't touch device. */ 
2198 bpf_detachd(d); 2197 bpf_detachd(d);
2199 mutex_exit(d->bd_mtx); 2198 mutex_exit(d->bd_mtx);
2200 goto again_d; 2199 goto again_d;
2201 } 2200 }
2202 mutex_exit(d->bd_mtx); 2201 mutex_exit(d->bd_mtx);
2203 } 2202 }
2204 2203
2205 again: 2204 again:
2206 BPF_IFLIST_WRITER_FOREACH(bp) { 2205 BPF_IFLIST_WRITER_FOREACH(bp) {
2207 if (bp->bif_ifp == ifp) { 2206 if (bp->bif_ifp == ifp) {
2208 BPF_IFLIST_WRITER_REMOVE(bp); 2207 BPF_IFLIST_WRITER_REMOVE(bp);
2209 2208
2210 pserialize_perform(bpf_psz); 2209 pserialize_perform(bpf_psz);

cvs diff -r1.158 -r1.159 src/sys/net/if_vlan.c (expand / switch to unified diff)

--- src/sys/net/if_vlan.c 2021/07/14 06:23:06 1.158
+++ src/sys/net/if_vlan.c 2021/07/14 06:50:22 1.159
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_vlan.c,v 1.158 2021/07/14 06:23:06 yamaguchi Exp $ */ 1/* $NetBSD: if_vlan.c,v 1.159 2021/07/14 06:50:22 yamaguchi Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. 4 * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran, and by Jason R. Thorpe of Zembu Labs, Inc. 8 * by Andrew Doran, and by Jason R. Thorpe of Zembu Labs, Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -68,27 +68,27 @@ @@ -68,27 +68,27 @@
68 * enough of an Ethernet implementation to make ARP work. The way we do 68 * enough of an Ethernet implementation to make ARP work. The way we do
69 * this is by telling everyone that we are an Ethernet interface, and then 69 * this is by telling everyone that we are an Ethernet interface, and then
70 * catch the packets that ether_output() left on our output queue when it 70 * catch the packets that ether_output() left on our output queue when it
71 * calls if_start(), rewrite them for use by the real outgoing interface, 71 * calls if_start(), rewrite them for use by the real outgoing interface,
72 * and ask it to send them. 72 * and ask it to send them.
73 * 73 *
74 * TODO: 74 * TODO:
75 * 75 *
76 * - Need some way to notify vlan interfaces when the parent 76 * - Need some way to notify vlan interfaces when the parent
77 * interface changes MTU. 77 * interface changes MTU.
78 */ 78 */
79 79
80#include <sys/cdefs.h> 80#include <sys/cdefs.h>
81__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.158 2021/07/14 06:23:06 yamaguchi Exp $"); 81__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.159 2021/07/14 06:50:22 yamaguchi Exp $");
82 82
83#ifdef _KERNEL_OPT 83#ifdef _KERNEL_OPT
84#include "opt_inet.h" 84#include "opt_inet.h"
85#include "opt_net_mpsafe.h" 85#include "opt_net_mpsafe.h"
86#endif 86#endif
87 87
88#include <sys/param.h> 88#include <sys/param.h>
89#include <sys/systm.h> 89#include <sys/systm.h>
90#include <sys/kernel.h> 90#include <sys/kernel.h>
91#include <sys/mbuf.h> 91#include <sys/mbuf.h>
92#include <sys/queue.h> 92#include <sys/queue.h>
93#include <sys/socket.h> 93#include <sys/socket.h>
94#include <sys/sockio.h> 94#include <sys/sockio.h>
@@ -691,28 +691,26 @@ vlan_unconfig_locked(struct ifvlan *ifv, @@ -691,28 +691,26 @@ vlan_unconfig_locked(struct ifvlan *ifv,
691 mutex_exit(&ifv->ifv_lock); 691 mutex_exit(&ifv->ifv_lock);
692 692
693 nmib_psref = NULL; 693 nmib_psref = NULL;
694 kmem_free(omib, sizeof(*omib)); 694 kmem_free(omib, sizeof(*omib));
695 695
696#ifdef INET6 696#ifdef INET6
697 KERNEL_LOCK_UNLESS_NET_MPSAFE(); 697 KERNEL_LOCK_UNLESS_NET_MPSAFE();
698 /* To delete v6 link local addresses */ 698 /* To delete v6 link local addresses */
699 if (in6_present) 699 if (in6_present)
700 in6_ifdetach(ifp); 700 in6_ifdetach(ifp);
701 KERNEL_UNLOCK_UNLESS_NET_MPSAFE(); 701 KERNEL_UNLOCK_UNLESS_NET_MPSAFE();
702#endif 702#endif
703 703
704 if ((ifp->if_flags & IFF_PROMISC) != 0) 
705 vlan_safe_ifpromisc_locked(ifp, 0); 
706 if_down_locked(ifp); 704 if_down_locked(ifp);
707 ifp->if_capabilities = 0; 705 ifp->if_capabilities = 0;
708 mutex_enter(&ifv->ifv_lock); 706 mutex_enter(&ifv->ifv_lock);
709done: 707done:
710 708
711 if (nmib_psref) 709 if (nmib_psref)
712 psref_target_destroy(nmib_psref, ifvm_psref_class); 710 psref_target_destroy(nmib_psref, ifvm_psref_class);
713 711
714 return error; 712 return error;
715} 713}
716 714
717static void 715static void
718vlan_hash_init(void) 716vlan_hash_init(void)