Skip to content

Commit 031ca0a

Browse files
author
Mete Durlu
committed
net/smc: fix missing byte order conversion in CLC handshake
JIRA: https://issues.redhat.com/browse/RHEL-73484 Conflicts: Code changes necessary to adapt to existing differences to upstream - no functional change commit c5a1039 Author: Wen Gu <guwen@linux.alibaba.com> Date: Thu Dec 7 01:02:37 2023 +0800 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 <guwen@linux.alibaba.com> Reviewed-by: Tony Lu <tonylu@linux.alibaba.com> Reviewed-by: Alexandra Winter <wintera@linux.ibm.com> Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com> Link: https://lore.kernel.org/r/1701882157-87956-1-git-send-email-guwen@linux.alibaba.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Mete Durlu <mdurlu@redhat.com>
1 parent b15c8df commit 031ca0a

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
@@ -692,7 +692,7 @@ static void smcd_conn_save_peer_info(struct smc_sock *smc,
692692
int bufsize = smc_uncompress_bufsize(clc->d0.dmbe_size);
693693

694694
smc->conn.peer_rmbe_idx = clc->d0.dmbe_idx;
695-
smc->conn.peer_token = clc->d0.token;
695+
smc->conn.peer_token = ntohll(clc->d0.token);
696696
/* msg header takes up space in the buffer */
697697
smc->conn.peer_rmbe_size = bufsize - sizeof(struct smcd_cdc_msg);
698698
atomic_set(&smc->conn.peer_rmbe_space, smc->conn.peer_rmbe_size);
@@ -1388,7 +1388,7 @@ static int smc_connect_ism(struct smc_sock *smc,
13881388
if (rc)
13891389
return rc;
13901390
}
1391-
ini->ism_peer_gid[ini->ism_selected] = aclc->d0.gid;
1391+
ini->ism_peer_gid[ini->ism_selected] = ntohll(aclc->d0.gid);
13921392

13931393
/* there is only one lgr role for SMC-D; use server lock */
13941394
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
@@ -1005,6 +1005,7 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
10051005
{
10061006
struct smc_connection *conn = &smc->conn;
10071007
struct smc_clc_first_contact_ext_v2x fce;
1008+
struct smcd_dev *smcd = conn->lgr->smcd;
10081009
struct smc_clc_msg_accept_confirm *clc;
10091010
struct smc_clc_fce_gid_ext gle;
10101011
struct smc_clc_msg_trail trl;
@@ -1022,17 +1023,15 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
10221023
memcpy(clc->hdr.eyecatcher, SMCD_EYECATCHER,
10231024
sizeof(SMCD_EYECATCHER));
10241025
clc->hdr.typev1 = SMC_TYPE_D;
1025-
clc->d0.gid =
1026-
conn->lgr->smcd->ops->get_local_gid(conn->lgr->smcd);
1027-
clc->d0.token = conn->rmb_desc->token;
1026+
clc->d0.gid = htonll(smcd->ops->get_local_gid(smcd));
1027+
clc->d0.token = htonll(conn->rmb_desc->token);
10281028
clc->d0.dmbe_size = conn->rmbe_size_short;
10291029
clc->d0.dmbe_idx = 0;
10301030
memcpy(&clc->d0.linkid, conn->lgr->id, SMC_LGR_ID_SIZE);
10311031
if (version == SMC_V1) {
10321032
clc->hdr.length = htons(SMCD_CLC_ACCEPT_CONFIRM_LEN);
10331033
} else {
1034-
clc_v2->d1.chid =
1035-
htons(smc_ism_get_chid(conn->lgr->smcd));
1034+
clc_v2->d1.chid = htons(smc_ism_get_chid(smcd));
10361035
if (eid && eid[0])
10371036
memcpy(clc_v2->d1.eid, eid, SMC_MAX_EID_LEN);
10381037
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)