netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: David Miller <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, oss-drivers@corigine.com
Subject: [PATCH net-next 4/9] nfp: flower: fixup ipv6/ipv4 route lookup for neigh events
Date: Thu,  5 May 2022 14:43:43 +0900	[thread overview]
Message-ID: <20220505054348.269511-5-simon.horman@corigine.com> (raw)
In-Reply-To: <20220505054348.269511-1-simon.horman@corigine.com>

From: Louis Peens <louis.peens@corigine.com>

When a callback is received to invalidate a neighbour entry
there is no need to try and populate any other flow information.
Only the flowX->daddr information is needed as lookup key to delete
an entry from the NFP neighbour table. Fix this by only doing the
lookup if the callback is for a new entry.

As part of this cleanup remove the setting of flow6.flowi6_proto, as
this is not needed either, it looks to be a possible leftover from a
previous implementation.

Signed-off-by: Louis Peens <louis.peens@corigine.com>
Signed-off-by: Yinjun Zhang <yinjun.zhang@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
---
 .../netronome/nfp/flower/tunnel_conf.c        | 52 ++++++++++++-------
 1 file changed, 33 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
index f5e8ed14e517..0cb016afbab3 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
@@ -494,7 +494,7 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event,
 	struct flowi6 flow6 = {};
 	struct neighbour *n;
 	struct nfp_app *app;
-	struct rtable *rt;
+	bool neigh_invalid;
 	bool ipv6 = false;
 	int err;
 
@@ -513,6 +513,8 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event,
 	if (n->tbl->family == AF_INET6)
 		ipv6 = true;
 
+	neigh_invalid = !(n->nud_state & NUD_VALID) || n->dead;
+
 	if (ipv6)
 		flow6.daddr = *(struct in6_addr *)n->primary_key;
 	else
@@ -533,29 +535,41 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event,
 #if IS_ENABLED(CONFIG_INET)
 	if (ipv6) {
 #if IS_ENABLED(CONFIG_IPV6)
-		struct dst_entry *dst;
-
-		dst = ipv6_stub->ipv6_dst_lookup_flow(dev_net(n->dev), NULL,
-						      &flow6, NULL);
-		if (IS_ERR(dst))
-			return NOTIFY_DONE;
-
-		dst_release(dst);
-		flow6.flowi6_proto = IPPROTO_UDP;
+		if (!neigh_invalid) {
+			struct dst_entry *dst;
+			/* Use ipv6_dst_lookup_flow to populate flow6->saddr
+			 * and other fields. This information is only needed
+			 * for new entries, lookup can be skipped when an entry
+			 * gets invalidated - as only the daddr is needed for
+			 * deleting.
+			 */
+			dst = ip6_dst_lookup_flow(dev_net(n->dev), NULL,
+						  &flow6, NULL);
+			if (IS_ERR(dst))
+				return NOTIFY_DONE;
+
+			dst_release(dst);
+		}
 		nfp_tun_write_neigh_v6(n->dev, app, &flow6, n, GFP_ATOMIC);
 #else
 		return NOTIFY_DONE;
 #endif /* CONFIG_IPV6 */
 	} else {
-		/* Do a route lookup to populate flow data. */
-		rt = ip_route_output_key(dev_net(n->dev), &flow4);
-		err = PTR_ERR_OR_ZERO(rt);
-		if (err)
-			return NOTIFY_DONE;
-
-		ip_rt_put(rt);
-
-		flow4.flowi4_proto = IPPROTO_UDP;
+		if (!neigh_invalid) {
+			struct rtable *rt;
+			/* Use ip_route_output_key to populate flow4->saddr and
+			 * other fields. This information is only needed for
+			 * new entries, lookup can be skipped when an entry
+			 * gets invalidated - as only the daddr is needed for
+			 * deleting.
+			 */
+			rt = ip_route_output_key(dev_net(n->dev), &flow4);
+			err = PTR_ERR_OR_ZERO(rt);
+			if (err)
+				return NOTIFY_DONE;
+
+			ip_rt_put(rt);
+		}
 		nfp_tun_write_neigh_v4(n->dev, app, &flow4, n, GFP_ATOMIC);
 	}
 #else
-- 
2.30.2


  parent reply	other threads:[~2022-05-05  5:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05  5:43 [PATCH net-next 0/9] nfp: flower: decap neighbour table rework Simon Horman
2022-05-05  5:43 ` [PATCH net-next 1/9] nfp: flower: add infrastructure for pre_tun rework Simon Horman
2022-05-05  5:43 ` [PATCH net-next 2/9] nfp: flower: add/remove predt_list entries Simon Horman
2022-05-05  5:43 ` [PATCH net-next 3/9] nfp: flower: enforce more strict pre_tun checks Simon Horman
2022-05-05  5:43 ` Simon Horman [this message]
2022-05-05  5:43 ` [PATCH net-next 5/9] nfp: flower: update nfp_tun_neigh structs Simon Horman
2022-05-05  5:43 ` [PATCH net-next 6/9] nfp: flower: rework tunnel neighbour configuration Simon Horman
2022-05-05  5:43 ` [PATCH net-next 7/9] nfp: flower: link pre_tun flow rules with neigh entries Simon Horman
2022-05-05  5:43 ` [PATCH net-next 8/9] nfp: flower: remove unused neighbour cache Simon Horman
2022-05-05  5:43 ` [PATCH net-next 9/9] nfp: flower: enable decap_v2 bit Simon Horman
2022-05-06 10:40 ` [PATCH net-next 0/9] nfp: flower: decap neighbour table rework patchwork-bot+netdevbpf

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=20220505054348.269511-5-simon.horman@corigine.com \
    --to=simon.horman@corigine.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@corigine.com \
    /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;
as well as URLs for NNTP newsgroup(s).