From nobody Wed Oct 02 12:20:59 2024 X-Original-To: dev-commits-src-all@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 4XJYn76t4Bz5YRxG; Wed, 02 Oct 2024 12:20:59 +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 4XJYn74ddYz4XNq; Wed, 2 Oct 2024 12:20:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727871659; 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=dkwvZsQSesuR28I78GZ7co0iYdtp5Nkjlr2iP7ZXXH0=; b=avXpe+AlX8DBmTPE5kD9TIzyjz65QjSqXlBo8fNi6/2f/nqcMFKaOgehpqCJh+1VYnkxr6 +HSKfOxkCDOEm9YyBDN/wJz/B19aAX+71iiLopbTFoXyIiyOcmC0VXjpbdQIrxxivCQ2Ag IbyDXbsHOs10hLli1jl2uHzB539wUUtN64UWdlvxlEME3QeD63CzfkO4tE0w3dtXlOX5Zy MQHapjG2hhPu5CZ8TKi+SXmrMIdsuX+VpFxTPulUSF9aWkWmAH66ZgGXK5HNZyQc9Stsw7 PW8laYMc3FKEB47PEPiOk4Tp2OZwQHjY+X6B6szMPSaAQbVtyZPuHTJxbuX/+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1727871659; 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=dkwvZsQSesuR28I78GZ7co0iYdtp5Nkjlr2iP7ZXXH0=; b=hva5DM6Er0+MOdKqhpBaG9ZdAjomPpzvv4Scm5vSRgIihT+jtuJRqd9Q3xyJJhVOKjUy9R J/0hoidVJdZ43p2d7GNLyrlG7tgXg4fQq1dHFjBhQTiZ8v2jwq7fuVzoOSjd2+jpALrMen 0JEbbfSWqpbwubpJuFVFDqy3P92F4Qq9/i4i9VmGKAdF06K9jZBgWs9OvWosYHfH/PgOGr UizmaUKVzjx8sumq/bekGp+p/6/Kscwq/Bgs8i8mjk/jnIY4Rtc9BtWZib+BvcWjP64OL2 LmPfDTjeOjLL0FX/2rUQyK6cDbHlNHqZ1T5uANimafI6uVPZC0rOT6UhUuEjWg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1727871659; a=rsa-sha256; cv=none; b=Em9kWE6fcuHxnqgjKx3/sQYLkJEyBFRYV8f7oAQfcaGFWja86Au3Qyg0f477lkle99NxdP FtHcR+4FwrEPP/RROH/v2JryVmt+ssAolspPxkH/XqgORzUtDE3QRKoUyB26E0iQfQgDrf r8SSz4ZHF6z6H8sYh5nVxTjYPfZJNjsrTeS6fqPiywgZZ/1AB5ZMcEORW5DAsivrZi7CMh 8QVu5kP3Q78Jw1mze8PwKkHIYCjhJFbTmCpf+djfLZO8OlIGuruBN6b2/K78D56YjZqxTb +Yz1IoT0KZ0iGWDkpKEDQiiY6erVwcddRLsffmVD0HbOj2Ec9AN1F9oeLZc0aQ== 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 4XJYn74FgGz1LDN; Wed, 2 Oct 2024 12:20:59 +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 492CKxr0091546; Wed, 2 Oct 2024 12:20:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 492CKxkQ091543; Wed, 2 Oct 2024 12:20:59 GMT (envelope-from git) Date: Wed, 2 Oct 2024 12:20:59 GMT Message-Id: <202410021220.492CKxkQ091543@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: 6bbef793552c - main - pf: Remove struct pf_pdesc->nat_rule List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: 6bbef793552cf6167c88c9d8e55e1874256f0d51 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=6bbef793552cf6167c88c9d8e55e1874256f0d51 commit 6bbef793552cf6167c88c9d8e55e1874256f0d51 Author: Kajetan Staszkiewicz AuthorDate: 2024-10-02 10:05:04 +0000 Commit: Kristof Provost CommitDate: 2024-10-02 10:05:08 +0000 pf: Remove struct pf_pdesc->nat_rule The variable struct pd->nat_rule is set only during rule evaluation, that is only for the first packet of a connection. Use struct pf_kstate->nat_rule instead. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D46867 --- sys/net/pfvar.h | 1 - sys/netpfil/pf/pf.c | 15 ++++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 79dcd0d65985..53bc77d14537 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1602,7 +1602,6 @@ struct pf_pdesc { char any[0]; } hdr; - struct pf_krule *nat_rule; /* nat/rdr rule applied to packet */ struct pf_addr *src; /* src address */ struct pf_addr *dst; /* dst address */ u_int16_t *sport; diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 51b4cebc88e9..b28503112db6 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -5131,7 +5131,6 @@ pf_test_rule(struct pf_krule **rm, struct pf_kstate **sm, struct pfi_kkif *kif, } if (nr->natpass) r = NULL; - pd->nat_rule = nr; } while (r != NULL) { @@ -7900,7 +7899,7 @@ pf_route(struct mbuf **m, struct pf_krule *r, struct ifnet *oifp, error = EMSGSIZE; KMOD_IPSTAT_INC(ips_cantfrag); if (r_rt != PF_DUPTO) { - if (s && pd->nat_rule != NULL) + if (s && s->nat_rule.ptr != NULL) PACKET_UNDO_NAT(m0, pd, (ip->ip_hl << 2) + (ip_off & IP_OFFMASK), s); @@ -8113,7 +8112,7 @@ pf_route6(struct mbuf **m, struct pf_krule *r, struct ifnet *oifp, else { in6_ifstat_inc(ifp, ifs6_in_toobig); if (r_rt != PF_DUPTO) { - if (s && pd->nat_rule != NULL) + if (s && s->nat_rule.ptr != NULL) PACKET_UNDO_NAT(m0, pd, ((caddr_t)ip6 - m0->m_data) + sizeof(struct ip6_hdr), s); @@ -8771,7 +8770,7 @@ pf_counters_inc(int action, struct pf_pdesc *pd, struct pfi_kkif *kif, struct pf_kstate *s, struct pf_krule *r, struct pf_krule *a) { - struct pf_krule *tr, *nr; + struct pf_krule *tr; int dir = pd->dir; int dirndx; @@ -8823,10 +8822,12 @@ pf_counters_inc(int action, struct pf_pdesc *pd, pf_counter_u64_add_protected(&ri->r->bytes[dirndx], pd->tot_len); } } + tr = r; - nr = (s != NULL) ? s->nat_rule.ptr : pd->nat_rule; - if (nr != NULL && r == &V_pf_default_rule) - tr = nr; + if (s != NULL && s->nat_rule.ptr != NULL && + r == &V_pf_default_rule) + tr = s->nat_rule.ptr; + if (tr->src.addr.type == PF_ADDR_TABLE) pfr_update_stats(tr->src.addr.p.tbl, (s == NULL) ? pd->src :