* [PATCH v2 1/2] ipv4: Fix packet size calculation in __ip_append_data
@ 2011-06-22 11:04 Steffen Klassert
2011-06-22 11:05 ` [PATCH 2/2] ipv4: Fix IPsec slowpath fragmentation problem Steffen Klassert
2011-06-28 3:39 ` [PATCH v2 1/2] ipv4: Fix packet size calculation in __ip_append_data David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Steffen Klassert @ 2011-06-22 11:04 UTC (permalink / raw)
To: David Miller, Eric Dumazet, Herbert Xu; +Cc: netdev
Git commit 59104f06 (ip: take care of last fragment in ip_append_data)
added a check to see if we exceed the mtu when we add trailer_len.
However, the mtu is already subtracted by the trailer length when the
xfrm transfomation bundles are set up. So IPsec packets with mtu
size get fragmented, or if the DF bit is set the packets will not
be send even though they match the mtu perfectly fine. This patch
actually reverts commit 59104f06.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/ip_output.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index a8024ea..6b894d4 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -888,12 +888,9 @@ alloc_new_skb:
* because we have no idea what fragment will be
* the last.
*/
- if (datalen == length + fraggap) {
+ if (datalen == length + fraggap)
alloclen += rt->dst.trailer_len;
- /* make sure mtu is not reached */
- if (datalen > mtu - fragheaderlen - rt->dst.trailer_len)
- datalen -= ALIGN(rt->dst.trailer_len, 8);
- }
+
if (transhdrlen) {
skb = sock_alloc_send_skb(sk,
alloclen + hh_len + 15,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] ipv4: Fix IPsec slowpath fragmentation problem
2011-06-22 11:04 [PATCH v2 1/2] ipv4: Fix packet size calculation in __ip_append_data Steffen Klassert
@ 2011-06-22 11:05 ` Steffen Klassert
2011-06-28 3:39 ` David Miller
2011-06-28 3:39 ` [PATCH v2 1/2] ipv4: Fix packet size calculation in __ip_append_data David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Steffen Klassert @ 2011-06-22 11:05 UTC (permalink / raw)
To: David Miller, Eric Dumazet, Herbert Xu; +Cc: netdev
ip_append_data() builds packets based on the mtu from dst_mtu(rt->dst.path).
On IPsec the effective mtu is lower because we need to add the protocol
headers and trailers later when we do the IPsec transformations. So after
the IPsec transformations the packet might be too big, which leads to a
slowpath fragmentation then. This patch fixes this by building the packets
based on the lower IPsec mtu from dst_mtu(&rt->dst) and adapts the exthdr
handling to this.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/ip_output.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 6b894d4..4a7e16b 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -802,8 +802,6 @@ static int __ip_append_data(struct sock *sk,
skb = skb_peek_tail(queue);
exthdrlen = !skb ? rt->dst.header_len : 0;
- length += exthdrlen;
- transhdrlen += exthdrlen;
mtu = cork->fragsize;
hh_len = LL_RESERVED_SPACE(rt->dst.dev);
@@ -883,6 +881,8 @@ alloc_new_skb:
else
alloclen = fraglen;
+ alloclen += exthdrlen;
+
/* The last fragment gets additional space at tail.
* Note, with MSG_MORE we overallocate on fragments,
* because we have no idea what fragment will be
@@ -923,11 +923,11 @@ alloc_new_skb:
/*
* Find where to start putting bytes.
*/
- data = skb_put(skb, fraglen);
+ data = skb_put(skb, fraglen + exthdrlen);
skb_set_network_header(skb, exthdrlen);
skb->transport_header = (skb->network_header +
fragheaderlen);
- data += fragheaderlen;
+ data += fragheaderlen + exthdrlen;
if (fraggap) {
skb->csum = skb_copy_and_csum_bits(
@@ -1061,7 +1061,7 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork,
*/
*rtp = NULL;
cork->fragsize = inet->pmtudisc == IP_PMTUDISC_PROBE ?
- rt->dst.dev->mtu : dst_mtu(rt->dst.path);
+ rt->dst.dev->mtu : dst_mtu(&rt->dst);
cork->dst = &rt->dst;
cork->length = 0;
cork->tx_flags = ipc->tx_flags;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 2/2] ipv4: Fix IPsec slowpath fragmentation problem
2011-06-22 11:05 ` [PATCH 2/2] ipv4: Fix IPsec slowpath fragmentation problem Steffen Klassert
@ 2011-06-28 3:39 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2011-06-28 3:39 UTC (permalink / raw)
To: steffen.klassert; +Cc: eric.dumazet, herbert, netdev
From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Wed, 22 Jun 2011 13:05:37 +0200
> ip_append_data() builds packets based on the mtu from dst_mtu(rt->dst.path).
> On IPsec the effective mtu is lower because we need to add the protocol
> headers and trailers later when we do the IPsec transformations. So after
> the IPsec transformations the packet might be too big, which leads to a
> slowpath fragmentation then. This patch fixes this by building the packets
> based on the lower IPsec mtu from dst_mtu(&rt->dst) and adapts the exthdr
> handling to this.
>
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] ipv4: Fix packet size calculation in __ip_append_data
2011-06-22 11:04 [PATCH v2 1/2] ipv4: Fix packet size calculation in __ip_append_data Steffen Klassert
2011-06-22 11:05 ` [PATCH 2/2] ipv4: Fix IPsec slowpath fragmentation problem Steffen Klassert
@ 2011-06-28 3:39 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2011-06-28 3:39 UTC (permalink / raw)
To: steffen.klassert; +Cc: eric.dumazet, herbert, netdev
From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Wed, 22 Jun 2011 13:04:37 +0200
> Git commit 59104f06 (ip: take care of last fragment in ip_append_data)
> added a check to see if we exceed the mtu when we add trailer_len.
> However, the mtu is already subtracted by the trailer length when the
> xfrm transfomation bundles are set up. So IPsec packets with mtu
> size get fragmented, or if the DF bit is set the packets will not
> be send even though they match the mtu perfectly fine. This patch
> actually reverts commit 59104f06.
>
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-06-28 3:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-22 11:04 [PATCH v2 1/2] ipv4: Fix packet size calculation in __ip_append_data Steffen Klassert
2011-06-22 11:05 ` [PATCH 2/2] ipv4: Fix IPsec slowpath fragmentation problem Steffen Klassert
2011-06-28 3:39 ` David Miller
2011-06-28 3:39 ` [PATCH v2 1/2] ipv4: Fix packet size calculation in __ip_append_data 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).