packet: Fix sparse warnings ICMPv6.
authorJesse Gross <jesse@nicira.com>
Wed, 3 Sep 2014 00:57:21 +0000 (17:57 -0700)
committerJesse Gross <jesse@nicira.com>
Wed, 3 Sep 2014 04:47:14 +0000 (21:47 -0700)
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 <alexw@nicira.com>
Signed-off-by: Jesse Gross <jesse@nicira.com>
lib/packets.c
lib/packets.h

index ace7d8e..65d8109 100644 (file)
@@ -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);
     }
index f294d84..9ebf4c1 100644 (file)
@@ -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