From owner-svn-src-head@freebsd.org Sun Dec 31 10:01:33 2017 Return-Path: Delivered-To: svn-src-head@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 2B52BEAE061; Sun, 31 Dec 2017 10:01:33 +0000 (UTC) (envelope-from kp@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 CD99F6C96F; Sun, 31 Dec 2017 10:01:32 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBVA1V7B060731; Sun, 31 Dec 2017 10:01:31 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBVA1V2c060728; Sun, 31 Dec 2017 10:01:31 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201712311001.vBVA1V2c060728@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sun, 31 Dec 2017 10:01:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327433 - in head/sys: net netpfil/pf X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: in head/sys: net netpfil/pf X-SVN-Commit-Revision: 327433 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Dec 2017 10:01:33 -0000 Author: kp Date: Sun Dec 31 10:01:31 2017 New Revision: 327433 URL: https://svnweb.freebsd.org/changeset/base/327433 Log: pf: Clean all fragments on shutdown When pf is unloaded, or a vnet jail using pf is stopped we need to ensure we clean up all fragments, not just the expired ones. Modified: head/sys/net/pfvar.h head/sys/netpfil/pf/pf.c head/sys/netpfil/pf/pf_norm.c Modified: head/sys/net/pfvar.h ============================================================================== --- head/sys/net/pfvar.h Sun Dec 31 09:24:41 2017 (r327432) +++ head/sys/net/pfvar.h Sun Dec 31 10:01:31 2017 (r327433) @@ -1619,6 +1619,7 @@ int pf_normalize_tcp_stateful(struct mbuf *, int, stru u_int32_t pf_state_expires(const struct pf_state *); void pf_purge_expired_fragments(void); +void pf_purge_fragments(uint32_t); int pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *, int); int pf_socket_lookup(int, struct pf_pdesc *, struct mbuf *); Modified: head/sys/netpfil/pf/pf.c ============================================================================== --- head/sys/netpfil/pf/pf.c Sun Dec 31 09:24:41 2017 (r327432) +++ head/sys/netpfil/pf/pf.c Sun Dec 31 10:01:31 2017 (r327433) @@ -1498,7 +1498,7 @@ pf_unload_vnet_purge(void) * Now purge everything. */ pf_purge_expired_states(0, pf_hashmask); - pf_purge_expired_fragments(); + pf_purge_fragments(UINT_MAX); pf_purge_expired_src_nodes(); /* Modified: head/sys/netpfil/pf/pf_norm.c ============================================================================== --- head/sys/netpfil/pf/pf_norm.c Sun Dec 31 09:24:41 2017 (r327432) +++ head/sys/netpfil/pf/pf_norm.c Sun Dec 31 10:01:31 2017 (r327433) @@ -219,9 +219,16 @@ pf_frag_compare(struct pf_fragment *a, struct pf_fragm void pf_purge_expired_fragments(void) { + u_int32_t expire = time_uptime - + V_pf_default_rule.timeout[PFTM_FRAG]; + + pf_purge_fragments(expire); +} + +void +pf_purge_fragments(uint32_t expire) +{ struct pf_fragment *frag; - u_int32_t expire = time_uptime - - V_pf_default_rule.timeout[PFTM_FRAG]; PF_FRAG_LOCK(); while ((frag = TAILQ_LAST(&V_pf_fragqueue, pf_fragqueue)) != NULL) {