TCP sockets aren't reset on ethernet cable reconnect #111

Open
opened 2024-08-02 11:26:06 +08:00 by atse · 5 comments
Contributor

It is possible to leave TCP sessions open when disconnecting an Ethernet cable to the Thermostat, and when reconnected they don't reset if the telnet client has already been killed prior.

This makes it possible to gradually use up all 4 TCP sessions, making the Thermostat refuse any new connections to it when we've lost all handles on previous sessions already, soft-locking it.

It is possible to leave TCP sessions open when disconnecting an Ethernet cable to the Thermostat, and when reconnected they don't reset if the telnet client has already been killed prior. This makes it possible to gradually use up all 4 TCP sessions, making the Thermostat refuse any new connections to it when we've lost all handles on previous sessions already, soft-locking it.
Owner

How is this handled in other projects like stabilizer?

How is this handled in other projects like stabilizer?
Author
Contributor

I haven't looked at Stabilizer yet but on Kirdy the TCP sockets are explicitly reset once a new link is up, and that doesn't seem to happen here. I'll need to port that over.

I haven't looked at Stabilizer yet but on Kirdy the TCP sockets are [explicitly reset once a new link is up](https://git.m-labs.hk/M-Labs/kirdy/src/commit/3f9a4bf140cb7cc4978d32448073d76e2559d58a/src/net/net.rs#L408-L423), and that doesn't seem to happen here. I'll need to port that over.
Owner

Please look at Stabilizer first.

Resetting all sockets on Ethernet link drop isn't necessarily the right thing to do and Kirdy might need fixing as well.

Please look at Stabilizer first. Resetting all sockets on Ethernet link drop isn't necessarily the right thing to do and Kirdy might need fixing as well.
Owner

Stabilizer Firmware does reset all the sockets when Ethernet link is dropped. Just the part that reset all sockets is written inside the smoltcp-nal crate.

74c43885d9/src/net/network_processor.rs (L38-L56)
e0c131d55e/src/lib.rs (L349-L363)

Stabilizer Firmware does reset all the sockets when Ethernet link is dropped. Just the part that reset all sockets is written inside the smoltcp-nal crate. https://github.com/quartiq/stabilizer/blob/74c43885d9d938d37ad9aecc815d3f0bac7b5d8e/src/net/network_processor.rs#L38-L56 https://github.com/quartiq/smoltcp-nal/blob/e0c131d55e7d5f6c772455200f0149d7ecc32910/src/lib.rs#L349-L363
Owner

Doesn't sound like a very sensible thing to do. Better (1) increase the number of sockets (we have a bloated MCU so we might as well make use of it) (2) terminate stale connections by implementing a heartbeat mechanism (TCP keepalive is built into smoltcp and could be used easily on the device side) and/or closing the oldest connection when a new one comes and we're out of socket handles.

Doesn't sound like a very sensible thing to do. Better (1) increase the number of sockets (we have a bloated MCU so we might as well make use of it) (2) terminate stale connections by implementing a heartbeat mechanism (TCP keepalive is built into smoltcp and could be used easily on the device side) and/or closing the oldest connection when a new one comes and we're out of socket handles.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/thermostat#111
No description provided.