From: Gerd Rausch <gerd.rausch@oracle.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>
Cc: linux-rdma@vger.kernel.org
Subject: [PATCH 1/1] RDMA/addr: Refresh neighbour entries upon "rdma_resolve_addr"
Date: Mon, 06 Jun 2022 12:38:36 -0700 [thread overview]
Message-ID: <eb4e348ec730900a47caeeb08fe4aff903337675.camel@oracle.com> (raw)
Unlike with IPv[46], where "ip_finish_output2" triggers
a refresh of STALE neighbour entries via "neigh_output",
"rdma_resolve_addr" never triggers an update.
If a wrong STALE entry ever enters the cache, it'll remain
wrong forever (unless refreshed via TCP/IP, or otherwise).
Let the cache inconsistency resolve itself by triggering
an update from "rdma_resolve_addr".
Signed-off-by: Gerd Rausch <gerd.rausch@oracle.com>
---
drivers/infiniband/core/addr.c | 40 ++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index f253295795f0..db2a86971e25 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -394,6 +394,8 @@ static int addr4_resolve(struct sockaddr *src_sock,
__be32 dst_ip = dst_in->sin_addr.s_addr;
struct rtable *rt;
struct flowi4 fl4;
+ struct net_device *dev;
+ struct neighbour *neigh;
int ret;
memset(&fl4, 0, sizeof(fl4));
@@ -409,6 +411,24 @@ static int addr4_resolve(struct sockaddr *src_sock,
addr->hoplimit = ip4_dst_hoplimit(&rt->dst);
+ /* trigger ARP-entry refresh if necessary,
+ * the same way "ip_finish_output2" does
+ */
+ if (addr->bound_dev_if) {
+ dev = dev_get_by_index(addr->net, addr->bound_dev_if);
+ } else {
+ dev = rt->dst.dev;
+ dev_hold(dev);
+ }
+ if (dev) {
+ rcu_read_lock_bh();
+ neigh = __ipv4_neigh_lookup_noref(dev, dst_ip);
+ if (neigh)
+ neigh_event_send(neigh, NULL);
+ rcu_read_unlock_bh();
+ dev_put(dev);
+ }
+
*prt = rt;
return 0;
}
@@ -424,6 +444,8 @@ static int addr6_resolve(struct sockaddr *src_sock,
(const struct sockaddr_in6 *)dst_sock;
struct flowi6 fl6;
struct dst_entry *dst;
+ struct net_device *dev;
+ struct neighbour *neigh;
memset(&fl6, 0, sizeof fl6);
fl6.daddr = dst_in->sin6_addr;
@@ -439,6 +461,24 @@ static int addr6_resolve(struct sockaddr *src_sock,
addr->hoplimit = ip6_dst_hoplimit(dst);
+ /* trigger neighbour-entry refresh if necessary,
+ * the same way "ip6_finish_output2" does
+ */
+ if (addr->bound_dev_if) {
+ dev = dev_get_by_index(addr->net, addr->bound_dev_if);
+ } else {
+ dev = dst->dev;
+ dev_hold(dev);
+ }
+ if (dev) {
+ rcu_read_lock_bh();
+ neigh = __ipv6_neigh_lookup_noref(dst->dev, &dst_in->sin6_addr);
+ if (neigh)
+ neigh_event_send(neigh, NULL);
+ rcu_read_unlock_bh();
+ dev_put(dev);
+ }
+
*pdst = dst;
return 0;
}
next reply other threads:[~2022-06-06 19:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-06 19:38 Gerd Rausch [this message]
2022-06-07 8:21 ` [PATCH 1/1] RDMA/addr: Refresh neighbour entries upon "rdma_resolve_addr" kernel test robot
2022-06-16 7:08 ` Leon Romanovsky
2022-06-16 15:50 ` Gerd Rausch
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=eb4e348ec730900a47caeeb08fe4aff903337675.camel@oracle.com \
--to=gerd.rausch@oracle.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-rdma@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.