xref: /linux/net/sctp/sm_statetable.c (revision c4ee0af3fa0dc65f690fc908f02b8355f9576ea0)
1 /* SCTP kernel implementation
2  * (C) Copyright IBM Corp. 2001, 2004
3  * Copyright (c) 1999-2000 Cisco, Inc.
4  * Copyright (c) 1999-2001 Motorola, Inc.
5  * Copyright (c) 2001 Intel Corp.
6  * Copyright (c) 2001 Nokia, Inc.
7  *
8  * This file is part of the SCTP kernel implementation
9  *
10  * These are the state tables for the SCTP state machine.
11  *
12  * This SCTP implementation is free software;
13  * you can redistribute it and/or modify it under the terms of
14  * the GNU General Public License as published by
15  * the Free Software Foundation; either version 2, or (at your option)
16  * any later version.
17  *
18  * This SCTP implementation is distributed in the hope that it
19  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
20  *                 ************************
21  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22  * See the GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with GNU CC; see the file COPYING.  If not, write to
26  * the Free Software Foundation, 59 Temple Place - Suite 330,
27  * Boston, MA 02111-1307, USA.
28  *
29  * Please send any bug reports or fixes you make to the
30  * email address(es):
31  *    lksctp developers <linux-sctp@vger.kernel.org>
32  *
33  * Written or modified by:
34  *    La Monte H.P. Yarroll <piggy@acm.org>
35  *    Karl Knutson          <karl@athena.chicago.il.us>
36  *    Jon Grimm             <jgrimm@us.ibm.com>
37  *    Hui Huang		    <hui.huang@nokia.com>
38  *    Daisy Chang	    <daisyc@us.ibm.com>
39  *    Ardelle Fan	    <ardelle.fan@intel.com>
40  *    Sridhar Samudrala	    <sri@us.ibm.com>
41  */
42 
43 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
44 
45 #include <linux/skbuff.h>
46 #include <net/sctp/sctp.h>
47 #include <net/sctp/sm.h>
48 
49 static const sctp_sm_table_entry_t
50 primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES];
51 static const sctp_sm_table_entry_t
52 other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES];
53 static const sctp_sm_table_entry_t
54 timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES];
55 
56 static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net,
57 							    sctp_cid_t cid,
58 							    sctp_state_t state);
59 
60 
61 static const sctp_sm_table_entry_t bug = {
62 	.fn = sctp_sf_bug,
63 	.name = "sctp_sf_bug"
64 };
65 
66 #define DO_LOOKUP(_max, _type, _table)					\
67 ({									\
68 	const sctp_sm_table_entry_t *rtn;				\
69 									\
70 	if ((event_subtype._type > (_max))) {				\
71 		pr_warn("table %p possible attack: event %d exceeds max %d\n", \
72 			_table, event_subtype._type, _max);		\
73 	        rtn = &bug;						\
74 	} else								\
75 		rtn = &_table[event_subtype._type][(int)state];		\
76 									\
77 	rtn;								\
78 })
79 
80 const sctp_sm_table_entry_t *sctp_sm_lookup_event(struct net *net,
81 						  sctp_event_t event_type,
82 						  sctp_state_t state,
83 						  sctp_subtype_t event_subtype)
84 {
85 	switch (event_type) {
86 	case SCTP_EVENT_T_CHUNK:
87 		return sctp_chunk_event_lookup(net, event_subtype.chunk, state);
88 	case SCTP_EVENT_T_TIMEOUT:
89 		return DO_LOOKUP(SCTP_EVENT_TIMEOUT_MAX, timeout,
90 				 timeout_event_table);
91 	case SCTP_EVENT_T_OTHER:
92 		return DO_LOOKUP(SCTP_EVENT_OTHER_MAX, other,
93 				 other_event_table);
94 	case SCTP_EVENT_T_PRIMITIVE:
95 		return DO_LOOKUP(SCTP_EVENT_PRIMITIVE_MAX, primitive,
96 				 primitive_event_table);
97 	default:
98 		/* Yikes!  We got an illegal event type.  */
99 		return &bug;
100 	}
101 }
102 
103 #define TYPE_SCTP_FUNC(func) {.fn = func, .name = #func}
104 
105 #define TYPE_SCTP_DATA { \
106 	/* SCTP_STATE_CLOSED */ \
107 	TYPE_SCTP_FUNC(sctp_sf_ootb), \
108 	/* SCTP_STATE_COOKIE_WAIT */ \
109 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
110 	/* SCTP_STATE_COOKIE_ECHOED */ \
111 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
112 	/* SCTP_STATE_ESTABLISHED */ \
113 	TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
114 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
115 	TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
116 	/* SCTP_STATE_SHUTDOWN_SENT */ \
117 	TYPE_SCTP_FUNC(sctp_sf_eat_data_fast_4_4), \
118 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
119 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
120 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
121 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
122 } /* TYPE_SCTP_DATA */
123 
124 #define TYPE_SCTP_INIT { \
125 	/* SCTP_STATE_CLOSED */ \
126 	TYPE_SCTP_FUNC(sctp_sf_do_5_1B_init), \
127 	/* SCTP_STATE_COOKIE_WAIT */ \
128 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
129 	/* SCTP_STATE_COOKIE_ECHOED */ \
130 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
131 	/* SCTP_STATE_ESTABLISHED */ \
132 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
133 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
134 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
135 	/* SCTP_STATE_SHUTDOWN_SENT */ \
136 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
137 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
138 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
139 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
140 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_reshutack), \
141 } /* TYPE_SCTP_INIT */
142 
143 #define TYPE_SCTP_INIT_ACK { \
144 	/* SCTP_STATE_CLOSED */ \
145 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_3_initack), \
146 	/* SCTP_STATE_COOKIE_WAIT */ \
147 	TYPE_SCTP_FUNC(sctp_sf_do_5_1C_ack), \
148 	/* SCTP_STATE_COOKIE_ECHOED */ \
149 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
150 	/* SCTP_STATE_ESTABLISHED */ \
151 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
152 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
153 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
154 	/* SCTP_STATE_SHUTDOWN_SENT */ \
155 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
156 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
157 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
158 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
159 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
160 } /* TYPE_SCTP_INIT_ACK */
161 
162 #define TYPE_SCTP_SACK { \
163 	/* SCTP_STATE_CLOSED */ \
164 	TYPE_SCTP_FUNC(sctp_sf_ootb), \
165 	/* SCTP_STATE_COOKIE_WAIT */ \
166 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
167 	/* SCTP_STATE_COOKIE_ECHOED */ \
168 	TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
169 	/* SCTP_STATE_ESTABLISHED */ \
170 	TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
171 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
172 	TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
173 	/* SCTP_STATE_SHUTDOWN_SENT */ \
174 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
175 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
176 	TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
177 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
178 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
179 } /* TYPE_SCTP_SACK */
180 
181 #define TYPE_SCTP_HEARTBEAT { \
182 	/* SCTP_STATE_CLOSED */ \
183 	TYPE_SCTP_FUNC(sctp_sf_ootb), \
184 	/* SCTP_STATE_COOKIE_WAIT */ \
185 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
186 	/* SCTP_STATE_COOKIE_ECHOED */ \
187 	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
188 	/* SCTP_STATE_ESTABLISHED */ \
189 	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
190 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
191 	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
192 	/* SCTP_STATE_SHUTDOWN_SENT */ \
193 	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
194 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
195 	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
196 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
197 	/* This should not happen, but we are nice.  */ \
198 	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
199 } /* TYPE_SCTP_HEARTBEAT */
200 
201 #define TYPE_SCTP_HEARTBEAT_ACK { \
202 	/* SCTP_STATE_CLOSED */ \
203 	TYPE_SCTP_FUNC(sctp_sf_ootb), \
204 	/* SCTP_STATE_COOKIE_WAIT */ \
205 	TYPE_SCTP_FUNC(sctp_sf_violation), \
206 	/* SCTP_STATE_COOKIE_ECHOED */ \
207 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
208 	/* SCTP_STATE_ESTABLISHED */ \
209 	TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
210 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
211 	TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
212 	/* SCTP_STATE_SHUTDOWN_SENT */ \
213 	TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
214 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
215 	TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
216 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
217 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
218 } /* TYPE_SCTP_HEARTBEAT_ACK */
219 
220 #define TYPE_SCTP_ABORT { \
221 	/* SCTP_STATE_CLOSED */ \
222 	TYPE_SCTP_FUNC(sctp_sf_pdiscard), \
223 	/* SCTP_STATE_COOKIE_WAIT */ \
224 	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_abort), \
225 	/* SCTP_STATE_COOKIE_ECHOED */ \
226 	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_abort), \
227 	/* SCTP_STATE_ESTABLISHED */ \
228 	TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
229 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
230 	TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_abort), \
231 	/* SCTP_STATE_SHUTDOWN_SENT */ \
232 	TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_abort), \
233 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
234 	TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
235 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
236 	TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_abort), \
237 } /* TYPE_SCTP_ABORT */
238 
239 #define TYPE_SCTP_SHUTDOWN { \
240 	/* SCTP_STATE_CLOSED */ \
241 	TYPE_SCTP_FUNC(sctp_sf_ootb), \
242 	/* SCTP_STATE_COOKIE_WAIT */ \
243 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
244 	/* SCTP_STATE_COOKIE_ECHOED */ \
245 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
246 	/* SCTP_STATE_ESTABLISHED */ \
247 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
248 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
249 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
250 	/* SCTP_STATE_SHUTDOWN_SENT */ \
251 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
252 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
253 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shut_ctsn), \
254 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
255 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
256 } /* TYPE_SCTP_SHUTDOWN */
257 
258 #define TYPE_SCTP_SHUTDOWN_ACK { \
259 	/* SCTP_STATE_CLOSED */ \
260 	TYPE_SCTP_FUNC(sctp_sf_ootb), \
261 	/* SCTP_STATE_COOKIE_WAIT */ \
262 	TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
263 	/* SCTP_STATE_COOKIE_ECHOED */ \
264 	TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
265 	/* SCTP_STATE_ESTABLISHED */ \
266 	TYPE_SCTP_FUNC(sctp_sf_violation), \
267 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
268 	TYPE_SCTP_FUNC(sctp_sf_violation), \
269 	/* SCTP_STATE_SHUTDOWN_SENT */ \
270 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
271 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
272 	TYPE_SCTP_FUNC(sctp_sf_violation), \
273 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
274 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
275 } /* TYPE_SCTP_SHUTDOWN_ACK */
276 
277 #define TYPE_SCTP_ERROR { \
278 	/* SCTP_STATE_CLOSED */ \
279 	TYPE_SCTP_FUNC(sctp_sf_ootb), \
280 	/* SCTP_STATE_COOKIE_WAIT */ \
281 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
282 	/* SCTP_STATE_COOKIE_ECHOED */ \
283 	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_err), \
284 	/* SCTP_STATE_ESTABLISHED */ \
285 	TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
286 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
287 	TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
288 	/* SCTP_STATE_SHUTDOWN_SENT */ \
289 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
290 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
291 	TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
292 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
293 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
294 } /* TYPE_SCTP_ERROR */
295 
296 #define TYPE_SCTP_COOKIE_ECHO { \
297 	/* SCTP_STATE_CLOSED */ \
298 	TYPE_SCTP_FUNC(sctp_sf_do_5_1D_ce), \
299 	/* SCTP_STATE_COOKIE_WAIT */ \
300 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
301 	/* SCTP_STATE_COOKIE_ECHOED */ \
302 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
303 	/* SCTP_STATE_ESTABLISHED */ \
304 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
305 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
306 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
307 	/* SCTP_STATE_SHUTDOWN_SENT */ \
308 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
309 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
310 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
311 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
312 	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
313 } /* TYPE_SCTP_COOKIE_ECHO */
314 
315 #define TYPE_SCTP_COOKIE_ACK { \
316 	/* SCTP_STATE_CLOSED */ \
317 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
318 	/* SCTP_STATE_COOKIE_WAIT */ \
319 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
320 	/* SCTP_STATE_COOKIE_ECHOED */ \
321 	TYPE_SCTP_FUNC(sctp_sf_do_5_1E_ca), \
322 	/* SCTP_STATE_ESTABLISHED */ \
323 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
324 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
325 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
326 	/* SCTP_STATE_SHUTDOWN_SENT */ \
327 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
328 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
329 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
330 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
331 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
332 } /* TYPE_SCTP_COOKIE_ACK */
333 
334 #define TYPE_SCTP_ECN_ECNE { \
335 	/* SCTP_STATE_CLOSED */ \
336 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
337 	/* SCTP_STATE_COOKIE_WAIT */ \
338 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
339 	/* SCTP_STATE_COOKIE_ECHOED */ \
340 	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
341 	/* SCTP_STATE_ESTABLISHED */ \
342 	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
343 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
344 	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
345 	/* SCTP_STATE_SHUTDOWN_SENT */ \
346 	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
347 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
348 	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
349 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
350 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
351 } /* TYPE_SCTP_ECN_ECNE */
352 
353 #define TYPE_SCTP_ECN_CWR { \
354 	/* SCTP_STATE_CLOSED */ \
355 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
356 	/* SCTP_STATE_COOKIE_WAIT */ \
357 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
358 	/* SCTP_STATE_COOKIE_ECHOED */ \
359 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
360 	/* SCTP_STATE_ESTABLISHED */ \
361 	TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
362 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
363 	TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
364 	/* SCTP_STATE_SHUTDOWN_SENT */ \
365 	TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
366 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
367 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
368 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
369 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
370 } /* TYPE_SCTP_ECN_CWR */
371 
372 #define TYPE_SCTP_SHUTDOWN_COMPLETE { \
373 	/* SCTP_STATE_CLOSED */ \
374 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
375 	/* SCTP_STATE_COOKIE_WAIT */ \
376 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
377 	/* SCTP_STATE_COOKIE_ECHOED */ \
378 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
379 	/* SCTP_STATE_ESTABLISHED */ \
380 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
381 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
382 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
383 	/* SCTP_STATE_SHUTDOWN_SENT */ \
384 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
385 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
386 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
387 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
388 	TYPE_SCTP_FUNC(sctp_sf_do_4_C), \
389 } /* TYPE_SCTP_SHUTDOWN_COMPLETE */
390 
391 /* The primary index for this table is the chunk type.
392  * The secondary index for this table is the state.
393  *
394  * For base protocol (RFC 2960).
395  */
396 static const sctp_sm_table_entry_t chunk_event_table[SCTP_NUM_BASE_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
397 	TYPE_SCTP_DATA,
398 	TYPE_SCTP_INIT,
399 	TYPE_SCTP_INIT_ACK,
400 	TYPE_SCTP_SACK,
401 	TYPE_SCTP_HEARTBEAT,
402 	TYPE_SCTP_HEARTBEAT_ACK,
403 	TYPE_SCTP_ABORT,
404 	TYPE_SCTP_SHUTDOWN,
405 	TYPE_SCTP_SHUTDOWN_ACK,
406 	TYPE_SCTP_ERROR,
407 	TYPE_SCTP_COOKIE_ECHO,
408 	TYPE_SCTP_COOKIE_ACK,
409 	TYPE_SCTP_ECN_ECNE,
410 	TYPE_SCTP_ECN_CWR,
411 	TYPE_SCTP_SHUTDOWN_COMPLETE,
412 }; /* state_fn_t chunk_event_table[][] */
413 
414 #define TYPE_SCTP_ASCONF { \
415 	/* SCTP_STATE_CLOSED */ \
416 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
417 	/* SCTP_STATE_COOKIE_WAIT */ \
418 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
419 	/* SCTP_STATE_COOKIE_ECHOED */ \
420 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
421 	/* SCTP_STATE_ESTABLISHED */ \
422 	TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
423 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
424 	TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
425 	/* SCTP_STATE_SHUTDOWN_SENT */ \
426 	TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
427 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
428 	TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
429 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
430 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
431 } /* TYPE_SCTP_ASCONF */
432 
433 #define TYPE_SCTP_ASCONF_ACK { \
434 	/* SCTP_STATE_CLOSED */ \
435 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
436 	/* SCTP_STATE_COOKIE_WAIT */ \
437 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
438 	/* SCTP_STATE_COOKIE_ECHOED */ \
439 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
440 	/* SCTP_STATE_ESTABLISHED */ \
441 	TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
442 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
443 	TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
444 	/* SCTP_STATE_SHUTDOWN_SENT */ \
445 	TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
446 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
447 	TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
448 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
449 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
450 } /* TYPE_SCTP_ASCONF_ACK */
451 
452 /* The primary index for this table is the chunk type.
453  * The secondary index for this table is the state.
454  */
455 static const sctp_sm_table_entry_t addip_chunk_event_table[SCTP_NUM_ADDIP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
456 	TYPE_SCTP_ASCONF,
457 	TYPE_SCTP_ASCONF_ACK,
458 }; /*state_fn_t addip_chunk_event_table[][] */
459 
460 #define TYPE_SCTP_FWD_TSN { \
461 	/* SCTP_STATE_CLOSED */ \
462 	TYPE_SCTP_FUNC(sctp_sf_ootb), \
463 	/* SCTP_STATE_COOKIE_WAIT */ \
464 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
465 	/* SCTP_STATE_COOKIE_ECHOED */ \
466 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
467 	/* SCTP_STATE_ESTABLISHED */ \
468 	TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
469 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
470 	TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
471 	/* SCTP_STATE_SHUTDOWN_SENT */ \
472 	TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn_fast), \
473 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
474 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
475 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
476 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
477 } /* TYPE_SCTP_FWD_TSN */
478 
479 /* The primary index for this table is the chunk type.
480  * The secondary index for this table is the state.
481  */
482 static const sctp_sm_table_entry_t prsctp_chunk_event_table[SCTP_NUM_PRSCTP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
483 	TYPE_SCTP_FWD_TSN,
484 }; /*state_fn_t prsctp_chunk_event_table[][] */
485 
486 #define TYPE_SCTP_AUTH { \
487 	/* SCTP_STATE_CLOSED */ \
488 	TYPE_SCTP_FUNC(sctp_sf_ootb), \
489 	/* SCTP_STATE_COOKIE_WAIT */ \
490 	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
491 	/* SCTP_STATE_COOKIE_ECHOED */ \
492 	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
493 	/* SCTP_STATE_ESTABLISHED */ \
494 	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
495 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
496 	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
497 	/* SCTP_STATE_SHUTDOWN_SENT */ \
498 	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
499 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
500 	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
501 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
502 	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
503 } /* TYPE_SCTP_AUTH */
504 
505 /* The primary index for this table is the chunk type.
506  * The secondary index for this table is the state.
507  */
508 static const sctp_sm_table_entry_t auth_chunk_event_table[SCTP_NUM_AUTH_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
509 	TYPE_SCTP_AUTH,
510 }; /*state_fn_t auth_chunk_event_table[][] */
511 
512 static const sctp_sm_table_entry_t
513 chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
514 	/* SCTP_STATE_CLOSED */
515 	TYPE_SCTP_FUNC(sctp_sf_ootb),
516 	/* SCTP_STATE_COOKIE_WAIT */
517 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
518 	/* SCTP_STATE_COOKIE_ECHOED */
519 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
520 	/* SCTP_STATE_ESTABLISHED */
521 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
522 	/* SCTP_STATE_SHUTDOWN_PENDING */
523 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
524 	/* SCTP_STATE_SHUTDOWN_SENT */
525 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
526 	/* SCTP_STATE_SHUTDOWN_RECEIVED */
527 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
528 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */
529 	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
530 };	/* chunk unknown */
531 
532 
533 #define TYPE_SCTP_PRIMITIVE_ASSOCIATE  { \
534 	/* SCTP_STATE_CLOSED */ \
535 	TYPE_SCTP_FUNC(sctp_sf_do_prm_asoc), \
536 	/* SCTP_STATE_COOKIE_WAIT */ \
537 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
538 	/* SCTP_STATE_COOKIE_ECHOED */ \
539 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
540 	/* SCTP_STATE_ESTABLISHED */ \
541 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
542 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
543 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
544 	/* SCTP_STATE_SHUTDOWN_SENT */ \
545 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
546 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
547 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
548 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
549 	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
550 } /* TYPE_SCTP_PRIMITIVE_ASSOCIATE */
551 
552 #define TYPE_SCTP_PRIMITIVE_SHUTDOWN  { \
553 	/* SCTP_STATE_CLOSED */ \
554 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
555 	/* SCTP_STATE_COOKIE_WAIT */ \
556 	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_shutdown), \
557 	/* SCTP_STATE_COOKIE_ECHOED */ \
558 	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_shutdown),\
559 	/* SCTP_STATE_ESTABLISHED */ \
560 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_prm_shutdown), \
561 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
562 	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
563 	/* SCTP_STATE_SHUTDOWN_SENT */ \
564 	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
565 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
566 	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
567 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
568 	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
569 } /* TYPE_SCTP_PRIMITIVE_SHUTDOWN */
570 
571 #define TYPE_SCTP_PRIMITIVE_ABORT  { \
572 	/* SCTP_STATE_CLOSED */ \
573 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
574 	/* SCTP_STATE_COOKIE_WAIT */ \
575 	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_abort), \
576 	/* SCTP_STATE_COOKIE_ECHOED */ \
577 	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_abort), \
578 	/* SCTP_STATE_ESTABLISHED */ \
579 	TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
580 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
581 	TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_prm_abort), \
582 	/* SCTP_STATE_SHUTDOWN_SENT */ \
583 	TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_prm_abort), \
584 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
585 	TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
586 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
587 	TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_prm_abort), \
588 } /* TYPE_SCTP_PRIMITIVE_ABORT */
589 
590 #define TYPE_SCTP_PRIMITIVE_SEND  { \
591 	/* SCTP_STATE_CLOSED */ \
592 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
593 	/* SCTP_STATE_COOKIE_WAIT */ \
594 	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
595 	/* SCTP_STATE_COOKIE_ECHOED */ \
596 	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
597 	/* SCTP_STATE_ESTABLISHED */ \
598 	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
599 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
600 	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
601 	/* SCTP_STATE_SHUTDOWN_SENT */ \
602 	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
603 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
604 	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
605 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
606 	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
607 } /* TYPE_SCTP_PRIMITIVE_SEND */
608 
609 #define TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT  { \
610 	/* SCTP_STATE_CLOSED */ \
611 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
612 	/* SCTP_STATE_COOKIE_WAIT */ \
613 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
614 	/* SCTP_STATE_COOKIE_ECHOED */ \
615 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
616 	/* SCTP_STATE_ESTABLISHED */ \
617 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
618 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
619 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
620 	/* SCTP_STATE_SHUTDOWN_SENT */ \
621 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
622 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
623 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
624 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
625 	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
626 } /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */
627 
628 #define TYPE_SCTP_PRIMITIVE_ASCONF { \
629 	/* SCTP_STATE_CLOSED */ \
630 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
631 	/* SCTP_STATE_COOKIE_WAIT */ \
632 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
633 	/* SCTP_STATE_COOKIE_ECHOED */ \
634 	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
635 	/* SCTP_STATE_ESTABLISHED */ \
636 	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
637 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
638 	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
639 	/* SCTP_STATE_SHUTDOWN_SENT */ \
640 	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
641 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
642 	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
643 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
644 	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
645 } /* TYPE_SCTP_PRIMITIVE_ASCONF */
646 
647 /* The primary index for this table is the primitive type.
648  * The secondary index for this table is the state.
649  */
650 static const sctp_sm_table_entry_t primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES] = {
651 	TYPE_SCTP_PRIMITIVE_ASSOCIATE,
652 	TYPE_SCTP_PRIMITIVE_SHUTDOWN,
653 	TYPE_SCTP_PRIMITIVE_ABORT,
654 	TYPE_SCTP_PRIMITIVE_SEND,
655 	TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT,
656 	TYPE_SCTP_PRIMITIVE_ASCONF,
657 };
658 
659 #define TYPE_SCTP_OTHER_NO_PENDING_TSN  { \
660 	/* SCTP_STATE_CLOSED */ \
661 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
662 	/* SCTP_STATE_COOKIE_WAIT */ \
663 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
664 	/* SCTP_STATE_COOKIE_ECHOED */ \
665 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
666 	/* SCTP_STATE_ESTABLISHED */ \
667 	TYPE_SCTP_FUNC(sctp_sf_do_no_pending_tsn), \
668 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
669 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_start_shutdown), \
670 	/* SCTP_STATE_SHUTDOWN_SENT */ \
671 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
672 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
673 	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
674 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
675 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
676 }
677 
678 #define TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH  { \
679 	/* SCTP_STATE_CLOSED */ \
680 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
681 	/* SCTP_STATE_COOKIE_WAIT */ \
682 	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_icmp_abort), \
683 	/* SCTP_STATE_COOKIE_ECHOED */ \
684 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
685 	/* SCTP_STATE_ESTABLISHED */ \
686 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
687 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
688 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
689 	/* SCTP_STATE_SHUTDOWN_SENT */ \
690 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
691 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
692 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
693 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
694 	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
695 }
696 
697 static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES] = {
698 	TYPE_SCTP_OTHER_NO_PENDING_TSN,
699 	TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH,
700 };
701 
702 #define TYPE_SCTP_EVENT_TIMEOUT_NONE { \
703 	/* SCTP_STATE_CLOSED */ \
704 	TYPE_SCTP_FUNC(sctp_sf_bug), \
705 	/* SCTP_STATE_COOKIE_WAIT */ \
706 	TYPE_SCTP_FUNC(sctp_sf_bug), \
707 	/* SCTP_STATE_COOKIE_ECHOED */ \
708 	TYPE_SCTP_FUNC(sctp_sf_bug), \
709 	/* SCTP_STATE_ESTABLISHED */ \
710 	TYPE_SCTP_FUNC(sctp_sf_bug), \
711 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
712 	TYPE_SCTP_FUNC(sctp_sf_bug), \
713 	/* SCTP_STATE_SHUTDOWN_SENT */ \
714 	TYPE_SCTP_FUNC(sctp_sf_bug), \
715 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
716 	TYPE_SCTP_FUNC(sctp_sf_bug), \
717 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
718 	TYPE_SCTP_FUNC(sctp_sf_bug), \
719 }
720 
721 #define TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE { \
722 	/* SCTP_STATE_CLOSED */ \
723 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
724 	/* SCTP_STATE_COOKIE_WAIT */ \
725 	TYPE_SCTP_FUNC(sctp_sf_bug), \
726 	/* SCTP_STATE_COOKIE_ECHOED */ \
727 	TYPE_SCTP_FUNC(sctp_sf_t1_cookie_timer_expire), \
728 	/* SCTP_STATE_ESTABLISHED */ \
729 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
730 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
731 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
732 	/* SCTP_STATE_SHUTDOWN_SENT */ \
733 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
734 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
735 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
736 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
737 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
738 }
739 
740 #define TYPE_SCTP_EVENT_TIMEOUT_T1_INIT { \
741 	/* SCTP_STATE_CLOSED */ \
742 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
743 	/* SCTP_STATE_COOKIE_WAIT */ \
744 	TYPE_SCTP_FUNC(sctp_sf_t1_init_timer_expire), \
745 	/* SCTP_STATE_COOKIE_ECHOED */ \
746 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
747 	/* SCTP_STATE_ESTABLISHED */ \
748 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
749 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
750 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
751 	/* SCTP_STATE_SHUTDOWN_SENT */ \
752 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
753 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
754 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
755 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
756 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
757 }
758 
759 #define TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN { \
760 	/* SCTP_STATE_CLOSED */ \
761 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
762 	/* SCTP_STATE_COOKIE_WAIT */ \
763 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
764 	/* SCTP_STATE_COOKIE_ECHOED */ \
765 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
766 	/* SCTP_STATE_ESTABLISHED */ \
767 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
768 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
769 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
770 	/* SCTP_STATE_SHUTDOWN_SENT */ \
771 	TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
772 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
773 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
774 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
775 	TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
776 }
777 
778 #define TYPE_SCTP_EVENT_TIMEOUT_T3_RTX { \
779 	/* SCTP_STATE_CLOSED */ \
780 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
781 	/* SCTP_STATE_COOKIE_WAIT */ \
782 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
783 	/* SCTP_STATE_COOKIE_ECHOED */ \
784 	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
785 	/* SCTP_STATE_ESTABLISHED */ \
786 	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
787 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
788 	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
789 	/* SCTP_STATE_SHUTDOWN_SENT */ \
790 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
791 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
792 	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
793 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
794 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
795 }
796 
797 #define TYPE_SCTP_EVENT_TIMEOUT_T4_RTO { \
798 	/* SCTP_STATE_CLOSED */ \
799 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
800 	/* SCTP_STATE_COOKIE_WAIT */ \
801 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
802 	/* SCTP_STATE_COOKIE_ECHOED */ \
803 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
804 	/* SCTP_STATE_ESTABLISHED */ \
805 	TYPE_SCTP_FUNC(sctp_sf_t4_timer_expire), \
806 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
807 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
808 	/* SCTP_STATE_SHUTDOWN_SENT */ \
809 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
810 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
811 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
812 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
813 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
814 }
815 
816 #define TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD { \
817 	/* SCTP_STATE_CLOSED */ \
818 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
819 	/* SCTP_STATE_COOKIE_WAIT */ \
820 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
821 	/* SCTP_STATE_COOKIE_ECHOED */ \
822 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
823 	/* SCTP_STATE_ESTABLISHED */ \
824 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
825 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
826 	TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
827 	/* SCTP_STATE_SHUTDOWN_SENT */ \
828 	TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
829 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
830 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
831 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
832 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
833 }
834 
835 #define TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT { \
836 	/* SCTP_STATE_CLOSED */ \
837 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
838 	/* SCTP_STATE_COOKIE_WAIT */ \
839 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
840 	/* SCTP_STATE_COOKIE_ECHOED */ \
841 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
842 	/* SCTP_STATE_ESTABLISHED */ \
843 	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
844 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
845 	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
846 	/* SCTP_STATE_SHUTDOWN_SENT */ \
847 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
848 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
849 	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
850 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
851 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
852 }
853 
854 #define TYPE_SCTP_EVENT_TIMEOUT_SACK { \
855 	/* SCTP_STATE_CLOSED */ \
856 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
857 	/* SCTP_STATE_COOKIE_WAIT */ \
858 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
859 	/* SCTP_STATE_COOKIE_ECHOED */ \
860 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
861 	/* SCTP_STATE_ESTABLISHED */ \
862 	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
863 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
864 	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
865 	/* SCTP_STATE_SHUTDOWN_SENT */ \
866 	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
867 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
868 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
869 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
870 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
871 }
872 
873 #define TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE { \
874 	/* SCTP_STATE_CLOSED */ \
875 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
876 	/* SCTP_STATE_COOKIE_WAIT */ \
877 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
878 	/* SCTP_STATE_COOKIE_ECHOED */ \
879 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
880 	/* SCTP_STATE_ESTABLISHED */ \
881 	TYPE_SCTP_FUNC(sctp_sf_autoclose_timer_expire), \
882 	/* SCTP_STATE_SHUTDOWN_PENDING */ \
883 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
884 	/* SCTP_STATE_SHUTDOWN_SENT */ \
885 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
886 	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
887 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
888 	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
889 	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
890 }
891 
892 static const sctp_sm_table_entry_t timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES] = {
893 	TYPE_SCTP_EVENT_TIMEOUT_NONE,
894 	TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE,
895 	TYPE_SCTP_EVENT_TIMEOUT_T1_INIT,
896 	TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
897 	TYPE_SCTP_EVENT_TIMEOUT_T3_RTX,
898 	TYPE_SCTP_EVENT_TIMEOUT_T4_RTO,
899 	TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD,
900 	TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT,
901 	TYPE_SCTP_EVENT_TIMEOUT_SACK,
902 	TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE,
903 };
904 
905 static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net,
906 							    sctp_cid_t cid,
907 							    sctp_state_t state)
908 {
909 	if (state > SCTP_STATE_MAX)
910 		return &bug;
911 
912 	if (cid <= SCTP_CID_BASE_MAX)
913 		return &chunk_event_table[cid][state];
914 
915 	if (net->sctp.prsctp_enable) {
916 		if (cid == SCTP_CID_FWD_TSN)
917 			return &prsctp_chunk_event_table[0][state];
918 	}
919 
920 	if (net->sctp.addip_enable) {
921 		if (cid == SCTP_CID_ASCONF)
922 			return &addip_chunk_event_table[0][state];
923 
924 		if (cid == SCTP_CID_ASCONF_ACK)
925 			return &addip_chunk_event_table[1][state];
926 	}
927 
928 	if (net->sctp.auth_enable) {
929 		if (cid == SCTP_CID_AUTH)
930 			return &auth_chunk_event_table[0][state];
931 	}
932 
933 	return &chunk_event_table_unknown[state];
934 }
935