Don't grab KERNEL_LOCK during if_output when NET_MPSAFE
The change makes L3 MP-safe work easy. At this point we deal with only IP forwarding. No functional change when NET_MPSAFE isn't enabled.
This commit is contained in:
parent
23af7a0ab0
commit
9817ed1a76
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_ethersubr.c,v 1.205 2014/11/28 08:29:00 ozaki-r Exp $ */
|
||||
/* $NetBSD: if_ethersubr.c,v 1.206 2015/04/03 07:55:18 ozaki-r Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -61,7 +61,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.205 2014/11/28 08:29:00 ozaki-r Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.206 2015/04/03 07:55:18 ozaki-r Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_atalk.h"
|
||||
|
@ -70,6 +70,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.205 2014/11/28 08:29:00 ozaki-r E
|
|||
#include "opt_mpls.h"
|
||||
#include "opt_gateway.h"
|
||||
#include "opt_pppoe.h"
|
||||
#include "opt_net_mpsafe.h"
|
||||
#include "vlan.h"
|
||||
#include "pppoe.h"
|
||||
#include "bridge.h"
|
||||
|
@ -214,7 +215,9 @@ ether_output(struct ifnet * const ifp0, struct mbuf * const m0,
|
|||
struct at_ifaddr *aa;
|
||||
#endif /* NETATALK */
|
||||
|
||||
#ifndef NET_MPSAFE
|
||||
KASSERT(KERNEL_LOCKED_P());
|
||||
#endif
|
||||
|
||||
#ifdef MBUFTRACE
|
||||
m_claimm(m, ifp->if_mowner);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_loop.c,v 1.80 2014/06/07 11:00:29 rmind Exp $ */
|
||||
/* $NetBSD: if_loop.c,v 1.81 2015/04/03 07:55:18 ozaki-r Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -65,14 +65,14 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.80 2014/06/07 11:00:29 rmind Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.81 2015/04/03 07:55:18 ozaki-r Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_atalk.h"
|
||||
#include "opt_ipx.h"
|
||||
#include "opt_mbuftrace.h"
|
||||
#include "opt_mpls.h"
|
||||
|
||||
#include "opt_net_mpsafe.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -218,7 +218,9 @@ looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
|
|||
size_t pktlen;
|
||||
|
||||
MCLAIM(m, ifp->if_mowner);
|
||||
#ifndef NET_MPSAFE
|
||||
KASSERT(KERNEL_LOCKED_P());
|
||||
#endif
|
||||
|
||||
if ((m->m_flags & M_PKTHDR) == 0)
|
||||
panic("looutput: no header mbuf");
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ip_output.c,v 1.235 2015/03/31 08:44:43 ozaki-r Exp $ */
|
||||
/* $NetBSD: ip_output.c,v 1.236 2015/04/03 07:55:18 ozaki-r Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -91,11 +91,12 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.235 2015/03/31 08:44:43 ozaki-r Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.236 2015/04/03 07:55:18 ozaki-r Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipsec.h"
|
||||
#include "opt_mrouting.h"
|
||||
#include "opt_net_mpsafe.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kmem.h>
|
||||
|
@ -557,9 +558,13 @@ sendit:
|
|||
if (__predict_true(
|
||||
(m->m_pkthdr.csum_flags & M_CSUM_TSOv4) == 0 ||
|
||||
(ifp->if_capenable & IFCAP_TSOv4) != 0)) {
|
||||
#ifndef NET_MPSAFE
|
||||
KERNEL_LOCK(1, NULL);
|
||||
#endif
|
||||
error = (*ifp->if_output)(ifp, m, sa, rt);
|
||||
#ifndef NET_MPSAFE
|
||||
KERNEL_UNLOCK_ONE(NULL);
|
||||
#endif
|
||||
} else {
|
||||
error = ip_tso_output(ifp, m, sa, rt);
|
||||
}
|
||||
|
@ -627,11 +632,15 @@ sendit:
|
|||
} else {
|
||||
KASSERT((m->m_pkthdr.csum_flags &
|
||||
(M_CSUM_UDPv4 | M_CSUM_TCPv4)) == 0);
|
||||
#ifndef NET_MPSAFE
|
||||
KERNEL_LOCK(1, NULL);
|
||||
#endif
|
||||
error = (*ifp->if_output)(ifp, m,
|
||||
(m->m_flags & M_MCAST) ?
|
||||
sintocsa(rdst) : sintocsa(dst), rt);
|
||||
#ifndef NET_MPSAFE
|
||||
KERNEL_UNLOCK_ONE(NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (error == 0) {
|
||||
|
@ -1722,7 +1731,11 @@ ip_mloopback(struct ifnet *ifp, struct mbuf *m, const struct sockaddr_in *dst)
|
|||
|
||||
ip->ip_sum = 0;
|
||||
ip->ip_sum = in_cksum(copym, ip->ip_hl << 2);
|
||||
#ifndef NET_MPSAFE
|
||||
KERNEL_LOCK(1, NULL);
|
||||
#endif
|
||||
(void)looutput(ifp, copym, sintocsa(dst), NULL);
|
||||
#ifndef NET_MPSAFE
|
||||
KERNEL_UNLOCK_ONE(NULL);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue