diff options
author | Kristof Provost <kp@FreeBSD.org> | 2024-12-02 16:50:02 +0000 |
---|---|---|
committer | Kristof Provost <kp@FreeBSD.org> | 2024-12-17 10:07:17 +0000 |
commit | 1df79d81343dc7683a234708e1852a8e368dbed2 (patch) | |
tree | 8a733689c83fa22a41a2752ebbf45182d376d2ce | |
parent | e128e988a26a2c439da6920a5d5839b961542285 (diff) |
pf: preserve TOS with nat64
When translating packets from one address family to another, pass the
TOS/Traffic Class field of the original packet. Discussed with mikeb@
Obtained from: OpenBSD, jca <jca@openbsd.org>, fd92f2bb4f
Sponsored by: Rubicon Communications, LLC ("Netgate")
-rw-r--r-- | sys/netpfil/pf/pf.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 13a299a8dcd4..881b3cf91140 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -3460,6 +3460,7 @@ pf_translate_af(struct pf_pdesc *pd) bzero(ip4, hlen); ip4->ip_v = IPVERSION; ip4->ip_hl = hlen >> 2; + ip4->ip_tos = pd->tos; ip4->ip_len = htons(hlen + (pd->tot_len - pd->off)); ip_fillid(ip4); ip4->ip_ttl = pd->ttl; @@ -3473,6 +3474,7 @@ pf_translate_af(struct pf_pdesc *pd) ip6 = mtod(pd->m, struct ip6_hdr *); bzero(ip6, hlen); ip6->ip6_vfc = IPV6_VERSION; + ip6->ip6_flow |= htonl((u_int32_t)pd->tos << 20); ip6->ip6_plen = htons(pd->tot_len - pd->off); ip6->ip6_nxt = pd->proto; if (!pd->ttl || pd->ttl > IPV6_DEFHLIM) |