blob: 88ea87f4f0e790dfb14cbb8261696655fa34fba8 [file] [log] [blame]
Thomas Gleixner47505b82019-05-23 11:14:41 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Vlad Yasevich60c778b2008-01-11 09:57:09 -05002/* SCTP kernel implementation
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * (C) Copyright IBM Corp. 2001, 2004
4 * Copyright (c) 1999-2000 Cisco, Inc.
5 * Copyright (c) 1999-2001 Motorola, Inc.
6 * Copyright (c) 2001 Intel Corp.
7 * Copyright (c) 2001 Nokia, Inc.
8 *
Vlad Yasevich60c778b2008-01-11 09:57:09 -05009 * This file is part of the SCTP kernel implementation
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 * These are the state tables for the SCTP state machine.
12 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 * Please send any bug reports or fixes you make to the
14 * email address(es):
Daniel Borkmann91705c62013-07-23 14:51:47 +020015 * lksctp developers <linux-sctp@vger.kernel.org>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 * Written or modified by:
18 * La Monte H.P. Yarroll <piggy@acm.org>
19 * Karl Knutson <karl@athena.chicago.il.us>
20 * Jon Grimm <jgrimm@us.ibm.com>
21 * Hui Huang <hui.huang@nokia.com>
22 * Daisy Chang <daisyc@us.ibm.com>
23 * Ardelle Fan <ardelle.fan@intel.com>
24 * Sridhar Samudrala <sri@us.ibm.com>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 */
26
Joe Perches145ce502010-08-24 13:21:08 +000027#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/skbuff.h>
30#include <net/sctp/sctp.h>
31#include <net/sctp/sm.h>
32
Xin Long8ee821a2017-08-11 10:23:56 +080033static const struct sctp_sm_table_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -070034primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES];
Xin Long8ee821a2017-08-11 10:23:56 +080035static const struct sctp_sm_table_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -070036other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES];
Xin Long8ee821a2017-08-11 10:23:56 +080037static const struct sctp_sm_table_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -070038timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES];
39
Xin Long8ee821a2017-08-11 10:23:56 +080040static const struct sctp_sm_table_entry *sctp_chunk_event_lookup(
Xin Long52106012017-08-05 19:59:59 +080041 struct net *net,
42 enum sctp_cid cid,
43 enum sctp_state state);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45
Xin Long8ee821a2017-08-11 10:23:56 +080046static const struct sctp_sm_table_entry bug = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 .fn = sctp_sf_bug,
48 .name = "sctp_sf_bug"
49};
50
Joe Perches145ce502010-08-24 13:21:08 +000051#define DO_LOOKUP(_max, _type, _table) \
52({ \
Xin Long8ee821a2017-08-11 10:23:56 +080053 const struct sctp_sm_table_entry *rtn; \
Joe Perches145ce502010-08-24 13:21:08 +000054 \
55 if ((event_subtype._type > (_max))) { \
56 pr_warn("table %p possible attack: event %d exceeds max %d\n", \
57 _table, event_subtype._type, _max); \
wangweidongf7010e62013-12-23 12:16:52 +080058 rtn = &bug; \
Joe Perches145ce502010-08-24 13:21:08 +000059 } else \
60 rtn = &_table[event_subtype._type][(int)state]; \
61 \
62 rtn; \
63})
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
Xin Long8ee821a2017-08-11 10:23:56 +080065const struct sctp_sm_table_entry *sctp_sm_lookup_event(
Xin Longbfc6f822017-08-05 20:00:04 +080066 struct net *net,
Xin Long88ee48c2018-11-18 16:08:53 +080067 enum sctp_event_type event_type,
Xin Longbfc6f822017-08-05 20:00:04 +080068 enum sctp_state state,
69 union sctp_subtype event_subtype)
Linus Torvalds1da177e2005-04-16 15:20:36 -070070{
71 switch (event_type) {
72 case SCTP_EVENT_T_CHUNK:
Eric W. Biederman55e26eb2012-08-07 07:25:24 +000073 return sctp_chunk_event_lookup(net, event_subtype.chunk, state);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 case SCTP_EVENT_T_TIMEOUT:
Joe Perches145ce502010-08-24 13:21:08 +000075 return DO_LOOKUP(SCTP_EVENT_TIMEOUT_MAX, timeout,
76 timeout_event_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 case SCTP_EVENT_T_OTHER:
Joe Perches145ce502010-08-24 13:21:08 +000078 return DO_LOOKUP(SCTP_EVENT_OTHER_MAX, other,
79 other_event_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 case SCTP_EVENT_T_PRIMITIVE:
Joe Perches145ce502010-08-24 13:21:08 +000081 return DO_LOOKUP(SCTP_EVENT_PRIMITIVE_MAX, primitive,
82 primitive_event_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 default:
84 /* Yikes! We got an illegal event type. */
85 return &bug;
Stephen Hemminger3ff50b72007-04-20 17:09:22 -070086 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070087}
88
Peter Zijlstra1ed176a2006-11-13 16:19:07 -080089#define TYPE_SCTP_FUNC(func) {.fn = func, .name = #func}
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091#define TYPE_SCTP_DATA { \
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 /* SCTP_STATE_CLOSED */ \
Vlad Yasevichece25df2007-09-07 16:30:54 -040093 TYPE_SCTP_FUNC(sctp_sf_ootb), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -080095 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -080097 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -080099 TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800101 TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800103 TYPE_SCTP_FUNC(sctp_sf_eat_data_fast_4_4), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800105 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800107 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108} /* TYPE_SCTP_DATA */
109
110#define TYPE_SCTP_INIT { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800112 TYPE_SCTP_FUNC(sctp_sf_do_5_1B_init), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800114 TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800116 TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800118 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800120 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800122 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800124 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800126 TYPE_SCTP_FUNC(sctp_sf_do_9_2_reshutack), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127} /* TYPE_SCTP_INIT */
128
129#define TYPE_SCTP_INIT_ACK { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 /* SCTP_STATE_CLOSED */ \
Vlad Yasevich610ab732007-01-15 19:18:30 -0800131 TYPE_SCTP_FUNC(sctp_sf_do_5_2_3_initack), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800133 TYPE_SCTP_FUNC(sctp_sf_do_5_1C_ack), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800135 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800137 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800139 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800141 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800143 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800145 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146} /* TYPE_SCTP_INIT_ACK */
147
148#define TYPE_SCTP_SACK { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 /* SCTP_STATE_CLOSED */ \
Vlad Yasevichece25df2007-09-07 16:30:54 -0400150 TYPE_SCTP_FUNC(sctp_sf_ootb), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800152 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800154 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800156 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800158 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800160 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800162 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800164 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165} /* TYPE_SCTP_SACK */
166
167#define TYPE_SCTP_HEARTBEAT { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 /* SCTP_STATE_CLOSED */ \
Vlad Yasevichece25df2007-09-07 16:30:54 -0400169 TYPE_SCTP_FUNC(sctp_sf_ootb), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800171 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800173 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800175 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800177 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800179 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800181 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
183 /* This should not happen, but we are nice. */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800184 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185} /* TYPE_SCTP_HEARTBEAT */
186
187#define TYPE_SCTP_HEARTBEAT_ACK { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 /* SCTP_STATE_CLOSED */ \
Vlad Yasevichece25df2007-09-07 16:30:54 -0400189 TYPE_SCTP_FUNC(sctp_sf_ootb), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800191 TYPE_SCTP_FUNC(sctp_sf_violation), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800193 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800195 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800197 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800199 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800201 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800203 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204} /* TYPE_SCTP_HEARTBEAT_ACK */
205
206#define TYPE_SCTP_ABORT { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800208 TYPE_SCTP_FUNC(sctp_sf_pdiscard), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800210 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800212 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800214 TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800216 TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800218 TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800220 TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800222 TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223} /* TYPE_SCTP_ABORT */
224
225#define TYPE_SCTP_SHUTDOWN { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 /* SCTP_STATE_CLOSED */ \
Vlad Yasevichece25df2007-09-07 16:30:54 -0400227 TYPE_SCTP_FUNC(sctp_sf_ootb), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800229 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800231 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800233 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Wei Yongjuncf896d52008-10-23 01:00:49 -0700235 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800237 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Wei Yongjun2e3f92d2008-10-23 01:01:18 -0700239 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shut_ctsn), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800241 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242} /* TYPE_SCTP_SHUTDOWN */
243
244#define TYPE_SCTP_SHUTDOWN_ACK { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800246 TYPE_SCTP_FUNC(sctp_sf_ootb), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800248 TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800250 TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800252 TYPE_SCTP_FUNC(sctp_sf_violation), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800254 TYPE_SCTP_FUNC(sctp_sf_violation), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800256 TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800258 TYPE_SCTP_FUNC(sctp_sf_violation), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800260 TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261} /* TYPE_SCTP_SHUTDOWN_ACK */
262
263#define TYPE_SCTP_ERROR { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 /* SCTP_STATE_CLOSED */ \
Vlad Yasevichece25df2007-09-07 16:30:54 -0400265 TYPE_SCTP_FUNC(sctp_sf_ootb), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800267 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800269 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_err), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800271 TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800273 TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800275 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800277 TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800279 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280} /* TYPE_SCTP_ERROR */
281
282#define TYPE_SCTP_COOKIE_ECHO { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800284 TYPE_SCTP_FUNC(sctp_sf_do_5_1D_ce), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800286 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800288 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800290 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800292 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800294 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800296 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800298 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299} /* TYPE_SCTP_COOKIE_ECHO */
300
301#define TYPE_SCTP_COOKIE_ACK { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800303 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800305 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800307 TYPE_SCTP_FUNC(sctp_sf_do_5_1E_ca), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800309 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800311 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800313 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800315 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800317 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318} /* TYPE_SCTP_COOKIE_ACK */
319
320#define TYPE_SCTP_ECN_ECNE { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800322 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800324 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800326 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800328 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800330 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800332 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800334 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800336 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337} /* TYPE_SCTP_ECN_ECNE */
338
339#define TYPE_SCTP_ECN_CWR { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800341 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800343 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800345 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800347 TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800349 TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800351 TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800353 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800355 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356} /* TYPE_SCTP_ECN_CWR */
357
358#define TYPE_SCTP_SHUTDOWN_COMPLETE { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800360 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800362 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800364 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800366 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800368 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800370 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800372 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800374 TYPE_SCTP_FUNC(sctp_sf_do_4_C), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375} /* TYPE_SCTP_SHUTDOWN_COMPLETE */
376
377/* The primary index for this table is the chunk type.
378 * The secondary index for this table is the state.
379 *
380 * For base protocol (RFC 2960).
381 */
Xin Long8ee821a2017-08-11 10:23:56 +0800382static const struct sctp_sm_table_entry
383chunk_event_table[SCTP_NUM_BASE_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 TYPE_SCTP_DATA,
385 TYPE_SCTP_INIT,
386 TYPE_SCTP_INIT_ACK,
387 TYPE_SCTP_SACK,
388 TYPE_SCTP_HEARTBEAT,
389 TYPE_SCTP_HEARTBEAT_ACK,
390 TYPE_SCTP_ABORT,
391 TYPE_SCTP_SHUTDOWN,
392 TYPE_SCTP_SHUTDOWN_ACK,
393 TYPE_SCTP_ERROR,
394 TYPE_SCTP_COOKIE_ECHO,
395 TYPE_SCTP_COOKIE_ACK,
396 TYPE_SCTP_ECN_ECNE,
397 TYPE_SCTP_ECN_CWR,
398 TYPE_SCTP_SHUTDOWN_COMPLETE,
399}; /* state_fn_t chunk_event_table[][] */
400
401#define TYPE_SCTP_ASCONF { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800403 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800405 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800407 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800409 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Vlad Yasevichba8a06d2007-12-20 14:11:11 -0800411 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 /* SCTP_STATE_SHUTDOWN_SENT */ \
Vlad Yasevichba8a06d2007-12-20 14:11:11 -0800413 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Vlad Yasevichba8a06d2007-12-20 14:11:11 -0800415 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800417 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418} /* TYPE_SCTP_ASCONF */
419
420#define TYPE_SCTP_ASCONF_ACK { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800422 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800424 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800426 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800428 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Vlad Yasevichba8a06d2007-12-20 14:11:11 -0800430 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 /* SCTP_STATE_SHUTDOWN_SENT */ \
Vlad Yasevichba8a06d2007-12-20 14:11:11 -0800432 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Vlad Yasevichba8a06d2007-12-20 14:11:11 -0800434 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800436 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437} /* TYPE_SCTP_ASCONF_ACK */
438
439/* The primary index for this table is the chunk type.
440 * The secondary index for this table is the state.
441 */
Xin Long8ee821a2017-08-11 10:23:56 +0800442static const struct sctp_sm_table_entry
443addip_chunk_event_table[SCTP_NUM_ADDIP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 TYPE_SCTP_ASCONF,
445 TYPE_SCTP_ASCONF_ACK,
446}; /*state_fn_t addip_chunk_event_table[][] */
447
448#define TYPE_SCTP_FWD_TSN { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 /* SCTP_STATE_CLOSED */ \
Vlad Yasevichece25df2007-09-07 16:30:54 -0400450 TYPE_SCTP_FUNC(sctp_sf_ootb), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800452 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800454 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800456 TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800458 TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800460 TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn_fast), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800462 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800464 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465} /* TYPE_SCTP_FWD_TSN */
466
467/* The primary index for this table is the chunk type.
468 * The secondary index for this table is the state.
469 */
Xin Long8ee821a2017-08-11 10:23:56 +0800470static const struct sctp_sm_table_entry
471prsctp_chunk_event_table[SCTP_NUM_PRSCTP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 TYPE_SCTP_FWD_TSN,
473}; /*state_fn_t prsctp_chunk_event_table[][] */
474
Xin Longd884aa62017-02-17 12:45:43 +0800475#define TYPE_SCTP_RECONF { \
476 /* SCTP_STATE_CLOSED */ \
477 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
478 /* SCTP_STATE_COOKIE_WAIT */ \
479 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
480 /* SCTP_STATE_COOKIE_ECHOED */ \
481 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
482 /* SCTP_STATE_ESTABLISHED */ \
483 TYPE_SCTP_FUNC(sctp_sf_do_reconf), \
484 /* SCTP_STATE_SHUTDOWN_PENDING */ \
485 TYPE_SCTP_FUNC(sctp_sf_do_reconf), \
486 /* SCTP_STATE_SHUTDOWN_SENT */ \
487 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
488 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
489 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
490 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
491 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
492} /* TYPE_SCTP_RECONF */
493
494/* The primary index for this table is the chunk type.
495 * The secondary index for this table is the state.
496 */
Xin Long8ee821a2017-08-11 10:23:56 +0800497static const struct sctp_sm_table_entry
498reconf_chunk_event_table[SCTP_NUM_RECONF_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
Xin Longd884aa62017-02-17 12:45:43 +0800499 TYPE_SCTP_RECONF,
500}; /*state_fn_t reconf_chunk_event_table[][] */
501
Vlad Yasevichbbd0d592007-10-03 17:51:34 -0700502#define TYPE_SCTP_AUTH { \
Vlad Yasevichbbd0d592007-10-03 17:51:34 -0700503 /* SCTP_STATE_CLOSED */ \
504 TYPE_SCTP_FUNC(sctp_sf_ootb), \
505 /* SCTP_STATE_COOKIE_WAIT */ \
506 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
507 /* SCTP_STATE_COOKIE_ECHOED */ \
508 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
509 /* SCTP_STATE_ESTABLISHED */ \
510 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
511 /* SCTP_STATE_SHUTDOWN_PENDING */ \
512 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
513 /* SCTP_STATE_SHUTDOWN_SENT */ \
514 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
515 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
516 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
517 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
518 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
519} /* TYPE_SCTP_AUTH */
520
521/* The primary index for this table is the chunk type.
522 * The secondary index for this table is the state.
523 */
Xin Long8ee821a2017-08-11 10:23:56 +0800524static const struct sctp_sm_table_entry
525auth_chunk_event_table[SCTP_NUM_AUTH_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
Vlad Yasevichbbd0d592007-10-03 17:51:34 -0700526 TYPE_SCTP_AUTH,
527}; /*state_fn_t auth_chunk_event_table[][] */
528
Xin Long8ee821a2017-08-11 10:23:56 +0800529static const struct sctp_sm_table_entry
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 /* SCTP_STATE_CLOSED */
Vlad Yasevichece25df2007-09-07 16:30:54 -0400532 TYPE_SCTP_FUNC(sctp_sf_ootb),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 /* SCTP_STATE_COOKIE_WAIT */
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800534 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 /* SCTP_STATE_COOKIE_ECHOED */
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800536 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 /* SCTP_STATE_ESTABLISHED */
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800538 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 /* SCTP_STATE_SHUTDOWN_PENDING */
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800540 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 /* SCTP_STATE_SHUTDOWN_SENT */
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800542 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 /* SCTP_STATE_SHUTDOWN_RECEIVED */
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800544 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 /* SCTP_STATE_SHUTDOWN_ACK_SENT */
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800546 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547}; /* chunk unknown */
548
549
550#define TYPE_SCTP_PRIMITIVE_ASSOCIATE { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800552 TYPE_SCTP_FUNC(sctp_sf_do_prm_asoc), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800554 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800556 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800558 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800560 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800562 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800564 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800566 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567} /* TYPE_SCTP_PRIMITIVE_ASSOCIATE */
568
569#define TYPE_SCTP_PRIMITIVE_SHUTDOWN { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800571 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800573 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_shutdown), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800575 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_shutdown),\
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800577 TYPE_SCTP_FUNC(sctp_sf_do_9_2_prm_shutdown), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800579 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800581 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800583 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800585 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586} /* TYPE_SCTP_PRIMITIVE_SHUTDOWN */
587
588#define TYPE_SCTP_PRIMITIVE_ABORT { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800590 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800592 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800594 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800596 TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800598 TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_prm_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800600 TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_prm_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800602 TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800604 TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_prm_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605} /* TYPE_SCTP_PRIMITIVE_ABORT */
606
607#define TYPE_SCTP_PRIMITIVE_SEND { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800609 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800611 TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800613 TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800615 TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800617 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800619 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800621 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800623 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624} /* TYPE_SCTP_PRIMITIVE_SEND */
625
626#define TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800628 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800630 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800632 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800634 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800636 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800638 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800640 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800642 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643} /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */
644
645#define TYPE_SCTP_PRIMITIVE_ASCONF { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800647 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800649 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800651 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800653 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Vlad Yasevichba8a06d2007-12-20 14:11:11 -0800655 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 /* SCTP_STATE_SHUTDOWN_SENT */ \
Vlad Yasevichba8a06d2007-12-20 14:11:11 -0800657 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Vlad Yasevichba8a06d2007-12-20 14:11:11 -0800659 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800661 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
Wei Yongjun4553e882009-04-07 16:36:14 +0800662} /* TYPE_SCTP_PRIMITIVE_ASCONF */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663
Xin Long7a090b02017-01-18 00:44:44 +0800664#define TYPE_SCTP_PRIMITIVE_RECONF { \
665 /* SCTP_STATE_CLOSED */ \
666 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
667 /* SCTP_STATE_COOKIE_WAIT */ \
668 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
669 /* SCTP_STATE_COOKIE_ECHOED */ \
670 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
671 /* SCTP_STATE_ESTABLISHED */ \
672 TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
673 /* SCTP_STATE_SHUTDOWN_PENDING */ \
674 TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
675 /* SCTP_STATE_SHUTDOWN_SENT */ \
676 TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
677 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
678 TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
679 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
680 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
681} /* TYPE_SCTP_PRIMITIVE_RECONF */
682
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683/* The primary index for this table is the primitive type.
684 * The secondary index for this table is the state.
685 */
Xin Long8ee821a2017-08-11 10:23:56 +0800686static const struct sctp_sm_table_entry
687primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 TYPE_SCTP_PRIMITIVE_ASSOCIATE,
689 TYPE_SCTP_PRIMITIVE_SHUTDOWN,
690 TYPE_SCTP_PRIMITIVE_ABORT,
691 TYPE_SCTP_PRIMITIVE_SEND,
692 TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT,
693 TYPE_SCTP_PRIMITIVE_ASCONF,
Xin Long7a090b02017-01-18 00:44:44 +0800694 TYPE_SCTP_PRIMITIVE_RECONF,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695};
696
697#define TYPE_SCTP_OTHER_NO_PENDING_TSN { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800699 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800701 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800703 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 /* SCTP_STATE_ESTABLISHED */ \
Wei Yongjune1cdd552011-04-17 17:29:03 +0000705 TYPE_SCTP_FUNC(sctp_sf_do_no_pending_tsn), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800707 TYPE_SCTP_FUNC(sctp_sf_do_9_2_start_shutdown), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800709 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800711 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800713 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714}
715
716#define TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800718 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800720 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_icmp_abort), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800722 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800724 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800726 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800728 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800730 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800732 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733}
734
Xin Long8ee821a2017-08-11 10:23:56 +0800735static const struct sctp_sm_table_entry
736other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 TYPE_SCTP_OTHER_NO_PENDING_TSN,
738 TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH,
739};
740
741#define TYPE_SCTP_EVENT_TIMEOUT_NONE { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800743 TYPE_SCTP_FUNC(sctp_sf_bug), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800745 TYPE_SCTP_FUNC(sctp_sf_bug), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800747 TYPE_SCTP_FUNC(sctp_sf_bug), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800749 TYPE_SCTP_FUNC(sctp_sf_bug), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800751 TYPE_SCTP_FUNC(sctp_sf_bug), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800753 TYPE_SCTP_FUNC(sctp_sf_bug), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800755 TYPE_SCTP_FUNC(sctp_sf_bug), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800757 TYPE_SCTP_FUNC(sctp_sf_bug), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758}
759
760#define TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800762 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800764 TYPE_SCTP_FUNC(sctp_sf_bug), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800766 TYPE_SCTP_FUNC(sctp_sf_t1_cookie_timer_expire), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800768 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800770 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800772 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800774 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800776 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777}
778
779#define TYPE_SCTP_EVENT_TIMEOUT_T1_INIT { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800781 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800783 TYPE_SCTP_FUNC(sctp_sf_t1_init_timer_expire), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800785 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800787 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800789 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800791 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800793 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800795 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796}
797
798#define TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800800 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800802 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800804 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800806 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800808 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800810 TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800812 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800814 TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815}
816
817#define TYPE_SCTP_EVENT_TIMEOUT_T3_RTX { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800819 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800821 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800823 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800825 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800827 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800829 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800831 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800833 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834}
835
836#define TYPE_SCTP_EVENT_TIMEOUT_T4_RTO { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800838 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800840 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800842 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800844 TYPE_SCTP_FUNC(sctp_sf_t4_timer_expire), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800846 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800848 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800850 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800852 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853}
854
855#define TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800857 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800859 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800861 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800863 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Thomas Graff8d96052011-07-07 00:28:35 +0000865 TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800867 TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800869 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800871 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872}
873
874#define TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800876 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800878 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800880 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800882 TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800884 TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700885 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800886 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800888 TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800890 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891}
892
893#define TYPE_SCTP_EVENT_TIMEOUT_SACK { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800895 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800897 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800899 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800901 TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800903 TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800905 TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800907 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800909 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910}
911
912#define TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE { \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913 /* SCTP_STATE_CLOSED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800914 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 /* SCTP_STATE_COOKIE_WAIT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800916 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917 /* SCTP_STATE_COOKIE_ECHOED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800918 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919 /* SCTP_STATE_ESTABLISHED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800920 TYPE_SCTP_FUNC(sctp_sf_autoclose_timer_expire), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921 /* SCTP_STATE_SHUTDOWN_PENDING */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800922 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700923 /* SCTP_STATE_SHUTDOWN_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800924 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800926 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
Peter Zijlstra1ed176a2006-11-13 16:19:07 -0800928 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929}
930
Xin Long7b9438d2017-01-18 00:44:43 +0800931#define TYPE_SCTP_EVENT_TIMEOUT_RECONF { \
932 /* SCTP_STATE_CLOSED */ \
933 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
934 /* SCTP_STATE_COOKIE_WAIT */ \
935 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
936 /* SCTP_STATE_COOKIE_ECHOED */ \
937 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
938 /* SCTP_STATE_ESTABLISHED */ \
939 TYPE_SCTP_FUNC(sctp_sf_send_reconf), \
940 /* SCTP_STATE_SHUTDOWN_PENDING */ \
941 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
942 /* SCTP_STATE_SHUTDOWN_SENT */ \
943 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
944 /* SCTP_STATE_SHUTDOWN_RECEIVED */ \
945 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
946 /* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
947 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
948}
949
Xin Long8ee821a2017-08-11 10:23:56 +0800950static const struct sctp_sm_table_entry
951timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952 TYPE_SCTP_EVENT_TIMEOUT_NONE,
953 TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE,
954 TYPE_SCTP_EVENT_TIMEOUT_T1_INIT,
955 TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
956 TYPE_SCTP_EVENT_TIMEOUT_T3_RTX,
957 TYPE_SCTP_EVENT_TIMEOUT_T4_RTO,
958 TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD,
959 TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT,
Xin Long7b9438d2017-01-18 00:44:43 +0800960 TYPE_SCTP_EVENT_TIMEOUT_RECONF,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961 TYPE_SCTP_EVENT_TIMEOUT_SACK,
962 TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE,
963};
964
Xin Long8ee821a2017-08-11 10:23:56 +0800965static const struct sctp_sm_table_entry *sctp_chunk_event_lookup(
Xin Long52106012017-08-05 19:59:59 +0800966 struct net *net,
967 enum sctp_cid cid,
968 enum sctp_state state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969{
970 if (state > SCTP_STATE_MAX)
971 return &bug;
972
Xin Long0fc2ea92017-12-15 00:41:27 +0800973 if (cid == SCTP_CID_I_DATA)
Xin Long9d4ceaf2017-12-08 21:04:03 +0800974 cid = SCTP_CID_DATA;
975
Bill Nottingham75202e72007-05-31 21:33:35 -0700976 if (cid <= SCTP_CID_BASE_MAX)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 return &chunk_event_table[cid][state];
978
Xin Long2f757632019-08-19 22:02:50 +0800979 switch ((u16)cid) {
980 case SCTP_CID_FWD_TSN:
981 case SCTP_CID_I_FWD_TSN:
982 return &prsctp_chunk_event_table[0][state];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983
Xin Long2f757632019-08-19 22:02:50 +0800984 case SCTP_CID_ASCONF:
985 return &addip_chunk_event_table[0][state];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986
Xin Long2f757632019-08-19 22:02:50 +0800987 case SCTP_CID_ASCONF_ACK:
988 return &addip_chunk_event_table[1][state];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989
Xin Long2f757632019-08-19 22:02:50 +0800990 case SCTP_CID_RECONF:
991 return &reconf_chunk_event_table[0][state];
Xin Longd884aa62017-02-17 12:45:43 +0800992
Xin Long2f757632019-08-19 22:02:50 +0800993 case SCTP_CID_AUTH:
994 return &auth_chunk_event_table[0][state];
Vlad Yasevichbbd0d592007-10-03 17:51:34 -0700995 }
996
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997 return &chunk_event_table_unknown[state];
998}