From 38a7e5b365edce1fc0a972a05bbda0673ca63cad Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 30 Sep 2019 16:25:42 +0200 Subject: checksum: 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. Based on patch from Alin Nastac, and patch description from Duncan Roe. Signed-off-by: Pablo Neira Ayuso --- src/extra/tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/extra/tcp.c') diff --git a/src/extra/tcp.c b/src/extra/tcp.c index d1cd79d..a66f392 100644 --- a/src/extra/tcp.c +++ b/src/extra/tcp.c @@ -96,7 +96,7 @@ nfq_tcp_compute_checksum_ipv4(struct tcphdr *tcph, struct iphdr *iph) { /* checksum field in header needs to be zero for calculation. */ tcph->check = 0; - tcph->check = nfq_checksum_tcpudp_ipv4(iph); + tcph->check = nfq_checksum_tcpudp_ipv4(iph, IPPROTO_TCP); } EXPORT_SYMBOL(nfq_tcp_compute_checksum_ipv4); @@ -110,7 +110,7 @@ nfq_tcp_compute_checksum_ipv6(struct tcphdr *tcph, struct ip6_hdr *ip6h) { /* checksum field in header needs to be zero for calculation. */ tcph->check = 0; - tcph->check = nfq_checksum_tcpudp_ipv6(ip6h, tcph); + tcph->check = nfq_checksum_tcpudp_ipv6(ip6h, tcph, IPPROTO_TCP); } EXPORT_SYMBOL(nfq_tcp_compute_checksum_ipv6); -- cgit v1.2.3