[SCSI] srp.h: avoid padding of structs

Several structs in <scsi/srp.h> get padded to a multiple of 8 bytes on
64-bit architectures and end up with a size that does not match the
definition in the SRP spec:

SRP spec 64-bit
sizeof (struct indirect_buf) 20 24
sizeof (struct srp_login_rsp) 52 56
sizeof (struct srp_rsp) 36 40

Fix this by adding __attribute__((packed)) to the offending structs.

Problem pointed out by Arne Redlich <arne.redlich@xiranet.com>.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by Roland Dreier and committed by James Bottomley ec448a0a e5dbfa66

+17 -6
+17 -6
include/scsi/srp.h
··· 95 96 /* 97 * We need the packed attribute because the SRP spec puts the list of 98 - * descriptors at an offset of 20, which is not aligned to the size 99 - * of struct srp_direct_buf. 100 */ 101 struct srp_indirect_buf { 102 struct srp_direct_buf table_desc; 103 __be32 len; 104 - struct srp_direct_buf desc_list[0] __attribute__((packed)); 105 - }; 106 107 enum { 108 SRP_MULTICHAN_SINGLE = 0, ··· 123 u8 target_port_id[16]; 124 }; 125 126 struct srp_login_rsp { 127 u8 opcode; 128 u8 reserved1[3]; ··· 138 __be16 buf_fmt; 139 u8 rsp_flags; 140 u8 reserved2[25]; 141 - }; 142 143 struct srp_login_rej { 144 u8 opcode; ··· 213 SRP_RSP_FLAG_DIUNDER = 1 << 5 214 }; 215 216 struct srp_rsp { 217 u8 opcode; 218 u8 sol_not; ··· 232 __be32 sense_data_len; 233 __be32 resp_data_len; 234 u8 data[0]; 235 - }; 236 237 #endif /* SCSI_SRP_H */
··· 95 96 /* 97 * We need the packed attribute because the SRP spec puts the list of 98 + * descriptors at an offset of 20, which is not aligned to the size of 99 + * struct srp_direct_buf. The whole structure must be packed to avoid 100 + * having the 20-byte structure padded to 24 bytes on 64-bit architectures. 101 */ 102 struct srp_indirect_buf { 103 struct srp_direct_buf table_desc; 104 __be32 len; 105 + struct srp_direct_buf desc_list[0]; 106 + } __attribute__((packed)); 107 108 enum { 109 SRP_MULTICHAN_SINGLE = 0, ··· 122 u8 target_port_id[16]; 123 }; 124 125 + /* 126 + * The SRP spec defines the size of the LOGIN_RSP structure to be 52 127 + * bytes, so it needs to be packed to avoid having it padded to 56 128 + * bytes on 64-bit architectures. 129 + */ 130 struct srp_login_rsp { 131 u8 opcode; 132 u8 reserved1[3]; ··· 132 __be16 buf_fmt; 133 u8 rsp_flags; 134 u8 reserved2[25]; 135 + } __attribute__((packed)); 136 137 struct srp_login_rej { 138 u8 opcode; ··· 207 SRP_RSP_FLAG_DIUNDER = 1 << 5 208 }; 209 210 + /* 211 + * The SRP spec defines the size of the RSP structure to be 36 bytes, 212 + * so it needs to be packed to avoid having it padded to 40 bytes on 213 + * 64-bit architectures. 214 + */ 215 struct srp_rsp { 216 u8 opcode; 217 u8 sol_not; ··· 221 __be32 sense_data_len; 222 __be32 resp_data_len; 223 u8 data[0]; 224 + } __attribute__((packed)); 225 226 #endif /* SCSI_SRP_H */