Commit c5a10397 authored by Wen Gu's avatar Wen Gu Committed by Jakub Kicinski

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: 3d9725a6 ("net/smc: common routine for CLC accept and confirm")
Signed-off-by: default avatarWen Gu <guwen@linux.alibaba.com>
Reviewed-by: default avatarTony Lu <tonylu@linux.alibaba.com>
Reviewed-by: default avatarAlexandra Winter <wintera@linux.ibm.com>
Reviewed-by: default avatarWenjia Zhang <wenjia@linux.ibm.com>
Link: https://lore.kernel.org/r/1701882157-87956-1-git-send-email-guwen@linux.alibaba.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 1499b892
...@@ -723,7 +723,7 @@ static void smcd_conn_save_peer_info(struct smc_sock *smc, ...@@ -723,7 +723,7 @@ static void smcd_conn_save_peer_info(struct smc_sock *smc,
int bufsize = smc_uncompress_bufsize(clc->d0.dmbe_size); int bufsize = smc_uncompress_bufsize(clc->d0.dmbe_size);
smc->conn.peer_rmbe_idx = clc->d0.dmbe_idx; smc->conn.peer_rmbe_idx = clc->d0.dmbe_idx;
smc->conn.peer_token = clc->d0.token; smc->conn.peer_token = ntohll(clc->d0.token);
/* msg header takes up space in the buffer */ /* msg header takes up space in the buffer */
smc->conn.peer_rmbe_size = bufsize - sizeof(struct smcd_cdc_msg); smc->conn.peer_rmbe_size = bufsize - sizeof(struct smcd_cdc_msg);
atomic_set(&smc->conn.peer_rmbe_space, smc->conn.peer_rmbe_size); 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, ...@@ -1415,7 +1415,7 @@ static int smc_connect_ism(struct smc_sock *smc,
if (rc) if (rc)
return rc; return rc;
} }
ini->ism_peer_gid[ini->ism_selected] = aclc->d0.gid; ini->ism_peer_gid[ini->ism_selected] = ntohll(aclc->d0.gid);
/* there is only one lgr role for SMC-D; use server lock */ /* there is only one lgr role for SMC-D; use server lock */
mutex_lock(&smc_server_lgr_pending); mutex_lock(&smc_server_lgr_pending);
......
...@@ -1004,6 +1004,7 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc, ...@@ -1004,6 +1004,7 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
{ {
struct smc_connection *conn = &smc->conn; struct smc_connection *conn = &smc->conn;
struct smc_clc_first_contact_ext_v2x fce; struct smc_clc_first_contact_ext_v2x fce;
struct smcd_dev *smcd = conn->lgr->smcd;
struct smc_clc_msg_accept_confirm *clc; struct smc_clc_msg_accept_confirm *clc;
struct smc_clc_fce_gid_ext gle; struct smc_clc_fce_gid_ext gle;
struct smc_clc_msg_trail trl; struct smc_clc_msg_trail trl;
...@@ -1021,17 +1022,15 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc, ...@@ -1021,17 +1022,15 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
memcpy(clc->hdr.eyecatcher, SMCD_EYECATCHER, memcpy(clc->hdr.eyecatcher, SMCD_EYECATCHER,
sizeof(SMCD_EYECATCHER)); sizeof(SMCD_EYECATCHER));
clc->hdr.typev1 = SMC_TYPE_D; clc->hdr.typev1 = SMC_TYPE_D;
clc->d0.gid = clc->d0.gid = htonll(smcd->ops->get_local_gid(smcd));
conn->lgr->smcd->ops->get_local_gid(conn->lgr->smcd); clc->d0.token = htonll(conn->rmb_desc->token);
clc->d0.token = conn->rmb_desc->token;
clc->d0.dmbe_size = conn->rmbe_size_comp; clc->d0.dmbe_size = conn->rmbe_size_comp;
clc->d0.dmbe_idx = 0; clc->d0.dmbe_idx = 0;
memcpy(&clc->d0.linkid, conn->lgr->id, SMC_LGR_ID_SIZE); memcpy(&clc->d0.linkid, conn->lgr->id, SMC_LGR_ID_SIZE);
if (version == SMC_V1) { if (version == SMC_V1) {
clc->hdr.length = htons(SMCD_CLC_ACCEPT_CONFIRM_LEN); clc->hdr.length = htons(SMCD_CLC_ACCEPT_CONFIRM_LEN);
} else { } else {
clc_v2->d1.chid = clc_v2->d1.chid = htons(smc_ism_get_chid(smcd));
htons(smc_ism_get_chid(conn->lgr->smcd));
if (eid && eid[0]) if (eid && eid[0])
memcpy(clc_v2->d1.eid, eid, SMC_MAX_EID_LEN); memcpy(clc_v2->d1.eid, eid, SMC_MAX_EID_LEN);
len = SMCD_CLC_ACCEPT_CONFIRM_LEN_V2; len = SMCD_CLC_ACCEPT_CONFIRM_LEN_V2;
......
...@@ -204,8 +204,8 @@ struct smcr_clc_msg_accept_confirm { /* SMCR accept/confirm */ ...@@ -204,8 +204,8 @@ struct smcr_clc_msg_accept_confirm { /* SMCR accept/confirm */
} __packed; } __packed;
struct smcd_clc_msg_accept_confirm_common { /* SMCD accept/confirm */ struct smcd_clc_msg_accept_confirm_common { /* SMCD accept/confirm */
u64 gid; /* Sender GID */ __be64 gid; /* Sender GID */
u64 token; /* DMB token */ __be64 token; /* DMB token */
u8 dmbe_idx; /* DMBE index */ u8 dmbe_idx; /* DMBE index */
#if defined(__BIG_ENDIAN_BITFIELD) #if defined(__BIG_ENDIAN_BITFIELD)
u8 dmbe_size : 4, /* buf size (compressed) */ u8 dmbe_size : 4, /* buf size (compressed) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment