Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Aug 2011 12:01:06 GMT
From:      Catalin Nicutar <cnicutar@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 197768 for review
Message-ID:  <201108171201.p7HC160f050273@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@197768?ac=10

Change 197768 by cnicutar@cnicutar_cronos on 2011/08/17 12:00:14

	Drop UTO connections from tcp_drain. Turn tcp_drain into a wrapper for
	tcp_drain_internal.

Affected files ...

.. //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_subr.c#4 edit
.. //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_var.h#6 edit

Differences ...

==== //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_subr.c#4 (text+ko) ====

@@ -994,78 +994,62 @@
 	return (tp);
 }
 
+/*
+ * Wrapper function for tcp_drain_internal.
+ */
 void
 tcp_drain(void)
 {
-	VNET_ITERATOR_DECL(vnet_iter);
-
-	if (!do_tcpdrain)
-		return;
-
-	VNET_LIST_RLOCK_NOSLEEP();
-	VNET_FOREACH(vnet_iter) {
-		CURVNET_SET(vnet_iter);
-		struct inpcb *inpb;
-		struct tcpcb *tcpb;
-
-	/*
-	 * Walk the tcpbs, if existing, and flush the reassembly queue,
-	 * if there is one...
-	 * XXX: The "Net/3" implementation doesn't imply that the TCP
-	 *      reassembly queue should be flushed, but in a situation
-	 *	where we're really low on mbufs, this is potentially
-	 *	usefull.
-	 */
-		INP_INFO_RLOCK(&V_tcbinfo);
-		LIST_FOREACH(inpb, V_tcbinfo.ipi_listhead, inp_list) {
-			if (inpb->inp_flags & INP_TIMEWAIT)
-				continue;
-			INP_WLOCK(inpb);
-			if ((tcpb = intotcpcb(inpb)) != NULL) {
-				tcp_reass_flush(tcpb);
-				tcp_clean_sackreport(tcpb);
-			}
-			INP_WUNLOCK(inpb);
-		}
-		INP_INFO_RUNLOCK(&V_tcbinfo);
-		CURVNET_RESTORE();
-	}
-	VNET_LIST_RUNLOCK_NOSLEEP();
+	if (do_tcpdrain)
+		return tcp_drain_internal(TCP_DRAIN_CLASSIC);
 }
 
-/*
- * This function walks the list of TCP connections and attempts to free
- * up space by dropping connections.
- *
- * XXX-CN This should be considered a work in progress. In particular
- * it's not yet clear wether this should be merged with tcp_drain (which
- * also iterates over TCP connections but uses a read lock for tcbinfo).
- *
- * In the future this function could be modified to drop more types of
- * TCP connections.
- */
 void
-tcp_drop_uto(void)
+tcp_drain_internal(u_int flags)
 {
 	VNET_ITERATOR_DECL(vnet_iter);
+
+	if (!flags)
+		return;
+
 	VNET_LIST_RLOCK_NOSLEEP();
 	VNET_FOREACH(vnet_iter) {
 		CURVNET_SET(vnet_iter);
 		struct inpcb *inp;
 		struct tcpcb *tp;
-
-		/*
-		 * Drop connections that wouldn't have survived without
-		 * UTO.
-		 * XXX-CN This negates the advantages of UTO for everyone
-		 * instead of just dropping misbehaving connections.
-		 */
+		
+		/* Walk the connections and try to free up space. */
 		INP_INFO_WLOCK(&V_tcbinfo);
 		LIST_FOREACH(inp, V_tcbinfo.ipi_listhead, inp_list) {
+			if (inp->inp_flags & INP_TIMEWAIT)
+				continue;
 			INP_WLOCK(inp);
-			if ((tp = intotcpcb(inp)) != NULL) {
-				if (tp->t_rxtshift > TCP_MAXRXTSHIFT)
-					tcp_drop(tp, ETIMEDOUT);
+			if ((tp = intotcpcb(inp)) == NULL) {
+				INP_WUNLOCK(inp);
+				continue;
+			}
+
+			/*
+			 * Drop connections that wouldn't have survived without
+			 * UTO.
+			 * XXX-CN This negates the advantages of UTO for
+			 * everyone instead of just dropping misbehaving
+			 * connections.
+			 */
+			if (flags & TCP_DRAIN_UTO &&
+			    tp->t_rxtshift > TCP_MAXRXTSHIFT)
+				tcp_drop(tp, ETIMEDOUT);
+
+			/*
+			 * Flush the reassembly queue, if there is one.
+			 * XXX: The "Net/3" implementation doesn't imply that
+			 * the TCP reassembly queue should be flushed, but in a
+			 * situation where we're really low on mbufs, this is
+			 * potentially usefull.
+			 */
+			if (flags & TCP_DRAIN_CLASSIC) {
+				tcp_reass_flush(tp);
+				tcp_clean_sackreport(tp);
 			}
 			INP_WUNLOCK(inp);
 		}

==== //depot/projects/soc2011/cnicutar_tcputo_9/src/sys/netinet/tcp_var.h#6 (text+ko) ====

@@ -328,6 +328,13 @@
 #define UTO_MINS	0x8000		/* Highest bit set means "minutes". */
 #define UTO_MINS_TH	3600		/* Send minutes if >= one hour. */
 
+/*
+ * Flags for tcp_drain_internal.
+ */
+#define TCP_DRAIN_CLASSIC	0x1	/* Flushes the reassembly queue. */
+#define TCP_DRAIN_UTO		0x2	/* Drops connections outside the
+					   normal resend window. */
+
 struct hc_metrics_lite {	/* must stay in sync with hc_metrics */
 	u_long	rmx_mtu;	/* MTU for this path */
 	u_long	rmx_ssthresh;	/* outbound gateway buffer limit */
@@ -679,7 +686,7 @@
 struct tcpcb *
 	 tcp_drop(struct tcpcb *, int);
 void	 tcp_drain(void);
-void	 tcp_drop_uto(void);
+void	 tcp_drain_internal(u_int flags);
 void	 tcp_init(void);
 #ifdef VIMAGE
 void	 tcp_destroy(void);



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