b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@meshcoding.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Marek Lindner <mareklindner@neomailbox.ch>,
	Antonio Quartulli <antonio@meshcoding.com>
Subject: [B.A.T.M.A.N.] [PATCH 11/14] batman-adv: add build checks for packet sizes
Date: Mon, 13 Jan 2014 23:31:35 +0100	[thread overview]
Message-ID: <1389652298-472-12-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <1389652298-472-1-git-send-email-antonio@meshcoding.com>

From: Simon Wunderlich <sw@simonwunderlich.de>

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>
---
 net/batman-adv/main.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 945e441..ad6aeed 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -419,13 +419,23 @@ static void batadv_recv_handler_init(void)
 	for (i = BATADV_UNICAST_MIN; i <= BATADV_UNICAST_MAX; i++)
 		batadv_rx_handler[i] = batadv_recv_unhandled_unicast_packet;
 
-	/* compile time checks for struct member offsets */
-	BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10);
-	BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4);
-	BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4);
-	BUILD_BUG_ON(offsetof(struct batadv_frag_packet, dest) != 4);
-	BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, dst) != 4);
-	BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, dst) != 4);
+	/* compile time checks for sizes */
+	BUILD_BUG_ON(sizeof(struct batadv_bla_claim_dst) != 6);
+	BUILD_BUG_ON(sizeof(struct batadv_ogm_packet) != 24);
+	BUILD_BUG_ON(sizeof(struct batadv_icmp_header) != 20);
+	BUILD_BUG_ON(sizeof(struct batadv_icmp_packet) != 20);
+	BUILD_BUG_ON(sizeof(struct batadv_icmp_packet_rr) != 116);
+	BUILD_BUG_ON(sizeof(struct batadv_unicast_packet) != 10);
+	BUILD_BUG_ON(sizeof(struct batadv_unicast_4addr_packet) != 18);
+	BUILD_BUG_ON(sizeof(struct batadv_frag_packet) != 20);
+	BUILD_BUG_ON(sizeof(struct batadv_bcast_packet) != 14);
+	BUILD_BUG_ON(sizeof(struct batadv_coded_packet) != 46);
+	BUILD_BUG_ON(sizeof(struct batadv_unicast_tvlv_packet) != 20);
+	BUILD_BUG_ON(sizeof(struct batadv_tvlv_hdr) != 4);
+	BUILD_BUG_ON(sizeof(struct batadv_tvlv_gateway_data) != 8);
+	BUILD_BUG_ON(sizeof(struct batadv_tvlv_tt_vlan_data) != 8);
+	BUILD_BUG_ON(sizeof(struct batadv_tvlv_tt_change) != 12);
+	BUILD_BUG_ON(sizeof(struct batadv_tvlv_roam_adv) != 8);
 
 	/* broadcast packet */
 	batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
-- 
1.8.5.2


  parent reply	other threads:[~2014-01-13 22:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13 22:31 [B.A.T.M.A.N.] pull request: batman-adv 2014-01-13 Antonio Quartulli
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 01/14] batman-adv: remove bonding and interface alternating Antonio Quartulli
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 02/14] batman-adv: split tq information in neigh_node struct Antonio Quartulli
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 03/14] batman-adv: split out router from orig_node Antonio Quartulli
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 04/14] batman-adv: add WiFi penalty Antonio Quartulli
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 05/14] batman-adv: consider outgoing interface in OGM sending Antonio Quartulli
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 06/14] batman-adv: add bonding again Antonio Quartulli
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 07/14] batman-adv: add debugfs structure for information per interface Antonio Quartulli
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 08/14] batman-adv: add debugfs support to view multiif tables Antonio Quartulli
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 09/14] batman-adv: remove returns at the end of void functions Antonio Quartulli
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 10/14] batman-adv: add missing sysfs attributes to README Antonio Quartulli
2014-01-13 22:31 ` Antonio Quartulli [this message]
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 12/14] batman-adv: update copyright years for 2014 Antonio Quartulli
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 13/14] batman-adv: Start new development cycle Antonio Quartulli
2014-01-13 22:31 ` [B.A.T.M.A.N.] [PATCH 14/14] batman-adv: drop dependency against CRC16 Antonio Quartulli
2014-01-15 13:16   ` Antonio Quartulli
2014-01-16  0:54     ` David Miller
2014-01-14  5:50 ` [B.A.T.M.A.N.] pull request: batman-adv 2014-01-13 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1389652298-472-12-git-send-email-antonio@meshcoding.com \
    --to=antonio@meshcoding.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=mareklindner@neomailbox.ch \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).