git: e6ad9d647a89 - stable/15 - ipfilter: Remove erroneous ntohs()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 13 Nov 2026 19:32:51 UTC
The branch stable/15 has been updated by cy:
URL: https://cgit.FreeBSD.org/src/commit/?id=e6ad9d647a890d71231949de3cd0c43acaf8ec83
commit e6ad9d647a890d71231949de3cd0c43acaf8ec83
Author: Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2026-11-09 23:13:21 +0000
Commit: Cy Schubert <cy@FreeBSD.org>
CommitDate: 2026-11-13 19:32:36 +0000
ipfilter: Remove erroneous ntohs()
The original commit was wrong. ipf_nat_builddivertmp() builds the UDP
template with the length in host byte order
M_DUP() copies that value unchanged. The old code was therefore correct.
It added fin_plen in host order and then did a single htons().
The original patch was discussed with Co-Pilot, which pointed out the
original bug. claude-opus-5-5 discovered the ntohs() error that
co-pilot suggested.
Interestingly this code had been running here for a couple of months.
Reported by: llm-postcr
Fixes: 72cc9e3766f4
(cherry picked from commit 86861520613f99c85b5fbdf92b5c955a13ed6624)
---
sys/netpfil/ipfilter/netinet/ip_nat.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/sys/netpfil/ipfilter/netinet/ip_nat.c b/sys/netpfil/ipfilter/netinet/ip_nat.c
index c8125c10e3f0..4b4890587f53 100644
--- a/sys/netpfil/ipfilter/netinet/ip_nat.c
+++ b/sys/netpfil/ipfilter/netinet/ip_nat.c
@@ -5156,7 +5156,6 @@ ipf_nat_out(fr_info_t *fin, nat_t *nat, int natadd, u_32_t nflags)
if (ip->ip_p == IPPROTO_UDP) {
uh = (udphdr_t *)(ip + 1);
- uh->uh_ulen = ntohs(uh->uh_ulen);
uh->uh_ulen += fin->fin_plen;
uh->uh_ulen = htons(uh->uh_ulen);
}