Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rds: Fix endianness annotations for RDS extension headers

Per the RDS 3.1 spec [1], RDS extension headers EXTHDR_NPATHS and
EXTHDR_GEN_NUM are be16 and be32 values respectively, exchanged during
normal operations over-the-wire (RDS Ping/Pong). This contrasts their
declarations as host endian unsigned ints.

Fix the annotations across occurrences. Flagged by Sparse.

[1] https://oss.oracle.com/projects/rds/dist/documentation/rds-3.1-spec.html

Signed-off-by: Ujwal Kundur <ujwal.kundur@gmail.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Link: https://patch.msgid.link/20250820175550.498-5-ujwal.kundur@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Ujwal Kundur and committed by
Jakub Kicinski
bcb28bee 77907a06

+6 -6
+2 -2
net/rds/message.c
··· 44 44 [RDS_EXTHDR_VERSION] = sizeof(struct rds_ext_header_version), 45 45 [RDS_EXTHDR_RDMA] = sizeof(struct rds_ext_header_rdma), 46 46 [RDS_EXTHDR_RDMA_DEST] = sizeof(struct rds_ext_header_rdma_dest), 47 - [RDS_EXTHDR_NPATHS] = sizeof(u16), 48 - [RDS_EXTHDR_GEN_NUM] = sizeof(u32), 47 + [RDS_EXTHDR_NPATHS] = sizeof(__be16), 48 + [RDS_EXTHDR_GEN_NUM] = sizeof(__be32), 49 49 }; 50 50 51 51 void rds_message_addref(struct rds_message *rm)
+2 -2
net/rds/recv.c
··· 202 202 unsigned int pos = 0, type, len; 203 203 union { 204 204 struct rds_ext_header_version version; 205 - u16 rds_npaths; 206 - u32 rds_gen_num; 205 + __be16 rds_npaths; 206 + __be32 rds_gen_num; 207 207 } buffer; 208 208 u32 new_peer_gen_num = 0; 209 209
+2 -2
net/rds/send.c
··· 1454 1454 1455 1455 if (RDS_HS_PROBE(be16_to_cpu(sport), be16_to_cpu(dport)) && 1456 1456 cp->cp_conn->c_trans->t_mp_capable) { 1457 - u16 npaths = cpu_to_be16(RDS_MPATH_WORKERS); 1458 - u32 my_gen_num = cpu_to_be32(cp->cp_conn->c_my_gen_num); 1457 + __be16 npaths = cpu_to_be16(RDS_MPATH_WORKERS); 1458 + __be32 my_gen_num = cpu_to_be32(cp->cp_conn->c_my_gen_num); 1459 1459 1460 1460 rds_message_add_extension(&rm->m_inc.i_hdr, 1461 1461 RDS_EXTHDR_NPATHS, &npaths,