From: Ronny Meeus <ronny.meeus@gmail.com>
To: netdev@vger.kernel.org
Subject: [PATCH] [PATCH] Fix deadlock in af_packet while stressing raw ethernet socket interface
Date: Sat, 11 Jun 2011 07:04:09 +0200 [thread overview]
Message-ID: <78567a0a1d2999f06d8f.1307768649@meeusr-laptop> (raw)
I was running a test: 1 application was sending raw Ethernet packets on a physical looped interface while a second application was receiving packets, so the latter application receives each packet 2 times (once while sending from the context of the first application and a second time while receiving from the hardware).
After some time, the test blocks due to a spinlock reentrance issue in af_packet. Both the sending application and the softIRQ receiving packets enter the spinlock code. After applying the patch below, the issue is resolved.
Signed-off-by: Ronny Meeus <ronny.meeus@gmail.com>
---
net/packet/af_packet.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff -r ab5136256418 -r 78567a0a1d29 net/packet/af_packet.c
--- a/net/packet/af_packet.c Fri Jun 10 20:31:07 2011 +0200
+++ b/net/packet/af_packet.c Sat Jun 11 07:03:55 2011 +0200
@@ -618,11 +618,11 @@
/* drop conntrack reference */
nf_reset(skb);
- spin_lock(&sk->sk_receive_queue.lock);
+ spin_lock_bh(&sk->sk_receive_queue.lock);
po->stats.tp_packets++;
skb->dropcount = atomic_read(&sk->sk_drops);
__skb_queue_tail(&sk->sk_receive_queue, skb);
- spin_unlock(&sk->sk_receive_queue.lock);
+ spin_unlock_bh(&sk->sk_receive_queue.lock);
sk->sk_data_ready(sk, skb->len);
return 0;
@@ -718,7 +718,7 @@
snaplen = 0;
}
- spin_lock(&sk->sk_receive_queue.lock);
+ spin_lock_bh(&sk->sk_receive_queue.lock);
h.raw = packet_current_frame(po, &po->rx_ring, TP_STATUS_KERNEL);
if (!h.raw)
goto ring_is_full;
@@ -730,7 +730,7 @@
}
if (!po->stats.tp_drops)
status &= ~TP_STATUS_LOSING;
- spin_unlock(&sk->sk_receive_queue.lock);
+ spin_unlock_bh(&sk->sk_receive_queue.lock);
skb_copy_bits(skb, 0, h.raw + macoff, snaplen);
@@ -816,7 +816,7 @@
ring_is_full:
po->stats.tp_drops++;
- spin_unlock(&sk->sk_receive_queue.lock);
+ spin_unlock_bh(&sk->sk_receive_queue.lock);
sk->sk_data_ready(sk, 0);
kfree_skb(copy_skb);
next reply other threads:[~2011-07-11 19:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-11 5:04 Ronny Meeus [this message]
2011-07-12 3:27 ` [PATCH] [PATCH] Fix deadlock in af_packet while stressing raw ethernet socket interface David Miller
2011-07-12 6:38 ` Ronny Meeus
2011-07-12 6:42 ` David Miller
2011-07-12 6:58 ` Eric Dumazet
2011-07-12 7:19 ` David Miller
2011-07-12 8:23 ` Eric Dumazet
2011-07-12 8:26 ` David Miller
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=78567a0a1d2999f06d8f.1307768649@meeusr-laptop \
--to=ronny.meeus@gmail.com \
--cc=netdev@vger.kernel.org \
/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