From owner-svn-src-stable@FreeBSD.ORG Thu Mar 26 14:20:17 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E31F51065857; Thu, 26 Mar 2009 14:20:16 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CC35F8FC19; Thu, 26 Mar 2009 14:20:16 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2QEKGDw020149; Thu, 26 Mar 2009 14:20:16 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2QEKGrk020147; Thu, 26 Mar 2009 14:20:16 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200903261420.n2QEKGrk020147@svn.freebsd.org> From: Robert Watson Date: Thu, 26 Mar 2009 14:20:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r190442 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb netinet X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2009 14:20:22 -0000 Author: rwatson Date: Thu Mar 26 14:20:16 2009 New Revision: 190442 URL: http://svn.freebsd.org/changeset/base/190442 Log: Merge r189657 from head to stable/7: Add INP_INHASHLIST flag for inpcb->inp_flags to indicate whether or not the inpcb is currenty on various hash lookup lists, rather than using (lport != 0) to detect this. This means that the full 4-tuple of a connection can be retained after close, which should lead to more sensible netstat output in the window between TCP close and socket close. Approved by: re (kib) Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/ath/ath_hal/ (props changed) stable/7/sys/dev/cxgb/ (props changed) stable/7/sys/netinet/in_pcb.c stable/7/sys/netinet/in_pcb.h Modified: stable/7/sys/netinet/in_pcb.c ============================================================================== --- stable/7/sys/netinet/in_pcb.c Thu Mar 26 13:27:26 2009 (r190441) +++ stable/7/sys/netinet/in_pcb.c Thu Mar 26 14:20:16 2009 (r190442) @@ -1,7 +1,7 @@ /*- * Copyright (c) 1982, 1986, 1991, 1993, 1995 * The Regents of the University of California. - * Copyright (c) 2007 Robert N. M. Watson + * Copyright (c) 2007-2009 Robert N. M. Watson * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -955,7 +955,7 @@ in_pcbdrop(struct inpcb *inp) INP_WLOCK_ASSERT(inp); inp->inp_vflag |= INP_DROPPED; - if (inp->inp_lport) { + if (inp->inp_flags & INP_INHASHLIST) { struct inpcbport *phd = inp->inp_phd; LIST_REMOVE(inp, inp_hash); @@ -964,7 +964,7 @@ in_pcbdrop(struct inpcb *inp) LIST_REMOVE(phd, phd_hash); free(phd, M_PCB); } - inp->inp_lport = 0; + inp->inp_flags &= ~INP_INHASHLIST; } } @@ -1344,6 +1344,8 @@ in_pcbinshash(struct inpcb *inp) INP_INFO_WLOCK_ASSERT(pcbinfo); INP_WLOCK_ASSERT(inp); + KASSERT((inp->inp_flags & INP_INHASHLIST) == 0, + ("in_pcbinshash: INP_INHASHLIST")); #ifdef INET6 if (inp->inp_vflag & INP_IPV6) @@ -1380,6 +1382,7 @@ in_pcbinshash(struct inpcb *inp) inp->inp_phd = phd; LIST_INSERT_HEAD(&phd->phd_pcblist, inp, inp_portlist); LIST_INSERT_HEAD(pcbhash, inp, inp_hash); + inp->inp_flags |= INP_INHASHLIST; return (0); } @@ -1398,6 +1401,8 @@ in_pcbrehash(struct inpcb *inp) INP_INFO_WLOCK_ASSERT(pcbinfo); INP_WLOCK_ASSERT(inp); + KASSERT(inp->inp_flags & INP_INHASHLIST, + ("in_pcbrehash: !INP_INHASHLIST")); #ifdef INET6 if (inp->inp_vflag & INP_IPV6) @@ -1425,7 +1430,7 @@ in_pcbremlists(struct inpcb *inp) INP_WLOCK_ASSERT(inp); inp->inp_gencnt = ++pcbinfo->ipi_gencnt; - if (inp->inp_lport) { + if (inp->inp_flags & INP_INHASHLIST) { struct inpcbport *phd = inp->inp_phd; LIST_REMOVE(inp, inp_hash); @@ -1434,6 +1439,7 @@ in_pcbremlists(struct inpcb *inp) LIST_REMOVE(phd, phd_hash); free(phd, M_PCB); } + inp->inp_flags &= ~INP_INHASHLIST; } LIST_REMOVE(inp, inp_list); pcbinfo->ipi_count--; Modified: stable/7/sys/netinet/in_pcb.h ============================================================================== --- stable/7/sys/netinet/in_pcb.h Thu Mar 26 13:27:26 2009 (r190441) +++ stable/7/sys/netinet/in_pcb.h Thu Mar 26 14:20:16 2009 (r190442) @@ -436,6 +436,7 @@ void inp_4tuple_get(struct inpcb *inp, #define INP_FAITH 0x200 /* accept FAITH'ed connections */ #define INP_RECVTTL 0x400 /* receive incoming IP TTL */ #define INP_DONTFRAG 0x800 /* don't fragment packet */ +#define INP_INHASHLIST 0x2000 /* in_pcbinshash() has been called */ #define IN6P_IPV6_V6ONLY 0x008000 /* restrict AF_INET6 socket for v6 */