mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-10-29 20:37:44 +00:00
80 lines
2.4 KiB
Diff
80 lines
2.4 KiB
Diff
From ff62d446371f58701517feca924eac6b8dff1684 Mon Sep 17 00:00:00 2001
|
|
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
Date: Thu, 21 Sep 2017 14:42:04 +0200
|
|
Subject: [PATCH 330/418] net: use trylock in icmp_sk
|
|
|
|
The locking path can be recursive (same as for sk->sk_lock.slock) and
|
|
therefore we need a trylock version for the locallock, too.
|
|
|
|
Cc: stable-rt@vger.kernel.org
|
|
Reported-by: Jacek Konieczny <jajcus@jajcus.net>
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
---
|
|
net/ipv4/icmp.c | 9 +++++----
|
|
1 file changed, 5 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
|
|
index 6e1ae84d662c..0310ea93f877 100644
|
|
--- a/net/ipv4/icmp.c
|
|
+++ b/net/ipv4/icmp.c
|
|
@@ -217,12 +217,16 @@ static inline struct sock *icmp_xmit_lock(struct net *net)
|
|
{
|
|
struct sock *sk;
|
|
|
|
+ if (!local_trylock(icmp_sk_lock))
|
|
+ return NULL;
|
|
+
|
|
sk = icmp_sk(net);
|
|
|
|
if (unlikely(!spin_trylock(&sk->sk_lock.slock))) {
|
|
/* This can happen if the output path signals a
|
|
* dst_link_failure() for an outgoing ICMP packet.
|
|
*/
|
|
+ local_unlock(icmp_sk_lock);
|
|
return NULL;
|
|
}
|
|
return sk;
|
|
@@ -231,6 +235,7 @@ static inline struct sock *icmp_xmit_lock(struct net *net)
|
|
static inline void icmp_xmit_unlock(struct sock *sk)
|
|
{
|
|
spin_unlock(&sk->sk_lock.slock);
|
|
+ local_unlock(icmp_sk_lock);
|
|
}
|
|
|
|
int sysctl_icmp_msgs_per_sec __read_mostly = 1000;
|
|
@@ -420,7 +425,6 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
|
|
|
|
/* Needed by both icmp_global_allow and icmp_xmit_lock */
|
|
local_bh_disable();
|
|
- local_lock(icmp_sk_lock);
|
|
|
|
/* global icmp_msgs_per_sec */
|
|
if (!icmpv4_global_allow(net, type, code))
|
|
@@ -465,7 +469,6 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
|
|
out_unlock:
|
|
icmp_xmit_unlock(sk);
|
|
out_bh_enable:
|
|
- local_unlock(icmp_sk_lock);
|
|
local_bh_enable();
|
|
}
|
|
|
|
@@ -661,7 +664,6 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
|
|
|
|
/* Needed by both icmp_global_allow and icmp_xmit_lock */
|
|
local_bh_disable();
|
|
- local_lock(icmp_sk_lock);
|
|
|
|
/* Check global sysctl_icmp_msgs_per_sec ratelimit, unless
|
|
* incoming dev is loopback. If outgoing dev change to not be
|
|
@@ -750,7 +752,6 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
|
|
out_unlock:
|
|
icmp_xmit_unlock(sk);
|
|
out_bh_enable:
|
|
- local_unlock(icmp_sk_lock);
|
|
local_bh_enable();
|
|
out:;
|
|
}
|
|
--
|
|
2.17.1
|
|
|