* PATCH: af_packet / TX_RING not fully non-blocking (w/ MSG_DONTWAIT)
@ 2015-05-03 11:28 Mathias Kretschmer
2015-05-03 21:39 ` Daniel Borkmann
0 siblings, 1 reply; 2+ messages in thread
From: Mathias Kretschmer @ 2015-05-03 11:28 UTC (permalink / raw)
To: netdev; +Cc: Daniel Borkmann
[-- Attachment #1: Type: text/plain, Size: 1467 bytes --]
Hi,
following up on my initial post and the feedback I have received,
please find attached/in-line an updated patch.
Changes:
*) keep the unlikely() in the case sock_alloc_send_skb() fails, as here
we enter the slow path, anyway.
*) pass on the return code from sock_alloc_send_skb(), i.e. EGAIN
Please consider this for inclusion.
Cheers,
Mathias
---
diff -uNpr linux-3.16.7.orig/net/packet/af_packet.c
linux-3.16.7/net/packet/af_packet.c
--- linux-3.16.7.orig/net/packet/af_packet.c 2014-10-30
16:41:01.000000000 +0000
+++ linux-3.16.7/net/packet/af_packet.c 2015-04-05 08:41:14.577535454 +0000
@@ -2291,11 +2291,14 @@ static int tpacket_snd(struct packet_soc
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) {
[-- Attachment #2: 005-af_packet_no_block_tx.patch --]
[-- Type: text/x-patch, Size: 802 bytes --]
diff -uNpr linux-3.16.7.orig/net/packet/af_packet.c linux-3.16.7/net/packet/af_packet.c
--- linux-3.16.7.orig/net/packet/af_packet.c 2014-10-30 16:41:01.000000000 +0000
+++ linux-3.16.7/net/packet/af_packet.c 2015-04-05 08:41:14.577535454 +0000
@@ -2291,11 +2291,14 @@ static int tpacket_snd(struct packet_soc
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) {
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH: af_packet / TX_RING not fully non-blocking (w/ MSG_DONTWAIT)
2015-05-03 11:28 PATCH: af_packet / TX_RING not fully non-blocking (w/ MSG_DONTWAIT) Mathias Kretschmer
@ 2015-05-03 21:39 ` Daniel Borkmann
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2015-05-03 21:39 UTC (permalink / raw)
To: Mathias Kretschmer, netdev
Hi Mathias,
On 05/03/2015 01:28 PM, Mathias Kretschmer wrote:
> Hi,
>
> following up on my initial post and the feedback I have received,
> please find attached/in-line an updated patch.
Yep, thanks for following up on this.
However, your submission (https://patchwork.ozlabs.org/patch/467377/)
format is not correct. Your email client corrupted the whitespace,
your Signed-off-by is missing, a proper commit description is missing
and which tree your patch is targeted at. I presume -net tree as it's
a fix.
You're best off sending this patch via git-send-email(1), see also
Documentation/SubmittingPatches from the kernel tree.
Taking a random example submission from patchwork, this is how the end
result could look like:
https://patchwork.ozlabs.org/patch/466743/
Thus, if you just write a proper commit message in git and use
git-format-patch(1) and git-send-email(1), you should be all set. Hope
that helps.
Cheers,
Daniel
> Changes:
> *) keep the unlikely() in the case sock_alloc_send_skb() fails, as here we enter the slow path, anyway.
> *) pass on the return code from sock_alloc_send_skb(), i.e. EGAIN
>
> Please consider this for inclusion.
>
> Cheers,
>
> Mathias
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-03 21:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-03 11:28 PATCH: af_packet / TX_RING not fully non-blocking (w/ MSG_DONTWAIT) Mathias Kretschmer
2015-05-03 21:39 ` Daniel Borkmann
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).