From owner-p4-projects@FreeBSD.ORG Wed Aug 17 12:01:07 2011 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0D2E61065672; Wed, 17 Aug 2011 12:01:07 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C568F106566C for ; Wed, 17 Aug 2011 12:01:06 +0000 (UTC) (envelope-from cnicutar@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:4f8:fff6::2d]) by mx1.freebsd.org (Postfix) with ESMTP id AB45D8FC0A for ; Wed, 17 Aug 2011 12:01:06 +0000 (UTC) Received: from skunkworks.freebsd.org (localhost [127.0.0.1]) by skunkworks.freebsd.org (8.14.4/8.14.4) with ESMTP id p7HC16XS050276 for ; Wed, 17 Aug 2011 12:01:06 GMT (envelope-from cnicutar@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.4/8.14.4/Submit) id p7HC160f050273 for perforce@freebsd.org; Wed, 17 Aug 2011 12:01:06 GMT (envelope-from cnicutar@freebsd.org) Date: Wed, 17 Aug 2011 12:01:06 GMT Message-Id: <201108171201.p7HC160f050273@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to cnicutar@freebsd.org using -f From: Catalin Nicutar To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 197768 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2011 12:01:07 -0000 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);