* [PATCH v2] net: tcp6: fix double call of tcp_v6_fill_cb()
@ 2015-03-26 8:28 Alexey Kodanev
2015-03-26 11:46 ` Eric Dumazet
2015-03-26 14:08 ` Sergei Shtylyov
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Kodanev @ 2015-03-26 8:28 UTC (permalink / raw)
To: netdev; +Cc: vasily.isaenko, Alexey Kodanev
Regression from the following commit: 2dc49d1680.
tcp_v6_fill_cb() will be called twice if socket's state changes from
TCP_TIME_WAIT to TCP_LISTEN. That can result in control buffer data
corruption because in the second tcp_v6_fill_cb() call it's not copying
IP6CB(skb) anymore, but 'seq', 'end_seq', etc., so we can get weird and
unpredictable results. Performance loss of up to 1200% has been observed
in LTP/vxlan03 test.
This can be fixed by copying inet6_skb_parm to the beginning of 'cb'
only if xfrm6_policy_check() and tcp_v6_fill_cb() are going to be
called again.
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
net/ipv6/tcp_ipv6.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 5d46832..7d21a78 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1411,6 +1411,15 @@ static void tcp_v6_fill_cb(struct sk_buff *skb, const struct ipv6hdr *hdr,
TCP_SKB_CB(skb)->sacked = 0;
}
+static void tcp_v6_restore_cb(struct sk_buff *skb)
+{
+ /* We need to move header back to the beginning if xfrm6_policy_check()
+ * and tcp_v6_fill_cb() are going to be called again.
+ */
+ memmove(IP6CB(skb), &TCP_SKB_CB(skb)->header.h6,
+ sizeof(struct inet6_skb_parm));
+}
+
static int tcp_v6_rcv(struct sk_buff *skb)
{
const struct tcphdr *th;
@@ -1543,6 +1552,7 @@ do_time_wait:
inet_twsk_deschedule(tw, &tcp_death_row);
inet_twsk_put(tw);
sk = sk2;
+ tcp_v6_restore_cb(skb);
goto process;
}
/* Fall through to ACK */
@@ -1551,6 +1561,7 @@ do_time_wait:
tcp_v6_timewait_ack(sk, skb);
break;
case TCP_TW_RST:
+ tcp_v6_restore_cb(skb);
goto no_tcp_socket;
case TCP_TW_SUCCESS:
;
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: tcp6: fix double call of tcp_v6_fill_cb()
2015-03-26 8:28 [PATCH v2] net: tcp6: fix double call of tcp_v6_fill_cb() Alexey Kodanev
@ 2015-03-26 11:46 ` Eric Dumazet
2015-03-26 14:08 ` Sergei Shtylyov
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2015-03-26 11:46 UTC (permalink / raw)
To: Alexey Kodanev; +Cc: netdev, vasily.isaenko
On Thu, 2015-03-26 at 11:28 +0300, Alexey Kodanev wrote:
> Regression from the following commit: 2dc49d1680.
>
> tcp_v6_fill_cb() will be called twice if socket's state changes from
> TCP_TIME_WAIT to TCP_LISTEN. That can result in control buffer data
> corruption because in the second tcp_v6_fill_cb() call it's not copying
> IP6CB(skb) anymore, but 'seq', 'end_seq', etc., so we can get weird and
> unpredictable results. Performance loss of up to 1200% has been observed
> in LTP/vxlan03 test.
>
> This can be fixed by copying inet6_skb_parm to the beginning of 'cb'
> only if xfrm6_policy_check() and tcp_v6_fill_cb() are going to be
> called again.
>
> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> ---
Thanks Alexey !
Fixes: 2dc49d1680b53 ("tcp6: don't move IP6CB before xfrm6_policy_check()")
Acked-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: tcp6: fix double call of tcp_v6_fill_cb()
2015-03-26 8:28 [PATCH v2] net: tcp6: fix double call of tcp_v6_fill_cb() Alexey Kodanev
2015-03-26 11:46 ` Eric Dumazet
@ 2015-03-26 14:08 ` Sergei Shtylyov
1 sibling, 0 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2015-03-26 14:08 UTC (permalink / raw)
To: Alexey Kodanev, netdev; +Cc: vasily.isaenko
Hello.
On 3/26/2015 11:28 AM, Alexey Kodanev wrote:
> Regression from the following commit: 2dc49d1680.
Please also specify that commit's summary line in parens.
> tcp_v6_fill_cb() will be called twice if socket's state changes from
> TCP_TIME_WAIT to TCP_LISTEN. That can result in control buffer data
> corruption because in the second tcp_v6_fill_cb() call it's not copying
> IP6CB(skb) anymore, but 'seq', 'end_seq', etc., so we can get weird and
> unpredictable results. Performance loss of up to 1200% has been observed
> in LTP/vxlan03 test.
> This can be fixed by copying inet6_skb_parm to the beginning of 'cb'
> only if xfrm6_policy_check() and tcp_v6_fill_cb() are going to be
> called again.
> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
[...]
WBR, Sergei
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-26 14:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-26 8:28 [PATCH v2] net: tcp6: fix double call of tcp_v6_fill_cb() Alexey Kodanev
2015-03-26 11:46 ` Eric Dumazet
2015-03-26 14:08 ` Sergei Shtylyov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.