Skip to content

Commit 9d5447e

Browse files
louis-peensdavem330
authored andcommitted
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: Louis Peens <[email protected]> Signed-off-by: Yinjun Zhang <[email protected]> Signed-off-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 38fc158 commit 9d5447e

File tree

1 file changed

+33
-19
lines changed

1 file changed

+33
-19
lines changed

drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event,
494494
struct flowi6 flow6 = {};
495495
struct neighbour *n;
496496
struct nfp_app *app;
497-
struct rtable *rt;
497+
bool neigh_invalid;
498498
bool ipv6 = false;
499499
int err;
500500

@@ -513,6 +513,8 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event,
513513
if (n->tbl->family == AF_INET6)
514514
ipv6 = true;
515515

516+
neigh_invalid = !(n->nud_state & NUD_VALID) || n->dead;
517+
516518
if (ipv6)
517519
flow6.daddr = *(struct in6_addr *)n->primary_key;
518520
else
@@ -533,29 +535,41 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event,
533535
#if IS_ENABLED(CONFIG_INET)
534536
if (ipv6) {
535537
#if IS_ENABLED(CONFIG_IPV6)
536-
struct dst_entry *dst;
537-
538-
dst = ipv6_stub->ipv6_dst_lookup_flow(dev_net(n->dev), NULL,
539-
&flow6, NULL);
540-
if (IS_ERR(dst))
541-
return NOTIFY_DONE;
542-
543-
dst_release(dst);
544-
flow6.flowi6_proto = IPPROTO_UDP;
538+
if (!neigh_invalid) {
539+
struct dst_entry *dst;
540+
/* Use ipv6_dst_lookup_flow to populate flow6->saddr
541+
* and other fields. This information is only needed
542+
* for new entries, lookup can be skipped when an entry
543+
* gets invalidated - as only the daddr is needed for
544+
* deleting.
545+
*/
546+
dst = ip6_dst_lookup_flow(dev_net(n->dev), NULL,
547+
&flow6, NULL);
548+
if (IS_ERR(dst))
549+
return NOTIFY_DONE;
550+
551+
dst_release(dst);
552+
}
545553
nfp_tun_write_neigh_v6(n->dev, app, &flow6, n, GFP_ATOMIC);
546554
#else
547555
return NOTIFY_DONE;
548556
#endif /* CONFIG_IPV6 */
549557
} else {
550-
/* Do a route lookup to populate flow data. */
551-
rt = ip_route_output_key(dev_net(n->dev), &flow4);
552-
err = PTR_ERR_OR_ZERO(rt);
553-
if (err)
554-
return NOTIFY_DONE;
555-
556-
ip_rt_put(rt);
557-
558-
flow4.flowi4_proto = IPPROTO_UDP;
558+
if (!neigh_invalid) {
559+
struct rtable *rt;
560+
/* Use ip_route_output_key to populate flow4->saddr and
561+
* other fields. This information is only needed for
562+
* new entries, lookup can be skipped when an entry
563+
* gets invalidated - as only the daddr is needed for
564+
* deleting.
565+
*/
566+
rt = ip_route_output_key(dev_net(n->dev), &flow4);
567+
err = PTR_ERR_OR_ZERO(rt);
568+
if (err)
569+
return NOTIFY_DONE;
570+
571+
ip_rt_put(rt);
572+
}
559573
nfp_tun_write_neigh_v4(n->dev, app, &flow4, n, GFP_ATOMIC);
560574
}
561575
#else

0 commit comments

Comments
 (0)