Commit 9d5447ed authored by Louis Peens's avatar Louis Peens Committed by David S. Miller

nfp: flower: fixup ipv6/ipv4 route lookup for neigh events

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: default avatarLouis Peens <louis.peens@corigine.com>
Signed-off-by: default avatarYinjun Zhang <yinjun.zhang@corigine.com>
Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 38fc158e
...@@ -494,7 +494,7 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event, ...@@ -494,7 +494,7 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event,
struct flowi6 flow6 = {}; struct flowi6 flow6 = {};
struct neighbour *n; struct neighbour *n;
struct nfp_app *app; struct nfp_app *app;
struct rtable *rt; bool neigh_invalid;
bool ipv6 = false; bool ipv6 = false;
int err; int err;
...@@ -513,6 +513,8 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event, ...@@ -513,6 +513,8 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event,
if (n->tbl->family == AF_INET6) if (n->tbl->family == AF_INET6)
ipv6 = true; ipv6 = true;
neigh_invalid = !(n->nud_state & NUD_VALID) || n->dead;
if (ipv6) if (ipv6)
flow6.daddr = *(struct in6_addr *)n->primary_key; flow6.daddr = *(struct in6_addr *)n->primary_key;
else else
...@@ -533,29 +535,41 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event, ...@@ -533,29 +535,41 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event,
#if IS_ENABLED(CONFIG_INET) #if IS_ENABLED(CONFIG_INET)
if (ipv6) { if (ipv6) {
#if IS_ENABLED(CONFIG_IPV6) #if IS_ENABLED(CONFIG_IPV6)
struct dst_entry *dst; if (!neigh_invalid) {
struct dst_entry *dst;
dst = ipv6_stub->ipv6_dst_lookup_flow(dev_net(n->dev), NULL, /* Use ipv6_dst_lookup_flow to populate flow6->saddr
&flow6, NULL); * and other fields. This information is only needed
if (IS_ERR(dst)) * for new entries, lookup can be skipped when an entry
return NOTIFY_DONE; * gets invalidated - as only the daddr is needed for
* deleting.
dst_release(dst); */
flow6.flowi6_proto = IPPROTO_UDP; 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); nfp_tun_write_neigh_v6(n->dev, app, &flow6, n, GFP_ATOMIC);
#else #else
return NOTIFY_DONE; return NOTIFY_DONE;
#endif /* CONFIG_IPV6 */ #endif /* CONFIG_IPV6 */
} else { } else {
/* Do a route lookup to populate flow data. */ if (!neigh_invalid) {
rt = ip_route_output_key(dev_net(n->dev), &flow4); struct rtable *rt;
err = PTR_ERR_OR_ZERO(rt); /* Use ip_route_output_key to populate flow4->saddr and
if (err) * other fields. This information is only needed for
return NOTIFY_DONE; * new entries, lookup can be skipped when an entry
* gets invalidated - as only the daddr is needed for
ip_rt_put(rt); * deleting.
*/
flow4.flowi4_proto = IPPROTO_UDP; 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); nfp_tun_write_neigh_v4(n->dev, app, &flow4, n, GFP_ATOMIC);
} }
#else #else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment