* [patch net v2 1/3] udp6: respect IPV6_DONTFRAG sockopt in case there are pending frames
2013-10-19 10:29 [patch net v2 0/3] UFO fixes Jiri Pirko
@ 2013-10-19 10:29 ` Jiri Pirko
2013-10-19 20:45 ` Hannes Frederic Sowa
2013-10-19 10:29 ` [patch net v2 2/3] ip6_output: do skb ufo init for peeked non ufo skb as well Jiri Pirko
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: Jiri Pirko @ 2013-10-19 10:29 UTC (permalink / raw)
To: netdev
Cc: davem, eric.dumazet, hannes, jdmason, yoshfuji, kuznet, jmorris,
kaber, herbert
if up->pending != 0 dontfrag is left with default value -1. That
causes that application that do:
sendto len>mtu flag MSG_MORE
sendto len>mtu flag 0
will receive EMSGSIZE errno as the result of the second sendto.
This patch fixes it by respecting IPV6_DONTFRAG socket option.
introduced by:
commit 4b340ae20d0e2366792abe70f46629e576adaf5e "IPv6: Complete IPV6_DONTFRAG support"
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
net/ipv6/udp.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 72b7eaa..1878609 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1225,9 +1225,6 @@ do_udp_sendmsg:
if (tclass < 0)
tclass = np->tclass;
- if (dontfrag < 0)
- dontfrag = np->dontfrag;
-
if (msg->msg_flags&MSG_CONFIRM)
goto do_confirm;
back_from_confirm:
@@ -1246,6 +1243,8 @@ back_from_confirm:
up->pending = AF_INET6;
do_append_data:
+ if (dontfrag < 0)
+ dontfrag = np->dontfrag;
up->len += ulen;
getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag;
err = ip6_append_data(sk, getfrag, msg->msg_iov, ulen,
--
1.8.3.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [patch net v2 1/3] udp6: respect IPV6_DONTFRAG sockopt in case there are pending frames
2013-10-19 10:29 ` [patch net v2 1/3] udp6: respect IPV6_DONTFRAG sockopt in case there are pending frames Jiri Pirko
@ 2013-10-19 20:45 ` Hannes Frederic Sowa
0 siblings, 0 replies; 12+ messages in thread
From: Hannes Frederic Sowa @ 2013-10-19 20:45 UTC (permalink / raw)
To: Jiri Pirko
Cc: netdev, davem, eric.dumazet, jdmason, yoshfuji, kuznet, jmorris,
kaber, herbert
On Sat, Oct 19, 2013 at 12:29:15PM +0200, Jiri Pirko wrote:
> if up->pending != 0 dontfrag is left with default value -1. That
> causes that application that do:
> sendto len>mtu flag MSG_MORE
> sendto len>mtu flag 0
> will receive EMSGSIZE errno as the result of the second sendto.
>
> This patch fixes it by respecting IPV6_DONTFRAG socket option.
>
> introduced by:
> commit 4b340ae20d0e2366792abe70f46629e576adaf5e "IPv6: Complete IPV6_DONTFRAG support"
>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [patch net v2 2/3] ip6_output: do skb ufo init for peeked non ufo skb as well
2013-10-19 10:29 [patch net v2 0/3] UFO fixes Jiri Pirko
2013-10-19 10:29 ` [patch net v2 1/3] udp6: respect IPV6_DONTFRAG sockopt in case there are pending frames Jiri Pirko
@ 2013-10-19 10:29 ` Jiri Pirko
2013-10-19 21:06 ` Hannes Frederic Sowa
2013-10-19 10:29 ` [patch net v2 3/3] ip_output: " Jiri Pirko
2013-10-19 23:21 ` [patch net v2 0/3] UFO fixes David Miller
3 siblings, 1 reply; 12+ messages in thread
From: Jiri Pirko @ 2013-10-19 10:29 UTC (permalink / raw)
To: netdev
Cc: davem, eric.dumazet, hannes, jdmason, yoshfuji, kuznet, jmorris,
kaber, herbert
Now, if user application does:
sendto len<mtu flag MSG_MORE
sendto len>mtu flag 0
The skb is not treated as fragmented one because it is not initialized
that way. So move the initialization to fix this.
introduced by:
commit e89e9cf539a28df7d0eb1d0a545368e9920b34ac "[IPv4/IPv6]: UFO Scatter-gather approach"
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
net/ipv6/ip6_output.c | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index a54c45c..975624b 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1008,6 +1008,7 @@ static inline int ip6_ufo_append_data(struct sock *sk,
{
struct sk_buff *skb;
+ struct frag_hdr fhdr;
int err;
/* There is support for UDP large send offload by network
@@ -1015,8 +1016,6 @@ static inline int ip6_ufo_append_data(struct sock *sk,
* udp datagram
*/
if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) {
- struct frag_hdr fhdr;
-
skb = sock_alloc_send_skb(sk,
hh_len + fragheaderlen + transhdrlen + 20,
(flags & MSG_DONTWAIT), &err);
@@ -1036,20 +1035,24 @@ static inline int ip6_ufo_append_data(struct sock *sk,
skb->transport_header = skb->network_header + fragheaderlen;
skb->protocol = htons(ETH_P_IPV6);
- skb->ip_summed = CHECKSUM_PARTIAL;
skb->csum = 0;
- /* Specify the length of each IPv6 datagram fragment.
- * It has to be a multiple of 8.
- */
- skb_shinfo(skb)->gso_size = (mtu - fragheaderlen -
- sizeof(struct frag_hdr)) & ~7;
- skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
- ipv6_select_ident(&fhdr, rt);
- skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
__skb_queue_tail(&sk->sk_write_queue, skb);
+ } else if (skb_is_gso(skb)) {
+ goto append;
}
+ skb->ip_summed = CHECKSUM_PARTIAL;
+ /* Specify the length of each IPv6 datagram fragment.
+ * It has to be a multiple of 8.
+ */
+ skb_shinfo(skb)->gso_size = (mtu - fragheaderlen -
+ sizeof(struct frag_hdr)) & ~7;
+ skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
+ ipv6_select_ident(&fhdr, rt);
+ skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
+
+append:
return skb_append_datato_frags(sk, skb, getfrag, from,
(length - transhdrlen));
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [patch net v2 2/3] ip6_output: do skb ufo init for peeked non ufo skb as well
2013-10-19 10:29 ` [patch net v2 2/3] ip6_output: do skb ufo init for peeked non ufo skb as well Jiri Pirko
@ 2013-10-19 21:06 ` Hannes Frederic Sowa
0 siblings, 0 replies; 12+ messages in thread
From: Hannes Frederic Sowa @ 2013-10-19 21:06 UTC (permalink / raw)
To: Jiri Pirko
Cc: netdev, davem, eric.dumazet, jdmason, yoshfuji, kuznet, jmorris,
kaber, herbert
On Sat, Oct 19, 2013 at 12:29:16PM +0200, Jiri Pirko wrote:
> Now, if user application does:
> sendto len<mtu flag MSG_MORE
> sendto len>mtu flag 0
> The skb is not treated as fragmented one because it is not initialized
> that way. So move the initialization to fix this.
>
> introduced by:
> commit e89e9cf539a28df7d0eb1d0a545368e9920b34ac "[IPv4/IPv6]: UFO Scatter-gather approach"
>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [patch net v2 3/3] ip_output: do skb ufo init for peeked non ufo skb as well
2013-10-19 10:29 [patch net v2 0/3] UFO fixes Jiri Pirko
2013-10-19 10:29 ` [patch net v2 1/3] udp6: respect IPV6_DONTFRAG sockopt in case there are pending frames Jiri Pirko
2013-10-19 10:29 ` [patch net v2 2/3] ip6_output: do skb ufo init for peeked non ufo skb as well Jiri Pirko
@ 2013-10-19 10:29 ` Jiri Pirko
2013-10-19 21:10 ` Hannes Frederic Sowa
2013-10-19 23:21 ` [patch net v2 0/3] UFO fixes David Miller
3 siblings, 1 reply; 12+ messages in thread
From: Jiri Pirko @ 2013-10-19 10:29 UTC (permalink / raw)
To: netdev
Cc: davem, eric.dumazet, hannes, jdmason, yoshfuji, kuznet, jmorris,
kaber, herbert
Now, if user application does:
sendto len<mtu flag MSG_MORE
sendto len>mtu flag 0
The skb is not treated as fragmented one because it is not initialized
that way. So move the initialization to fix this.
introduced by:
commit e89e9cf539a28df7d0eb1d0a545368e9920b34ac "[IPv4/IPv6]: UFO Scatter-gather approach"
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
net/ipv4/ip_output.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index a04d872..3982eab 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -772,15 +772,20 @@ static inline int ip_ufo_append_data(struct sock *sk,
/* initialize protocol header pointer */
skb->transport_header = skb->network_header + fragheaderlen;
- skb->ip_summed = CHECKSUM_PARTIAL;
skb->csum = 0;
- /* specify the length of each IP datagram fragment */
- skb_shinfo(skb)->gso_size = maxfraglen - fragheaderlen;
- skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
+
__skb_queue_tail(queue, skb);
+ } else if (skb_is_gso(skb)) {
+ goto append;
}
+ skb->ip_summed = CHECKSUM_PARTIAL;
+ /* specify the length of each IP datagram fragment */
+ skb_shinfo(skb)->gso_size = maxfraglen - fragheaderlen;
+ skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
+
+append:
return skb_append_datato_frags(sk, skb, getfrag, from,
(length - transhdrlen));
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [patch net v2 3/3] ip_output: do skb ufo init for peeked non ufo skb as well
2013-10-19 10:29 ` [patch net v2 3/3] ip_output: " Jiri Pirko
@ 2013-10-19 21:10 ` Hannes Frederic Sowa
0 siblings, 0 replies; 12+ messages in thread
From: Hannes Frederic Sowa @ 2013-10-19 21:10 UTC (permalink / raw)
To: Jiri Pirko
Cc: netdev, davem, eric.dumazet, jdmason, yoshfuji, kuznet, jmorris,
kaber, herbert
On Sat, Oct 19, 2013 at 12:29:17PM +0200, Jiri Pirko wrote:
> Now, if user application does:
> sendto len<mtu flag MSG_MORE
> sendto len>mtu flag 0
> The skb is not treated as fragmented one because it is not initialized
> that way. So move the initialization to fix this.
>
> introduced by:
> commit e89e9cf539a28df7d0eb1d0a545368e9920b34ac "[IPv4/IPv6]: UFO Scatter-gather approach"
>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Thanks Jiri!
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch net v2 0/3] UFO fixes
2013-10-19 10:29 [patch net v2 0/3] UFO fixes Jiri Pirko
` (2 preceding siblings ...)
2013-10-19 10:29 ` [patch net v2 3/3] ip_output: " Jiri Pirko
@ 2013-10-19 23:21 ` David Miller
2013-10-20 3:26 ` Hannes Frederic Sowa
3 siblings, 1 reply; 12+ messages in thread
From: David Miller @ 2013-10-19 23:21 UTC (permalink / raw)
To: jiri
Cc: netdev, eric.dumazet, hannes, jdmason, yoshfuji, kuznet, jmorris,
kaber, herbert
From: Jiri Pirko <jiri@resnulli.us>
Date: Sat, 19 Oct 2013 12:29:14 +0200
> Couple of patches fixing UFO functionality in different situations.
>
> v1->v2:
> - minor if{}else{} coding style adjustment suggested by Sergei Shtylyov
Series applied, thanks Jiri.
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [patch net v2 0/3] UFO fixes
2013-10-19 23:21 ` [patch net v2 0/3] UFO fixes David Miller
@ 2013-10-20 3:26 ` Hannes Frederic Sowa
2013-10-21 20:26 ` David Miller
0 siblings, 1 reply; 12+ messages in thread
From: Hannes Frederic Sowa @ 2013-10-20 3:26 UTC (permalink / raw)
To: David Miller
Cc: jiri, netdev, eric.dumazet, jdmason, yoshfuji, kuznet, jmorris,
kaber, herbert
Hi David!
On Sat, Oct 19, 2013 at 07:21:47PM -0400, David Miller wrote:
> From: Jiri Pirko <jiri@resnulli.us>
> Date: Sat, 19 Oct 2013 12:29:14 +0200
>
> > Couple of patches fixing UFO functionality in different situations.
> >
> > v1->v2:
> > - minor if{}else{} coding style adjustment suggested by Sergei Shtylyov
>
> Series applied, thanks Jiri.
I would propose that the patches
"ip6_output: do skb ufo init for peeked non ufo skb as well"
(c547dbf55d5f8cf615ccc0e7265e98db27d3fb8b)
and
"ip_output: do skb ufo init for peeked non ufo skb as well"
(e93b7d748be887cd7639b113ba7d7ef792a7efb9)
should go to stable because they solve a possible memory corruption
from userspace.
Thanks,
Hannes
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [patch net v2 0/3] UFO fixes
2013-10-20 3:26 ` Hannes Frederic Sowa
@ 2013-10-21 20:26 ` David Miller
2013-10-21 21:14 ` Hannes Frederic Sowa
0 siblings, 1 reply; 12+ messages in thread
From: David Miller @ 2013-10-21 20:26 UTC (permalink / raw)
To: hannes
Cc: jiri, netdev, eric.dumazet, jdmason, yoshfuji, kuznet, jmorris,
kaber, herbert
From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Sun, 20 Oct 2013 05:26:17 +0200
> Hi David!
>
> On Sat, Oct 19, 2013 at 07:21:47PM -0400, David Miller wrote:
>> From: Jiri Pirko <jiri@resnulli.us>
>> Date: Sat, 19 Oct 2013 12:29:14 +0200
>>
>> > Couple of patches fixing UFO functionality in different situations.
>> >
>> > v1->v2:
>> > - minor if{}else{} coding style adjustment suggested by Sergei Shtylyov
>>
>> Series applied, thanks Jiri.
>
> I would propose that the patches
>
> "ip6_output: do skb ufo init for peeked non ufo skb as well"
> (c547dbf55d5f8cf615ccc0e7265e98db27d3fb8b)
>
> and
>
> "ip_output: do skb ufo init for peeked non ufo skb as well"
> (e93b7d748be887cd7639b113ba7d7ef792a7efb9)
>
> should go to stable because they solve a possible memory corruption
> from userspace.
I suppose... the reason I didn't automatically queue these up for -stable
is that they are rather non-trivial.
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [patch net v2 0/3] UFO fixes
2013-10-21 20:26 ` David Miller
@ 2013-10-21 21:14 ` Hannes Frederic Sowa
2013-10-21 21:15 ` David Miller
0 siblings, 1 reply; 12+ messages in thread
From: Hannes Frederic Sowa @ 2013-10-21 21:14 UTC (permalink / raw)
To: David Miller
Cc: jiri, netdev, eric.dumazet, jdmason, yoshfuji, kuznet, jmorris,
kaber, herbert
On Mon, Oct 21, 2013 at 04:26:12PM -0400, David Miller wrote:
> From: Hannes Frederic Sowa <hannes@stressinduktion.org>
> Date: Sun, 20 Oct 2013 05:26:17 +0200
>
> > Hi David!
> >
> > On Sat, Oct 19, 2013 at 07:21:47PM -0400, David Miller wrote:
> >> From: Jiri Pirko <jiri@resnulli.us>
> >> Date: Sat, 19 Oct 2013 12:29:14 +0200
> >>
> >> > Couple of patches fixing UFO functionality in different situations.
> >> >
> >> > v1->v2:
> >> > - minor if{}else{} coding style adjustment suggested by Sergei Shtylyov
> >>
> >> Series applied, thanks Jiri.
> >
> > I would propose that the patches
> >
> > "ip6_output: do skb ufo init for peeked non ufo skb as well"
> > (c547dbf55d5f8cf615ccc0e7265e98db27d3fb8b)
> >
> > and
> >
> > "ip_output: do skb ufo init for peeked non ufo skb as well"
> > (e93b7d748be887cd7639b113ba7d7ef792a7efb9)
> >
> > should go to stable because they solve a possible memory corruption
> > from userspace.
>
> I suppose... the reason I didn't automatically queue these up for -stable
> is that they are rather non-trivial.
This patch I proposed before is IMHO more simple. Would you consider
this a candidate for stable only? I would send a proper patch then.
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6d56840..3565450 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1308,6 +1308,11 @@ static inline int skb_pagelen(const struct sk_buff *skb)
return len + skb_headlen(skb);
}
+static inline bool skb_has_frags(const struct sk_buff *skb)
+{
+ return skb_shinfo(skb)->nr_frags;
+}
+
/**
* __skb_fill_page_desc - initialise a paged fragment in an skb
* @skb: buffer containing fragment to be initialised
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 7d8357b..8dc3d8d 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -836,7 +836,7 @@ static int __ip_append_data(struct sock *sk,
csummode = CHECKSUM_PARTIAL;
cork->length += length;
- if (((length > mtu) || (skb && skb_is_gso(skb))) &&
+ if (((length > mtu) || (skb && skb_has_frags(skb))) &&
(sk->sk_protocol == IPPROTO_UDP) &&
(rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len) {
err = ip_ufo_append_data(sk, queue, getfrag, from, length,
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index a54c45c..ded4f6f 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1227,7 +1227,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
skb = skb_peek_tail(&sk->sk_write_queue);
cork->length += length;
if (((length > mtu) ||
- (skb && skb_is_gso(skb))) &&
+ (skb && skb_has_frags(skb))) &&
(sk->sk_protocol == IPPROTO_UDP) &&
(rt->dst.dev->features & NETIF_F_UFO)) {
err = ip6_ufo_append_data(sk, getfrag, from, length,
Greetings,
Hannes
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [patch net v2 0/3] UFO fixes
2013-10-21 21:14 ` Hannes Frederic Sowa
@ 2013-10-21 21:15 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2013-10-21 21:15 UTC (permalink / raw)
To: hannes
Cc: jiri, netdev, eric.dumazet, jdmason, yoshfuji, kuznet, jmorris,
kaber, herbert
From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Mon, 21 Oct 2013 23:14:26 +0200
> This patch I proposed before is IMHO more simple. Would you consider
> this a candidate for stable only? I would send a proper patch then.
Yes, I would.
Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread