Skip to content

Commit

Permalink
ipv6: Use RCU in ip6_input()
Browse files Browse the repository at this point in the history
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 <edumazet@google.com>
Link: https://patch.msgid.link/20250205155120.1676781-13-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Eric Dumazet authored and Jakub Kicinski committed Feb 7, 2025
1 parent 34aef2b commit b768294
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions net/ipv6/ip6_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,19 +477,23 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
{
skb_clear_delivery_time(skb);
rcu_read_lock();
ip6_protocol_deliver_rcu(net, skb, 0, false);
rcu_read_unlock();

return 0;
}


int ip6_input(struct sk_buff *skb)
{
return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_IN,
dev_net(skb->dev), NULL, skb, skb->dev, NULL,
ip6_input_finish);
int res;

rcu_read_lock();
res = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_IN,
dev_net_rcu(skb->dev), NULL, skb, skb->dev, NULL,
ip6_input_finish);
rcu_read_unlock();

return res;
}
EXPORT_SYMBOL_GPL(ip6_input);

Expand Down

0 comments on commit b768294

Please sign in to comment.