From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, Kuniyuki Iwashima <kuniyu@amazon.com>,
Simon Horman <horms@kernel.org>,
eric.dumazet@gmail.com, Eric Dumazet <edumazet@google.com>
Subject: [PATCH v3 net 02/16] ipv4: add RCU protection to ip4_dst_hoplimit()
Date: Tue, 4 Feb 2025 13:23:43 +0000 [thread overview]
Message-ID: <20250204132357.102354-3-edumazet@google.com> (raw)
In-Reply-To: <20250204132357.102354-1-edumazet@google.com>
ip4_dst_hoplimit() must use RCU protection to make
sure the net structure it reads does not disappear.
Fixes: fa50d974d104 ("ipv4: Namespaceify ip_default_ttl sysctl knob")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
include/net/route.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/net/route.h b/include/net/route.h
index f86775be3e2934697533a61f566aca1ef196d74e..c605fd5ec0c08cc7658c3cf6aa6223790d463ede 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -382,10 +382,15 @@ static inline int inet_iif(const struct sk_buff *skb)
static inline int ip4_dst_hoplimit(const struct dst_entry *dst)
{
int hoplimit = dst_metric_raw(dst, RTAX_HOPLIMIT);
- struct net *net = dev_net(dst->dev);
- if (hoplimit == 0)
+ if (hoplimit == 0) {
+ const struct net *net;
+
+ rcu_read_lock();
+ net = dev_net_rcu(dst->dev);
hoplimit = READ_ONCE(net->ipv4.sysctl_ip_default_ttl);
+ rcu_read_unlock();
+ }
return hoplimit;
}
--
2.48.1.362.g079036d154-goog
next prev parent reply other threads:[~2025-02-04 13:24 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-04 13:23 [PATCH v3 net 00/16] net: first round to use dev_net_rcu() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 01/16] net: add dev_net_rcu() helper Eric Dumazet
2025-02-04 13:23 ` Eric Dumazet [this message]
2025-02-04 13:23 ` [PATCH v3 net 03/16] ipv4: use RCU protection in ip_dst_mtu_maybe_forward() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 04/16] ipv4: use RCU protection in ipv4_default_advmss() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 05/16] ipv4: use RCU protection in rt_is_expired() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 06/16] tcp: convert to dev_net_rcu() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 07/16] net: gro: convert four dev_net() calls Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 08/16] udp: convert to dev_net_rcu() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 09/16] ipv4: icmp: " Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 10/16] ipv6: " Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 11/16] ipv6: input: " Eric Dumazet
2025-02-04 20:09 ` Jakub Kicinski
2025-02-04 20:10 ` Eric Dumazet
2025-02-04 21:00 ` Jakub Kicinski
2025-02-04 21:06 ` Eric Dumazet
2025-02-04 21:17 ` Paul E. McKenney
2025-02-04 21:30 ` Jakub Kicinski
2025-02-04 23:25 ` Paul E. McKenney
2025-02-05 7:57 ` Eric Dumazet
2025-02-05 8:05 ` Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 12/16] ipv6: output: " Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 13/16] ipv6: use RCU protection in ip6_default_advmss() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 14/16] net: filter: convert to dev_net_rcu() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 15/16] flow_dissector: use rcu protection to fetch dev_net() Eric Dumazet
2025-02-04 13:23 ` [PATCH v3 net 16/16] ipv4: use RCU protection in inet_select_addr() Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250204132357.102354-3-edumazet@google.com \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).