BUG: src: Fix UDP checksum calculation
PATCH 1/1 BUG: src: Fix UDP checksum calculation
The level 4 protocol is part of the UDP and TCP calculations. nfq_checksum_tcpudp_ipv4() was using IPPROTO_TCP in this calculation, which gave the wrong answer for UDP.
--- src/extra/checksum.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/extra/checksum.c +1 -1
@@ -46,7 +46,7 @@ uint16_t nfq_checksum_tcpudp_ipv4(struct iphdr *iph) sum += (iph->saddr) &0xFFFF ; sum += (iph->daddr >>16 ) &0xFFFF ; sum += (iph->daddr) &0xFFFF ; - sum +=htons (IPPROTO_TCP ); + sum +=htons (iph->protocol); sum +=htons (len);return nfq_checksum (sum, (uint16_t *)payload, len);
Signature · 1 line
2.14.5
Pablo Neira Ayuso
maintainerQuoted 3 lines · Duncan Roe
The level 4 protocol is part of the UDP and TCP calculations.
nfq_checksum_tcpudp_ipv4()was usingIPPROTO_TCPin this calculation, which gave the wrong answer for UDP.
Thanks Duncan, I sent this patch to fix IPv6 too:
Duncan Roe
Acked-byQuoted 9 lines · Pablo Neira Ayuso
Quoted 3 lines · Duncan Roe
The level 4 protocol is part of the UDP and TCP calculations.
nfq_checksum_tcpudp_ipv4()was usingIPPROTO_TCPin this calculation, which gave the wrong answer for UDP.Thanks Duncan, I sent this patch to fix IPv6 too:
LGTM
Acked-by Duncan Roe <[email protected]>