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.
This commit is contained in:
ozaki-r 2017-12-19 03:32:35 +00:00
parent ee9841898b
commit 436bca6c47
7 changed files with 38 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dwc_gmac.c,v 1.43 2017/11/16 03:07:17 ozaki-r Exp $ */
/* $NetBSD: dwc_gmac.c,v 1.44 2017/12/19 03:32:35 ozaki-r 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.43 2017/11/16 03:07:17 ozaki-r Exp $");
__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.44 2017/12/19 03:32:35 ozaki-r Exp $");
/* #define DWC_GMAC_DEBUG 1 */
@ -223,7 +223,9 @@ dwc_gmac_attach(struct dwc_gmac_softc *sc, uint32_t mii_clk)
ifp->if_softc = sc;
strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
#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;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_bridge.c,v 1.145 2017/12/11 03:29:20 ozaki-r Exp $ */
/* $NetBSD: if_bridge.c,v 1.146 2017/12/19 03:32:35 ozaki-r Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.145 2017/12/11 03:29:20 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.146 2017/12/19 03:32:35 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_bridge_ipf.h"
@ -424,7 +424,10 @@ bridge_clone_create(struct if_clone *ifc, int unit)
if_initname(ifp, ifc->ifc_name, unit);
ifp->if_softc = sc;
ifp->if_extflags = IFEF_MPSAFE | IFEF_NO_LINK_STATE_CHANGE;
ifp->if_extflags = IFEF_NO_LINK_STATE_CHANGE;
#ifdef NET_MPSAFE
ifp->if_extflags |= IFEF_MPSAFE;
#endif
ifp->if_mtu = ETHERMTU;
ifp->if_ioctl = bridge_ioctl;
ifp->if_output = bridge_output;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_l2tp.c,v 1.16 2017/12/06 08:23:17 knakahara Exp $ */
/* $NetBSD: if_l2tp.c,v 1.17 2017/12/19 03:32:35 ozaki-r Exp $ */
/*
* Copyright (c) 2017 Internet Initiative Japan Inc.
@ -31,10 +31,11 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.16 2017/12/06 08:23:17 knakahara Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_l2tp.c,v 1.17 2017/12/19 03:32:35 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
#include "opt_net_mpsafe.h"
#endif
#include <sys/param.h>
@ -265,7 +266,10 @@ l2tpattach0(struct l2tp_softc *sc)
sc->l2tp_ec.ec_if.if_addrlen = 0;
sc->l2tp_ec.ec_if.if_mtu = L2TP_MTU;
sc->l2tp_ec.ec_if.if_flags = IFF_POINTOPOINT|IFF_MULTICAST|IFF_SIMPLEX;
sc->l2tp_ec.ec_if.if_extflags = IFEF_MPSAFE | IFEF_NO_LINK_STATE_CHANGE;
sc->l2tp_ec.ec_if.if_extflags = IFEF_NO_LINK_STATE_CHANGE;
#ifdef NET_MPSAFE
sc->l2tp_ec.ec_if.if_extflags |= IFEF_MPSAFE;
#endif
sc->l2tp_ec.ec_if.if_ioctl = l2tp_ioctl;
sc->l2tp_ec.ec_if.if_output = l2tp_output;
sc->l2tp_ec.ec_if.if_type = IFT_L2TP;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_loop.c,v 1.100 2017/12/06 07:40:16 ozaki-r Exp $ */
/* $NetBSD: if_loop.c,v 1.101 2017/12/19 03:32:35 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.100 2017/12/06 07:40:16 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.101 2017/12/19 03:32:35 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -183,7 +183,9 @@ loop_clone_create(struct if_clone *ifc, int unit)
ifp->if_mtu = LOMTU;
ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST;
#ifdef NET_MPSAFE
ifp->if_extflags = IFEF_MPSAFE;
#endif
ifp->if_ioctl = loioctl;
ifp->if_output = looutput;
#ifdef ALTQ

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tap.c,v 1.104 2017/11/30 20:25:55 christos Exp $ */
/* $NetBSD: if_tap.c,v 1.105 2017/12/19 03:32:35 ozaki-r Exp $ */
/*
* Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation.
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.104 2017/11/30 20:25:55 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.105 2017/12/19 03:32:35 ozaki-r Exp $");
#if defined(_KERNEL_OPT)
@ -358,7 +358,10 @@ tap_attach(device_t parent, device_t self, void *aux)
strcpy(ifp->if_xname, device_xname(self));
ifp->if_softc = sc;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_extflags = IFEF_MPSAFE | IFEF_NO_LINK_STATE_CHANGE;
ifp->if_extflags = IFEF_NO_LINK_STATE_CHANGE;
#ifdef NET_MPSAFE
ifp->if_extflags |= IFEF_MPSAFE;
#endif
ifp->if_ioctl = tap_ioctl;
ifp->if_start = tap_start;
ifp->if_stop = tap_stop;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_vlan.c,v 1.120 2017/12/15 04:03:46 ozaki-r Exp $ */
/* $NetBSD: if_vlan.c,v 1.121 2017/12/19 03:32:35 ozaki-r Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@ -78,10 +78,11 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.120 2017/12/15 04:03:46 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.121 2017/12/19 03:32:35 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
#include "opt_net_mpsafe.h"
#endif
#include <sys/param.h>
@ -358,7 +359,10 @@ vlan_clone_create(struct if_clone *ifc, int unit)
if_initname(ifp, ifc->ifc_name, unit);
ifp->if_softc = ifv;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_extflags = IFEF_MPSAFE | IFEF_NO_LINK_STATE_CHANGE;
ifp->if_extflags = IFEF_NO_LINK_STATE_CHANGE;
#ifdef NET_MPSAFE
ifp->if_extflags |= IFEF_MPSAFE;
#endif
ifp->if_start = vlan_start;
ifp->if_transmit = vlan_transmit;
ifp->if_ioctl = vlan_ioctl;

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_canloop.c,v 1.4 2017/12/06 07:40:16 ozaki-r Exp $ */
/* $NetBSD: if_canloop.c,v 1.5 2017/12/19 03:32:35 ozaki-r Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_canloop.c,v 1.4 2017/12/06 07:40:16 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_canloop.c,v 1.5 2017/12/19 03:32:35 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_can.h"
@ -112,7 +112,9 @@ canloop_clone_create(struct if_clone *ifc, int unit)
if_initname(ifp, ifc->ifc_name, unit);
ifp->if_flags = IFF_LOOPBACK;
#ifdef NET_MPSAFE
ifp->if_extflags = IFEF_MPSAFE;
#endif
ifp->if_ioctl = canloop_ioctl;
ifp->if_start = canloop_ifstart;
can_ifattach(ifp);