Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys make gif(4) and ip_encap MP-ify
details: https://anonhg.NetBSD.org/src/rev/6b469ba608f7
branches: trunk
changeset: 346267:6b469ba608f7
user: knakahara <knakahara%NetBSD.org@localhost>
date: Mon Jul 04 04:40:13 2016 +0000
description:
make gif(4) and ip_encap MP-ify
diffstat:
sys/net/if_gif.c | 61 +++++++++++++++++++++++++++++++++++++++----------
sys/netinet/ip_encap.c | 24 +++++++++++++++++--
2 files changed, 69 insertions(+), 16 deletions(-)
diffs (truncated from 305 to 300 lines):
diff -r 27291b929a62 -r 6b469ba608f7 sys/net/if_gif.c
--- a/sys/net/if_gif.c Mon Jul 04 04:38:14 2016 +0000
+++ b/sys/net/if_gif.c Mon Jul 04 04:40:13 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gif.c,v 1.117 2016/07/04 04:35:09 knakahara Exp $ */
+/* $NetBSD: if_gif.c,v 1.118 2016/07/04 04:40:13 knakahara Exp $ */
/* $KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $ */
/*
@@ -31,10 +31,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.117 2016/07/04 04:35:09 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.118 2016/07/04 04:40:13 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
+#include "opt_net_mpsafe.h"
#endif
#include <sys/param.h>
@@ -86,6 +87,10 @@
#include "ioconf.h"
+#ifdef NET_MPSAFE
+#define GIF_MPSAFE 1
+#endif
+
/*
* gif global variable definitions
*/
@@ -322,7 +327,9 @@
{
struct gif_softc *sc = ifp->if_softc;
int error = 0;
+#ifndef GIF_MPSAFE
int s;
+#endif
IFQ_CLASSIFY(&ifp->if_snd, m, dst->sa_family);
@@ -353,13 +360,19 @@
m->m_pkthdr.csum_flags = 0;
m->m_pkthdr.csum_data = 0;
+#ifndef GIF_MPSAFE
s = splnet();
+#endif
IFQ_ENQUEUE(&ifp->if_snd, m, error);
if (error) {
+#ifndef GIF_MPSAFE
splx(s);
+#endif
goto end;
}
+#ifndef GIF_MPSAFE
splx(s);
+#endif
gif_start(ifp);
@@ -378,16 +391,22 @@
struct mbuf *m;
int family;
int len;
+#ifndef GIF_MPSAFE
int s;
+#endif
int error;
sc = ifp->if_softc;
/* output processing */
while (1) {
+#ifndef GIF_MPSAFE
s = splnet();
+#endif
IFQ_DEQUEUE(&sc->gif_if.if_snd, m);
+#ifndef GIF_MPSAFE
splx(s);
+#endif
if (m == NULL)
break;
@@ -446,7 +465,9 @@
{
pktqueue_t *pktq;
size_t pktlen;
+#ifndef GIF_MPSAFE
int s;
+#endif
if (ifp == NULL) {
/* just in case */
@@ -481,14 +502,18 @@
return;
}
+#ifndef GIF_MPSAFE
s = splnet();
+#endif
if (__predict_true(pktq_enqueue(pktq, m, 0))) {
ifp->if_ibytes += pktlen;
ifp->if_ipackets++;
} else {
m_freem(m);
}
+#ifndef GIF_MPSAFE
splx(s);
+#endif
}
/* XXX how should we handle IPv6 scope on SIOC[GS]IFPHYADDR? */
@@ -825,13 +850,17 @@
struct gif_softc *sc2;
struct sockaddr *osrc, *odst;
struct sockaddr *nsrc, *ndst;
+ int error;
+#ifndef GIF_MPSAFE
int s;
- int error;
s = splsoftnet();
+#endif
error = encap_lock_enter();
if (error) {
+#ifndef GIF_MPSAFE
splx(s);
+#endif
return error;
}
@@ -844,24 +873,21 @@
if (sockaddr_cmp(sc2->gif_pdst, dst) == 0 &&
sockaddr_cmp(sc2->gif_psrc, src) == 0) {
/* continue to use the old configureation. */
- encap_lock_exit();
- splx(s);
- return EADDRNOTAVAIL;
+ error = EADDRNOTAVAIL;
+ goto out;
}
/* XXX both end must be valid? (I mean, not 0.0.0.0) */
}
if ((nsrc = sockaddr_dup(src, M_WAITOK)) == NULL) {
- encap_lock_exit();
- splx(s);
- return ENOMEM;
+ error = ENOMEM;
+ goto out;
}
if ((ndst = sockaddr_dup(dst, M_WAITOK)) == NULL) {
sockaddr_free(nsrc);
- encap_lock_exit();
- splx(s);
- return ENOMEM;
+ error = ENOMEM;
+ goto out;
}
gif_encap_pause(sc);
@@ -910,8 +936,11 @@
else
ifp->if_flags &= ~IFF_RUNNING;
+ out:
encap_lock_exit();
+#ifndef GIF_MPSAFE
splx(s);
+#endif
return error;
}
@@ -919,13 +948,17 @@
gif_delete_tunnel(struct ifnet *ifp)
{
struct gif_softc *sc = ifp->if_softc;
+ int error;
+#ifndef GIF_MPSAFE
int s;
- int error;
s = splsoftnet();
+#endif
error = encap_lock_enter();
if (error) {
+#ifndef GIF_MPSAFE
splx(s);
+#endif
return;
}
@@ -952,5 +985,7 @@
ifp->if_flags &= ~IFF_RUNNING;
encap_lock_exit();
+#ifndef GIF_MPSAFE
splx(s);
+#endif
}
diff -r 27291b929a62 -r 6b469ba608f7 sys/netinet/ip_encap.c
--- a/sys/netinet/ip_encap.c Mon Jul 04 04:38:14 2016 +0000
+++ b/sys/netinet/ip_encap.c Mon Jul 04 04:40:13 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_encap.c,v 1.60 2016/07/04 04:38:14 knakahara Exp $ */
+/* $NetBSD: ip_encap.c,v 1.61 2016/07/04 04:40:13 knakahara Exp $ */
/* $KAME: ip_encap.c,v 1.73 2001/10/02 08:30:58 itojun Exp $ */
/*
@@ -68,11 +68,12 @@
#define USE_RADIX
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.60 2016/07/04 04:38:14 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.61 2016/07/04 04:40:13 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_mrouting.h"
#include "opt_inet.h"
+#include "opt_net_mpsafe.h"
#endif
#include <sys/param.h>
@@ -110,6 +111,10 @@
#include <net/net_osdep.h>
+#ifdef NET_MPSAFE
+#define ENCAP_MPSAFE 1
+#endif
+
enum direction { INBOUND, OUTBOUND };
#ifdef INET
@@ -648,14 +653,17 @@
{
struct encaptab *ep;
int error;
- int s, pss;
+ int pss;
size_t l;
struct ip_pack4 *pack4;
#ifdef INET6
struct ip_pack6 *pack6;
#endif
+#ifndef ENCAP_MPSAFE
+ int s;
s = splsoftnet();
+#endif
/* sanity check on args */
error = encap_afcheck(af, sp, dp);
if (error)
@@ -761,7 +769,9 @@
goto gc;
error = 0;
+#ifndef ENCAP_MPSAFE
splx(s);
+#endif
return ep;
gc:
@@ -772,7 +782,9 @@
if (ep)
kmem_free(ep, sizeof(*ep));
fail:
+#ifndef ENCAP_MPSAFE
splx(s);
+#endif
return NULL;
}
@@ -783,9 +795,11 @@
{
struct encaptab *ep;
int error;
+#ifndef ENCAP_MPSAFE
int s;
s = splsoftnet();
+#endif
/* sanity check on args */
if (!func) {
error = EINVAL;
@@ -815,11 +829,15 @@
goto fail;
error = 0;
+#ifndef ENCAP_MPSAFE
splx(s);
+#endif
return ep;
fail:
+#ifndef ENCAP_MPSAFE
Home |
Main Index |
Thread Index |
Old Index