netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH-net] af_packet / TX_RING not fully non-blocking (w/ MSG_DONTWAIT).
@ 2015-05-08 13:44 Mathias Kretschmer
  2015-05-10 23:40 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Mathias Kretschmer @ 2015-05-08 13:44 UTC (permalink / raw)
  To: davem; +Cc: netdev, Mathias Kretschmer

This patch fixes an issue where the send(MSG_DONTWAIT) call
on a TX_RING is not fully non-blocking in cases where the device's sndBuf is
full. We pass nonblock=true to sock_alloc_send_skb() and return any possibly
occuring error code (most likely EGAIN) to the caller. As the fast-path stays
as it is, we keep the unlikely() around skb == NULL. 

Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>

---
 net/packet/af_packet.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 5102c3c..b5989c6 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2311,11 +2311,14 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
 		tlen = dev->needed_tailroom;
 		skb = sock_alloc_send_skb(&po->sk,
 				hlen + tlen + sizeof(struct sockaddr_ll),
-				0, &err);
+				!need_wait, &err);
 
-		if (unlikely(skb == NULL))
+		if (unlikely(skb == NULL)) {
+			/* we assume the socket was initially writeable ... */
+			if (likely(len_sum > 0))
+				err = len_sum;
 			goto out_status;
-
+		}
 		tp_len = tpacket_fill_skb(po, skb, ph, dev, size_max, proto,
 					  addr, hlen);
 		if (tp_len > dev->mtu + dev->hard_header_len) {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH-net] af_packet / TX_RING not fully non-blocking (w/ MSG_DONTWAIT).
  2015-05-08 13:44 [PATCH-net] af_packet / TX_RING not fully non-blocking (w/ MSG_DONTWAIT) Mathias Kretschmer
@ 2015-05-10 23:40 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-05-10 23:40 UTC (permalink / raw)
  To: mathias.kretschmer; +Cc: netdev

From: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>
Date: Fri, 8 May 2015 15:44:37 +0200

> This patch fixes an issue where the send(MSG_DONTWAIT) call
> on a TX_RING is not fully non-blocking in cases where the device's sndBuf is
> full. We pass nonblock=true to sock_alloc_send_skb() and return any possibly
> occuring error code (most likely EGAIN) to the caller. As the fast-path stays
> as it is, we keep the unlikely() around skb == NULL. 
> 
> Signed-off-by: Mathias Kretschmer <mathias.kretschmer@fokus.fraunhofer.de>

This looks correct to me, applied, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-10 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-08 13:44 [PATCH-net] af_packet / TX_RING not fully non-blocking (w/ MSG_DONTWAIT) Mathias Kretschmer
2015-05-10 23:40 ` David Miller

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).