Skip to content

Commit 67f415d

Browse files
tracywwnjdavem330
authored andcommitted
ipv6: convert rx data path to not take refcnt on dst
ip6_route_input() is the key function to do the route lookup in the rx data path. All the callers to this function are already holding rcu lock. So it is fairly easy to convert it to not take refcnt on the dst: We pass in flag RT6_LOOKUP_F_DST_NOREF and do skb_dst_set_noref(). This saves a few atomic inc or dec operations and should boost performance overall. This also makes the logic more aligned with v4. Signed-off-by: Wei Wang <[email protected]> Acked-by: Eric Dumazet <[email protected]> Acked-by: Mahesh Bandewar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d64a1f5 commit 67f415d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net/ipv6/route.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,11 +2375,12 @@ u32 rt6_multipath_hash(const struct net *net, const struct flowi6 *fl6,
23752375
return mhash >> 1;
23762376
}
23772377

2378+
/* Called with rcu held */
23782379
void ip6_route_input(struct sk_buff *skb)
23792380
{
23802381
const struct ipv6hdr *iph = ipv6_hdr(skb);
23812382
struct net *net = dev_net(skb->dev);
2382-
int flags = RT6_LOOKUP_F_HAS_SADDR;
2383+
int flags = RT6_LOOKUP_F_HAS_SADDR | RT6_LOOKUP_F_DST_NOREF;
23832384
struct ip_tunnel_info *tun_info;
23842385
struct flowi6 fl6 = {
23852386
.flowi6_iif = skb->dev->ifindex,
@@ -2401,8 +2402,8 @@ void ip6_route_input(struct sk_buff *skb)
24012402
if (unlikely(fl6.flowi6_proto == IPPROTO_ICMPV6))
24022403
fl6.mp_hash = rt6_multipath_hash(net, &fl6, skb, flkeys);
24032404
skb_dst_drop(skb);
2404-
skb_dst_set(skb,
2405-
ip6_route_input_lookup(net, skb->dev, &fl6, skb, flags));
2405+
skb_dst_set_noref(skb, ip6_route_input_lookup(net, skb->dev,
2406+
&fl6, skb, flags));
24062407
}
24072408

24082409
static struct rt6_info *ip6_pol_route_output(struct net *net,

0 commit comments

Comments
 (0)