Skip to content

Commit 9bfab6d

Browse files
lxinFlorian Westphal
authored andcommitted
netfilter: set default timeout to 3 secs for sctp shutdown send and recv state
In SCTP protocol, it is using the same timer (T2 timer) for SHUTDOWN and SHUTDOWN_ACK retransmission. However in sctp conntrack the default timeout value for SCTP_CONNTRACK_SHUTDOWN_ACK_SENT state is 3 secs while it's 300 msecs for SCTP_CONNTRACK_SHUTDOWN_SEND/RECV state. As Paolo Valerio noticed, this might cause unwanted expiration of the ct entry. In my test, with 1s tc netem delay set on the NAT path, after the SHUTDOWN is sent, the sctp ct entry enters SCTP_CONNTRACK_SHUTDOWN_SEND state. However, due to 300ms (too short) delay, when the SHUTDOWN_ACK is sent back from the peer, the sctp ct entry has expired and been deleted, and then the SHUTDOWN_ACK has to be dropped. Also, it is confusing these two sysctl options always show 0 due to all timeout values using sec as unit: net.netfilter.nf_conntrack_sctp_timeout_shutdown_recd = 0 net.netfilter.nf_conntrack_sctp_timeout_shutdown_sent = 0 This patch fixes it by also using 3 secs for sctp shutdown send and recv state in sctp conntrack, which is also RTO.initial value in SCTP protocol. Note that the very short time value for SCTP_CONNTRACK_SHUTDOWN_SEND/RECV was probably used for a rare scenario where SHUTDOWN is sent on 1st path but SHUTDOWN_ACK is replied on 2nd path, then a new connection started immediately on 1st path. So this patch also moves from SHUTDOWN_SEND/RECV to CLOSE when receiving INIT in the ORIGINAL direction. Fixes: 9fb9cbb ("[NETFILTER]: Add nf_conntrack subsystem.") Reported-by: Paolo Valerio <pvalerio@redhat.com> Signed-off-by: Xin Long <lucien.xin@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Florian Westphal <fw@strlen.de>
1 parent 7845914 commit 9bfab6d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Documentation/networking/nf_conntrack-sysctl.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ nf_conntrack_sctp_timeout_established - INTEGER (seconds)
178178
Default is set to (hb_interval * path_max_retrans + rto_max)
179179

180180
nf_conntrack_sctp_timeout_shutdown_sent - INTEGER (seconds)
181-
default 0.3
181+
default 3
182182

183183
nf_conntrack_sctp_timeout_shutdown_recd - INTEGER (seconds)
184-
default 0.3
184+
default 3
185185

186186
nf_conntrack_sctp_timeout_shutdown_ack_sent - INTEGER (seconds)
187187
default 3

net/netfilter/nf_conntrack_proto_sctp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ static const unsigned int sctp_timeouts[SCTP_CONNTRACK_MAX] = {
4949
[SCTP_CONNTRACK_COOKIE_WAIT] = 3 SECS,
5050
[SCTP_CONNTRACK_COOKIE_ECHOED] = 3 SECS,
5151
[SCTP_CONNTRACK_ESTABLISHED] = 210 SECS,
52-
[SCTP_CONNTRACK_SHUTDOWN_SENT] = 300 SECS / 1000,
53-
[SCTP_CONNTRACK_SHUTDOWN_RECD] = 300 SECS / 1000,
52+
[SCTP_CONNTRACK_SHUTDOWN_SENT] = 3 SECS,
53+
[SCTP_CONNTRACK_SHUTDOWN_RECD] = 3 SECS,
5454
[SCTP_CONNTRACK_SHUTDOWN_ACK_SENT] = 3 SECS,
5555
[SCTP_CONNTRACK_HEARTBEAT_SENT] = 30 SECS,
5656
};
@@ -105,7 +105,7 @@ static const u8 sctp_conntracks[2][11][SCTP_CONNTRACK_MAX] = {
105105
{
106106
/* ORIGINAL */
107107
/* sNO, sCL, sCW, sCE, sES, sSS, sSR, sSA, sHS */
108-
/* init */ {sCL, sCL, sCW, sCE, sES, sSS, sSR, sSA, sCW},
108+
/* init */ {sCL, sCL, sCW, sCE, sES, sCL, sCL, sSA, sCW},
109109
/* init_ack */ {sCL, sCL, sCW, sCE, sES, sSS, sSR, sSA, sCL},
110110
/* abort */ {sCL, sCL, sCL, sCL, sCL, sCL, sCL, sCL, sCL},
111111
/* shutdown */ {sCL, sCL, sCW, sCE, sSS, sSS, sSR, sSA, sCL},

0 commit comments

Comments
 (0)