Skip to content

Commit bdb244c

Browse files
committed
pf: always log nat rule and do it pre-rewrite
PR: opnsense/core#5005
1 parent a18f78f commit bdb244c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

sys/netpfil/pf/pf.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3346,6 +3346,14 @@ pf_test_rule(struct pf_rule **rm, struct pf_state **sm, int direction,
33463346
KASSERT(sk != NULL, ("%s: null sk", __func__));
33473347
KASSERT(nk != NULL, ("%s: null nk", __func__));
33483348

3349+
if (nr->log) {
3350+
u_short natreason;
3351+
3352+
REASON_SET(&natreason, PFRES_MATCH);
3353+
PFLOG_PACKET(kif, m, af, direction, natreason, nr, a,
3354+
ruleset, pd, 1);
3355+
}
3356+
33493357
if (pd->ip_sum)
33503358
bip_sum = *pd->ip_sum;
33513359

@@ -3559,10 +3567,10 @@ pf_test_rule(struct pf_rule **rm, struct pf_state **sm, int direction,
35593567

35603568
REASON_SET(&reason, PFRES_MATCH);
35613569

3562-
if (r->log || (nr != NULL && nr->log)) {
3570+
if (r->log) {
35633571
if (rewrite)
35643572
m_copyback(m, off, hdrlen, pd->hdr.any);
3565-
PFLOG_PACKET(kif, m, af, direction, reason, r->log ? r : nr, a,
3573+
PFLOG_PACKET(kif, m, af, direction, reason, r, a,
35663574
ruleset, pd, 1);
35673575
}
35683576

0 commit comments

Comments
 (0)