From nobody Fri Sep 09 17:04:06 2022 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 4MPMlp4Y5Zz4bs3P; Fri, 9 Sep 2022 17:04:06 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MPMlp44lbz49cZ; Fri, 9 Sep 2022 17:04:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662743046; 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=jCCLjAkJ+f3iLTloFjtIiTReLM0XsguNT+LcNXXIopk=; b=TDuIH6AhTA9PtQPNZFB9oMars7F7n6p5SFo/qnch0vIM7RcYb1pYfaZrRDQ+ZQlZPbz7wd tWjE/uUIcoYwFlo7ZteV8PiWn/0JLxJ49/DyqC+ZCj2b655ZiJGp89nVcML8B2tmp6YzY/ 3cZS9s1IRKntXCKIKEFn2xmCKAequ8op722rgD5PMZPI6RZHm4nB0XOrp3zEwiDmdMpUjM wsmXwOtLQ86dMVc04tY7qdkNLrN3opSom23oTHoBkIGmwOu7ufckw4bg/C2bZi25WYACZD qMVHcTXwlGtbmFdseDsZ5ikuwF8EB9Aks+TZ2HpNDmMOqV1WJMvpaVBu2j8htQ== 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 4MPMlp37Qbz1Gwb; Fri, 9 Sep 2022 17:04:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 289H46Cm033527; Fri, 9 Sep 2022 17:04:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 289H46Hb033526; Fri, 9 Sep 2022 17:04:06 GMT (envelope-from git) Date: Fri, 9 Sep 2022 17:04:06 GMT Message-Id: <202209091704.289H46Hb033526@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 6b94546a7ea2 - main - pf: partially depessimize pf_match_translation 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6b94546a7ea2dc593f5765bd5465a8b7bb80c325 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1662743046; 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=jCCLjAkJ+f3iLTloFjtIiTReLM0XsguNT+LcNXXIopk=; b=EhRkxoCrSboq1gh8y4av3hvnAs9ZTeEejFlBfoaAUEDONe53NOWAIYN0sfdHJMaDobp9Fh YiSKqI69MWZq7h0DAgN7aLozyTlOUTf+ilEx7WQia3aSM5Kf8dIjpBkUqZMfKpiy2FGsOW 4Auu48diKkznOH0f2LZ3O2gzORcxxF+HqBCJk+/z5e2cDguVyvEezZBUYcRT9UNGsrKcPC mg1hwhp5x7Dmdz/tCLuibVmH3m+LS3rxCpY+WZ4XCnyn9D/OSyUP+VHN4MGPrD8jKq21Jt kwbZPV3hW/G/sYHDGtiSf1ou2Xf+yDLct6aMvRvQngIU6lm4St5gLACKazRZfQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1662743046; a=rsa-sha256; cv=none; b=ywDbao6bOXb0ehf4xBhG5CwLWXJSbJw31p5QboR5uF5nczJpzewOXqw00AW6EBh/btThuB rHlN7LO7tRKb5fjxFTh4JcAYAMa2rY/p9QCqKsgBJ/82T0y9ZLE9VmMpmQlkoKDblCQdwF H98D+5O6AVTonR3EKL3njGkUDnZC+f7Jwt8eNJc3fbEVEl/GwAazJZ8qnVWeOU7DTL1YEy whOA0nOxPBrODJXxJu2WTQ0i7p/nqq+4kX6Knw6Mwf5EvswEr2wZWTnZ3g8ZjdjuKFhfp5 +1Z2q9+CGtNRYc4ji2WHfURLA8oICHhFxrhVD2s4LJFLIaptzNhywBvGVxioAA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=6b94546a7ea2dc593f5765bd5465a8b7bb80c325 commit 6b94546a7ea2dc593f5765bd5465a8b7bb80c325 Author: Mateusz Guzik AuthorDate: 2022-09-09 16:37:00 +0000 Commit: Mateusz Guzik CommitDate: 2022-09-09 17:03:55 +0000 pf: partially depessimize pf_match_translation Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf_lb.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/netpfil/pf/pf_lb.c b/sys/netpfil/pf/pf_lb.c index 3803ff27a111..186634edbd56 100644 --- a/sys/netpfil/pf/pf_lb.c +++ b/sys/netpfil/pf/pf_lb.c @@ -136,7 +136,7 @@ pf_match_translation(struct pf_pdesc *pd, struct mbuf *m, int off, int asd = 0; r = TAILQ_FIRST(pf_main_ruleset.rules[rs_num].active.ptr); - while (r && rm == NULL) { + while (r != NULL) { struct pf_rule_addr *src = NULL, *dst = NULL; struct pf_addr_wrap *xdst = NULL; @@ -191,6 +191,12 @@ pf_match_translation(struct pf_pdesc *pd, struct mbuf *m, int off, rtableid = r->rtableid; if (r->anchor == NULL) { rm = r; + if (rm->action == PF_NONAT || + rm->action == PF_NORDR || + rm->action == PF_NOBINAT) { + rm = NULL; + } + break; } else pf_step_into_anchor(anchor_stack, &asd, &ruleset, rs_num, &r, NULL, NULL); @@ -205,9 +211,6 @@ pf_match_translation(struct pf_pdesc *pd, struct mbuf *m, int off, if (rtableid >= 0) M_SETFIB(m, rtableid); - if (rm != NULL && (rm->action == PF_NONAT || - rm->action == PF_NORDR || rm->action == PF_NOBINAT)) - return (NULL); return (rm); }