Skip to content

Commit 3e0c40a

Browse files
karstengrdavem330
authored andcommitted
net/smc: add termination reason and handle LLC protocol violation
Allow to set the reason code for the link group termination, and set meaningful values before termination processing is triggered. This reason code is sent to the peer in the final delete link message. When the LLC request or response layer receives a message type that was not handled, drop a warning and terminate the link group. Signed-off-by: Karsten Graul <[email protected]> Reviewed-by: Ursula Braun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ad6c111 commit 3e0c40a

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

net/smc/smc_core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,11 @@ static void smc_lgr_cleanup(struct smc_link_group *lgr)
878878
smc_ism_put_vlan(lgr->smcd, lgr->vlan_id);
879879
put_device(&lgr->smcd->dev);
880880
} else {
881-
smc_llc_send_link_delete_all(lgr, false,
882-
SMC_LLC_DEL_OP_INIT_TERM);
881+
u32 rsn = lgr->llc_termination_rsn;
882+
883+
if (!rsn)
884+
rsn = SMC_LLC_DEL_PROG_INIT_TERM;
885+
smc_llc_send_link_delete_all(lgr, false, rsn);
883886
for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++) {
884887
struct smc_link *lnk = &lgr->lnk[i];
885888

@@ -1018,6 +1021,7 @@ void smc_smcr_terminate_all(struct smc_ib_device *smcibdev)
10181021

10191022
list_for_each_entry_safe(lgr, lg, &lgr_free_list, list) {
10201023
list_del_init(&lgr->list);
1024+
smc_llc_set_termination_rsn(lgr, SMC_LLC_DEL_OP_INIT_TERM);
10211025
__smc_lgr_terminate(lgr, false);
10221026
}
10231027

net/smc/smc_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ struct smc_link_group {
271271
/* protects llc flow */
272272
int llc_testlink_time;
273273
/* link keep alive time */
274+
u32 llc_termination_rsn;
275+
/* rsn code for termination */
274276
};
275277
struct { /* SMC-D */
276278
u64 peer_gid;

net/smc/smc_llc.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,14 @@ static void smc_llc_rmt_delete_rkey(struct smc_link_group *lgr)
14201420
smc_llc_flow_qentry_del(&lgr->llc_flow_rmt);
14211421
}
14221422

1423+
static void smc_llc_protocol_violation(struct smc_link_group *lgr, u8 type)
1424+
{
1425+
pr_warn_ratelimited("smc: SMC-R lg %*phN LLC protocol violation: "
1426+
"llc_type %d\n", SMC_LGR_ID_SIZE, &lgr->id, type);
1427+
smc_llc_set_termination_rsn(lgr, SMC_LLC_DEL_PROT_VIOL);
1428+
smc_lgr_terminate_sched(lgr);
1429+
}
1430+
14231431
/* flush the llc event queue */
14241432
static void smc_llc_event_flush(struct smc_link_group *lgr)
14251433
{
@@ -1520,6 +1528,9 @@ static void smc_llc_event_handler(struct smc_llc_qentry *qentry)
15201528
smc_llc_flow_stop(lgr, &lgr->llc_flow_rmt);
15211529
}
15221530
return;
1531+
default:
1532+
smc_llc_protocol_violation(lgr, llc->raw.hdr.common.type);
1533+
break;
15231534
}
15241535
out:
15251536
kfree(qentry);
@@ -1579,6 +1590,9 @@ static void smc_llc_rx_response(struct smc_link *link,
15791590
case SMC_LLC_CONFIRM_RKEY_CONT:
15801591
/* not used because max links is 3 */
15811592
break;
1593+
default:
1594+
smc_llc_protocol_violation(link->lgr, llc_type);
1595+
break;
15821596
}
15831597
kfree(qentry);
15841598
}

net/smc/smc_llc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ static inline struct smc_link *smc_llc_usable_link(struct smc_link_group *lgr)
6060
return NULL;
6161
}
6262

63+
/* set the termination reason code for the link group */
64+
static inline void smc_llc_set_termination_rsn(struct smc_link_group *lgr,
65+
u32 rsn)
66+
{
67+
if (!lgr->llc_termination_rsn)
68+
lgr->llc_termination_rsn = rsn;
69+
}
70+
6371
/* transmit */
6472
int smc_llc_send_confirm_link(struct smc_link *lnk,
6573
enum smc_llc_reqresp reqresp);

0 commit comments

Comments
 (0)