nic_router: drop closed tcp links immediately

RFCs recommend to keep TCP connections for a certain time even after they
finished a close handshake, AFAIK, in order to be able to recognize astray
packets when they arrive later. This seems overambitious especially when in
the context of the router where session quota is pretty limited. Therefore,
this commit drops this final timeout and drops closed connections immediately.

Ref #4729
This commit is contained in:
Martin Stein 2024-06-03 10:32:21 +02:00 committed by Norman Feske
parent 58726a6707
commit 20371d0445

View File

@ -259,11 +259,11 @@ void Tcp_link::_tcp_packet(Tcp_packet &tcp,
}
}
}
if (_state == State::OPENING || _state == State::OPEN) {
_packet();
} else {
_dissolve_timeout.schedule(
Microseconds(_config_ptr->tcp_max_segm_lifetime().value << 1));
switch (_state) {
case State::OPENING:
case State::OPEN: _packet(); break;
case State::CLOSED: _dissolve_timeout.schedule(Microseconds(0UL)); break;
default: _dissolve_timeout.schedule(Microseconds(_config_ptr->tcp_max_segm_lifetime().value << 1)); break;
}
}