Module Name:    src
Committed By:   ozaki-r
Date:           Fri Apr  3 07:55:18 UTC 2015

Modified Files:
        src/sys/net: if_ethersubr.c if_loop.c
        src/sys/netinet: ip_output.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.205 -r1.206 src/sys/net/if_ethersubr.c
cvs rdiff -u -r1.80 -r1.81 src/sys/net/if_loop.c
cvs rdiff -u -r1.235 -r1.236 src/sys/netinet/ip_output.c

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

Modified files:

Index: src/sys/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.205 src/sys/net/if_ethersubr.c:1.206
--- src/sys/net/if_ethersubr.c:1.205	Fri Nov 28 08:29:00 2014
+++ src/sys/net/if_ethersubr.c	Fri Apr  3 07:55:18 2015
@@ -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
 #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 at_ifaddr *aa;
 #endif /* NETATALK */
 
+#ifndef NET_MPSAFE
 	KASSERT(KERNEL_LOCKED_P());
+#endif
 
 #ifdef MBUFTRACE
 	m_claimm(m, ifp->if_mowner);

Index: src/sys/net/if_loop.c
diff -u src/sys/net/if_loop.c:1.80 src/sys/net/if_loop.c:1.81
--- src/sys/net/if_loop.c:1.80	Sat Jun  7 11:00:29 2014
+++ src/sys/net/if_loop.c	Fri Apr  3 07:55:18 2015
@@ -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 
 	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");

Index: src/sys/netinet/ip_output.c
diff -u src/sys/netinet/ip_output.c:1.235 src/sys/netinet/ip_output.c:1.236
--- src/sys/netinet/ip_output.c:1.235	Tue Mar 31 08:44:43 2015
+++ src/sys/netinet/ip_output.c	Fri Apr  3 07:55:18 2015
@@ -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 m
 
 	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
 }

Reply via email to