From: Ido Schimmel <idosch@idosch.org>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, Simon Horman <horms@kernel.org>,
David Ahern <dsahern@kernel.org>,
Kuniyuki Iwashima <kuniyu@amazon.com>,
eric.dumazet@gmail.com
Subject: Re: [PATCH net-next 4/4] inetpeer: do not get a refcount in inet_getpeer()
Date: Sun, 15 Dec 2024 17:48:53 +0200 [thread overview]
Message-ID: <Z176ZdYvXpwm6bpa@shredder> (raw)
In-Reply-To: <20241213130212.1783302-5-edumazet@google.com>
On Fri, Dec 13, 2024 at 01:02:12PM +0000, Eric Dumazet wrote:
> diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
> index 5eeb9f569a706cf2766d74bcf1a667c8930804f2..7a1b1af2edcae0b0648ef3c3411b4ef36e6d9b14 100644
> --- a/net/ipv4/icmp.c
> +++ b/net/ipv4/icmp.c
> @@ -322,11 +322,11 @@ static bool icmpv4_xrlim_allow(struct net *net, struct rtable *rt,
> goto out;
>
> vif = l3mdev_master_ifindex(dst->dev);
> + rcu_read_lock();
> peer = inet_getpeer_v4(net->ipv4.peers, fl4->daddr, vif);
> rc = inet_peer_xrlim_allow(peer,
> READ_ONCE(net->ipv4.sysctl_icmp_ratelimit));
> - if (peer)
> - inet_putpeer(peer);
> + rcu_read_unlock();
> out:
> if (!rc)
> __ICMP_INC_STATS(net, ICMP_MIB_RATELIMITHOST);
Maybe convert l3mdev_master_ifindex() to l3mdev_master_ifindex_rcu() and
move it into the RCU critical section?
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 7a1b1af2edca..094084b61bff 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -312,7 +312,6 @@ static bool icmpv4_xrlim_allow(struct net *net, struct rtable *rt,
struct dst_entry *dst = &rt->dst;
struct inet_peer *peer;
bool rc = true;
- int vif;
if (!apply_ratelimit)
return true;
@@ -321,9 +320,9 @@ static bool icmpv4_xrlim_allow(struct net *net, struct rtable *rt,
if (dst->dev && (dst->dev->flags&IFF_LOOPBACK))
goto out;
- vif = l3mdev_master_ifindex(dst->dev);
rcu_read_lock();
- peer = inet_getpeer_v4(net->ipv4.peers, fl4->daddr, vif);
+ peer = inet_getpeer_v4(net->ipv4.peers, fl4->daddr,
+ l3mdev_master_ifindex_rcu(dst->dev));
rc = inet_peer_xrlim_allow(peer,
READ_ONCE(net->ipv4.sysctl_icmp_ratelimit));
rcu_read_unlock();
[...]
> @@ -975,9 +975,9 @@ static int ip_error(struct sk_buff *skb)
> break;
> }
>
> + rcu_read_lock();
> peer = inet_getpeer_v4(net->ipv4.peers, ip_hdr(skb)->saddr,
> l3mdev_master_ifindex(skb->dev));
> -
> send = true;
> if (peer) {
> now = jiffies;
And here?
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index d2086648dcf1..9f9d4e6ea1b9 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -977,7 +977,7 @@ static int ip_error(struct sk_buff *skb)
rcu_read_lock();
peer = inet_getpeer_v4(net->ipv4.peers, ip_hdr(skb)->saddr,
- l3mdev_master_ifindex(skb->dev));
+ l3mdev_master_ifindex_rcu(skb->dev));
send = true;
if (peer) {
now = jiffies;
next prev parent reply other threads:[~2024-12-15 15:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-13 13:02 [PATCH net-next 0/4] inetpeer: reduce false sharing and atomic operations Eric Dumazet
2024-12-13 13:02 ` [PATCH net-next 1/4] inetpeer: remove create argument of inet_getpeer_v[46]() Eric Dumazet
2024-12-13 13:02 ` [PATCH net-next 2/4] inetpeer: remove create argument of inet_getpeer() Eric Dumazet
2024-12-13 20:16 ` Simon Horman
2024-12-13 20:47 ` Eric Dumazet
2024-12-14 14:34 ` kernel test robot
2024-12-13 13:02 ` [PATCH net-next 3/4] inetpeer: update inetpeer timestamp in inet_getpeer() Eric Dumazet
2024-12-15 15:34 ` Ido Schimmel
2024-12-13 13:02 ` [PATCH net-next 4/4] inetpeer: do not get a refcount " Eric Dumazet
2024-12-15 15:48 ` Ido Schimmel [this message]
2024-12-15 17:42 ` 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=Z176ZdYvXpwm6bpa@shredder \
--to=idosch@idosch.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--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).