tcp resets are misrouted
Subsystems (3)
PATCH 1/1 tcp resets are misrouted
After commit e2446eaa.. tcp resets are always lost, when routing is asymmetric. Yes, backing out that patch will result in misrouting of resets for dead connections which used interface binding when were alive, but we actually cannot do anything here. What's died that's died and correct handling normal unbound connections is obviously a priority.
Comment to comment:
Quoted 2 lines
This has few benefits:
1.tcp_v6_send_resetalready did that.
It was done to route resets for IPv6 link local addresses. It was a mistake to do so for global addresses. The patch fixes this as well.
Actually, the problem appears to be even more serious than guaranteed loss of resets. As reported by Sergey Soloviev <[email protected]>, those misrouted resets create a lot of arp traffic and huge amount of unresolved arp entires putting down to knees NAT firewalls which use asymmetric routing.
--- net/ipv4/tcp_ipv4.c | 7 ++++--- net/ipv6/tcp_ipv6.c | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-)
net/ipv4/tcp_ipv4.c +4 -3
@@ -708,10 +708,11 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) arg.csumoffset = offsetof(struct tcphdr , check) /2 ; arg.flags = (sk &&inet_sk (sk)->transparent) ?IP_REPLY_ARG_NOSRCCHECK :0 ;/* When socket is gone, all binding information is lost. -* routing might fail in this case. using iif for oif to -* make sure we can deliver it +* routing might fail in this case. No choice here, if we choose to force +* input interface, we will misroute in case of asymmetric route. */ - arg.bound_dev_if = sk ? sk->sk_bound_dev_if :inet_iif (skb); +if (sk) + arg.bound_dev_if = sk->sk_bound_dev_if; net =dev_net (skb_dst (skb)->dev); arg.tos =ip_hdr (skb)->tos;
net/ipv6/tcp_ipv6.c +2 -1
@@ -877,7 +877,8 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,__tcp_v6_send_check (buff, &fl6.saddr, &fl6.daddr); fl6.flowi6_proto =IPPROTO_TCP ; - fl6.flowi6_oif =inet6_iif (skb); +if (ipv6_addr_type (&fl6.daddr) &IPV6_ADDR_LINKLOCAL ) + fl6.flowi6_oif =inet6_iif (skb); fl6.fl6_dport = t1->dest; fl6.fl6_sport = t1->source;security_skb_classify_flow (skb,flowi6_to_flowi (&fl6));
Signature · 1 line
1.7.2.3
Quoted 57 lines · Alexey Kuznetsov
After commit
e2446eaa.. tcp resets are always lost, when routing is asymmetric. Yes, backing out that patch will result in misrouting of resets for dead connections which used interface binding when were alive, but we actually cannot do anything here. What's died that's died and correct handling normal unbound connections is obviously a priority.Comment to comment:
Quoted 2 lines
This has few benefits:
1.tcp_v6_send_resetalready did that.It was done to route resets for IPv6 link local addresses. It was a mistake to do so for global addresses. The patch fixes this as well.
Actually, the problem appears to be even more serious than guaranteed loss of resets. As reported by Sergey Soloviev <[email protected]>, those misrouted resets create a lot of arp traffic and huge amount of unresolved arp entires putting down to knees NAT firewalls which use asymmetric routing.
Signed-off-by Alexey Kuznetsov <[email protected]>--- net/ipv4/tcp_ipv4.c | 7 ++++--- net/ipv6/tcp_ipv6.c | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-)net/ipv4/tcp_ipv4.c +4
-3@@ -708,10 +708,11 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) arg.csumoffset = offsetof(struct tcphdr , check) /2 ; arg.flags = (sk &&inet_sk (sk)->transparent) ?IP_REPLY_ARG_NOSRCCHECK :0 ;/* When socket is gone, all binding information is lost. -* routing might fail in this case. using iif for oif to -* make sure we can deliver it +* routing might fail in this case. No choice here, if we choose to force +* input interface, we will misroute in case of asymmetric route. */ - arg.bound_dev_if = sk ? sk->sk_bound_dev_if :inet_iif (skb); +if (sk) + arg.bound_dev_if = sk->sk_bound_dev_if; net =dev_net (skb_dst (skb)->dev); arg.tos =ip_hdr (skb)->tos;net/ipv6/tcp_ipv6.c +2
-2@@ -877,7 +877,8 @@ static void tcp_v6_send_response(struct sk_buff *skb, u32 seq, u32 ack, u32 win,__tcp_v6_send_check (buff, &fl6.saddr, &fl6.daddr); fl6.flowi6_proto =IPPROTO_TCP ; - fl6.flowi6_oif =inet6_iif (skb); +if (ipv6_addr_type (&fl6.daddr) &IPV6_ADDR_LINKLOCAL ) + fl6.flowi6_oif =inet6_iif (skb); fl6.fl6_dport = t1->dest; fl6.fl6_sport = t1->source;security_skb_classify_flow (skb,flowi6_to_flowi (&fl6)); --
Quoted 2 lines
1.7.2.3
We ran into this as well and pulled that commit from our tree, it was causing serious problems. Sending the RST back on the iif was definitely the wrong thing to do. Patch looks good to me.
Thanks,
Debabrata
I admit the commit e2446eaa did break the reset in asymmetric case. There are also many use cases in interface binding, we don't want to break it too... I am ok with your patch, if asymmetric route take higher priority. Somehow, we need come up with another one to resolve RST lost in binding interface case, otherwise, people using interface binding will find later on that RST break again...
thanks!
Shawn Lu <[email protected]>
Quoted 88 lines
-----Original Message-----
From: Debabrata Banerjee [mailto:[email protected]]
Sent: Friday, October 12, 2012 8:57 AM
To: Alexey Kuznetsov; Banerjee, Debabrata
Cc: [email protected]; [email protected]; Shawn Lu; [email protected]; [email protected]
Subject: Re: [PATCH] tcp resets are misroutedQuoted 1 line · Alexey Kuznetsov
After commit
e2446eaa.. tcp resets are always lost, whenrouting is asymmetric.
Quoted 2 lines
Yes, backing out that patch will result in misrouting of resets for dead connections which used interface binding when were
alive, but we actually cannot do anything here.
Quoted 1 line
What's died that's died and correct handling normal unbound
connections is obviously a priority.
Quoted 9 lines
Comment to comment:
Quoted 2 lines
This has few benefits:
1.tcp_v6_send_resetalready did that.It was done to route resets for IPv6 link local addresses. It was a mistake to do so for global addresses. The patch fixes this as well.
Actually, the problem appears to be even more serious than
guaranteed loss of resets.
Quoted 2 lines
As reported by Sergey Soloviev <[email protected]>, those misrouted resets create a lot of arp traffic and huge amount of unresolved
arp entires
net/ipv4/tcp_ipv4.c static void tcp_v4_send_reset(struct
Quoted 13 lines
putting down to knees NAT firewalls which use asymmetric routing.
Signed-off-by Alexey Kuznetsov <[email protected]>--- net/ipv4/tcp_ipv4.c | 7 ++++--- net/ipv6/tcp_ipv6.c | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-)net/ipv4/tcp_ipv4.c index renamed from net/ipv4/tcp_ipv4.c +0
-075735c9..ef998b0 100644
net/ipv4/tcp_ipv4.c +0
-0@@ -708,10 +708,11 @@ static void tcp_v4_send_reset(structsock *sk, struct
sk_buff*skb)net/ipv4/tcp_ipv4.c static void tcp_v4_send_reset(struct · line 709
Quoted 2 lines
net/ipv4/tcp_ipv4.c +0
-0arg.csumoffset = offsetof(struct tcphdr , check) /2 ; arg.flags = (sk && inet_sk(sk)->transparent) ?
IP_REPLY_ARG_NOSRCCHECK: 0;net/ipv4/tcp_ipv4.c static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
Quoted 4 lines
net/ipv4/tcp_ipv4.c +1
-2/* When socket is gone, all binding information is lost. -* routing might fail in this case. using iif for oif to -* make sure we can deliver it +* routing might fail in this case. No choice here, if we choose to force
net/ipv4/tcp_ipv4.c static void tcp_v4_send_reset(struct · line 712
Quoted 1 line
net/ipv4/tcp_ipv4.c +1
-0+* input interface, we will misroute in case of asymmetric route.
net/ipv6/tcp_ipv6.c static void tcp_v6_send_response(struct
Quoted 12 lines
net/ipv4/tcp_ipv4.c +2
-1*/ - arg.bound_dev_if = sk ? sk->sk_bound_dev_if :inet_iif (skb); +if (sk) + arg.bound_dev_if = sk->sk_bound_dev_if; net =dev_net (skb_dst (skb)->dev); arg.tos =ip_hdr (skb)->tos;net/ipv6/tcp_ipv6.c index renamed from net/ipv6/tcp_ipv6.c +0
-049c8903..26175bf 100644
net/ipv6/tcp_ipv6.c +0
-0@@ -877,7 +877,8 @@ static void tcp_v6_send_response(struct
sk_buff*skb, u32 seq, u32 ack, u32 win,Quoted 10 lines
net/ipv6/tcp_ipv6.c +2
-2__tcp_v6_send_check (buff, &fl6.saddr, &fl6.daddr); fl6.flowi6_proto =IPPROTO_TCP ; - fl6.flowi6_oif =inet6_iif (skb); +if (ipv6_addr_type (&fl6.daddr) &IPV6_ADDR_LINKLOCAL ) + fl6.flowi6_oif =inet6_iif (skb); fl6.fl6_dport = t1->dest; fl6.fl6_sport = t1->source;security_skb_classify_flow (skb,flowi6_to_flowi (&fl6)); --Quoted 2 lines
1.7.2.3
We ran into this as well and pulled that commit from our tree, it was causing serious problems. Sending the RST back on the iif was definitely the wrong thing to do. Patch looks good to me.
Thanks,
Debabrata
I was trying to think of the scenario you were running into, since it falls back to using a route lookup. You do not have routes on your machine that would correctly send the packet, I assume? Then it simply comes down to the kernel doesn't have enough information to know where to send the packet.
Debabrata
Quoted 31 lines · Shawn Lu
I admit the commit
e2446eaadid break the reset in asymmetric case. There are also many use cases in interface binding, we don't want to break it too... I am ok with your patch, if asymmetric route take higher priority. Somehow, we need come up with another one to resolve RST lost in binding interface case, otherwise, people using interface binding will find later on that RST break again...thanks!
Shawn Lu <[email protected]>
Quoted 20 lines
-----Original Message-----
From: Debabrata Banerjee [mailto:[email protected]]
Sent: Friday, October 12, 2012 8:57 AM
To: Alexey Kuznetsov; Banerjee, Debabrata
Cc: [email protected]; [email protected]; Shawn Lu; [email protected]; [email protected]
Subject: Re: [PATCH] tcp resets are misroutedOn Fri, Oct 12, 2012 at 10:34 AM, Alexey Kuznetsov <[email protected]> wrote:
We ran into this as well and pulled that commit from our tree, it was causing serious problems. Sending the RST back on the iif was definitely the wrong thing to do. Patch looks good to me.
Thanks,
Debabrata
Yes. The scenario is the kernel doesn't have enough information to routing the packet, so application depend on binding to interface to shortcut routing.
thanks!
Shawn Lu <[email protected]>
Quoted 53 lines
-----Original Message-----
From: Banerjee, Debabrata [mailto:[email protected]]
Sent: Friday, October 12, 2012 10:48 AM
To: Shawn Lu; Debabrata Banerjee; Alexey Kuznetsov
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] tcp resets are misroutedI was trying to think of the scenario you were running into, since it falls back to using a route lookup. You do not have routes on your machine that would correctly send the packet, I assume? Then it simply comes down to the kernel doesn't have enough information to know where to send the packet.
Debabrata
Quoted 4 lines · Shawn Lu
I admit the commit
e2446eaadid break the reset in asymmetric case. There are also many use cases in interface binding, we don't want to break it too... I am ok with your patch, if asymmetric route take higher priority. Somehow, we need come up with another oneto resolve
Quoted 1 line
RST lost in binding interface case, otherwise, people using
interface
Quoted 19 lines
binding will find later on that RST break again...
thanks!
Shawn Lu <[email protected]>
Quoted 13 lines
-----Original Message-----
From: Debabrata Banerjee [mailto:[email protected]]
Sent: Friday, October 12, 2012 8:57 AM
To: Alexey Kuznetsov; Banerjee, Debabrata
Cc: [email protected]; [email protected]; Shawn Lu; [email protected]; [email protected]
Subject: Re: [PATCH] tcp resets are misroutedOn Fri, Oct 12, 2012 at 10:34 AM, Alexey Kuznetsov <[email protected]> wrote:
We ran into this as well and pulled that commit from our
tree, it was
Quoted 6 lines
Quoted 6 lines
causing serious problems. Sending the RST back on the iif was definitely the wrong thing to do. Patch looks good to me.
Thanks,
Debabrata
David Miller
maintainerFrom: Alexey Kuznetsov <[email protected]>
Date: Fri, 12 Oct 2012 18:34:17 +0400
Quoted 12 lines
After commit
e2446eaa.. tcp resets are always lost, when routing is asymmetric. Yes, backing out that patch will result in misrouting of resets for dead connections which used interface binding when were alive, but we actually cannot do anything here. What's died that's died and correct handling normal unbound connections is obviously a priority.Comment to comment:
Quoted 2 lines
This has few benefits:
1.tcp_v6_send_resetalready did that.It was done to route resets for IPv6 link local addresses. It was a mistake to do so for global addresses. The patch fixes this as well.
Quoted 6 lines
Actually, the problem appears to be even more serious than guaranteed loss of resets. As reported by Sergey Soloviev <[email protected]>, those misrouted resets create a lot of arp traffic and huge amount of unresolved arp entires putting down to knees NAT firewalls which use asymmetric routing.
Signed-off-by Alexey Kuznetsov <[email protected]>
Applied and queued up for -stable, thanks!