From 8f5a096d888d4dc992e4152cfb1881b7a86511aa Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Tue, 2 Sep 2014 17:57:21 -0700 Subject: [PATCH] packet: Fix sparse warnings ICMPv6. The system defined ICMPv6 header doesn't have sparse annotation, so this adds a definition so that endianness can be checked. Reported-by: Alex Wang Signed-off-by: Jesse Gross --- lib/packets.c | 5 +++-- lib/packets.h | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/packets.c b/lib/packets.c index ace7d8ed5..65d810962 100644 --- a/lib/packets.c +++ b/lib/packets.c @@ -715,8 +715,9 @@ packet_update_csum128(struct ofpbuf *packet, uint8_t proto, uh->udp_csum = htons(0xffff); } } - } else if (proto == IPPROTO_ICMPV6 && l4_size >= sizeof(struct icmp6_hdr)) { - struct icmp6_hdr *icmp = ofpbuf_l4(packet); + } else if (proto == IPPROTO_ICMPV6 && + l4_size >= sizeof(struct icmp6_header)) { + struct icmp6_header *icmp = ofpbuf_l4(packet); icmp->icmp6_cksum = recalc_csum128(icmp->icmp6_cksum, addr, new_addr); } diff --git a/lib/packets.h b/lib/packets.h index f294d847e..9ebf4c1e3 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -609,6 +609,15 @@ struct ovs_16aligned_ip6_frag { ovs_16aligned_be32 ip6f_ident; }; +#define ICMP6_HEADER_LEN 4 +struct icmp6_header { + uint8_t icmp6_type; + uint8_t icmp6_code; + ovs_be16 icmp6_cksum; + uint8_t icmp6_data[0]; +}; +BUILD_ASSERT_DECL(ICMP6_HEADER_LEN == sizeof(struct icmp6_header)); + /* The IPv6 flow label is in the lower 20 bits of the first 32-bit word. */ #define IPV6_LABEL_MASK 0x000fffff -- 2.20.1