From 413c15988ea381fbafa4eedbf821fe51f6d1651a Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 6 Mar 2024 16:34:28 +1100 Subject: udp: Use existing helper for UDP checksum on inbound IPv6 packets Currently we open code the calculation of the UDP checksum in udp_update_hdr6(). We calling a helper to handle the IPv6 pseudo-header, and preset the checksum field to 0 so an uninitialised value doesn't get folded in. We already have a helper to do this: csum_udp6() which we use in some slow paths. Use it here as well. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- udp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'udp.c') diff --git a/udp.c b/udp.c index fe3a6cd..45b7cc9 100644 --- a/udp.c +++ b/udp.c @@ -671,10 +671,7 @@ static size_t udp_update_hdr6(const struct ctx *c, struct udp6_l2_buf_t *b, b->uh.source = b->s_in6.sin6_port; b->uh.dest = htons(dstport); b->uh.len = b->ip6h.payload_len; - b->uh.check = 0; - b->uh.check = csum(&b->uh, payload_len, - proto_ipv6_header_psum(payload_len, IPPROTO_UDP, - src, dst)); + csum_udp6(&b->uh, src, dst, b->data, datalen); return tap_iov_len(c, &b->taph, payload_len + sizeof(b->ip6h)); } -- cgit v1.2.3