aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitalii Demianets <vitas@nppfactor.kiev.ua>2011-05-12 19:04:29 -0400
committerDavid S. Miller <davem@davemloft.net>2011-05-13 15:13:24 -0400
commita10e14667635dde504ed9e7ee851494c2cf2ae8e (patch)
treebf5ad736713e1fcb80fadb05825184b44d50c87e
parentca06707022d6ba4744198a8ebbe4994786b0c613 (diff)
bonding,llc: Fix structure sizeof incompatibility for some PDUs
With some combinations of arch/compiler (e.g. arm-linux-gcc) the sizeof operator on structure returns value greater than expected. In cases when the structure is used for mapping PDU fields it may lead to unexpected results (such as holes and alignment problems in skb data). __packed prevents this undesired behavior. Signed-off-by: Vitalii Demianets <vitas@nppfactor.kiev.ua> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/bonding/bond_3ad.h10
-rw-r--r--include/net/llc_pdu.h8
2 files changed, 9 insertions, 9 deletions
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h
index b28baff70864..01b8a6af275b 100644
--- a/drivers/net/bonding/bond_3ad.h
+++ b/drivers/net/bonding/bond_3ad.h
@@ -39,7 +39,7 @@
39 39
40typedef struct mac_addr { 40typedef struct mac_addr {
41 u8 mac_addr_value[ETH_ALEN]; 41 u8 mac_addr_value[ETH_ALEN];
42} mac_addr_t; 42} __packed mac_addr_t;
43 43
44enum { 44enum {
45 BOND_AD_STABLE = 0, 45 BOND_AD_STABLE = 0,
@@ -134,12 +134,12 @@ typedef struct lacpdu {
134 u8 tlv_type_terminator; // = terminator 134 u8 tlv_type_terminator; // = terminator
135 u8 terminator_length; // = 0 135 u8 terminator_length; // = 0
136 u8 reserved_50[50]; // = 0 136 u8 reserved_50[50]; // = 0
137} lacpdu_t; 137} __packed lacpdu_t;
138 138
139typedef struct lacpdu_header { 139typedef struct lacpdu_header {
140 struct ethhdr hdr; 140 struct ethhdr hdr;
141 struct lacpdu lacpdu; 141 struct lacpdu lacpdu;
142} lacpdu_header_t; 142} __packed lacpdu_header_t;
143 143
144// Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard) 144// Marker Protocol Data Unit(PDU) structure(43.5.3.2 in the 802.3ad standard)
145typedef struct bond_marker { 145typedef struct bond_marker {
@@ -155,12 +155,12 @@ typedef struct bond_marker {
155 u8 tlv_type_terminator; // = 0x00 155 u8 tlv_type_terminator; // = 0x00
156 u8 terminator_length; // = 0x00 156 u8 terminator_length; // = 0x00
157 u8 reserved_90[90]; // = 0 157 u8 reserved_90[90]; // = 0
158} bond_marker_t; 158} __packed bond_marker_t;
159 159
160typedef struct bond_marker_header { 160typedef struct bond_marker_header {
161 struct ethhdr hdr; 161 struct ethhdr hdr;
162 struct bond_marker marker; 162 struct bond_marker marker;
163} bond_marker_header_t; 163} __packed bond_marker_header_t;
164 164
165#pragma pack() 165#pragma pack()
166 166
diff --git a/include/net/llc_pdu.h b/include/net/llc_pdu.h
index 75b8e2968c9b..f57e7d46a453 100644
--- a/include/net/llc_pdu.h
+++ b/include/net/llc_pdu.h
@@ -199,7 +199,7 @@ struct llc_pdu_sn {
199 u8 ssap; 199 u8 ssap;
200 u8 ctrl_1; 200 u8 ctrl_1;
201 u8 ctrl_2; 201 u8 ctrl_2;
202}; 202} __packed;
203 203
204static inline struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb) 204static inline struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb)
205{ 205{
@@ -211,7 +211,7 @@ struct llc_pdu_un {
211 u8 dsap; 211 u8 dsap;
212 u8 ssap; 212 u8 ssap;
213 u8 ctrl_1; 213 u8 ctrl_1;
214}; 214} __packed;
215 215
216static inline struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb) 216static inline struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb)
217{ 217{
@@ -359,7 +359,7 @@ struct llc_xid_info {
359 u8 fmt_id; /* always 0x81 for LLC */ 359 u8 fmt_id; /* always 0x81 for LLC */
360 u8 type; /* different if NULL/non-NULL LSAP */ 360 u8 type; /* different if NULL/non-NULL LSAP */
361 u8 rw; /* sender receive window */ 361 u8 rw; /* sender receive window */
362}; 362} __packed;
363 363
364/** 364/**
365 * llc_pdu_init_as_xid_cmd - sets bytes 3, 4 & 5 of LLC header as XID 365 * llc_pdu_init_as_xid_cmd - sets bytes 3, 4 & 5 of LLC header as XID
@@ -415,7 +415,7 @@ struct llc_frmr_info {
415 u8 curr_ssv; /* current send state variable val */ 415 u8 curr_ssv; /* current send state variable val */
416 u8 curr_rsv; /* current receive state variable */ 416 u8 curr_rsv; /* current receive state variable */
417 u8 ind_bits; /* indicator bits set with macro */ 417 u8 ind_bits; /* indicator bits set with macro */
418}; 418} __packed;
419 419
420extern void llc_pdu_set_cmd_rsp(struct sk_buff *skb, u8 type); 420extern void llc_pdu_set_cmd_rsp(struct sk_buff *skb, u8 type);
421extern void llc_pdu_set_pf_bit(struct sk_buff *skb, u8 bit_value); 421extern void llc_pdu_set_pf_bit(struct sk_buff *skb, u8 bit_value);