Module Name:    src
Committed By:   knakahara
Date:           Fri Jun 24 04:38:12 UTC 2016

Modified Files:
        src/sys/net: if_gif.c if_gif.h

Log Message:
eliminate gif(4) Tx softint

- remove gif_si from struct gif_softc
- directly call gifintr() from gif_output()
- rename gifintr() to gif_start()
- remove Tx softint processing from gif_set_tunnel() and gif_delete_tunnel()


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/net/if_gif.c
cvs rdiff -u -r1.23 -r1.24 src/sys/net/if_gif.h

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_gif.c
diff -u src/sys/net/if_gif.c:1.110 src/sys/net/if_gif.c:1.111
--- src/sys/net/if_gif.c:1.110	Fri Jun 10 13:27:16 2016
+++ src/sys/net/if_gif.c	Fri Jun 24 04:38:12 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gif.c,v 1.110 2016/06/10 13:27:16 ozaki-r Exp $	*/
+/*	$NetBSD: if_gif.c,v 1.111 2016/06/24 04:38:12 knakahara Exp $	*/
 /*	$KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.110 2016/06/10 13:27:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.111 2016/06/24 04:38:12 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -85,8 +85,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1
 
 #include "ioconf.h"
 
-static void	gifintr(void *);
-
 /*
  * gif global variable definitions
  */
@@ -95,6 +93,7 @@ static LIST_HEAD(, gif_softc) gif_softc_
 static void	gifattach0(struct gif_softc *);
 static int	gif_output(struct ifnet *, struct mbuf *,
 			   const struct sockaddr *, const struct rtentry *);
+static void	gif_start(struct ifnet *);
 static int	gif_ioctl(struct ifnet *, u_long, void *);
 static int	gif_set_tunnel(struct ifnet *, struct sockaddr *,
 			       struct sockaddr *);
@@ -329,8 +328,7 @@ gif_output(struct ifnet *ifp, struct mbu
 
 	m->m_flags &= ~(M_BCAST|M_MCAST);
 	if (!(ifp->if_flags & IFF_UP) ||
-	    sc->gif_psrc == NULL || sc->gif_pdst == NULL ||
-	    sc->gif_si == NULL) {
+	    sc->gif_psrc == NULL || sc->gif_pdst == NULL) {
 		m_freem(m);
 		error = ENETDOWN;
 		goto end;
@@ -356,11 +354,10 @@ gif_output(struct ifnet *ifp, struct mbu
 		splx(s);
 		goto end;
 	}
-
-	/* softint_schedule() must be called with kpreempt_disabled() */
-	softint_schedule(sc->gif_si);
 	splx(s);
 
+	gif_start(ifp);
+
 	error = 0;
 
   end:
@@ -370,27 +367,16 @@ gif_output(struct ifnet *ifp, struct mbu
 }
 
 static void
-gifintr(void *arg)
+gif_start(struct ifnet *ifp)
 {
 	struct gif_softc *sc;
-	struct ifnet *ifp;
 	struct mbuf *m;
 	int family;
 	int len;
 	int s;
 	int error;
 
-	sc = arg;
-	ifp = &sc->gif_if;
-
-	/*
-	 * other CPUs does {set,delete}_tunnel after curcpu have done
-	 * softint_schedule().
-	 */
-	if (sc->gif_pdst == NULL || sc->gif_psrc == NULL) {
-		IFQ_PURGE(&ifp->if_snd);
-		return;
-	}
+	sc = ifp->if_softc;
 
 	/* output processing */
 	while (1) {
@@ -418,16 +404,21 @@ gifintr(void *arg)
 		switch (sc->gif_psrc->sa_family) {
 #ifdef INET
 		case AF_INET:
-			mutex_enter(softnet_lock);
+			/* XXX
+			 * To add mutex_enter(softnet_lock) or
+			 * KASSERT(mutex_owned(softnet_lock)) here, we shold
+			 * coordinate softnet_lock between in6_if_up() and
+			 * in6_purgeif().
+			 */
 			error = in_gif_output(ifp, family, m);
-			mutex_exit(softnet_lock);
 			break;
 #endif
 #ifdef INET6
 		case AF_INET6:
-			mutex_enter(softnet_lock);
+			/* XXX
+			 * the same as in_gif_output()
+			 */
 			error = in6_gif_output(ifp, family, m);
-			mutex_exit(softnet_lock);
 			break;
 #endif
 		default:
@@ -790,7 +781,6 @@ gif_set_tunnel(struct ifnet *ifp, struct
 	struct gif_softc *sc2;
 	struct sockaddr *osrc, *odst;
 	struct sockaddr *nsrc, *ndst;
-	void *osi;
 	int s;
 	int error;
 
@@ -823,33 +813,6 @@ gif_set_tunnel(struct ifnet *ifp, struct
 	}
 
 	/* Firstly, clear old configurations. */
-	if (sc->gif_si) {
-		osrc = sc->gif_psrc;
-		odst = sc->gif_pdst;
-		osi = sc->gif_si;
-		sc->gif_psrc = NULL;
-		sc->gif_pdst = NULL;
-		sc->gif_si = NULL;
-		/*
-		 * At this point, gif_output() does not softint_schedule()
-		 * any more. However, there are below 2 fears of other CPUs
-		 * which would cause panic because of the race between
-		 * softint_execute() and softint_disestablish().
-		 *     (a) gif_output() has done softint_schedule(), and softint
-		 *         (gifintr()) is waiting for execution
-		 *         => This pattern is avoided by waiting SOFTINT_PENDING
-		 *            CPUs in softint_disestablish()
-		 *     (b) gifintr() is already running
-		 *         => This pattern is avoided by waiting SOFTINT_ACTIVE
-		 *            CPUs in softint_disestablish()
-		 */
-
-		softint_disestablish(osi);
-		sc->gif_psrc = osrc;
-		sc->gif_pdst = odst;
-		osrc = NULL;
-		odst = NULL;
-	}
 	/* XXX we can detach from both, but be polite just in case */
 	if (sc->gif_psrc)
 		(void)gif_encap_detach(sc);
@@ -874,20 +837,6 @@ gif_set_tunnel(struct ifnet *ifp, struct
 
 			continue;
 		}
-
-		sc->gif_si = softint_establish(SOFTINT_NET, gifintr, sc);
-		if (sc->gif_si == NULL) {
-			(void)gif_encap_detach(sc);
-
-			/* rollback to the last configuration. */
-			nsrc = osrc;
-			ndst = odst;
-			osrc = sc->gif_psrc;
-			odst = sc->gif_pdst;
-
-			error = ENOMEM;
-			continue;
-		}
 	} while (error != 0 && (nsrc != NULL && ndst != NULL));
 	/* Thirdly, even rollback failed, clear configurations. */
 	if (error) {
@@ -915,25 +864,10 @@ static void
 gif_delete_tunnel(struct ifnet *ifp)
 {
 	struct gif_softc *sc = ifp->if_softc;
-	struct sockaddr *osrc, *odst;
-	void *osi;
 	int s;
 
 	s = splsoftnet();
 
-	if (sc->gif_si) {
-		osrc = sc->gif_psrc;
-		odst = sc->gif_pdst;
-		osi = sc->gif_si;
-
-		sc->gif_psrc = NULL;
-		sc->gif_pdst = NULL;
-		sc->gif_si = NULL;
-
-		softint_disestablish(osi);
-		sc->gif_psrc = osrc;
-		sc->gif_pdst = odst;
-	}
 	if (sc->gif_psrc) {
 		sockaddr_free(sc->gif_psrc);
 		sc->gif_psrc = NULL;

Index: src/sys/net/if_gif.h
diff -u src/sys/net/if_gif.h:1.23 src/sys/net/if_gif.h:1.24
--- src/sys/net/if_gif.h:1.23	Tue May 31 03:52:40 2016
+++ src/sys/net/if_gif.h	Fri Jun 24 04:38:12 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gif.h,v 1.23 2016/05/31 03:52:40 knakahara Exp $	*/
+/*	$NetBSD: if_gif.h,v 1.24 2016/06/24 04:38:12 knakahara Exp $	*/
 /*	$KAME: if_gif.h,v 1.23 2001/07/27 09:21:42 itojun Exp $	*/
 
 /*
@@ -59,7 +59,6 @@ struct gif_softc {
 	const struct encaptab *encap_cookie4;
 	const struct encaptab *encap_cookie6;
 	LIST_ENTRY(gif_softc) gif_list;	/* list of all gifs */
-	void	*gif_si;		/* softintr handle */
 };
 #define GIF_ROUTE_TTL	10
 

Reply via email to