pf: fix icmp-in-icmp handling with if-bound states

When we receive an ICMP packet containing another ICMP packet we look up the
original ICMP state. This is done through a second struct pf_pdesc ('pd2'),
containing relevant information (i.e. addresses, type, id, ..).
pd2 did not contain the network interface ('kif'), leading to state lookup
failures. This only affected if-bound mode, because floating states match all
interfaces.

Set kif in pd2.

Extend the icmp.py:test_fragmentation_needed test case to use if-bound mode. It
already checked that we handled icmp-in-icmp correctly.

PR:		284866
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
This commit is contained in:
Kristof Provost 2025-02-19 13:28:33 +01:00
parent 170059d6d3
commit 86f2641b99
2 changed files with 2 additions and 0 deletions

View file

@ -7792,6 +7792,7 @@ pf_test_state_icmp(struct pf_kstate **state, struct pf_pdesc *pd,
pd2.sidx = (pd->dir == PF_IN) ? 1 : 0;
pd2.didx = (pd->dir == PF_IN) ? 0 : 1;
pd2.m = pd->m;
pd2.kif = pd->kif;
switch (pd->af) {
#ifdef INET
case AF_INET:

View file

@ -53,6 +53,7 @@ class TestICMP(VnetTestTemplate):
ToolsHelper.print_output("/sbin/pfctl -e")
ToolsHelper.pf_rules([
"set reassemble yes",
"set state-policy if-bound",
"block",
"pass inet proto icmp icmp-type echoreq",
])