pf: postpone clearing of struct pf_pdesc

Postpone zeroing out pd until after the PFI_IFLAG_SKIP/M_SKIP_FIREWALL
checks. We don't need it until then, and it saves us a few CPU cycles in
some cases.
This isn't expected to make a measurable performance change though.

Reviewed by:	mjg, glebius
Pointed out by:	markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33815
This commit is contained in:
Kristof Provost 2022-01-10 18:43:35 +01:00
parent ecc393594d
commit 751d4c7b87

View File

@ -6461,8 +6461,6 @@ pf_test(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb *
if (!V_pf_status.running)
return (PF_PASS);
memset(&pd, 0, sizeof(pd));
kif = (struct pfi_kkif *)ifp->if_pf_kif;
if (kif == NULL) {
@ -6476,6 +6474,7 @@ pf_test(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb *
if (m->m_flags & M_SKIP_FIREWALL)
return (PF_PASS);
memset(&pd, 0, sizeof(pd));
pd.pf_mtag = pf_find_mtag(m);
if (ip_dn_io_ptr != NULL && pd.pf_mtag != NULL &&
@ -6962,9 +6961,6 @@ pf_test6(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb
if (!V_pf_status.running)
return (PF_PASS);
memset(&pd, 0, sizeof(pd));
pd.pf_mtag = pf_find_mtag(m);
kif = (struct pfi_kkif *)ifp->if_pf_kif;
if (kif == NULL) {
DPFPRINTF(PF_DEBUG_URGENT,
@ -6977,6 +6973,9 @@ pf_test6(int dir, int pflags, struct ifnet *ifp, struct mbuf **m0, struct inpcb
if (m->m_flags & M_SKIP_FIREWALL)
return (PF_PASS);
memset(&pd, 0, sizeof(pd));
pd.pf_mtag = pf_find_mtag(m);
if (ip_dn_io_ptr != NULL && pd.pf_mtag != NULL &&
pd.pf_mtag->flags & PF_TAG_DUMMYNET) {
pd.pf_mtag->flags &= ~PF_TAG_DUMMYNET;