diff mbox series

[net] net/smc: fix missing byte order conversion in CLC handshake

Message ID 1701882157-87956-1-git-send-email-guwen@linux.alibaba.com (mailing list archive)
State Accepted
Commit c5a10397d4571bcfd4bd7ca211ee47bcb6792ec3
Delegated to: Netdev Maintainers
Headers show
Series [net] net/smc: fix missing byte order conversion in CLC handshake | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success SINGLE THREAD; Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1115 this patch: 1115
netdev/cc_maintainers success CCed 12 of 12 maintainers
netdev/build_clang success Errors and warnings before: 1142 this patch: 1142
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1142 this patch: 1142
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 53 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Wen Gu Dec. 6, 2023, 5:02 p.m. UTC
The byte order conversions of ISM GID and DMB token are missing in
process of CLC accept and confirm. So fix it.

Fixes: 3d9725a6a133 ("net/smc: common routine for CLC accept and confirm")
Signed-off-by: Wen Gu <guwen@linux.alibaba.com>
---
 net/smc/af_smc.c  | 4 ++--
 net/smc/smc_clc.c | 9 ++++-----
 net/smc/smc_clc.h | 4 ++--
 3 files changed, 8 insertions(+), 9 deletions(-)

Comments

Tony Lu Dec. 7, 2023, 6:02 a.m. UTC | #1
On Thu, Dec 07, 2023 at 01:02:37AM +0800, Wen Gu wrote:
> The byte order conversions of ISM GID and DMB token are missing in
> process of CLC accept and confirm. So fix it.
> 
> Fixes: 3d9725a6a133 ("net/smc: common routine for CLC accept and confirm")
> Signed-off-by: Wen Gu <guwen@linux.alibaba.com>

LGTM.

Reviewed-by: Tony Lu <tonylu@linux.alibaba.com>

> ---
>  net/smc/af_smc.c  | 4 ++--
>  net/smc/smc_clc.c | 9 ++++-----
>  net/smc/smc_clc.h | 4 ++--
>  3 files changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index c61666e..7fc2f3c 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c
> @@ -723,7 +723,7 @@ static void smcd_conn_save_peer_info(struct smc_sock *smc,
>  	int bufsize = smc_uncompress_bufsize(clc->d0.dmbe_size);
>  
>  	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 */
>  	smc->conn.peer_rmbe_size = bufsize - sizeof(struct smcd_cdc_msg);
>  	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,
>  		if (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 */
>  	mutex_lock(&smc_server_lgr_pending);
> diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
> index 0fda515..95e19aa 100644
> --- a/net/smc/smc_clc.c
> +++ b/net/smc/smc_clc.c
> @@ -1005,6 +1005,7 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
>  {
>  	struct smc_connection *conn = &smc->conn;
>  	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_fce_gid_ext gle;
>  	struct smc_clc_msg_trail trl;
> @@ -1022,17 +1023,15 @@ static int smc_clc_send_confirm_accept(struct smc_sock *smc,
>  		memcpy(clc->hdr.eyecatcher, SMCD_EYECATCHER,
>  		       sizeof(SMCD_EYECATCHER));
>  		clc->hdr.typev1 = SMC_TYPE_D;
> -		clc->d0.gid =
> -			conn->lgr->smcd->ops->get_local_gid(conn->lgr->smcd);
> -		clc->d0.token = conn->rmb_desc->token;
> +		clc->d0.gid = htonll(smcd->ops->get_local_gid(smcd));
> +		clc->d0.token = htonll(conn->rmb_desc->token);
>  		clc->d0.dmbe_size = conn->rmbe_size_comp;
>  		clc->d0.dmbe_idx = 0;
>  		memcpy(&clc->d0.linkid, conn->lgr->id, SMC_LGR_ID_SIZE);
>  		if (version == SMC_V1) {
>  			clc->hdr.length = htons(SMCD_CLC_ACCEPT_CONFIRM_LEN);
>  		} else {
> -			clc_v2->d1.chid =
> -				htons(smc_ism_get_chid(conn->lgr->smcd));
> +			clc_v2->d1.chid = htons(smc_ism_get_chid(smcd));
>  			if (eid && eid[0])
>  				memcpy(clc_v2->d1.eid, eid, SMC_MAX_EID_LEN);
>  			len = SMCD_CLC_ACCEPT_CONFIRM_LEN_V2;
> diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h
> index 89b258c..1697b84 100644
> --- a/net/smc/smc_clc.h
> +++ b/net/smc/smc_clc.h
> @@ -204,8 +204,8 @@ struct smcr_clc_msg_accept_confirm {	/* SMCR accept/confirm */
>  } __packed;
>  
>  struct smcd_clc_msg_accept_confirm_common {	/* SMCD accept/confirm */
> -	u64 gid;		/* Sender GID */
> -	u64 token;		/* DMB token */
> +	__be64 gid;		/* Sender GID */
> +	__be64 token;		/* DMB token */
>  	u8 dmbe_idx;		/* DMBE index */
>  #if defined(__BIG_ENDIAN_BITFIELD)
>  	u8 dmbe_size : 4,	/* buf size (compressed) */
> -- 
> 1.8.3.1
Alexandra Winter Dec. 7, 2023, 1:12 p.m. UTC | #2
On 06.12.23 18:02, Wen Gu wrote:
> The byte order conversions of ISM GID and DMB token are missing in
> process of CLC accept and confirm. So fix it.
> 
> Fixes: 3d9725a6a133 ("net/smc: common routine for CLC accept and confirm")
> Signed-off-by: Wen Gu <guwen@linux.alibaba.com>
> ---

Thank you
Reviewed-by: Alexandra Winter <wintera@linux.ibm.com>
Wenjia Zhang Dec. 7, 2023, 2:48 p.m. UTC | #3
On 07.12.23 14:12, Wen Gu wrote:

> The byte order conversions of ISM GID and DMB token are missing in
> process of CLC accept and confirm. So fix it.
>
> Fixes: 3d9725a6a133 ("net/smc: common routine for CLC accept and confirm")
> Signed-off-by: Wen Gu <guwen@linux.alibaba.com>
> ---

[...]

LGTM, thank you!

Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com>
patchwork-bot+netdevbpf@kernel.org Dec. 7, 2023, 6:20 p.m. UTC | #4
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  7 Dec 2023 01:02:37 +0800 you wrote:
> The byte order conversions of ISM GID and DMB token are missing in
> process of CLC accept and confirm. So fix it.
> 
> Fixes: 3d9725a6a133 ("net/smc: common routine for CLC accept and confirm")
> Signed-off-by: Wen Gu <guwen@linux.alibaba.com>
> ---
>  net/smc/af_smc.c  | 4 ++--
>  net/smc/smc_clc.c | 9 ++++-----
>  net/smc/smc_clc.h | 4 ++--
>  3 files changed, 8 insertions(+), 9 deletions(-)

Here is the summary with links:
  - [net] net/smc: fix missing byte order conversion in CLC handshake
    https://git.kernel.org/netdev/net/c/c5a10397d457

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index c61666e..7fc2f3c 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -723,7 +723,7 @@  static void smcd_conn_save_peer_info(struct smc_sock *smc,
 	int bufsize = smc_uncompress_bufsize(clc->d0.dmbe_size);
 
 	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 */
 	smc->conn.peer_rmbe_size = bufsize - sizeof(struct smcd_cdc_msg);
 	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,
 		if (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 */
 	mutex_lock(&smc_server_lgr_pending);
diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
index 0fda515..95e19aa 100644
--- a/net/smc/smc_clc.c
+++ b/net/smc/smc_clc.c
@@ -1005,6 +1005,7 @@  static int smc_clc_send_confirm_accept(struct smc_sock *smc,
 {
 	struct smc_connection *conn = &smc->conn;
 	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_fce_gid_ext gle;
 	struct smc_clc_msg_trail trl;
@@ -1022,17 +1023,15 @@  static int smc_clc_send_confirm_accept(struct smc_sock *smc,
 		memcpy(clc->hdr.eyecatcher, SMCD_EYECATCHER,
 		       sizeof(SMCD_EYECATCHER));
 		clc->hdr.typev1 = SMC_TYPE_D;
-		clc->d0.gid =
-			conn->lgr->smcd->ops->get_local_gid(conn->lgr->smcd);
-		clc->d0.token = conn->rmb_desc->token;
+		clc->d0.gid = htonll(smcd->ops->get_local_gid(smcd));
+		clc->d0.token = htonll(conn->rmb_desc->token);
 		clc->d0.dmbe_size = conn->rmbe_size_comp;
 		clc->d0.dmbe_idx = 0;
 		memcpy(&clc->d0.linkid, conn->lgr->id, SMC_LGR_ID_SIZE);
 		if (version == SMC_V1) {
 			clc->hdr.length = htons(SMCD_CLC_ACCEPT_CONFIRM_LEN);
 		} else {
-			clc_v2->d1.chid =
-				htons(smc_ism_get_chid(conn->lgr->smcd));
+			clc_v2->d1.chid = htons(smc_ism_get_chid(smcd));
 			if (eid && eid[0])
 				memcpy(clc_v2->d1.eid, eid, SMC_MAX_EID_LEN);
 			len = SMCD_CLC_ACCEPT_CONFIRM_LEN_V2;
diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h
index 89b258c..1697b84 100644
--- a/net/smc/smc_clc.h
+++ b/net/smc/smc_clc.h
@@ -204,8 +204,8 @@  struct smcr_clc_msg_accept_confirm {	/* SMCR accept/confirm */
 } __packed;
 
 struct smcd_clc_msg_accept_confirm_common {	/* SMCD accept/confirm */
-	u64 gid;		/* Sender GID */
-	u64 token;		/* DMB token */
+	__be64 gid;		/* Sender GID */
+	__be64 token;		/* DMB token */
 	u8 dmbe_idx;		/* DMBE index */
 #if defined(__BIG_ENDIAN_BITFIELD)
 	u8 dmbe_size : 4,	/* buf size (compressed) */