Skip to content

Commit

Permalink
net/smc: fix toleration of fake add_link messages
Browse files Browse the repository at this point in the history
Older SMCR implementations had no link failover support and used one
link only. Because the handshake protocol requires to try the
establishment of a second link the old code sent a fake add_link message
and declined any server response afterwards.
The current code supports multiple links and inspects the received fake
add_link message more closely. To tolerate the fake add_link messages
smc_llc_is_local_add_link() needs an improved check of the message to
be able to separate between locally enqueued and fake add_link messages.
And smc_llc_cli_add_link() needs to check if the provided qp_mtu size is
invalid and reject the add_link request in that case.

Fixes: c48254f ("net/smc: move add link processing for new device into llc layer")
Reviewed-by: Ursula Braun <[email protected]>
Signed-off-by: Karsten Graul <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
karstengr authored and davem330 committed Sep 3, 2020
1 parent 5566993 commit fffe83c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion net/smc/smc_llc.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,9 @@ int smc_llc_cli_add_link(struct smc_link *link, struct smc_llc_qentry *qentry)
struct smc_init_info ini;
int lnk_idx, rc = 0;

if (!llc->qp_mtu)
goto out_reject;

ini.vlan_id = lgr->vlan_id;
smc_pnet_find_alt_roce(lgr, &ini, link->smcibdev);
if (!memcmp(llc->sender_gid, link->peer_gid, SMC_GID_SIZE) &&
Expand Down Expand Up @@ -917,10 +920,20 @@ static void smc_llc_cli_add_link_invite(struct smc_link *link,
kfree(qentry);
}

static bool smc_llc_is_empty_llc_message(union smc_llc_msg *llc)
{
int i;

for (i = 0; i < ARRAY_SIZE(llc->raw.data); i++)
if (llc->raw.data[i])
return false;
return true;
}

static bool smc_llc_is_local_add_link(union smc_llc_msg *llc)
{
if (llc->raw.hdr.common.type == SMC_LLC_ADD_LINK &&
!llc->add_link.qp_mtu && !llc->add_link.link_num)
smc_llc_is_empty_llc_message(llc))
return true;
return false;
}
Expand Down

0 comments on commit fffe83c

Please sign in to comment.