[ovs-dev] [PATCH] packet: Fix sparse warnings ICMPv6.
Jesse Gross
jesse at nicira.com
Wed Sep 3 01:00:08 UTC 2014
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 at nicira.com>
Signed-off-by: Jesse Gross <jesse at nicira.com>
---
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 ace7d8e..65d8109 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 0258745..5747c42 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -631,6 +631,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
--
1.9.1
More information about the dev
mailing list