Commit f6c57a46 authored by Sven Eckelmann's avatar Sven Eckelmann Committed by Antonio Quartulli

batman-adv: Mark correctly aligned headers not as __packed

Headers which are already perfectly aligned and create a 4 byte boundary
non-ethernet header payload can have the __packed attribute removed. The
__packed attribute doesn't change the appeareance of the packet for these
headers because no extra padding is necessary to align the data members. The
compiler will also create slightly faster code for loads of multi-byte members.
Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
Signed-off-by: default avatarAntonio Quartulli <ordex@autistici.org>
parent 5b246574
...@@ -106,13 +106,16 @@ struct batadv_bla_claim_dst { ...@@ -106,13 +106,16 @@ struct batadv_bla_claim_dst {
uint8_t magic[3]; /* FF:43:05 */ uint8_t magic[3]; /* FF:43:05 */
uint8_t type; /* bla_claimframe */ uint8_t type; /* bla_claimframe */
__be16 group; /* group id */ __be16 group; /* group id */
} __packed; };
struct batadv_header { struct batadv_header {
uint8_t packet_type; uint8_t packet_type;
uint8_t version; /* batman version field */ uint8_t version; /* batman version field */
uint8_t ttl; uint8_t ttl;
} __packed; /* the parent struct has to add a byte after the header to make
* everything 4 bytes aligned again
*/
};
struct batadv_ogm_packet { struct batadv_ogm_packet {
struct batadv_header header; struct batadv_header header;
...@@ -137,7 +140,7 @@ struct batadv_icmp_packet { ...@@ -137,7 +140,7 @@ struct batadv_icmp_packet {
__be16 seqno; __be16 seqno;
uint8_t uid; uint8_t uid;
uint8_t reserved; uint8_t reserved;
} __packed; };
#define BATADV_RR_LEN 16 #define BATADV_RR_LEN 16
...@@ -153,13 +156,16 @@ struct batadv_icmp_packet_rr { ...@@ -153,13 +156,16 @@ struct batadv_icmp_packet_rr {
uint8_t uid; uint8_t uid;
uint8_t rr_cur; uint8_t rr_cur;
uint8_t rr[BATADV_RR_LEN][ETH_ALEN]; uint8_t rr[BATADV_RR_LEN][ETH_ALEN];
} __packed; };
struct batadv_unicast_packet { struct batadv_unicast_packet {
struct batadv_header header; struct batadv_header header;
uint8_t ttvn; /* destination translation table version number */ uint8_t ttvn; /* destination translation table version number */
uint8_t dest[ETH_ALEN]; uint8_t dest[ETH_ALEN];
} __packed; /* "4 bytes boundary + 2 bytes" long to make the payload after the
* following ethernet header again 4 bytes boundary aligned
*/
};
struct batadv_unicast_frag_packet { struct batadv_unicast_frag_packet {
struct batadv_header header; struct batadv_header header;
...@@ -176,6 +182,9 @@ struct batadv_bcast_packet { ...@@ -176,6 +182,9 @@ struct batadv_bcast_packet {
uint8_t reserved; uint8_t reserved;
__be32 seqno; __be32 seqno;
uint8_t orig[ETH_ALEN]; uint8_t orig[ETH_ALEN];
/* "4 bytes boundary + 2 bytes" long to make the payload after the
* following ethernet header again 4 bytes boundary aligned
*/
} __packed; } __packed;
struct batadv_vis_packet { struct batadv_vis_packet {
...@@ -187,7 +196,7 @@ struct batadv_vis_packet { ...@@ -187,7 +196,7 @@ struct batadv_vis_packet {
uint8_t vis_orig[ETH_ALEN]; /* originator reporting its neighbors */ uint8_t vis_orig[ETH_ALEN]; /* originator reporting its neighbors */
uint8_t target_orig[ETH_ALEN]; /* who should receive this packet */ uint8_t target_orig[ETH_ALEN]; /* who should receive this packet */
uint8_t sender_orig[ETH_ALEN]; /* who sent or forwarded this packet */ uint8_t sender_orig[ETH_ALEN]; /* who sent or forwarded this packet */
} __packed; };
struct batadv_tt_query_packet { struct batadv_tt_query_packet {
struct batadv_header header; struct batadv_header header;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment