[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 95 96 96 /* 97 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. 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. 100 101 */ 101 102 struct srp_indirect_buf { 102 103 struct srp_direct_buf table_desc; 103 104 __be32 len; 104 - struct srp_direct_buf desc_list[0] __attribute__((packed)); 105 - }; 105 + struct srp_direct_buf desc_list[0]; 106 + } __attribute__((packed)); 106 107 107 108 enum { 108 109 SRP_MULTICHAN_SINGLE = 0, ··· 123 122 u8 target_port_id[16]; 124 123 }; 125 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 + */ 126 130 struct srp_login_rsp { 127 131 u8 opcode; 128 132 u8 reserved1[3]; ··· 138 132 __be16 buf_fmt; 139 133 u8 rsp_flags; 140 134 u8 reserved2[25]; 141 - }; 135 + } __attribute__((packed)); 142 136 143 137 struct srp_login_rej { 144 138 u8 opcode; ··· 213 207 SRP_RSP_FLAG_DIUNDER = 1 << 5 214 208 }; 215 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 + */ 216 215 struct srp_rsp { 217 216 u8 opcode; 218 217 u8 sol_not; ··· 232 221 __be32 sense_data_len; 233 222 __be32 resp_data_len; 234 223 u8 data[0]; 235 - }; 224 + } __attribute__((packed)); 236 225 237 226 #endif /* SCSI_SRP_H */