Skip to content

Commit b768294

Browse files
edumazetkuba-moo
authored andcommitted
ipv6: Use RCU in ip6_input()
Instead of grabbing rcu_read_lock() from ip6_input_finish(), do it earlier in is caller, so that ip6_input() access to dev_net() can be validated by LOCKDEP. Signed-off-by: Eric Dumazet <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 34aef2b commit b768294

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

net/ipv6/ip6_input.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,19 +477,23 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
477477
static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
478478
{
479479
skb_clear_delivery_time(skb);
480-
rcu_read_lock();
481480
ip6_protocol_deliver_rcu(net, skb, 0, false);
482-
rcu_read_unlock();
483481

484482
return 0;
485483
}
486484

487485

488486
int ip6_input(struct sk_buff *skb)
489487
{
490-
return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_IN,
491-
dev_net(skb->dev), NULL, skb, skb->dev, NULL,
492-
ip6_input_finish);
488+
int res;
489+
490+
rcu_read_lock();
491+
res = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_IN,
492+
dev_net_rcu(skb->dev), NULL, skb, skb->dev, NULL,
493+
ip6_input_finish);
494+
rcu_read_unlock();
495+
496+
return res;
493497
}
494498
EXPORT_SYMBOL_GPL(ip6_input);
495499

0 commit comments

Comments
 (0)