Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/sys Pull up following revision(s) (requested by ozaki-r i...



details:   https://anonhg.NetBSD.org/src/rev/efbd00b00964
branches:  netbsd-8
changeset: 434519:efbd00b00964
user:      snj <snj%NetBSD.org@localhost>
date:      Tue Jan 02 10:20:32 2018 +0000

description:
Pull up following revision(s) (requested by ozaki-r in ticket #456):
        sys/arch/arm/sunxi/sunxi_emac.c: 1.9
        sys/dev/ic/dwc_gmac.c: 1.43-1.44
        sys/dev/pci/if_iwm.c: 1.75
        sys/dev/pci/if_wm.c: 1.543
        sys/dev/pci/ixgbe/ixgbe.c: 1.112
        sys/dev/pci/ixgbe/ixv.c: 1.74
        sys/kern/sys_socket.c: 1.75
        sys/net/agr/if_agr.c: 1.43
        sys/net/bpf.c: 1.219
        sys/net/if.c: 1.397, 1.399, 1.401-1.403, 1.406-1.410, 1.412-1.416
        sys/net/if.h: 1.242-1.247, 1.250, 1.252-1.257
        sys/net/if_bridge.c: 1.140 via patch, 1.142-1.146
        sys/net/if_etherip.c: 1.40
        sys/net/if_ethersubr.c: 1.243, 1.246
        sys/net/if_faith.c: 1.57
        sys/net/if_gif.c: 1.132
        sys/net/if_l2tp.c: 1.15, 1.17
        sys/net/if_loop.c: 1.98-1.101
        sys/net/if_media.c: 1.35
        sys/net/if_pppoe.c: 1.131-1.132
        sys/net/if_spppsubr.c: 1.176-1.177
        sys/net/if_tun.c: 1.142
        sys/net/if_vlan.c: 1.107, 1.109, 1.114-1.121
        sys/net/npf/npf_ifaddr.c: 1.3
        sys/net/npf/npf_os.c: 1.8-1.9
        sys/net/rtsock.c: 1.230
        sys/netcan/if_canloop.c: 1.3-1.5
        sys/netinet/if_arp.c: 1.255
        sys/netinet/igmp.c: 1.65
        sys/netinet/in.c: 1.210-1.211
        sys/netinet/in_pcb.c: 1.180
        sys/netinet/ip_carp.c: 1.92, 1.94
        sys/netinet/ip_flow.c: 1.81
        sys/netinet/ip_input.c: 1.362
        sys/netinet/ip_mroute.c: 1.147
        sys/netinet/ip_output.c: 1.283, 1.285, 1.287
        sys/netinet6/frag6.c: 1.61
        sys/netinet6/in6.c: 1.251, 1.255
        sys/netinet6/in6_pcb.c: 1.162
        sys/netinet6/ip6_flow.c: 1.35
        sys/netinet6/ip6_input.c: 1.183
        sys/netinet6/ip6_output.c: 1.196
        sys/netinet6/mld6.c: 1.90
        sys/netinet6/nd6.c: 1.239-1.240
        sys/netinet6/nd6_nbr.c: 1.139
        sys/netinet6/nd6_rtr.c: 1.136
        sys/netipsec/ipsec_output.c: 1.65
        sys/rump/net/lib/libnetinet/netinet_component.c: 1.9-1.10
kmem_intr_free kmem_intr_[z]alloced memory
the underlying pools are the same but api-wise those should match
Unify IFEF_*_MPSAFE into IFEF_MPSAFE
There are already two flags for if_output and if_start, however, it seems such
MPSAFE flags are eventually needed for all if_XXX operations. Having discrete
flags for each operation is wasteful of if_extflags bits. So let's unify
the flags into one: IFEF_MPSAFE.
Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so
we can change them without breaking backward compatibility of the releases
(though the kernel version of -current should be bumped).
Note that if an interface have both MP-safe and non-MP-safe operations at a
time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe
opeartions take the kernel lock.
Proposed on tech-kern@ and tech-net@
Provide macros for softnet_lock and KERNEL_LOCK hiding NET_MPSAFE switch
It reduces C&P codes such as "#ifndef NET_MPSAFE KERNEL_LOCK(1, NULL); ..."
scattered all over the source code and makes it easy to identify remaining
KERNEL_LOCK and/or softnet_lock that are held even if NET_MPSAFE.
No functional change
Hold KERNEL_LOCK on if_ioctl selectively based on IFEF_MPSAFE
If IFEF_MPSAFE is set, hold the lock and otherwise don't hold.
This change requires additions of KERNEL_LOCK to subsequence functions from
if_ioctl such as ifmedia_ioctl and ifioctl_common to protect non-MP-safe
components.
Proposed on tech-kern@ and tech-net@
Ensure to hold if_ioctl_lock when calling if_flags_set
Fix locking against myself on ifpromisc
vlan_unconfig_locked could be called with holding if_ioctl_lock.
Ensure to not turn on IFF_RUNNING of an interface until its initialization completes
And ensure to turn off it before destruction as per IFF_RUNNING's description
"resource allocated". (The description is a bit doubtful though, I believe the
change is still proper.)
Ensure to hold if_ioctl_lock on if_up and if_down
One exception for if_down is if_detach; in the case the lock isn't needed
because it's guaranteed that no other one can access ifp at that point.
Make if_link_queue MP-safe if IFEF_MPSAFE
if_link_queue is a queue to store events of link state changes, which is
used to pass events from (typically) an interrupt handler to
if_link_state_change softint. The queue was protected by KERNEL_LOCK so far,
but if IFEF_MPSAFE is enabled, it becomes unsafe because (perhaps) an interrupt
handler of an interface with IFEF_MPSAFE doesn't take KERNEL_LOCK. Protect it
by a spin mutex.
Additionally with this change KERNEL_LOCK of if_link_state_change softint is
omitted if NET_MPSAFE is enabled.
Note that the spin mutex is now ifp->if_snd.ifq_lock as well as the case of
if_timer (see the comment).
Use IFADDR_WRITER_FOREACH instead of IFADDR_READER_FOREACH
At that point no other one modifies the list so IFADDR_READER_FOREACH
is unnecessary. Use of IFADDR_READER_FOREACH is harmless in general though,
if we try to detect contract violations of pserialize, using it violates
the contract. So avoid using it makes life easy.
Ensure to call if_addr_init with holding if_ioctl_lock
Get rid of outdated comments
Fix build of kernels without ether
By throwing out if_enable_vlan_mtu and if_disable_vlan_mtu that
created a unnecessary dependency from if.c to if_ethersubr.c.
PR kern/52790
Rename IFNET_LOCK to IFNET_GLOBAL_LOCK
IFNET_LOCK will be used in another lock, if_ioctl_lock (might be renamed then).
Wrap if_ioctl_lock with IFNET_* macros (NFC)
Also if_ioctl_lock perhaps needs to be renamed to something because it's now
not just for ioctl...
Reorder some destruction routines in if_detach
- Destroy if_ioctl_lock at the end of the if_detach because it's used in various
  destruction routines
- Move psref_target_destroy after pr_purgeif because we want to use psref in
  pr_purgeif (otherwise destruction procedures can be tricky)
Ensure to call if_mcast_op with holding IFNET_LOCK
Note that CARP doesn't deal with IFNET_LOCK yet.
Remove IFNET_GLOBAL_LOCK where it's unnecessary because IFNET_LOCK is held
Describe which lock is used to protect each member variable of struct ifnet
Requested by skrll@
Write a guideline for converting an interface to IFEF_MPSAFE
Requested by skrll@
Note that IFNET_LOCK must not be held in softint
Don't set IFEF_MPSAFE unless NET_MPSAFE at this point
Because recent investigations show that interfaces with IFEF_MPSAFE need to
follow additional restrictions to work with the flag safely. We should enable it
on an interface by default only if the interface surely satisfies the
restrictions, which are described in if.h.
Note that enabling IFEF_MPSAFE solely gains a few benefit on performance because
the network stack is still serialized by the big kernel locks by default.

diffstat:

 sys/arch/arm/sunxi/sunxi_emac.c                 |    6 +-
 sys/dev/ic/dwc_gmac.c                           |   10 +-
 sys/dev/pci/if_iwm.c                            |    6 +-
 sys/dev/pci/if_wm.c                             |   10 +-
 sys/dev/pci/ixgbe/ixgbe.c                       |    4 +-
 sys/dev/pci/ixgbe/ixv.c                         |    4 +-
 sys/kern/sys_socket.c                           |   12 +-
 sys/net/agr/if_agr.c                            |    8 +-
 sys/net/bpf.c                                   |   28 +-
 sys/net/if.c                                    |  278 ++++++++++++++++-----
 sys/net/if.h                                    |  301 ++++++++++++++++-------
 sys/net/if_bridge.c                             |   30 +-
 sys/net/if_etherip.c                            |   10 +-
 sys/net/if_ethersubr.c                          |   18 +-
 sys/net/if_faith.c                              |    6 +-
 sys/net/if_gif.c                                |    6 +-
 sys/net/if_l2tp.c                               |   11 +-
 sys/net/if_loop.c                               |   22 +-
 sys/net/if_media.c                              |   24 +-
 sys/net/if_pppoe.c                              |   15 +-
 sys/net/if_spppsubr.c                           |   16 +-
 sys/net/if_tun.c                                |    7 +-
 sys/net/if_vlan.c                               |   79 +++++-
 sys/net/npf/npf_ifaddr.c                        |    8 +-
 sys/net/npf/npf_os.c                            |   28 +-
 sys/net/rtsock.c                                |   14 +-
 sys/netcan/if_canloop.c                         |   13 +-
 sys/netinet/if_arp.c                            |   25 +-
 sys/netinet/igmp.c                              |   12 +-
 sys/netinet/in.c                                |   15 +-
 sys/netinet/in_pcb.c                            |    7 +-
 sys/netinet/ip_carp.c                           |   11 +-
 sys/netinet/ip_flow.c                           |   42 +--
 sys/netinet/ip_input.c                          |   22 +-
 sys/netinet/ip_mroute.c                         |   10 +-
 sys/netinet/ip_output.c                         |   34 +-
 sys/netinet6/frag6.c                            |   24 +-
 sys/netinet6/in6.c                              |   27 +-
 sys/netinet6/in6_pcb.c                          |   11 +-
 sys/netinet6/ip6_flow.c                         |   42 +--
 sys/netinet6/ip6_input.c                        |   12 +-
 sys/netinet6/ip6_output.c                       |   21 +-
 sys/netinet6/mld6.c                             |   16 +-
 sys/netinet6/nd6.c                              |   99 +++++--
 sys/netinet6/nd6_nbr.c                          |   14 +-
 sys/netinet6/nd6_rtr.c                          |    6 +-
 sys/netipsec/ipsec_output.c                     |   12 +-
 sys/rump/net/lib/libnetinet/netinet_component.c |    6 +-
 48 files changed, 862 insertions(+), 580 deletions(-)

diffs (truncated from 3687 to 300 lines):

diff -r 651535ae9d36 -r efbd00b00964 sys/arch/arm/sunxi/sunxi_emac.c
--- a/sys/arch/arm/sunxi/sunxi_emac.c   Mon Jan 01 19:11:07 2018 +0000
+++ b/sys/arch/arm/sunxi/sunxi_emac.c   Tue Jan 02 10:20:32 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_emac.c,v 1.4.4.3 2017/09/11 05:24:16 snj Exp $ */
+/* $NetBSD: sunxi_emac.c,v 1.4.4.4 2018/01/02 10:20:32 snj Exp $ */
 
 /*-
  * Copyright (c) 2016-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -33,7 +33,7 @@
 #include "opt_net_mpsafe.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_emac.c,v 1.4.4.3 2017/09/11 05:24:16 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_emac.c,v 1.4.4.4 2018/01/02 10:20:32 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -1368,7 +1368,7 @@
        snprintf(ifp->if_xname, IFNAMSIZ, EMAC_IFNAME, device_unit(self));
        ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 #ifdef EMAC_MPSAFE
-       ifp->if_extflags = IFEF_START_MPSAFE;
+       ifp->if_extflags = IFEF_MPSAFE;
 #endif
        ifp->if_start = sunxi_emac_start;
        ifp->if_ioctl = sunxi_emac_ioctl;
diff -r 651535ae9d36 -r efbd00b00964 sys/dev/ic/dwc_gmac.c
--- a/sys/dev/ic/dwc_gmac.c     Mon Jan 01 19:11:07 2018 +0000
+++ b/sys/dev/ic/dwc_gmac.c     Tue Jan 02 10:20:32 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.40.6.1 2017/12/10 10:10:23 snj Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.40.6.2 2018/01/02 10:20:32 snj Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.40.6.1 2017/12/10 10:10:23 snj Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.40.6.2 2018/01/02 10:20:32 snj Exp $");
 
 /* #define     DWC_GMAC_DEBUG  1 */
 
@@ -223,7 +223,9 @@
        ifp->if_softc = sc;
        strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
        ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
-       ifp->if_extflags = IFEF_START_MPSAFE;
+#ifdef DWCGMAC_MPSAFE
+       ifp->if_extflags = IFEF_MPSAFE;
+#endif
        ifp->if_ioctl = dwc_gmac_ioctl;
        ifp->if_start = dwc_gmac_start;
        ifp->if_init = dwc_gmac_init;
@@ -836,7 +838,7 @@
 dwc_gmac_start(struct ifnet *ifp)
 {
        struct dwc_gmac_softc *sc = ifp->if_softc;
-       KASSERT(ifp->if_extflags & IFEF_START_MPSAFE);
+       KASSERT(if_is_mpsafe(ifp));
 
        mutex_enter(sc->sc_lock);
        if (!sc->sc_stopping) {
diff -r 651535ae9d36 -r efbd00b00964 sys/dev/pci/if_iwm.c
--- a/sys/dev/pci/if_iwm.c      Mon Jan 01 19:11:07 2018 +0000
+++ b/sys/dev/pci/if_iwm.c      Tue Jan 02 10:20:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_iwm.c,v 1.73.2.2 2017/12/10 10:10:24 snj Exp $      */
+/*     $NetBSD: if_iwm.c,v 1.73.2.3 2018/01/02 10:20:33 snj Exp $      */
 /*     OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp  */
 #define IEEE80211_NO_HT
 /*
@@ -106,7 +106,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.73.2.2 2017/12/10 10:10:24 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.73.2.3 2018/01/02 10:20:33 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -6321,7 +6321,7 @@
        int arg = iwmns->ns_arg;
        int s;
 
-       kmem_free(iwmns, sizeof(*iwmns));
+       kmem_intr_free(iwmns, sizeof(*iwmns));
 
        s = splnet();
 
diff -r 651535ae9d36 -r efbd00b00964 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Mon Jan 01 19:11:07 2018 +0000
+++ b/sys/dev/pci/if_wm.c       Tue Jan 02 10:20:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.508.4.10 2017/12/10 10:16:09 snj Exp $     */
+/*     $NetBSD: if_wm.c,v 1.508.4.11 2018/01/02 10:20:33 snj Exp $     */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -83,7 +83,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.10 2017/12/10 10:16:09 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.508.4.11 2018/01/02 10:20:33 snj Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -2636,7 +2636,7 @@
        ifp->if_softc = sc;
        ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 #ifdef WM_MPSAFE
-       ifp->if_extflags = IFEF_START_MPSAFE;
+       ifp->if_extflags = IFEF_MPSAFE;
 #endif
        ifp->if_ioctl = wm_ioctl;
        if ((sc->sc_flags & WM_F_NEWQUEUE) != 0) {
@@ -7001,7 +7001,7 @@
        struct wm_txqueue *txq = &sc->sc_queue[0].wmq_txq;
 
 #ifdef WM_MPSAFE
-       KASSERT(ifp->if_extflags & IFEF_START_MPSAFE);
+       KASSERT(if_is_mpsafe(ifp));
 #endif
        /*
         * ifp->if_obytes and ifp->if_omcasts are added in if_transmit()@if.c.
@@ -7594,7 +7594,7 @@
        struct wm_txqueue *txq = &sc->sc_queue[0].wmq_txq;
 
 #ifdef WM_MPSAFE
-       KASSERT(ifp->if_extflags & IFEF_START_MPSAFE);
+       KASSERT(if_is_mpsafe(ifp));
 #endif
        /*
         * ifp->if_obytes and ifp->if_omcasts are added in if_transmit()@if.c.
diff -r 651535ae9d36 -r efbd00b00964 sys/dev/pci/ixgbe/ixgbe.c
--- a/sys/dev/pci/ixgbe/ixgbe.c Mon Jan 01 19:11:07 2018 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.c Tue Jan 02 10:20:32 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.88.2.6 2017/12/21 19:28:54 snj Exp $ */
+/* $NetBSD: ixgbe.c,v 1.88.2.7 2018/01/02 10:20:33 snj Exp $ */
 
 /******************************************************************************
 
@@ -1219,7 +1219,7 @@
        ifp->if_softc = adapter;
        ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 #ifdef IXGBE_MPSAFE
-       ifp->if_extflags = IFEF_START_MPSAFE;
+       ifp->if_extflags = IFEF_MPSAFE;
 #endif
        ifp->if_ioctl = ixgbe_ioctl;
 #if __FreeBSD_version >= 1100045
diff -r 651535ae9d36 -r efbd00b00964 sys/dev/pci/ixgbe/ixv.c
--- a/sys/dev/pci/ixgbe/ixv.c   Mon Jan 01 19:11:07 2018 +0000
+++ b/sys/dev/pci/ixgbe/ixv.c   Tue Jan 02 10:20:32 2018 +0000
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.56.2.3 2017/12/21 19:28:54 snj Exp $*/
+/*$NetBSD: ixv.c,v 1.56.2.4 2018/01/02 10:20:33 snj Exp $*/
 
 /******************************************************************************
 
@@ -1398,7 +1398,7 @@
        ifp->if_softc = adapter;
        ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 #ifdef IXGBE_MPSAFE
-       ifp->if_extflags = IFEF_START_MPSAFE;
+       ifp->if_extflags = IFEF_MPSAFE;
 #endif
        ifp->if_ioctl = ixv_ioctl;
        if (adapter->feat_en & IXGBE_FEATURE_LEGACY_TX) {
diff -r 651535ae9d36 -r efbd00b00964 sys/kern/sys_socket.c
--- a/sys/kern/sys_socket.c     Mon Jan 01 19:11:07 2018 +0000
+++ b/sys/kern/sys_socket.c     Tue Jan 02 10:20:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_socket.c,v 1.74 2016/07/07 06:55:43 msaitoh Exp $  */
+/*     $NetBSD: sys_socket.c,v 1.74.10.1 2018/01/02 10:20:33 snj Exp $ */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.74 2016/07/07 06:55:43 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_socket.c,v 1.74.10.1 2018/01/02 10:20:33 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -197,14 +197,18 @@
                 * interface and routing ioctls should have a
                 * different entry since a socket's unnecessary
                 */
-               KERNEL_LOCK(1, NULL);
                if (IOCGROUP(cmd) == 'i')
+                       /*
+                        * KERNEL_LOCK will be held later if if_ioctl() of the
+                        * interface isn't MP-safe.
+                        */
                        error = ifioctl(so, cmd, data, curlwp);
                else {
+                       KERNEL_LOCK(1, NULL);
                        error = (*so->so_proto->pr_usrreqs->pr_ioctl)(so,
                            cmd, data, NULL);
+                       KERNEL_UNLOCK_ONE(NULL);
                }
-               KERNEL_UNLOCK_ONE(NULL);
                break;
        }
 
diff -r 651535ae9d36 -r efbd00b00964 sys/net/agr/if_agr.c
--- a/sys/net/agr/if_agr.c      Mon Jan 01 19:11:07 2018 +0000
+++ b/sys/net/agr/if_agr.c      Tue Jan 02 10:20:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_agr.c,v 1.41 2017/01/28 22:56:09 maya Exp $ */
+/*     $NetBSD: if_agr.c,v 1.41.6.1 2018/01/02 10:20:33 snj Exp $      */
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.41 2017/01/28 22:56:09 maya Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.41.6.1 2018/01/02 10:20:33 snj Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -703,8 +703,6 @@
                goto cleanup;
        }
 
-       ifp->if_flags |= IFF_RUNNING;
-
        agrport_config_promisc(port, (ifp->if_flags & IFF_PROMISC) != 0);
        error = (*sc->sc_iftop->iftop_configmulti_port)(sc, port, true);
        if (error) {
@@ -719,6 +717,8 @@
        if (error && port) {
                free(port, M_DEVBUF);
        }
+       if (error == 0)
+               ifp->if_flags |= IFF_RUNNING;
        return error;
 
 cleanup:
diff -r 651535ae9d36 -r efbd00b00964 sys/net/bpf.c
--- a/sys/net/bpf.c     Mon Jan 01 19:11:07 2018 +0000
+++ b/sys/net/bpf.c     Tue Jan 02 10:20:32 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bpf.c,v 1.216.6.3 2017/12/21 21:51:37 snj Exp $        */
+/*     $NetBSD: bpf.c,v 1.216.6.4 2018/01/02 10:20:33 snj Exp $        */
 
 /*
  * Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.216.6.3 2017/12/21 21:51:37 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.216.6.4 2018/01/02 10:20:33 snj Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_bpf.h"
@@ -484,13 +484,9 @@
                 * the interface was configured down, so only panic
                 * if we don't get an unexpected error.
                 */
-#ifndef NET_MPSAFE
-               KERNEL_LOCK(1, NULL);
-#endif
+               KERNEL_LOCK_UNLESS_NET_MPSAFE();
                error = ifpromisc(bp->bif_ifp, 0);
-#ifndef NET_MPSAFE
-               KERNEL_UNLOCK_ONE(NULL);
-#endif
+               KERNEL_UNLOCK_UNLESS_NET_MPSAFE();
 #ifdef DIAGNOSTIC
                if (error)
                        printf("%s: ifpromisc failed: %d", __func__, error);
@@ -1025,13 +1021,9 @@
                        break;
                }
                if (d->bd_promisc == 0) {
-#ifndef NET_MPSAFE
-                       KERNEL_LOCK(1, NULL);
-#endif
+                       KERNEL_LOCK_UNLESS_NET_MPSAFE();
                        error = ifpromisc(d->bd_bif->bif_ifp, 1);
-#ifndef NET_MPSAFE
-                       KERNEL_UNLOCK_ONE(NULL);
-#endif
+                       KERNEL_UNLOCK_UNLESS_NET_MPSAFE();
                        if (error == 0)
                                d->bd_promisc = 1;
                }
@@ -2250,13 +2242,9 @@
        bpf_attachd(d, bp);



Home | Main Index | Thread Index | Old Index