From owner-svn-src-all@freebsd.org Wed Jul 6 16:17:15 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6CD0EB75C7F; Wed, 6 Jul 2016 16:17:15 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1CE6A194D; Wed, 6 Jul 2016 16:17:15 +0000 (UTC) (envelope-from jtl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u66GHErQ086717; Wed, 6 Jul 2016 16:17:14 GMT (envelope-from jtl@FreeBSD.org) Received: (from jtl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u66GHEsY086712; Wed, 6 Jul 2016 16:17:14 GMT (envelope-from jtl@FreeBSD.org) Message-Id: <201607061617.u66GHEsY086712@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jtl set sender to jtl@FreeBSD.org using -f From: "Jonathan T. Looney" Date: Wed, 6 Jul 2016 16:17:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302374 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jul 2016 16:17:15 -0000 Author: jtl Date: Wed Jul 6 16:17:13 2016 New Revision: 302374 URL: https://svnweb.freebsd.org/changeset/base/302374 Log: The TCPPCAP debugging feature caches recently-used mbufs for use in debugging TCP connections. This commit provides a mechanism to free those mbufs when the system is under memory pressure. Because this will result in lost debugging information, the behavior is controllable by a sysctl. The default setting is to free the mbufs. Reviewed by: gnn Approved by: re (gjb) Differential Revision: https://reviews.freebsd.org/D6931 Input from: novice_techie.com Modified: head/sys/netinet/tcp_pcap.c head/sys/netinet/tcp_pcap.h head/sys/netinet/tcp_subr.c Modified: head/sys/netinet/tcp_pcap.c ============================================================================== --- head/sys/netinet/tcp_pcap.c Wed Jul 6 16:02:15 2016 (r302373) +++ head/sys/netinet/tcp_pcap.c Wed Jul 6 16:17:13 2016 (r302374) @@ -42,9 +42,13 @@ #define M_LEADINGSPACE_NOWRITE(m) \ ((m)->m_data - M_START(m)) +int tcp_pcap_aggressive_free = 1; static int tcp_pcap_clusters_referenced_cur = 0; static int tcp_pcap_clusters_referenced_max = 0; +SYSCTL_INT(_net_inet_tcp, OID_AUTO, tcp_pcap_aggressive_free, + CTLFLAG_RW, &tcp_pcap_aggressive_free, 0, + "Free saved packets when the memory system comes under pressure"); SYSCTL_INT(_net_inet_tcp, OID_AUTO, tcp_pcap_clusters_referenced_cur, CTLFLAG_RD, &tcp_pcap_clusters_referenced_cur, 0, "Number of clusters currently referenced on TCP PCAP queues"); Modified: head/sys/netinet/tcp_pcap.h ============================================================================== --- head/sys/netinet/tcp_pcap.h Wed Jul 6 16:02:15 2016 (r302373) +++ head/sys/netinet/tcp_pcap.h Wed Jul 6 16:17:13 2016 (r302374) @@ -36,4 +36,6 @@ void tcp_pcap_tcpcb_init(struct tcpcb *t void tcp_pcap_set_sock_max(struct mbufq *queue, int newval); int tcp_pcap_get_sock_max(struct mbufq *queue); +extern int tcp_pcap_aggressive_free; + #endif /* _NETINET_TCP_PCAP_H_ */ Modified: head/sys/netinet/tcp_subr.c ============================================================================== --- head/sys/netinet/tcp_subr.c Wed Jul 6 16:02:15 2016 (r302373) +++ head/sys/netinet/tcp_subr.c Wed Jul 6 16:17:13 2016 (r302374) @@ -1605,6 +1605,13 @@ tcp_drain(void) if ((tcpb = intotcpcb(inpb)) != NULL) { tcp_reass_flush(tcpb); tcp_clean_sackreport(tcpb); +#ifdef TCPPCAP + if (tcp_pcap_aggressive_free) { + /* Free the TCP PCAP queues. */ + tcp_pcap_drain(&(tcpb->t_inpkts)); + tcp_pcap_drain(&(tcpb->t_outpkts)); + } +#endif } INP_WUNLOCK(inpb); }