aboutgitcodebugslistschat
path: root/udp.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-05-01 16:53:48 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-05-02 16:13:21 +0200
commit9e22c53aa92552bd5c015c2597512056f8def4d8 (patch)
treeb4068984c67af419bbeaf6aad34c9d6921b5d034 /udp.c
parent1095a7b0c9a150cb488ff5bd5fd74c897dd9236e (diff)
downloadpasst-9e22c53aa92552bd5c015c2597512056f8def4d8.tar
passt-9e22c53aa92552bd5c015c2597512056f8def4d8.tar.gz
passt-9e22c53aa92552bd5c015c2597512056f8def4d8.tar.bz2
passt-9e22c53aa92552bd5c015c2597512056f8def4d8.tar.lz
passt-9e22c53aa92552bd5c015c2597512056f8def4d8.tar.xz
passt-9e22c53aa92552bd5c015c2597512056f8def4d8.tar.zst
passt-9e22c53aa92552bd5c015c2597512056f8def4d8.zip
checksum: Make csum_ip4_header() take a host endian length
csum_ip4_header() takes the packet length as a network endian value. In general it's very error-prone to pass non-native-endian values as a raw integer. It's particularly bad here because this differs from other checksum functions (e.g. proto_ipv4_header_psum()) which take host native lengths. It turns out all the callers have easy access to the native endian value, so switch it to use host order like everything else. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'udp.c')
-rw-r--r--udp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/udp.c b/udp.c
index 4bf9059..09f9813 100644
--- a/udp.c
+++ b/udp.c
@@ -605,7 +605,7 @@ static size_t udp_update_hdr4(const struct ctx *c, struct udp4_l2_buf_t *b,
b->iph.tot_len = htons(ip_len);
b->iph.daddr = c->ip4.addr_seen.s_addr;
b->iph.saddr = src.s_addr;
- b->iph.check = csum_ip4_header(b->iph.tot_len, IPPROTO_UDP,
+ b->iph.check = csum_ip4_header(ip_len, IPPROTO_UDP,
src, c->ip4.addr_seen);
b->uh.source = b->s_in.sin_port;