netfilter: conntrack: simplify sctp state machine
Subsystems (2)
RFC PATCH v3 1/1 netfilter: conntrack: simplify sctp state machine
All the paths in an SCTP connection are kept alive either by actual DATA/SACK running through the connection or by HEARTBEAT. This patch proposes a simple state machine with only two states OPEN_WAIT and ESTABLISHED (similar to UDP). The reason for this change is a full stateful approach to SCTP is difficult when the association is multihomed since the endpoints could use different paths in the network during the lifetime of an association.
Default timeouts are:
OPEN_WAIT: 3 seconds (rto_initial) ESTABLISHED: 210 seconds (rto_max + hb_interval * path_max_retrans)
Important changes/notes
- Timeout is used to clean up conntrack entries
- VTAG checks are kept as is (can be moved to a conntrack extension if desired)
- SCTP chunks are parsed only once, and a map is populated with the information on the chunks present in the packet
Changes since v2:
- fix for connection re-use bug reported by Long Xin <[email protected]>
Changes since v1:
- sctp_new() brought back for unconfirmed CT entries
- sctp_vtag_check() does all vtag related check, except for HEARTBEAT/HEARTBEACK_ACK chunks
- Style check fixes
- Revert all UAPI changes
--- .../uapi/linux/netfilter/nf_conntrack_sctp.h | 1 + .../linux/netfilter/nfnetlink_cttimeout.h | 1 + net/netfilter/nf_conntrack_proto_sctp.c | 617 +++++------------- net/netfilter/nf_conntrack_standalone.c | 72 +- 4 files changed, 172 insertions(+), 519 deletions(-)
include/uapi/linux/netfilter/nf_conntrack_sctp.h +1 -0
@@ -9,6 +9,7 @@ enum sctp_conntrack {SCTP_CONNTRACK_NONE ,SCTP_CONNTRACK_CLOSED ,SCTP_CONNTRACK_COOKIE_WAIT , +SCTP_CONNTRACK_OPEN_WAIT =SCTP_CONNTRACK_COOKIE_WAIT ,SCTP_CONNTRACK_COOKIE_ECHOED ,SCTP_CONNTRACK_ESTABLISHED , SCTP_CONNTRACK_SHUTDOWN_SENT,
include/uapi/linux/netfilter/nfnetlink_cttimeout.h +1 -0
@@ -88,6 +88,7 @@ enum ctattr_timeout_sctp {CTA_TIMEOUT_SCTP_UNSPEC ,CTA_TIMEOUT_SCTP_CLOSED ,CTA_TIMEOUT_SCTP_COOKIE_WAIT , +CTA_TIMEOUT_SCTP_OPEN_WAIT =CTA_TIMEOUT_SCTP_COOKIE_WAIT ,CTA_TIMEOUT_SCTP_COOKIE_ECHOED ,CTA_TIMEOUT_SCTP_ESTABLISHED , CTA_TIMEOUT_SCTP_SHUTDOWN_SENT,
net/netfilter/nf_conntrack_proto_sctp.c +166 -451
725 lines not on this page · raw message
net/netfilter/nf_conntrack_standalone.c +4 -68
98 lines not on this page · raw message
Signature · 1 line
2.34.1
Florian Westphal
maintainerQuoted 26 lines · Sriram Yagnaraman
net/netfilter/nf_conntrack_proto_sctp.c +2
-4@@ -5,12 +5,13 @@* Copyright (c) 2004 Kiran Kumar Immidi <[email protected]> * Copyright (c) 2004-2012 Patrick McHardy <[email protected]> * -* SCTP is defined in RFC 2960. References to various sections in this code +* SCTP is defined in RFC 4960. References to various sections in this code * are to this RFC. */ #include <linux/types.h> #include <linux/timer.h> +#include <linux/jiffies.h> #include <linux/netfilter.h> #include <linux/in.h> #include <linux/ip.h> @@ -27,127 +28,19 @@#include <net/netfilter/nf_conntrack_ecache.h> #include <net/netfilter/nf_conntrack_timeout.h> -/* FIXME: Examine ipfilter's timeouts and conntrack transitions more -closely. They're more complex. --RR -
net/netfilter/nf_conntrack_proto_sctp.c line 36
Quoted 10 lines
net/netfilter/nf_conntrack_proto_sctp.c +2
-4-And so for me for SCTP :D -Kiran */ +#define SCTP_FLAG_HEARTBEAT_VTAG_FAILED 1static const char *const sctp_conntrack_names[] = {"NONE" , -"CLOSED" , -"COOKIE_WAIT" , -"COOKIE_ECHOED" , +"OPEN_WAIT" ,"ESTABLISHED" ,
You either need to leave the other strings in place or you need to use [SCTP_CONNTRACK_ESTABLISHED] = "ESTABLISHED",
else the mapping of enum value to string isn't correct anymore.