Commit cbc137d2 authored by Guvenc Gulce's avatar Guvenc Gulce Committed by Litao Jiao
Browse files

net/smc: Correct smc link connection counter in case of smc client

mainline inclusion
from mainline-v5.14-rc6
commit 64513d26
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I79GVV
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=64513d269e8971aabb7e787955a1b320e3031306



--------------------------------

SMC clients may be assigned to a different link after the initial
connection between two peers was established. In such a case,
the connection counter was not correctly set.

Update the connection counter correctly when a smc client connection
is assigned to a different smc link.

Fixes: 07d51580 ("net/smc: Add connection counters for links")
Signed-off-by: default avatarGuvenc Gulce <guvenc@linux.ibm.com>
Tested-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGengbiao Shen <shengengbiao@sangfor.com.cn>
parent fdfd10be
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -805,7 +805,7 @@ static int smc_connect_rdma(struct smc_sock *smc,
			reason_code = SMC_CLC_DECL_NOSRVLINK;
			goto connect_abort;
		}
		smc->conn.lnk = link;
		smc_switch_link_and_count(&smc->conn, link);
	}

	/* create send buffer and rmb */
+2 −2
Original line number Diff line number Diff line
@@ -532,7 +532,7 @@ static int smc_switch_cursor(struct smc_sock *smc, struct smc_cdc_tx_pend *pend,
	return rc;
}

static void smc_switch_link_and_count(struct smc_connection *conn,
void smc_switch_link_and_count(struct smc_connection *conn,
			       struct smc_link *to_lnk)
{
	atomic_dec(&conn->lnk->conn_cnt);
+2 −0
Original line number Diff line number Diff line
@@ -410,6 +410,8 @@ void smc_core_exit(void);
int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk,
		   u8 link_idx, struct smc_init_info *ini);
void smcr_link_clear(struct smc_link *lnk, bool log);
void smc_switch_link_and_count(struct smc_connection *conn,
			       struct smc_link *to_lnk);
int smcr_buf_map_lgr(struct smc_link *lnk);
int smcr_buf_reg_lgr(struct smc_link *lnk);
void smcr_lgr_set_type(struct smc_link_group *lgr, enum smc_lgr_type new_type);