Crazy TCP bug (keepalive flood?) in 2.6.32?
Subsystems (2)
Hi
I did upgrade of my lusca(squid) proxies and notice that some users getting up to 8-15 Mbit/s flood (while they are shaped to 128Kbit/s). After tracing i end up on one of proxies host and seems it is bug in kernel tcp stack.
I check packets inside - it is same repeating content (and even same tcp sequence, so it is almost sure tcp bug). Sender also ignoring ICMP unreachable packets and continue flooding destination
Here is some examples
ss output for corresponding entry
ESTAB 0 8267 194.146.153.114:8080 172.16.67.243:2512
20:32:08.491470 IP (tos 0x0, ttl 64, id 49493, offset 0, flags [DF], proto TCP (6), length 655)
194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63
(correct), seq 0:615, ack 1, win 7504, length 615
20:32:08.492487 IP (tos 0x0, ttl 64, id 49494, offset 0, flags [DF], proto TCP
(6), length 655)
194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63
(correct), seq 0:615, ack 1, win 7504, length 615
20:32:08.493468 IP (tos 0x0, ttl 64, id 49495, offset 0, flags [DF], proto TCP
(6), length 655)
194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63
(correct), seq 0:615, ack 1, win 7504, length 615
20:32:08.494463 IP (tos 0x0, ttl 64, id 49496, offset 0, flags [DF], proto TCP
(6), length 655)
194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63
(correct), seq 0:615, ack 1, win 7504, length 615
20:32:08.495463 IP (tos 0x0, ttl 64, id 49497, offset 0, flags [DF], proto TCP
(6), length 655)
194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615
20:32:08.496467 IP (tos 0x0, ttl 64, id 49498, offset 0, flags [DF], proto TCP (6), length 655)
One more
20:36:13.310718 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.311725 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.312729 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.313717 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.314717 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.315718 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.316725 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
I run multiple times ss
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,172) uid:101 ino:4772596 sk:c0ce84c0
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,43) uid:101 ino:4772596 sk:c0ce84c0
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,17) uid:101 ino:4772596 sk:c0ce84c0
After i kill squid it will switch socket to FIN-WAIT state and flood will stop.
Some sysctl tuning done during boot (maybe related) sysctl -w net.ipv4.tcp_frto=2
sysctl -w net.ipv4.tcp_frto_response=2
And most probably it is related to keepalive. I have it set on this socket:http_port 8080 transparent tcpkeepalive=30,30,60 http11
Quoted 1 line
From manual
#<-----> tcpkeepalive[=idle,interval,timeout]
#<-----><------><------>Enable TCP keepalive probes of idle connections #<-----><------><------>idle is the initial time before TCP starts probing #<-----><------><------>the connection, interval how often to probe, and #<-----><------><------>timeout the time before giving up.
I am not able to reproduce reliably bug, but it is appearing on different cluster pc's randomly for single connection each 5-10 minutes (around 8000 established connections to each at moment, 8 pc's in cluster) and dissapearing after 10-50 seconds of flood.
Cc Damian.
Quoted 82 lines · Denys Fedoryshchenko
Hi
I did upgrade of my lusca(squid) proxies and notice that some users getting up to 8-15 Mbit/s flood (while they are shaped to 128Kbit/s). After tracing i end up on one of proxies host and seems it is bug in kernel tcp stack.
I check packets inside - it is same repeating content (and even same tcp sequence, so it is almost sure tcp bug). Sender also ignoring ICMP unreachable packets and continue flooding destination
Here is some examples
ss output for corresponding entryESTAB 0 8267 194.146.153.114:8080 172.16.67.243:2512
20:32:08.491470 IP (tos
0x0, ttl 64, id 49493, offset 0, flags [DF], proto TCP (6), length 655)194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.492487 IP (tos 0x0, ttl 64, id 49494, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.493468 IP (tos 0x0, ttl 64, id 49495, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.494463 IP (tos 0x0, ttl 64, id 49496, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.495463 IP (tos 0x0, ttl 64, id 49497, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63(correct), seq 0:615, ack 1, win 7504, length 615
20:32:08.496467 IP (tos0x0, ttl 64, id 49498, offset 0, flags [DF], proto TCP (6), length 655)One more
20:36:13.310718 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.311725 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.312729 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.313717 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.314717 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.315718 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.316725 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440I run multiple times ss
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,172) uid:101 ino:4772596 sk:c0ce84c0
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,43) uid:101 ino:4772596 sk:c0ce84c0
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,17) uid:101 ino:4772596 sk:c0ce84c0After i kill squid it will switch socket to FIN-WAIT state and flood will stop.
Some sysctl tuning done during boot (maybe related) sysctl -w net.ipv4.tcp_frto=2
sysctl -w net.ipv4.tcp_frto_response=2And most probably it is related to keepalive. I have it set on this socket:
http_port8080 transparent tcpkeepalive=30,30,60 http11From manual
#<-----> tcpkeepalive[=idle,interval,timeout]
#<-----><------><------>Enable TCP keepalive probes of idle connections #<-----><------><------>idle is the initial time before TCP starts probing #<-----><------><------>the connection, interval how often to probe, and #<-----><------><------>timeout the time before giving up.
Quoted 4 lines
I am not able to reproduce reliably bug, but it is appearing on different cluster pc's randomly for single connection each 5-10 minutes (around 8000 established connections to each at moment, 8 pc's in cluster) and dissapearing after 10-50 seconds of flood.
Damian, can you please take a look. ...It's a bit weird after a very brief look (as if RTO would trigger way too often). Maybe its backoff is broken now?
Signature · 1 line
i.
Quoted 86 lines · Ilpo Järvinen
Cc Damian.
Quoted 82 lines · Denys Fedoryshchenko
Hi
I did upgrade of my lusca(squid) proxies and notice that some users getting up to 8-15 Mbit/s flood (while they are shaped to 128Kbit/s). After tracing i end up on one of proxies host and seems it is bug in kernel tcp stack.
I check packets inside - it is same repeating content (and even same tcp sequence, so it is almost sure tcp bug). Sender also ignoring ICMP unreachable packets and continue flooding destination
Here is some examples
ss output for corresponding entryESTAB 0 8267 194.146.153.114:8080 172.16.67.243:2512
20:32:08.491470 IP (tos
0x0, ttl 64, id 49493, offset 0, flags [DF], proto TCP (6), length 655)194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.492487 IP (tos 0x0, ttl 64, id 49494, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.493468 IP (tos 0x0, ttl 64, id 49495, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.494463 IP (tos 0x0, ttl 64, id 49496, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.495463 IP (tos 0x0, ttl 64, id 49497, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63(correct), seq 0:615, ack 1, win 7504, length 615
20:32:08.496467 IP (tos0x0, ttl 64, id 49498, offset 0, flags [DF], proto TCP (6), length 655)One more
20:36:13.310718 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.311725 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.312729 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.313717 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.314717 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.315718 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.316725 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440I run multiple times ss
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,172) uid:101 ino:4772596 sk:c0ce84c0
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,43) uid:101 ino:4772596 sk:c0ce84c0
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,17) uid:101 ino:4772596 sk:c0ce84c0After i kill squid it will switch socket to FIN-WAIT state and flood will stop.
Some sysctl tuning done during boot (maybe related) sysctl -w net.ipv4.tcp_frto=2
sysctl -w net.ipv4.tcp_frto_response=2And most probably it is related to keepalive. I have it set on this socket:
http_port8080 transparent tcpkeepalive=30,30,60 http11From manual
#<-----> tcpkeepalive[=idle,interval,timeout]
#<-----><------><------>Enable TCP keepalive probes of idle connections #<-----><------><------>idle is the initial time before TCP starts probing #<-----><------><------>the connection, interval how often to probe, and #<-----><------><------>timeout the time before giving up.
Quoted 8 lines
Quoted 4 lines
I am not able to reproduce reliably bug, but it is appearing on different cluster pc's randomly for single connection each 5-10 minutes (around 8000 established connections to each at moment, 8 pc's in cluster) and dissapearing after 10-50 seconds of flood.
Damian, can you please take a look. ...It's a bit weird after a very brief look (as if RTO would trigger way too often). Maybe its backoff is broken now?
...I meant broken when keepalives are in use.
Signature · 1 line
i.
Quoted 93 lines · Ilpo Järvinen
Quoted 91 lines · Ilpo Järvinen
Cc Damian.
Quoted 86 lines · Denys Fedoryshchenko
Hi
I did upgrade of my lusca(squid) proxies and notice that some users getting up to 8-15 Mbit/s flood (while they are shaped to 128Kbit/s). After tracing i end up on one of proxies host and seems it is bug in kernel tcp stack.
I check packets inside - it is same repeating content (and even same tcp sequence, so it is almost sure tcp bug). Sender also ignoring ICMP unreachable packets and continue flooding destination
Here is some examples
ss output for corresponding entryESTAB 0 8267 194.146.153.114:8080 172.16.67.243:2512
20:32:08.491470 IP (tos
0x0, ttl 64, id 49493, offset 0, flags [DF], proto TCP (6), length 655)194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.492487 IP (tos 0x0, ttl 64, id 49494, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.493468 IP (tos 0x0, ttl 64, id 49495, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.494463 IP (tos 0x0, ttl 64, id 49496, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.495463 IP (tos 0x0, ttl 64, id 49497, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63(correct), seq 0:615, ack 1, win 7504, length 615
20:32:08.496467 IP (tos0x0, ttl 64, id 49498, offset 0, flags [DF], proto TCP (6), length 655)One more
20:36:13.310718 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.311725 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.312729 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.313717 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.314717 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.315718 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.316725 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440I run multiple times ss
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,172) uid:101 ino:4772596 sk:c0ce84c0
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,43) uid:101 ino:4772596 sk:c0ce84c0
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,17) uid:101 ino:4772596 sk:c0ce84c0After i kill squid it will switch socket to FIN-WAIT state and flood will stop.
Some sysctl tuning done during boot (maybe related) sysctl -w net.ipv4.tcp_frto=2
sysctl -w net.ipv4.tcp_frto_response=2And most probably it is related to keepalive. I have it set on this socket:
http_port8080 transparent tcpkeepalive=30,30,60 http11From manual
#<-----> tcpkeepalive[=idle,interval,timeout]
#<-----><------><------>Enable TCP keepalive probes of idle connections #<-----><------><------>idle is the initial time before TCP starts probing #<-----><------><------>the connection, interval how often to probe, and #<-----><------><------>timeout the time before giving up.I am not able to reproduce reliably bug, but it is appearing on different cluster pc's randomly for single connection each 5-10 minutes (around 8000 established connections to each at moment, 8 pc's in cluster) and dissapearing after 10-50 seconds of flood.
Quoted 5 lines
Quoted 3 lines
Damian, can you please take a look. ...It's a bit weird after a very brief look (as if RTO would trigger way too often). Maybe its backoff is broken now?
...I meant broken when keepalives are in use.
I guess it's that the ICMPs are somehow triggering the tcp_retransmit_timer call in tcp_ipv4 even though they're not supposed to do that until the RTO timeout would have fired. I've no idea why remaining doesn't do what it's supposed to.
Signature · 1 line
i.
Quoted 10 lines · Ilpo Järvinen
Quoted 8 lines · Ilpo Järvinen
Quoted 6 lines · Ilpo Järvinen
Cc Damian.
Quoted 2 lines · Denys Fedoryshchenko
Hi
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
I did upgrade of my lusca(squid) proxies and notice that some users getting up to 8-15 Mbit/s flood (while they are shaped to 128Kbit/s). After tracing i end up on one of proxies host and seems it is bug in kernel tcp stack.
I check packets inside - it is same repeating content (and even same tcp sequence, so it is almost sure tcp bug). Sender also ignoring ICMP unreachable packets and continue flooding destination
By "also" you mean, that the sender is flooding with and without ICMPs?
Quoted 80 lines
Quoted 80 lines
Quoted 80 lines
Quoted 73 lines
Here is some examples
ss output for corresponding entryESTAB 0 8267 194.146.153.114:8080 172.16.67.243:2512
20:32:08.491470 IP (tos
0x0, ttl 64, id 49493, offset 0, flags [DF], proto TCP (6), length 655)194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.492487 IP (tos 0x0, ttl 64, id 49494, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.493468 IP (tos 0x0, ttl 64, id 49495, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.494463 IP (tos 0x0, ttl 64, id 49496, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.495463 IP (tos 0x0, ttl 64, id 49497, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63(correct), seq 0:615, ack 1, win 7504, length 615
20:32:08.496467 IP (tos0x0, ttl 64, id 49498, offset 0, flags [DF], proto TCP (6), length 655)One more
20:36:13.310718 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.311725 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.312729 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.313717 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.314717 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.315718 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.316725 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440I run multiple times ss
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,172) uid:101 ino:4772596 sk:c0ce84c0
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,43) uid:101 ino:4772596 sk:c0ce84c0
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,17) uid:101 ino:4772596 sk:c0ce84c0After i kill squid it will switch socket to FIN-WAIT state and flood will stop.
Some sysctl tuning done during boot (maybe related) sysctl -w net.ipv4.tcp_frto=2
sysctl -w net.ipv4.tcp_frto_response=2And most probably it is related to keepalive. I have it set on this socket:
http_port8080 transparent tcpkeepalive=30,30,60 http11From manual
#<-----> tcpkeepalive[=idle,interval,timeout]
#<-----><------><------>Enable TCP keepalive probes of idle connections #<-----><------><------>idle is the initial time before TCP starts probing #<-----><------><------>the connection, interval how often to probe, and #<-----><------><------>timeout the time before giving up.Quoted 4 lines
I am not able to reproduce reliably bug, but it is appearing on different cluster pc's randomly for single connection each 5-10 minutes (around 8000 established connections to each at moment, 8 pc's in cluster) and dissapearing after 10-50 seconds of flood.
Damian, can you please take a look. ...It's a bit weird after a very brief look (as if RTO would trigger way too often). Maybe its backoff is broken now?
Quoted 7 lines
Quoted 1 line
...I meant broken when keepalives are in use.
I guess it's that the ICMPs are somehow triggering the
tcp_retransmit_timercall intcp_ipv4even though they're not supposed to do that until the RTO timeout would have fired. I've no idea why remaining doesn't do what it's supposed to.
Hm.
Those ICMPs will trigger only, if icsk_backoff and retransmits is non-zero. If that's because of a retransmission (which was thought to be), then packets_out is non-zero and tcp_probe_timer will return before sending anything. Correct me, if I'm wrong here.
I'll try to think of a case, where those are non-zero with no packets_out.
Damian
Quoted 109 lines · Damian Lukowski
Quoted 10 lines · Ilpo Järvinen
Quoted 8 lines · Ilpo Järvinen
Quoted 6 lines · Ilpo Järvinen
Cc Damian.
Quoted 2 lines · Denys Fedoryshchenko
Hi
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
I did upgrade of my lusca(squid) proxies and notice that some users getting up to 8-15 Mbit/s flood (while they are shaped to 128Kbit/s). After tracing i end up on one of proxies host and seems it is bug in kernel tcp stack.
I check packets inside - it is same repeating content (and even same tcp sequence, so it is almost sure tcp bug). Sender also ignoring ICMP unreachable packets and continue flooding destination
By "also" you mean, that the sender is flooding with and without ICMPs?
Quoted 80 lines
Quoted 80 lines
Quoted 80 lines
Quoted 73 lines
Here is some examples
ss output for corresponding entryESTAB 0 8267 194.146.153.114:8080 172.16.67.243:2512
20:32:08.491470 IP (tos
0x0, ttl 64, id 49493, offset 0, flags [DF], proto TCP (6), length 655)194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.492487 IP (tos 0x0, ttl 64, id 49494, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.493468 IP (tos 0x0, ttl 64, id 49495, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.494463 IP (tos 0x0, ttl 64, id 49496, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63 (correct), seq 0:615, ack 1, win 7504, length 615 20:32:08.495463 IP (tos 0x0, ttl 64, id 49497, offset 0, flags [DF], proto TCP (6), length 655) 194.146.153.114.8080 > 172.16.67.243.2512: Flags [P.], cksum 0xce63(correct), seq 0:615, ack 1, win 7504, length 615
20:32:08.496467 IP (tos0x0, ttl 64, id 49498, offset 0, flags [DF], proto TCP (6), length 655)One more
20:36:13.310718 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.311725 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.312729 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.313717 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.314717 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.315718 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440
20:36:13.316725 IP 194.146.153.114.8080 > 172.16.49.30.1319: Flags [.], ack 1, win 7469, length 1440I run multiple times ss
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,172) uid:101 ino:4772596 sk:c0ce84c0
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,43) uid:101 ino:4772596 sk:c0ce84c0
ESTAB 0 7730 194.146.153.114:8080 172.16.49.30:1319
timer:(on,,17) uid:101 ino:4772596 sk:c0ce84c0After i kill squid it will switch socket to FIN-WAIT state and flood will stop.
Some sysctl tuning done during boot (maybe related) sysctl -w net.ipv4.tcp_frto=2
sysctl -w net.ipv4.tcp_frto_response=2And most probably it is related to keepalive. I have it set on this socket:
http_port8080 transparent tcpkeepalive=30,30,60 http11From manual
#<-----> tcpkeepalive[=idle,interval,timeout]
#<-----><------><------>Enable TCP keepalive probes of idle connections #<-----><------><------>idle is the initial time before TCP starts probing #<-----><------><------>the connection, interval how often to probe, and #<-----><------><------>timeout the time before giving up.Quoted 4 lines
I am not able to reproduce reliably bug, but it is appearing on different cluster pc's randomly for single connection each 5-10 minutes (around 8000 established connections to each at moment, 8 pc's in cluster) and dissapearing after 10-50 seconds of flood.
Damian, can you please take a look. ...It's a bit weird after a very brief look (as if RTO would trigger way too often). Maybe its backoff is broken now?
Quoted 7 lines
Quoted 1 line
...I meant broken when keepalives are in use.
I guess it's that the ICMPs are somehow triggering the
tcp_retransmit_timercall intcp_ipv4even though they're not supposed to do that until the RTO timeout would have fired. I've no idea why remaining doesn't do what it's supposed to.
Quoted 6 lines
Hm.
Those ICMPs will trigger only, ificsk_backoffand retransmits is non-zero. If that's because of a retransmission (which was thought to be), thenpackets_outis non-zero andtcp_probe_timerwill return before sending anything. Correct me, if I'm wrong here.
I'll try to think of a case, where those are non-zero with nopackets_out.
...I thought that myself too but after some thinking I concluded that zero packets_out alone would not end up into a loop. ...As the when field would then get set to a rather valid value on the first (bogus) transmission of the not yet sent segment, so no loop for the next ICMP anymore because there should then be plenty of time remaining. I couldn't immediately determine whether that packets_out == 0 could occur (I suppose we need to think that through but I'm a bit skeptic that it is the reason here).
Another alternative to cause this is that icsk_rto become very small for some reason.
Signature · 1 line
i.
Quoted 10 lines
...I thought that myself too but after some thinking I concluded that zero
packets_outalone would not end up into a loop. ...As the when field would then get set to a rather valid value on the first (bogus) transmission of the not yet sent segment, so no loop for the next ICMP anymore because there should then be plenty of time remaining. I couldn't immediately determine whether thatpackets_out== 0 could occur (I suppose we need to think that through but I'm a bit skeptic that it is the reason here).
Quoted 3 lines
Another alternative to cause this is that
icsk_rtobecome very small for some reason.
Is there anything i can do?
2.6.32.2 have same issue, and actually hosts doing DDoS for my network. It is local network with limited capacity and i can manage it, but i imagine if real world network will have such issue...
Is there anything i can help to debug this?
I try to disable frto,
to put keepalive to default value (2 hours) - issue triggered much earlier after program restart
tried to disable also timestamps.
All hosts have similar hardware, but not completely same. r8169, Intel motherboards, Dual core processors(E5300), nothing unusual. Clocksource tsc
Nothing helps to workaround this bug. And weird thing, why it does ignore ICMP unreachable?
It seems keeps 10400 bytes in buffer and trying to send them non-stop.
tcp 0 10400 194.146.153.114:8080 172.16.120.230:49435
ESTABLISHED2078/squid
Proxy-16 ~ # ss -et|grep 120.230
ESTAB 0 0 194.146.153.114:http-alt 172.16.16.120:2307
uid:101 ino:97182030 sk:d884e3c0
ESTAB 0 10400 194.146.153.114:http-alt 172.16.120.230:49435
timer:(on,,207) uid:101 ino:97063205 sk:dcdf9c80
Proxy-16 ~ # ss -et|grep 120.230
ESTAB 0 0 194.146.153.114:http-alt 172.16.16.120:2307
uid:101 ino:97182030 sk:d884e3c0
ESTAB 0 10400 194.146.153.114:http-alt 172.16.120.230:49435
timer:(on,,88) uid:101 ino:97063205 sk:dcdf9c80
Proxy-16 ~ # ss -et|grep 120.230
ESTAB 0 0 194.146.153.114:http-alt 172.16.16.120:2307
uid:101 ino:97182030 sk:d884e3c0
ESTAB 0 10400 194.146.153.114:http-alt 172.16.120.230:49435
timer:(on,,113) uid:101 ino:97063205 sk:dcdf9c80
Proxy-16 ~ # ss -aet|grep 120.230
ESTAB 0 10400 194.146.153.114:http-alt 172.16.120.230:49435
timer:(on,,7) uid:101 ino:97063205 sk:dcdf9c80
Proxy-16 ~ # ss -aet|grep 120.230
ESTAB 0 10400 194.146.153.114:http-alt 172.16.120.230:49435
timer:(on,,3) uid:101 ino:97063205 sk:dcdf9c80
Proxy-16 ~ # ss -aet|grep 120.230
ESTAB 0 10400 194.146.153.114:http-alt 172.16.120.230:49435
timer:(on,,9) uid:101 ino:97063205 sk:dcdf9c80
Proxy-16 ~ # ss -aet|grep 120.230
ESTAB 0 10400 194.146.153.114:http-alt 172.16.120.230:49435
timer:(on,,221) uid:101 ino:97063205 sk:dcdf9c80
16:39:43.167575 IP (tos 0x0, ttl 64, id 33482, offset 0, flags [DF], proto TCP (6), length 1219)
194.146.153.114.8080 > 172.16.120.230.49435: Flags [P.], cksum 0xe340
(correct), seq 0:1179, ack 1, win 118, length 1179
16:39:43.168580 IP (tos 0x0, ttl 64, id 33483, offset 0, flags [DF], proto TCP
(6), length 1219)
194.146.153.114.8080 > 172.16.120.230.49435: Flags [P.], cksum 0xe340
(correct), seq 0:1179, ack 1, win 118, length 1179
16:39:43.169571 IP (tos 0x0, ttl 64, id 33484, offset 0, flags [DF], proto TCP
(6), length 1219)
194.146.153.114.8080 > 172.16.120.230.49435: Flags [P.], cksum 0xe340 (correct), seq 0:1179, ack 1, win 118, length 1179
Proxy-16 /config # tcpdump -ni eth0 src host 172.16.120.230 -vvv -s 1500
tcpdump: WARNING:
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 1500 bytes
16:41:54.774385 IP (tos 0xc0, ttl 59, id 31922, offset 0, flags [none], proto ICMP (1), length 576)
172.16.120.230 > 194.146.153.114: ICMP host 172.16.120.230 unreachable,
length 556
IP (tos 0x0, ttl 58, id 31545, offset 0, flags [DF], proto TCP (6),
length 1219)
194.146.153.114.8080 > 172.16.120.230.49435: Flags [P.], seq
3520354182:3520355361, ack 598087346, win 118, length 1179
16:41:54.774509 IP (tos 0xc0, ttl 59, id 31923, offset 0, flags [none], proto
ICMP (1), length 576)
172.16.120.230 > 194.146.153.114: ICMP host 172.16.120.230 unreachable,
length 556
IP (tos 0x0, ttl 58, id 31634, offset 0, flags [DF], proto TCP (6),
length 1219)
194.146.153.114.8080 > 172.16.120.230.49435: Flags [P.], seq 0:1179, ack
1, win 118, length 1179
16:41:54.774389 IP (tos 0xc0, ttl 59, id 31924, offset 0, flags [none], proto
ICMP (1), length 576)
172.16.120.230 > 194.146.153.114: ICMP host 172.16.120.230 unreachable,
length 556
IP (tos 0x0, ttl 58, id 31732, offset 0, flags [DF], proto TCP (6),
length 1219)
194.146.153.114.8080 > 172.16.120.230.49435: Flags [P.], seq 0:1179, ack 1, win 118, length 1179
16:41:57.741989 IP (tos 0xc0, ttl 59, id 31925, offset 0, flags [none], proto ICMP (1), length 576)
172.16.120.230 > 194.146.153.114: ICMP host 172.16.120.230 unreachable,
length 556
IP (tos 0x0, ttl 58, id 34579, offset 0, flags [DF], proto TCP (6),
length 1219)
194.146.153.114.8080 > 172.16.120.230.49435: Flags [P.], seq 0:1179, ack
1, win 118, length 1179
16:41:57.742169 IP (tos 0xc0, ttl 59, id 31926, offset 0, flags [none], proto
ICMP (1), length 576)
172.16.120.230 > 194.146.153.114: ICMP host 172.16.120.230 unreachable,
length 556
IP (tos 0x0, ttl 58, id 34689, offset 0, flags [DF], proto TCP (6),
length 1219)
194.146.153.114.8080 > 172.16.120.230.49435: Flags [P.], seq 0:1179, ack
1, win 118, length 1179
16:41:57.742174 IP (tos 0xc0, ttl 59, id 31927, offset 0, flags [none], proto
ICMP (1), length 576)
172.16.120.230 > 194.146.153.114: ICMP host 172.16.120.230 unreachable,
length 556
IP (tos 0x0, ttl 58, id 34723, offset 0, flags [DF], proto TCP (6),
length 1219)
194.146.153.114.8080 > 172.16.120.230.49435: Flags [P.], seq 0:1179, ack
1, win 118, length 1179
16:42:00.748848 IP (tos 0xc0, ttl 59, id 31928, offset 0, flags [none], proto
ICMP (1), length 576)
172.16.120.230 > 194.146.153.114: ICMP host 172.16.120.230 unreachable,
length 556
IP (tos 0x0, ttl 58, id 37556, offset 0, flags [DF], proto TCP (6),
length 1219)
194.146.153.114.8080 > 172.16.120.230.49435: Flags [P.], seq 0:1179, ack
1, win 118, length 1179
16:42:00.748856 IP (tos 0xc0, ttl 59, id 31929, offset 0, flags [none], proto
ICMP (1), length 576)
172.16.120.230 > 194.146.153.114: ICMP host 172.16.120.230 unreachable,
length 556
IP (tos 0x0, ttl 58, id 37597, offset 0, flags [DF], proto TCP (6),
length 1219)
194.146.153.114.8080 > 172.16.120.230.49435: Flags [P.], seq 0:1179, ack
1, win 118, length 1179
16:42:00.759461 IP (tos 0xc0, ttl 59, id 31930, offset 0, flags [none], proto
ICMP (1), length 576)
172.16.120.230 > 194.146.153.114: ICMP host 172.16.120.230 unreachable,
length 556
IP (tos 0x0, ttl 58, id 37715, offset 0, flags [DF], proto TCP (6),
length 1219)
194.146.153.114.8080 > 172.16.120.230.49435: Flags [P.], seq 0:1179, ack 1, win 118, length 1179