Skip to content

Commit 6ac1e65

Browse files
GuangguanWangdavem330
authored andcommitted
net/smc: support smc v2.x features validate
Support SMC v2.x features validate for SMC v2.1. This is the frame code for SMC v2.x features validate, and will take effects only when the negotiated release version is v2.1 or later. For Server, v2.x features' validation should be done in smc_clc_srv_ v2x_features_validate when receiving v2.1 or later CLC Proposal Message, such as max conns, max links negotiation, the decision of the final value of max conns and max links should be made in this function. And final check for server when receiving v2.1 or later CLC Confirm Message should be done in smc_clc_v2x_features_confirm_check. For client, v2.x features' validation should be done in smc_clc_clnt_ v2x_features_validate when receiving v2.1 or later CLC Accept Message, for example, the decision to accpt the accepted value or to decline should be made in this function. Signed-off-by: Guangguan Wang <guangguan.wang@linux.alibaba.com> Reviewed-by: Tony Lu <tonylu@linux.alibaba.com> Reviewed-by: Jan Karcher <jaka@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7290178 commit 6ac1e65

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

net/smc/af_smc.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,7 @@ static int smc_connect_rdma_v2_prepare(struct smc_sock *smc,
11991199
(struct smc_clc_msg_accept_confirm_v2 *)aclc;
12001200
struct smc_clc_first_contact_ext *fce =
12011201
smc_get_clc_first_contact_ext(clc_v2, false);
1202+
int rc;
12021203

12031204
if (!ini->first_contact_peer || aclc->hdr.version == SMC_V1)
12041205
return 0;
@@ -1219,6 +1220,9 @@ static int smc_connect_rdma_v2_prepare(struct smc_sock *smc,
12191220
}
12201221

12211222
ini->release_nr = fce->release;
1223+
rc = smc_clc_clnt_v2x_features_validate(fce, ini);
1224+
if (rc)
1225+
return rc;
12221226

12231227
return 0;
12241228
}
@@ -1393,6 +1397,9 @@ static int smc_connect_ism(struct smc_sock *smc,
13931397
smc_get_clc_first_contact_ext(aclc_v2, true);
13941398

13951399
ini->release_nr = fce->release;
1400+
rc = smc_clc_clnt_v2x_features_validate(fce, ini);
1401+
if (rc)
1402+
return rc;
13961403
}
13971404

13981405
rc = smc_v2_determine_accepted_chid(aclc_v2, ini);
@@ -2443,6 +2450,10 @@ static void smc_listen_work(struct work_struct *work)
24432450
if (rc)
24442451
goto out_decl;
24452452

2453+
rc = smc_clc_srv_v2x_features_validate(pclc, ini);
2454+
if (rc)
2455+
goto out_decl;
2456+
24462457
mutex_lock(&smc_server_lgr_pending);
24472458
smc_close_init(new_smc);
24482459
smc_rx_init(new_smc);
@@ -2475,6 +2486,13 @@ static void smc_listen_work(struct work_struct *work)
24752486
goto out_decl;
24762487
}
24772488

2489+
rc = smc_clc_v2x_features_confirm_check(cclc, ini);
2490+
if (rc) {
2491+
if (!ini->is_smcd)
2492+
goto out_unlock;
2493+
goto out_decl;
2494+
}
2495+
24782496
/* finish worker */
24792497
if (!ini->is_smcd) {
24802498
rc = smc_listen_rdma_finish(new_smc, cclc,

net/smc/smc_clc.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,52 @@ int smc_clc_send_accept(struct smc_sock *new_smc, bool srv_first_contact,
11581158
return len > 0 ? 0 : len;
11591159
}
11601160

1161+
int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
1162+
struct smc_init_info *ini)
1163+
{
1164+
struct smc_clc_v2_extension *pclc_v2_ext;
1165+
1166+
if ((!(ini->smcd_version & SMC_V2) && !(ini->smcr_version & SMC_V2)) ||
1167+
ini->release_nr < SMC_RELEASE_1)
1168+
return 0;
1169+
1170+
pclc_v2_ext = smc_get_clc_v2_ext(pclc);
1171+
if (!pclc_v2_ext)
1172+
return SMC_CLC_DECL_NOV2EXT;
1173+
1174+
return 0;
1175+
}
1176+
1177+
int smc_clc_clnt_v2x_features_validate(struct smc_clc_first_contact_ext *fce,
1178+
struct smc_init_info *ini)
1179+
{
1180+
if (ini->release_nr < SMC_RELEASE_1)
1181+
return 0;
1182+
1183+
return 0;
1184+
}
1185+
1186+
int smc_clc_v2x_features_confirm_check(struct smc_clc_msg_accept_confirm *cclc,
1187+
struct smc_init_info *ini)
1188+
{
1189+
struct smc_clc_msg_accept_confirm_v2 *clc_v2 =
1190+
(struct smc_clc_msg_accept_confirm_v2 *)cclc;
1191+
struct smc_clc_first_contact_ext *fce =
1192+
smc_get_clc_first_contact_ext(clc_v2, ini->is_smcd);
1193+
1194+
if (cclc->hdr.version == SMC_V1 ||
1195+
!(cclc->hdr.typev2 & SMC_FIRST_CONTACT_MASK))
1196+
return 0;
1197+
1198+
if (ini->release_nr != fce->release)
1199+
return SMC_CLC_DECL_RELEASEERR;
1200+
1201+
if (fce->release < SMC_RELEASE_1)
1202+
return 0;
1203+
1204+
return 0;
1205+
}
1206+
11611207
void smc_clc_get_hostname(u8 **host)
11621208
{
11631209
*host = &smc_hostname[0];

net/smc/smc_clc.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#define SMC_CLC_DECL_NOSEID 0x03030006 /* peer sent no SEID */
4646
#define SMC_CLC_DECL_NOSMCD2DEV 0x03030007 /* no SMC-Dv2 device found */
4747
#define SMC_CLC_DECL_NOUEID 0x03030008 /* peer sent no UEID */
48+
#define SMC_CLC_DECL_RELEASEERR 0x03030009 /* release version negotiate failed */
4849
#define SMC_CLC_DECL_MODEUNSUPP 0x03040000 /* smc modes do not match (R or D)*/
4950
#define SMC_CLC_DECL_RMBE_EC 0x03050000 /* peer has eyecatcher in RMBE */
5051
#define SMC_CLC_DECL_OPTUNSUPP 0x03060000 /* fastopen sockopt not supported */
@@ -415,6 +416,12 @@ int smc_clc_send_confirm(struct smc_sock *smc, bool clnt_first_contact,
415416
u8 version, u8 *eid, struct smc_init_info *ini);
416417
int smc_clc_send_accept(struct smc_sock *smc, bool srv_first_contact,
417418
u8 version, u8 *negotiated_eid, struct smc_init_info *ini);
419+
int smc_clc_srv_v2x_features_validate(struct smc_clc_msg_proposal *pclc,
420+
struct smc_init_info *ini);
421+
int smc_clc_clnt_v2x_features_validate(struct smc_clc_first_contact_ext *fce,
422+
struct smc_init_info *ini);
423+
int smc_clc_v2x_features_confirm_check(struct smc_clc_msg_accept_confirm *cclc,
424+
struct smc_init_info *ini);
418425
void smc_clc_init(void) __init;
419426
void smc_clc_exit(void);
420427
void smc_clc_get_hostname(u8 **host);

0 commit comments

Comments
 (0)