Skip to content

Commit c5a1039

Browse files
Wen Gukuba-moo
authored andcommitted
net/smc: fix missing byte order conversion in CLC handshake
The byte order conversions of ISM GID and DMB token are missing in process of CLC accept and confirm. So fix it. Fixes: 3d9725a ("net/smc: common routine for CLC accept and confirm") Signed-off-by: Wen Gu <[email protected]> Reviewed-by: Tony Lu <[email protected]> Reviewed-by: Alexandra Winter <[email protected]> Reviewed-by: Wenjia Zhang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 1499b89 commit c5a1039

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

net/smc/af_smc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ static void smcd_conn_save_peer_info(struct smc_sock *smc,
723723
int bufsize = smc_uncompress_bufsize(clc->d0.dmbe_size);
724724

725725
smc->conn.peer_rmbe_idx = clc->d0.dmbe_idx;
726-
smc->conn.peer_token = clc->d0.token;
726+
smc->conn.peer_token = ntohll(clc->d0.token);
727727
/* msg header takes up space in the buffer */
728728
smc->conn.peer_rmbe_size = bufsize - sizeof(struct smcd_cdc_msg);
729729
atomic_set(&smc->conn.peer_rmbe_space, smc->conn.peer_rmbe_size);
@@ -1415,7 +1415,7 @@ static int smc_connect_ism(struct smc_sock *smc,
14151415
if (rc)
14161416
return rc;
14171417
}
1418-
ini->ism_peer_gid[ini->ism_selected] = aclc->d0.gid;
1418+
ini->ism_peer_gid[ini->ism_selected] = ntohll(aclc->d0.gid);
14191419

14201420
/* there is only one lgr role for SMC-D; use server lock */
14211421
mutex_lock(&smc_server_lgr_pending);

net/smc/smc_clc.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,7 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
10041004
{
10051005
struct smc_connection *conn = &smc->conn;
10061006
struct smc_clc_first_contact_ext_v2x fce;
1007+
struct smcd_dev *smcd = conn->lgr->smcd;
10071008
struct smc_clc_msg_accept_confirm *clc;
10081009
struct smc_clc_fce_gid_ext gle;
10091010
struct smc_clc_msg_trail trl;
@@ -1021,17 +1022,15 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
10211022
memcpy(clc->hdr.eyecatcher, SMCD_EYECATCHER,
10221023
sizeof(SMCD_EYECATCHER));
10231024
clc->hdr.typev1 = SMC_TYPE_D;
1024-
clc->d0.gid =
1025-
conn->lgr->smcd->ops->get_local_gid(conn->lgr->smcd);
1026-
clc->d0.token = conn->rmb_desc->token;
1025+
clc->d0.gid = htonll(smcd->ops->get_local_gid(smcd));
1026+
clc->d0.token = htonll(conn->rmb_desc->token);
10271027
clc->d0.dmbe_size = conn->rmbe_size_comp;
10281028
clc->d0.dmbe_idx = 0;
10291029
memcpy(&clc->d0.linkid, conn->lgr->id, SMC_LGR_ID_SIZE);
10301030
if (version == SMC_V1) {
10311031
clc->hdr.length = htons(SMCD_CLC_ACCEPT_CONFIRM_LEN);
10321032
} else {
1033-
clc_v2->d1.chid =
1034-
htons(smc_ism_get_chid(conn->lgr->smcd));
1033+
clc_v2->d1.chid = htons(smc_ism_get_chid(smcd));
10351034
if (eid && eid[0])
10361035
memcpy(clc_v2->d1.eid, eid, SMC_MAX_EID_LEN);
10371036
len = SMCD_CLC_ACCEPT_CONFIRM_LEN_V2;

net/smc/smc_clc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ struct smcr_clc_msg_accept_confirm { /* SMCR accept/confirm */
204204
} __packed;
205205

206206
struct smcd_clc_msg_accept_confirm_common { /* SMCD accept/confirm */
207-
u64 gid; /* Sender GID */
208-
u64 token; /* DMB token */
207+
__be64 gid; /* Sender GID */
208+
__be64 token; /* DMB token */
209209
u8 dmbe_idx; /* DMBE index */
210210
#if defined(__BIG_ENDIAN_BITFIELD)
211211
u8 dmbe_size : 4, /* buf size (compressed) */

0 commit comments

Comments
 (0)