From: Karsten Graul <kgraul@linux.ibm.com>
To: David Miller <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org,
Heiko Carstens <hca@linux.ibm.com>,
linux-rdma@vger.kernel.org
Subject: [PATCH net-next v2 11/11] net/smc: stop links when their GID is removed
Date: Thu, 14 Oct 2021 18:47:52 +0200 [thread overview]
Message-ID: <20211014164752.3647027-12-kgraul@linux.ibm.com> (raw)
In-Reply-To: <20211014164752.3647027-1-kgraul@linux.ibm.com>
With SMC-Rv2 the GID is an IP address that can be deleted from the
device. When an IB_EVENT_GID_CHANGE event is provided then iterate over
all active links and check if their GID is still defined. Otherwise
stop the affected link.
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
---
net/smc/smc_ib.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c
index 32f9d2fdc474..d93055ec17ae 100644
--- a/net/smc/smc_ib.c
+++ b/net/smc/smc_ib.c
@@ -295,6 +295,58 @@ int smc_ib_determine_gid(struct smc_ib_device *smcibdev, u8 ibport,
return -ENODEV;
}
+/* check if gid is still defined on smcibdev */
+static bool smc_ib_check_link_gid(u8 gid[SMC_GID_SIZE], bool smcrv2,
+ struct smc_ib_device *smcibdev, u8 ibport)
+{
+ const struct ib_gid_attr *attr;
+ bool rc = false;
+ int i;
+
+ for (i = 0; !rc && i < smcibdev->pattr[ibport - 1].gid_tbl_len; i++) {
+ attr = rdma_get_gid_attr(smcibdev->ibdev, ibport, i);
+ if (IS_ERR(attr))
+ continue;
+
+ rcu_read_lock();
+ if ((!smcrv2 && attr->gid_type == IB_GID_TYPE_ROCE) ||
+ (smcrv2 && attr->gid_type == IB_GID_TYPE_ROCE_UDP_ENCAP &&
+ !(ipv6_addr_type((const struct in6_addr *)&attr->gid)
+ & IPV6_ADDR_LINKLOCAL)))
+ if (!memcmp(gid, &attr->gid, SMC_GID_SIZE))
+ rc = true;
+ rcu_read_unlock();
+ rdma_put_gid_attr(attr);
+ }
+ return rc;
+}
+
+/* check all links if the gid is still defined on smcibdev */
+static void smc_ib_gid_check(struct smc_ib_device *smcibdev, u8 ibport)
+{
+ struct smc_link_group *lgr;
+ int i;
+
+ spin_lock_bh(&smc_lgr_list.lock);
+ list_for_each_entry(lgr, &smc_lgr_list.list, list) {
+ if (strncmp(smcibdev->pnetid[ibport - 1], lgr->pnet_id,
+ SMC_MAX_PNETID_LEN))
+ continue; /* lgr is not affected */
+ if (list_empty(&lgr->list))
+ continue;
+ for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++) {
+ if (lgr->lnk[i].state == SMC_LNK_UNUSED ||
+ lgr->lnk[i].smcibdev != smcibdev)
+ continue;
+ if (!smc_ib_check_link_gid(lgr->lnk[i].gid,
+ lgr->smc_version == SMC_V2,
+ smcibdev, ibport))
+ smcr_port_err(smcibdev, ibport);
+ }
+ }
+ spin_unlock_bh(&smc_lgr_list.lock);
+}
+
static int smc_ib_remember_port_attr(struct smc_ib_device *smcibdev, u8 ibport)
{
int rc;
@@ -333,6 +385,7 @@ static void smc_ib_port_event_work(struct work_struct *work)
} else {
clear_bit(port_idx, smcibdev->ports_going_away);
smcr_port_add(smcibdev, port_idx + 1);
+ smc_ib_gid_check(smcibdev, port_idx + 1);
}
}
}
--
2.25.1
next prev parent reply other threads:[~2021-10-14 16:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-14 16:47 [PATCH net-next v2 00/11] net/smc: introduce SMC-Rv2 support Karsten Graul
2021-10-14 16:47 ` [PATCH net-next v2 01/11] net/smc: improved fix wait on already cleared link Karsten Graul
2021-10-14 16:47 ` [PATCH net-next v2 02/11] net/smc: save stack space and allocate smc_init_info Karsten Graul
2021-10-14 16:47 ` [PATCH net-next v2 03/11] net/smc: prepare for SMC-Rv2 connection Karsten Graul
2021-10-14 16:47 ` [PATCH net-next v2 04/11] net/smc: add SMC-Rv2 connection establishment Karsten Graul
2021-10-14 16:47 ` [PATCH net-next v2 05/11] net/smc: add listen processing for SMC-Rv2 Karsten Graul
2021-10-14 16:47 ` [PATCH net-next v2 06/11] net/smc: add v2 format of CLC decline message Karsten Graul
2021-10-14 16:47 ` [PATCH net-next v2 07/11] net/smc: retrieve v2 gid from IB device Karsten Graul
2021-10-14 16:47 ` [PATCH net-next v2 08/11] net/smc: add v2 support to the work request layer Karsten Graul
2021-10-14 16:47 ` [PATCH net-next v2 09/11] net/smc: extend LLC layer for SMC-Rv2 Karsten Graul
2021-10-14 16:47 ` [PATCH net-next v2 10/11] net/smc: add netlink support " Karsten Graul
2021-10-14 16:47 ` Karsten Graul [this message]
2021-10-16 8:03 ` [PATCH net-next v2 00/11] net/smc: introduce SMC-Rv2 support David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211014164752.3647027-12-kgraul@linux.ibm.com \
--to=kgraul@linux.ibm.com \
--cc=davem@davemloft.net \
--cc=hca@linux.ibm.com \
--cc=kuba@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox