From nobody Sat Sep 28 19:23:35 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XGHLb3Mrtz5Xkvn; Sat, 28 Sep 2024 19:23:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XGHLb2WcMz53WC; Sat, 28 Sep 2024 19:23:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727551415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZSgmzBjFUX1WMcLt8twPvyzABopP5t/I0cPzb3G5kUg=; b=nmRjo0RAFqPiSWsVxSyHqrzLZ1v3cyk60xcawSU6HVupyISeEat/CgL76HQ/IEldm4Hsho 8Ku0/NTzbokqFjMKrdwH9nS2BlPvW9VaV/Uif1UwKEnjSkbTFpz7ZjQqUt/Dsr+yVH+IsB cUefHY3ctb4Ttwf/X6V+zfU65YraayGLuVSrm9d4TxItKQwH+yb0uVFwrW+3tG6xMOqKB3 d72KFPuVEWf+h9MQZltXgsYnv/rmW8pOLfY8xBU0/G5gBPOn2tzu+yWsnwbk0iBWxtj2UF U7b6Ew5c4xg87m6bBN1J/WO/oZq7fWdJw1TyCf+EN4j6D31OaIWIlUO+QYmfxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727551415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZSgmzBjFUX1WMcLt8twPvyzABopP5t/I0cPzb3G5kUg=; b=Yln/HrkSPYq9pNqraJ+V54KmNOOjM9cmFKfd05tJjJvKrPVpg/dwiLUqspdedZAVx0DhM3 z0Eqq0IcINknlh8g9AVqJdJf5gChnw+hEwjdKPAws1gvsvs5/eFh9cCdI/Za8HqGVfg567 lfKrA8Uu/QMc01Ay9evs9bNzYbgsMO6lPTtx/BAYQGG+pg1NlKRiCYytmbOcAqID5v352X w2MHjEvdZyykG2Kv+GSeDVduyZTQBoU41BXXGeoaL6TivrZOXuKU+Wyv9vewVWA6ZvZnNp /qCTzQGnuWt58zuRJ7Aw9mAnYggXb6xoDF9YgXNPk9OJ3H356tfcuvBdM/B01Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727551415; a=rsa-sha256; cv=none; b=kGv3DeVJGvcklW3jpItsUvdE93ACwYwx+u18Q0nxTKLFZHOC22jHXbpA6aK1tJ600eSWw7 uX6fxnDiSI1Q043nBpitk63Wz/DYnlvuvXK0nqaiXGKmTpW71HLBqgZzy2TCeOcMkkgv0J Px84GoVdgMSnPSTAWFBGK7Hwjn1MvQb/7Qdm29zb5hvsuq+JrWO3GtctmPxRNn7koczHJn /oSYtTc0UsFBHj+OaNP3/kz+qloE/BYEINQ7kQeByBjUD+8ovcBIcSxTz2Db5lzGpgyej3 K8ueo8IgJDIjjRNHkV86WTyuRitxJyJYu/0XH/slrtKvqrfXAbRkL8kQfXz2qg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XGHLb1pmLzdNZ; Sat, 28 Sep 2024 19:23:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48SJNZsq096622; Sat, 28 Sep 2024 19:23:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48SJNZ4Z096619; Sat, 28 Sep 2024 19:23:35 GMT (envelope-from git) Date: Sat, 28 Sep 2024 19:23:35 GMT Message-Id: <202409281923.48SJNZ4Z096619@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 37881f65eacd - main - pf: pf_clear_srcnodes() is always called with NULL List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 37881f65eacd200b6aa31bcf75bdda089b83fbd5 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=37881f65eacd200b6aa31bcf75bdda089b83fbd5 commit 37881f65eacd200b6aa31bcf75bdda089b83fbd5 Author: Kajetan Staszkiewicz AuthorDate: 2024-09-28 16:59:13 +0000 Commit: Kristof Provost CommitDate: 2024-09-28 19:23:14 +0000 pf: pf_clear_srcnodes() is always called with NULL The functions pf_clear_srcnodes() is only used to perform a removal of all source nodes, never of a given one. Remove the code allowing for removal of a given source node. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D46819 --- sys/netpfil/pf/pf_ioctl.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 0a573a017ef3..6e2fcd358b68 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -233,7 +233,7 @@ static int pf_clearstates_nv(struct pfioc_nv *); static int pf_getstate(struct pfioc_nv *); static int pf_getstatus(struct pfioc_nv *); static int pf_clear_tables(void); -static void pf_clear_srcnodes(struct pf_ksrc_node *); +static void pf_clear_srcnodes(void); static void pf_kill_srcnodes(struct pfioc_src_node_kill *); static int pf_keepcounters(struct pfioc_nv *); static void pf_tbladdr_copyout(struct pf_addr_wrap *); @@ -5427,7 +5427,7 @@ DIOCCHANGEADDR_error: } case DIOCCLRSRCNODES: { - pf_clear_srcnodes(NULL); + pf_clear_srcnodes(); pf_purge_expired_src_nodes(); break; } @@ -5904,40 +5904,32 @@ pf_clear_tables(void) } static void -pf_clear_srcnodes(struct pf_ksrc_node *n) +pf_clear_srcnodes(void) { - struct pf_kstate *s; - int i; + struct pf_kstate *s; + struct pf_srchash *sh; + struct pf_ksrc_node *sn; + int i; for (i = 0; i <= V_pf_hashmask; i++) { struct pf_idhash *ih = &V_pf_idhash[i]; PF_HASHROW_LOCK(ih); LIST_FOREACH(s, &ih->states, entry) { - if (n == NULL || n == s->src_node) - s->src_node = NULL; - if (n == NULL || n == s->nat_src_node) - s->nat_src_node = NULL; + s->src_node = NULL; + s->nat_src_node = NULL; } PF_HASHROW_UNLOCK(ih); } - if (n == NULL) { - struct pf_srchash *sh; - - for (i = 0, sh = V_pf_srchash; i <= V_pf_srchashmask; - i++, sh++) { - PF_HASHROW_LOCK(sh); - LIST_FOREACH(n, &sh->nodes, entry) { - n->expire = 1; - n->states = 0; - } - PF_HASHROW_UNLOCK(sh); + for (i = 0, sh = V_pf_srchash; i <= V_pf_srchashmask; + i++, sh++) { + PF_HASHROW_LOCK(sh); + LIST_FOREACH(sn, &sh->nodes, entry) { + sn->expire = 1; + sn->states = 0; } - } else { - /* XXX: hash slot should already be locked here. */ - n->expire = 1; - n->states = 0; + PF_HASHROW_UNLOCK(sh); } } @@ -6406,7 +6398,7 @@ shutdown_pf(void) pf_clear_all_states(); - pf_clear_srcnodes(NULL); + pf_clear_srcnodes(); /* status does not use malloced mem so no need to cleanup */ /* fingerprints and interfaces have their own cleanup code */