From 7abd2b0d727b4dad0f92d8c3130931d023e58514 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 19 Oct 2022 11:43:44 +1100 Subject: Add csum_icmp6() helper for calculating ICMPv6 checksums At least two places in passt calculate ICMPv6 checksums, ndp() and tap_ip_send(). Add a helper to handle this calculation in both places. For future flexibility, the new helper takes parameters for the fields in the IPv6 pseudo-header, so an IPv6 header or pseudo-header doesn't need to be explicitly constructed. It also allows the ICMPv6 header and payload to be in separate buffers, although we don't use this yet. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- ndp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'ndp.c') diff --git a/ndp.c b/ndp.c index dec36a9..03f1d06 100644 --- a/ndp.c +++ b/ndp.c @@ -189,10 +189,7 @@ dns_done: ip6hr->saddr = c->ip6.addr_ll; ip6hr->payload_len = htons(sizeof(*ihr) + len); - ip6hr->hop_limit = IPPROTO_ICMPV6; - ihr->icmp6_cksum = 0; - ihr->icmp6_cksum = csum_unaligned(ip6hr, sizeof(*ip6hr) + - sizeof(*ihr) + len, 0); + csum_icmp6(ihr, &ip6hr->saddr, &ip6hr->daddr, ihr + 1, len); ip6hr->version = 6; ip6hr->nexthdr = IPPROTO_ICMPV6; -- cgit v1.2.3