Thread View: muc.lists.freebsd.bugs
2 messages
2 total messages
Started by bugzilla-noreply
Mon, 02 Nov 2026 22:16
[Bug 300461] pf: af-to inet → inet6 never maps ICMP echo type, so echo replies from NAT64 don't match the state
Author: bugzilla-noreply
Date: Mon, 02 Nov 2026 22:16
Date: Mon, 02 Nov 2026 22:16
113 lines
6291 bytes
6291 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300461
Bug ID: 300461
Summary: pf: af-to inet → inet6 never maps ICMP echo type, so
echo replies from NAT64 don't match the state
Product: Base System
Version: 15.1-RELEASE
Hardware: amd64
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: charles@wozi.com
Created attachment 276925
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=276925&action=edit
Fix ICMP echo type mapping for af-to inet -> inet6
**Version:** 15.1-RELEASE-p5 (amd64). The code is the same in main.
**Setup:** a LAN host's IPv4 traffic is translated to IPv6 for a provider's
NAT64 (T-Mobile US):
pass in quick on ix2 inet from 192.168.1.169 to any \
scrub (max-mss 1412) af-to inet6 from 2607:fb91:2268:4408::464 to
64:ff9b::/96
TCP and UDP work through this rule: HTTPS, DNS and multi-MB transfers. ICMP
echo from the LAN host doesn't: 0 replies.
**Observed:** tcpdump on the IPv6 side shows the translated echo request going
out and the ICMPv6 echo reply coming back:
IP6 2607:fb91:2268:4408::464 > 64:ff9b::101:101: ICMP6, echo request, id
52163, seq 101
IP6 64:ff9b::101:101 > 2607:fb91:2268:4408::464: ICMP6, echo reply, id
52163, seq 101
The reply is never translated back. `pfctl -ss` shows why: the IPv6-side key of
the af-to state still carries the ICMPv4 echo type (8), and the reply then
creates a separate state through an ordinary icmp6 pass rule, keyed with the
ICMPv6 type (128):
all icmp 2607:fb91:2268:4408::464[52163] (192.168.1.169:52163) ->
64:ff9b::101:101[8] (1.1.1.1:52163) 0:0
all ipv6-icmp 2607:fb91:2268:4408::464[52163] <- 64:ff9b::101:101[128]
NO_TRAFFIC:NO_TRAFFIC
**Cause:** in `pf_get_transaddr_af()` (sys/netpfil/pf/pf_lb.c), the inet →
inet6 branch byte-swaps `nsport` but then compares and assigns `ndport`:
} else if (pd->proto == IPPROTO_ICMP && pd->naf == AF_INET6) {
pd->nsport = ntohs(pd->nsport);
if (pd->ndport == ICMP_ECHO)
pd->ndport = ICMP6_ECHO_REQUEST;
else if (pd->ndport == ICMP_ECHOREPLY)
pd->ndport = ICMP6_ECHO_REPLY;
pd->nsport = htons(pd->nsport);
}
`ndport` is still in network byte order, so on little-endian it is never equal
to `ICMP_ECHO`. The type is not mapped and the state key keeps 8. The inet6 →
inet branch just above converts `ndport` correctly.
It looks like a porting slip. OpenBSD's version (sys/net/pf_lb.c,
`pf_get_transaddr_af()`) splits each branch on `pd->dir`: `PF_IN` converts and
maps `ndport`, and `PF_OUT` converts and maps `nsport`. FreeBSD only allows
af-to on inbound rules and keeps one body per branch. The inet6 → inet branch
kept OpenBSD's `PF_IN` body, but the inet → inet6 branch combined the `PF_OUT`
byte swaps (`nsport`) with the `PF_IN` comparison (`ndport`). The patch makes
it OpenBSD's `PF_IN` body verbatim.
**Fix:** the attached patch converts `ndport` instead of `nsport` in that
branch. It is a two-line change.
**Testing:** I haven't built a kernel with the patch, so it is untested. The
cause is from reading the source and matches the observed state key exactly. A
regression test would help: tests/sys/netpfil/pf/nat64.sh only covers the inet6
→ inet direction (`pass in ... inet6 ... af-to inet`), so the inet → inet6
direction has no coverage. An `icmp_echo` case would catch this: a client ping
through `pass in on <v4 if> inet af-to inet6 from <rtr v6> to 64:ff9b::/96`,
against an IPv6 destination that answers for the 64:ff9b::/96 address.
Possibly related: 284944 and D49143 (ICMP error translation in af-to), 291617
(af-to does not generate ICMPv6 packet too big).
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300461] pf: af-to inet → inet6 never maps ICMP echo type, so echo replies from NAT64 don't match the state
Author: bugzilla-noreply
Date: Tue, 03 Nov 2026 00:09
Date: Tue, 03 Nov 2026 00:09
19 lines
2929 bytes
2929 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300461
Mark Linimon <linimon@FreeBSD.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|bugs@FreeBSD.org |pf@FreeBSD.org
CC| |pf@FreeBSD.org
Flags| |maintainer-feedback?(pf@Fre
| |eBSD.org)
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads