Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Jan 2009 13:27:56 +0000 (UTC)
From:      Randall Stewart <rrs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r186821 - in head/sys: netinet netinet6
Message-ID:  <200901061327.n06DRuLo032332@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rrs
Date: Tue Jan  6 13:27:56 2009
New Revision: 186821
URL: http://svn.freebsd.org/changeset/base/186821

Log:
  Addresses Roberts comments on comments. Also adds
  the KASSERT and checks suggested.
  
  Reviewed by:	The udp tunneling was discussed on net@ under the
                  thread entitled "Heads up -- Thinking about UDP and tunneling"

Modified:
  head/sys/netinet/udp_usrreq.c
  head/sys/netinet6/udp6_usrreq.c

Modified: head/sys/netinet/udp_usrreq.c
==============================================================================
--- head/sys/netinet/udp_usrreq.c	Tue Jan  6 13:12:26 2009	(r186820)
+++ head/sys/netinet/udp_usrreq.c	Tue Jan  6 13:27:56 2009	(r186821)
@@ -501,13 +501,8 @@ udp_input(struct mbuf *m, int off)
 					 * Engage the tunneling protocol we
 					 * will have to leave the info_lock
 					 * up, since we are hunting through
-					 * multiple UDP inp's hope we don't
-					 * break.
+					 * multiple UDP's.
 					 * 
-					 * XXXML: Maybe add a flag to the
-					 * prototype so that the tunneling
-					 * can defer work that can't be done
-					 * under the info lock?
 					 */
 					udp_tun_func_t tunnel_func;
 
@@ -546,9 +541,7 @@ udp_input(struct mbuf *m, int off)
 			INP_INFO_RUNLOCK(&V_udbinfo);
 		} else {
 			/*
-			 * Engage the tunneling protocol we must make sure
-			 * all locks are released when we call the tunneling
-			 * protocol.
+			 * Engage the tunneling protocol.
 			 */
 			udp_tun_func_t tunnel_func;
 
@@ -602,8 +595,7 @@ udp_input(struct mbuf *m, int off)
 	}
 	if (inp->inp_ppcb != NULL) {
 		/*
-		 * Engage the tunneling protocol we must make sure all locks
-		 * are released when we call the tunneling protocol.
+		 * Engage the tunneling protocol.
 		 */
 		udp_tun_func_t tunnel_func;
 
@@ -1205,6 +1197,8 @@ udp_set_kernel_tunneling(struct socket *
 	struct inpcb *inp;
 
 	inp = (struct inpcb *)so->so_pcb;
+	KASSERT(so->so_type == SOCK_DGRAM, ("udp_set_kernel_tunneling: !dgram"));
+	KASSERT(so->so_pcb != NULL, ("udp_set_kernel_tunneling: NULL inp"));
 	if (so->so_type != SOCK_DGRAM) {
 		/* Not UDP socket... sorry! */
 		return (ENOTSUP);
@@ -1214,6 +1208,10 @@ udp_set_kernel_tunneling(struct socket *
 		return (EINVAL);
 	}
 	INP_WLOCK(inp);
+	if (inp->inp_ppcb != NULL) {
+		INP_WUNLOCK(inp);
+		return (EBUSY);
+	}
 	inp->inp_ppcb = f;
 	INP_WUNLOCK(inp);
 	return (0);

Modified: head/sys/netinet6/udp6_usrreq.c
==============================================================================
--- head/sys/netinet6/udp6_usrreq.c	Tue Jan  6 13:12:26 2009	(r186820)
+++ head/sys/netinet6/udp6_usrreq.c	Tue Jan  6 13:27:56 2009	(r186821)
@@ -293,8 +293,7 @@ udp6_input(struct mbuf **mp, int *offp, 
 						 * protocol we will have to
 						 * leave the info_lock up,
 						 * since we are hunting
-						 * through multiple UDP
-						 * inp's hope we don't break.
+						 * through multiple UDP's.
 						 * 
 						 */
 						udp_tun_func_t tunnel_func;
@@ -336,9 +335,7 @@ udp6_input(struct mbuf **mp, int *offp, 
 		INP_INFO_RUNLOCK(&V_udbinfo);
 		if (last->inp_ppcb != NULL) {
 			/*
-			 * Engage the tunneling protocol we must make sure
-			 * all locks are released when we call the tunneling
-			 * protocol.
+			 * Engage the tunneling protocol.
 			 */
 			udp_tun_func_t tunnel_func;
 
@@ -386,8 +383,7 @@ udp6_input(struct mbuf **mp, int *offp, 
 	INP_INFO_RUNLOCK(&V_udbinfo);
 	if (inp->inp_ppcb != NULL) {
 		/*
-		 * Engage the tunneling protocol we must make sure all locks
-		 * are released when we call the tunneling protocol.
+		 * Engage the tunneling protocol.
 		 */
 		udp_tun_func_t tunnel_func;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901061327.n06DRuLo032332>