conntrack, idle TCP connection and keep-alives
Hello!
It seems that, when masquerading, conntrack silently drops idle connection after nf_conntrack_tcp_timeout_established seconds. This's pretty terrible, as application inside the network, if it never sends anything, will never know that connection was dropped.
RFC 5382 gives us a solution to this:
Quoted 2 lines
A NAT can check if an endpoint for a session has crashed by sending a TCP keep-alive packet and receiving a TCP RST packet in response.
However, it I couldn't find such feature in netfilter. It would be pretty nice to have.
It would be much more effective than enabling keep-alives system-wide (which is not even possible in practice). It makes sense that NAT has to manage such things, as only NAT knows the timeouts of itself. If there's a NAT along the route, it will send keep-alives (overhead, but inevitable). If there's no NATs, there will be no keep-alives. Simple.
AFAIK, Cisco implements this under name Dead Connection Detection.
Quoted 4 lines · WGH
It seems that, when masquerading, conntrack silently drops idle connection after
nf_conntrack_tcp_timeout_establishedseconds. This's pretty terrible, as application inside the network, if it never sends anything, will never know that connection was dropped.
If this is a problem for you, then increase nf_conntrack_tcp_timeout_established to an insanely high value. You do realize, of course, that the conntrack table has a finite number of entries.
Quoted 6 lines
RFC 5382 gives us a solution to this:
Quoted 2 lines
A NAT can check if an endpoint for a session has crashed by sending a TCP keep-alive packet and receiving a TCP RST packet in response.
However, it I couldn't find such feature in netfilter. It would be pretty nice to have.
Keepalives should be done in the application, not in the firewall.
Phil
Quoted 10 lines · Phil Oester
Quoted 4 lines · WGH
It seems that, when masquerading, conntrack silently drops idle connection after
nf_conntrack_tcp_timeout_establishedseconds. This's pretty terrible, as application inside the network, if it never sends anything, will never know that connection was dropped.If this is a problem for you, then increase
nf_conntrack_tcp_timeout_establishedto an insanely high value. You do realize, of course, that the conntrack table has a finite number of entries.
Quoted 8 lines
Quoted 6 lines
RFC 5382 gives us a solution to this:
Quoted 2 lines
A NAT can check if an endpoint for a session has crashed by sending a TCP keep-alive packet and receiving a TCP RST packet in response.
However, it I couldn't find such feature in netfilter. It would be pretty nice to have.
Keepalives should be done in the application, not in the firewall.
Actually I think its a pretty nice idea to reduce breakage introduced by NATs. There a millions of embedded devices that use very small timeout values to reduce memory usage, at the cost of frequently breaking idle connections.
Quoted 18 lines · Patrick McHardy
Quoted 17 lines · Phil Oester
Quoted 4 lines · WGH
It seems that, when masquerading, conntrack silently drops idle connection after
nf_conntrack_tcp_timeout_establishedseconds. This's pretty terrible, as application inside the network, if it never sends anything, will never know that connection was dropped.If this is a problem for you, then increase
nf_conntrack_tcp_timeout_establishedto an insanely high value. You do realize, of course, that the conntrack table has a finite number of entries.Quoted 6 lines
RFC 5382 gives us a solution to this:
Quoted 2 lines
A NAT can check if an endpoint for a session has crashed by sending a TCP keep-alive packet and receiving a TCP RST packet in response.
However, it I couldn't find such feature in netfilter. It would be pretty nice to have.
Quoted 6 lines
Quoted 1 line
Keepalives should be done in the application, not in the firewall.
Actually I think its a pretty nice idea to reduce breakage introduced by NATs. There a millions of embedded devices that use very small timeout values to reduce memory usage, at the cost of frequently breaking idle connections.
The downside seems to be that we'd need to keep track of timestamp values to send valid keepalives, which also costs extra memory. I don't think that cost is justifiable for NAT keepalives alone.
Quoted 21 lines · Patrick McHardy
Quoted 20 lines · Patrick McHardy
Quoted 18 lines · Phil Oester
Quoted 4 lines · WGH
It seems that, when masquerading, conntrack silently drops idle connection after
nf_conntrack_tcp_timeout_establishedseconds. This's pretty terrible, as application inside the network, if it never sends anything, will never know that connection was dropped.If this is a problem for you, then increase
nf_conntrack_tcp_timeout_establishedto an insanely high value. You do realize, of course, that the conntrack table has a finite number of entries.Quoted 6 lines
RFC 5382 gives us a solution to this:
Quoted 2 lines
A NAT can check if an endpoint for a session has crashed by sending a TCP keep-alive packet and receiving a TCP RST packet in response.
However, it I couldn't find such feature in netfilter. It would be pretty nice to have.
Keepalives should be done in the application, not in the firewall.
Quoted 8 lines
Quoted 4 lines
Actually I think its a pretty nice idea to reduce breakage introduced by NATs. There a millions of embedded devices that use very small timeout values to reduce memory usage, at the cost of frequently breaking idle connections.
The downside seems to be that we'd need to keep track of timestamp values to send valid keepalives, which also costs extra memory. I don't think that cost is justifiable for NAT keepalives alone.
I think a single flag could be sufficient: if the timer in conntrack goes off and the entry is in the ESTABLISHED state and this flag is not set, then send a TCP keepalive packet and start the timer with a short timeout. If we receive the reply packet, then the long ESTABLISHED timeout value can be restored and the flag cleared.
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
H-1525 Budapest 114, POB. 49, Hungary
Quoted 32 lines · Jozsef Kadlecsik
Quoted 21 lines · Patrick McHardy
Quoted 20 lines · Patrick McHardy
Quoted 18 lines · Phil Oester
Quoted 4 lines · WGH
It seems that, when masquerading, conntrack silently drops idle connection after
nf_conntrack_tcp_timeout_establishedseconds. This's pretty terrible, as application inside the network, if it never sends anything, will never know that connection was dropped.If this is a problem for you, then increase
nf_conntrack_tcp_timeout_establishedto an insanely high value. You do realize, of course, that the conntrack table has a finite number of entries.Quoted 6 lines
RFC 5382 gives us a solution to this:
Quoted 2 lines
A NAT can check if an endpoint for a session has crashed by sending a TCP keep-alive packet and receiving a TCP RST packet in response.
However, it I couldn't find such feature in netfilter. It would be pretty nice to have.
Keepalives should be done in the application, not in the firewall.
Quoted 8 lines
Quoted 4 lines
Actually I think its a pretty nice idea to reduce breakage introduced by NATs. There a millions of embedded devices that use very small timeout values to reduce memory usage, at the cost of frequently breaking idle connections.
The downside seems to be that we'd need to keep track of timestamp values to send valid keepalives, which also costs extra memory. I don't think that cost is justifiable for NAT keepalives alone.
Quoted 5 lines
I think a single flag could be sufficient: if the timer in conntrack goes off and the entry is in the ESTABLISHED state and this flag is not set, then send a TCP keepalive packet and start the timer with a short timeout. If we receive the reply packet, then the long ESTABLISHED timeout value can be restored and the flag cleared.
Sure, I think we wouldn't even need that flag, we can just send the keepalive and set a short timeout. If a RST is received, the connection is killed anyway, otherwise it will be refreshed with the ESTABLISHED timeout.
But we do need a timestamp value to pass PAWS.
Quoted 11 lines · Patrick McHardy
Quoted 5 lines · Jozsef Kadlecsik
I think a single flag could be sufficient: if the timer in conntrack goes off and the entry is in the ESTABLISHED state and this flag is not set, then send a TCP keepalive packet and start the timer with a short timeout. If we receive the reply packet, then the long ESTABLISHED timeout value can be restored and the flag cleared.
Sure, I think we wouldn't even need that flag, we can just send the keepalive and set a short timeout. If a RST is received, the connection is killed anyway, otherwise it will be refreshed with the ESTABLISHED timeout.
But we do need a timestamp value to pass PAWS.
I believe you forgot the third scenario: neither ACK nor RST is received in reply.
Quoted 7 lines · WGH
Quoted 6 lines · Patrick McHardy
Quoted 5 lines · Jozsef Kadlecsik
I think a single flag could be sufficient: if the timer in conntrack goes off and the entry is in the ESTABLISHED state and this flag is not set, then send a TCP keepalive packet and start the timer with a short timeout. If we receive the reply packet, then the long ESTABLISHED timeout value can be restored and the flag cleared.
Quoted 7 lines
Quoted 5 lines
Sure, I think we wouldn't even need that flag, we can just send the keepalive and set a short timeout. If a RST is received, the connection is killed anyway, otherwise it will be refreshed with the ESTABLISHED timeout.
But we do need a timestamp value to pass PAWS.
I believe you forgot the third scenario: neither ACK nor RST is received in reply.
Actually no, "... and set a short timeout ...".
Quoted 12 lines · Patrick McHardy
Quoted 11 lines · WGH
Quoted 10 lines · Patrick McHardy
Quoted 5 lines · Jozsef Kadlecsik
I think a single flag could be sufficient: if the timer in conntrack goes off and the entry is in the ESTABLISHED state and this flag is not set, then send a TCP keepalive packet and start the timer with a short timeout. If we receive the reply packet, then the long ESTABLISHED timeout value can be restored and the flag cleared.
Sure, I think we wouldn't even need that flag, we can just send the keepalive and set a short timeout. If a RST is received, the connection is killed anyway, otherwise it will be refreshed with the ESTABLISHED timeout.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
But we do need a timestamp value to pass PAWS.
I believe you forgot the third scenario: neither ACK nor RST is received in reply.
Actually no, "... and set a short timeout ...".
Well, OK, we do need a flag to distinguish normal timeout from probe timeout. But still I don't see how we can do this without increasing the size of every conntrack by at least 4 bytes.
Quoted 14 lines · Patrick McHardy
Quoted 13 lines · Patrick McHardy
Quoted 12 lines · WGH
Quoted 11 lines · Patrick McHardy
Quoted 5 lines · Jozsef Kadlecsik
I think a single flag could be sufficient: if the timer in conntrack goes off and the entry is in the ESTABLISHED state and this flag is not set, then send a TCP keepalive packet and start the timer with a short timeout. If we receive the reply packet, then the long ESTABLISHED timeout value can be restored and the flag cleared.
Sure, I think we wouldn't even need that flag, we can just send the keepalive and set a short timeout. If a RST is received, the connection is killed anyway, otherwise it will be refreshed with the ESTABLISHED timeout.
But we do need a timestamp value to pass PAWS.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I believe you forgot the third scenario: neither ACK nor RST is received in reply.
Actually no, "... and set a short timeout ...".
Well, OK, we do need a flag to distinguish normal timeout from probe timeout. But still I don't see how we can do this without increasing the size of every conntrack by at least 4 bytes.
Yes, you're right: PAWS assumes all packets carry timestamps option, an option-less ACK isn't sufficient. And increasing every conntrack entry does seem too expensive when the application itself could send keep-alive packets.
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
H-1525 Budapest 114, POB. 49, Hungary
Quoted 21 lines · Jozsef Kadlecsik
Quoted 19 lines · Patrick McHardy
Quoted 17 lines · Patrick McHardy
Quoted 7 lines · WGH
Quoted 6 lines · Patrick McHardy
Quoted 5 lines · Jozsef Kadlecsik
I think a single flag could be sufficient: if the timer in conntrack goes off and the entry is in the ESTABLISHED state and this flag is not set, then send a TCP keepalive packet and start the timer with a short timeout. If we receive the reply packet, then the long ESTABLISHED timeout value can be restored and the flag cleared.
Quoted 7 lines
Quoted 5 lines
Sure, I think we wouldn't even need that flag, we can just send the keepalive and set a short timeout. If a RST is received, the connection is killed anyway, otherwise it will be refreshed with the ESTABLISHED timeout.
But we do need a timestamp value to pass PAWS.
I believe you forgot the third scenario: neither ACK nor RST is received in reply.
Actually no, "... and set a short timeout ...".
Quoted 8 lines
Quoted 3 lines
Well, OK, we do need a flag to distinguish normal timeout from probe timeout. But still I don't see how we can do this without increasing the size of every conntrack by at least 4 bytes.
Yes, you're right: PAWS assumes all packets carry timestamps option, an option-less ACK isn't sufficient. And increasing every conntrack entry does seem too expensive when the application itself could send keep-alive packets.
Looking at the source code, actually, the Linux TCP stack handles gracefully TCP packets without timestamp options when sender originally announced TCP timestamps. So it seems to me we could send a simple, option-less "keep-alive" packet. RFC1323 does not discuss the case but if the option is missing, stacks should fall back to the base handling, isn't it? ;-)
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences
H-1525 Budapest 114, POB. 49, Hungary
Quoted 32 lines · Jozsef Kadlecsik
Quoted 21 lines · Jozsef Kadlecsik
Quoted 19 lines · Patrick McHardy
Quoted 17 lines · Patrick McHardy
Quoted 7 lines · WGH
Quoted 6 lines · Patrick McHardy
Quoted 5 lines · Jozsef Kadlecsik
I think a single flag could be sufficient: if the timer in conntrack goes off and the entry is in the ESTABLISHED state and this flag is not set, then send a TCP keepalive packet and start the timer with a short timeout. If we receive the reply packet, then the long ESTABLISHED timeout value can be restored and the flag cleared.
Quoted 7 lines
Quoted 5 lines
Sure, I think we wouldn't even need that flag, we can just send the keepalive and set a short timeout. If a RST is received, the connection is killed anyway, otherwise it will be refreshed with the ESTABLISHED timeout.
But we do need a timestamp value to pass PAWS.
I believe you forgot the third scenario: neither ACK nor RST is received in reply.
Actually no, "... and set a short timeout ...".
Quoted 8 lines
Quoted 3 lines
Well, OK, we do need a flag to distinguish normal timeout from probe timeout. But still I don't see how we can do this without increasing the size of every conntrack by at least 4 bytes.
Yes, you're right: PAWS assumes all packets carry timestamps option, an option-less ACK isn't sufficient. And increasing every conntrack entry does seem too expensive when the application itself could send keep-alive packets.
Quoted 6 lines
Looking at the source code, actually, the Linux TCP stack handles gracefully TCP packets without timestamp options when sender originally announced TCP timestamps. So it seems to me we could send a simple, option-less "keep-alive" packet. RFC1323 does not discuss the case but if the option is missing, stacks should fall back to the base handling, isn't it? ;-)
That would be one option. Alternatively we could just make it optional by putting it into an extend or, looking at the NAT structure, shrink it a bit more for the NAT case to make up for the size increase by moving the PPtP helper data to an extend.
Quoted 3 lines · Phil Oester
If this is a problem for you, then increase
nf_conntrack_tcp_timeout_establishedto an insanely high value. You do realize, of course, that the conntrack table has a finite number of entries.
It'll delay the problem, but not fix it. Besides, it'll worsen the situtation that established timeout intended to fix - genuinely crashed connections will linger for said insane value.
Quoted 1 line
Keepalives should be done in the application, not in the firewall.
Why not, actually? It isn't strictly keep-alive in application sense, but rather a way that NAT may use to detect broken connections. It addresses breakage caused by NAT itself, while keep-alives issued by application will address other problems (like physical connection loss), if necessary.