* [PATCH net-next] ndisc: ndisc_send_redirect() cleanup
@ 2025-02-14 14:07 Eric Dumazet
2025-02-14 15:02 ` David Ahern
2025-02-15 17:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2025-02-14 14:07 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, David Ahern, Simon Horman, eric.dumazet, Eric Dumazet
ndisc_send_redirect() is always called under rcu_read_lock().
It can use dev_net_rcu() and avoid one redundant
rcu_read_lock()/rcu_read_unlock() pair.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ipv6/ndisc.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 8699d1a188dc4a15ac0b65229c4dd19240c9c054..ecb5c4b8518fdd72d0e89640641ec917743e9c72 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1680,7 +1680,7 @@ static void ndisc_fill_redirect_hdr_option(struct sk_buff *skb,
void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
{
struct net_device *dev = skb->dev;
- struct net *net = dev_net(dev);
+ struct net *net = dev_net_rcu(dev);
struct sock *sk = net->ipv6.ndisc_sk;
int optlen = 0;
struct inet_peer *peer;
@@ -1695,8 +1695,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
ops_data_buf[NDISC_OPS_REDIRECT_DATA_SPACE], *ops_data = NULL;
bool ret;
- if (netif_is_l3_master(skb->dev)) {
- dev = dev_get_by_index_rcu(dev_net(skb->dev), IPCB(skb)->iif);
+ if (netif_is_l3_master(dev)) {
+ dev = dev_get_by_index_rcu(net, IPCB(skb)->iif);
if (!dev)
return;
}
@@ -1734,10 +1734,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
goto release;
}
- rcu_read_lock();
peer = inet_getpeer_v6(net->ipv6.peers, &ipv6_hdr(skb)->saddr);
ret = inet_peer_xrlim_allow(peer, 1*HZ);
- rcu_read_unlock();
if (!ret)
goto release;
--
2.48.1.601.g30ceb7b040-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ndisc: ndisc_send_redirect() cleanup
2025-02-14 14:07 [PATCH net-next] ndisc: ndisc_send_redirect() cleanup Eric Dumazet
@ 2025-02-14 15:02 ` David Ahern
2025-02-15 17:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2025-02-14 15:02 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, Simon Horman, eric.dumazet
On 2/14/25 7:07 AM, Eric Dumazet wrote:
> ndisc_send_redirect() is always called under rcu_read_lock().
>
> It can use dev_net_rcu() and avoid one redundant
> rcu_read_lock()/rcu_read_unlock() pair.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
> net/ipv6/ndisc.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
Reviewed-by: David Ahern <dsahern@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] ndisc: ndisc_send_redirect() cleanup
2025-02-14 14:07 [PATCH net-next] ndisc: ndisc_send_redirect() cleanup Eric Dumazet
2025-02-14 15:02 ` David Ahern
@ 2025-02-15 17:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-15 17:30 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, kuba, pabeni, netdev, dsahern, horms, eric.dumazet
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 14 Feb 2025 14:07:05 +0000 you wrote:
> ndisc_send_redirect() is always called under rcu_read_lock().
>
> It can use dev_net_rcu() and avoid one redundant
> rcu_read_lock()/rcu_read_unlock() pair.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
>
> [...]
Here is the summary with links:
- [net-next] ndisc: ndisc_send_redirect() cleanup
https://git.kernel.org/netdev/net-next/c/0784d83df3bf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-15 17:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-14 14:07 [PATCH net-next] ndisc: ndisc_send_redirect() cleanup Eric Dumazet
2025-02-14 15:02 ` David Ahern
2025-02-15 17:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).