aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSimon Wunderlich <sw@simonwunderlich.de>2013-12-17 13:12:12 -0500
committerAntonio Quartulli <antonio@meshcoding.com>2014-01-12 08:41:19 -0500
commit031ace8d052c943da7d32fbeb12de3c7ac2a5953 (patch)
tree8b0d2726387140170dcac73d6b0ff11567f3502d /net
parentc28c0b6b14e09e2c2a9ef328bc44ddb75020d9d1 (diff)
batman-adv: add build checks for packet sizes
With unrolling the batadv_header into the respective structures, the offsetof checks are now useless. Instead, add build checks for all packet types which go over the wire to avoid problems with wrong sizes or compatibility issues on some architectures which don't use every day. Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch> Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/main.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 945e441b579d..ad6aeedd1497 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -419,13 +419,23 @@ static void batadv_recv_handler_init(void)
419 for (i = BATADV_UNICAST_MIN; i <= BATADV_UNICAST_MAX; i++) 419 for (i = BATADV_UNICAST_MIN; i <= BATADV_UNICAST_MAX; i++)
420 batadv_rx_handler[i] = batadv_recv_unhandled_unicast_packet; 420 batadv_rx_handler[i] = batadv_recv_unhandled_unicast_packet;
421 421
422 /* compile time checks for struct member offsets */ 422 /* compile time checks for sizes */
423 BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10); 423 BUILD_BUG_ON(sizeof(struct batadv_bla_claim_dst) != 6);
424 BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4); 424 BUILD_BUG_ON(sizeof(struct batadv_ogm_packet) != 24);
425 BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4); 425 BUILD_BUG_ON(sizeof(struct batadv_icmp_header) != 20);
426 BUILD_BUG_ON(offsetof(struct batadv_frag_packet, dest) != 4); 426 BUILD_BUG_ON(sizeof(struct batadv_icmp_packet) != 20);
427 BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4); 427 BUILD_BUG_ON(sizeof(struct batadv_icmp_packet_rr) != 116);
428 BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4); 428 BUILD_BUG_ON(sizeof(struct batadv_unicast_packet) != 10);
429 BUILD_BUG_ON(sizeof(struct batadv_unicast_4addr_packet) != 18);
430 BUILD_BUG_ON(sizeof(struct batadv_frag_packet) != 20);
431 BUILD_BUG_ON(sizeof(struct batadv_bcast_packet) != 14);
432 BUILD_BUG_ON(sizeof(struct batadv_coded_packet) != 46);
433 BUILD_BUG_ON(sizeof(struct batadv_unicast_tvlv_packet) != 20);
434 BUILD_BUG_ON(sizeof(struct batadv_tvlv_hdr) != 4);
435 BUILD_BUG_ON(sizeof(struct batadv_tvlv_gateway_data) != 8);
436 BUILD_BUG_ON(sizeof(struct batadv_tvlv_tt_vlan_data) != 8);
437 BUILD_BUG_ON(sizeof(struct batadv_tvlv_tt_change) != 12);
438 BUILD_BUG_ON(sizeof(struct batadv_tvlv_roam_adv) != 8);
429 439
430 /* broadcast packet */ 440 /* broadcast packet */
431 batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet; 441 batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;