From: Jesse Gross Date: Wed, 3 Sep 2014 00:57:21 +0000 (-0700) Subject: packet: Fix sparse warnings ICMPv6. X-Git-Tag: v2.3.1~44 X-Git-Url: http://git.cascardo.eti.br/?a=commitdiff_plain;h=8f5a096d888d4dc992e4152cfb1881b7a86511aa;hp=89b92e474e72b70ef237ed160d50fa74847aa402;p=cascardo%2Fovs.git 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 --- 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