Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Aug 2021 13:52:06 GMT
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: bf530621e401 - stable/12 - pf: save on branching in the common case in pf_test
Message-ID:  <202108231352.17NDq6Pb032345@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=bf530621e4019039cd123cac9b1f765eb5dc157b

commit bf530621e4019039cd123cac9b1f765eb5dc157b
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2021-08-17 18:04:31 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2021-08-23 13:47:35 +0000

    pf: save on branching in the common case in pf_test
    
    Reviewed by:    kp
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    
    (cherry picked from commit 5091ca26507b83ebd5ce677dd26bd10e4bad4153)
---
 sys/netpfil/pf/pf.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index f1b1890f50c5..ae2fdbc32401 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -6235,7 +6235,7 @@ pf_test(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb *
 
 	PF_RULES_RLOCK();
 
-	if (ip_divert_ptr != NULL &&
+	if (__predict_false(ip_divert_ptr != NULL) &&
 	    ((ipfwtag = m_tag_locate(m, MTAG_IPFW_RULE, 0, NULL)) != NULL)) {
 		struct ipfw_rule_ref *rr = (struct ipfw_rule_ref *)(ipfwtag+1);
 		if (rr->info & IPFW_IS_DIVERT && rr->rulenum == 0) {
@@ -6505,9 +6505,8 @@ done:
 	    IN_LOOPBACK(ntohl(pd.dst->v4.s_addr)))
 		m->m_flags |= M_SKIP_FIREWALL;
 
-	if (action == PF_PASS && r->divert.port && ip_divert_ptr != NULL &&
-	    !PACKET_LOOPED(&pd)) {
-
+	if (__predict_false(ip_divert_ptr != NULL) && action == PF_PASS &&
+	    r->divert.port && !PACKET_LOOPED(&pd)) {
 		ipfwtag = m_tag_alloc(MTAG_IPFW_RULE, 0,
 		    sizeof(struct ipfw_rule_ref), M_NOWAIT | M_ZERO);
 		if (ipfwtag != NULL) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108231352.17NDq6Pb032345>