sm_statetable.c 31.5 KB
Newer Older
1
/* SCTP kernel implementation
L
Linus Torvalds 已提交
2 3 4 5 6 7
 * (C) Copyright IBM Corp. 2001, 2004
 * Copyright (c) 1999-2000 Cisco, Inc.
 * Copyright (c) 1999-2001 Motorola, Inc.
 * Copyright (c) 2001 Intel Corp.
 * Copyright (c) 2001 Nokia, Inc.
 *
8
 * This file is part of the SCTP kernel implementation
L
Linus Torvalds 已提交
9 10 11
 *
 * These are the state tables for the SCTP state machine.
 *
12
 * This SCTP implementation is free software;
L
Linus Torvalds 已提交
13 14 15 16 17
 * you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
18
 * This SCTP implementation is distributed in the hope that it
L
Linus Torvalds 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
 *                 ************************
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GNU CC; see the file COPYING.  If not, write to
 * the Free Software Foundation, 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Please send any bug reports or fixes you make to the
 * email address(es):
 *    lksctp developers <lksctp-developers@lists.sourceforge.net>
 *
 * Or submit a bug report through the following website:
 *    http://www.sf.net/projects/lksctp
 *
 * Written or modified by:
 *    La Monte H.P. Yarroll <piggy@acm.org>
 *    Karl Knutson          <karl@athena.chicago.il.us>
 *    Jon Grimm             <jgrimm@us.ibm.com>
 *    Hui Huang		    <hui.huang@nokia.com>
 *    Daisy Chang	    <daisyc@us.ibm.com>
 *    Ardelle Fan	    <ardelle.fan@intel.com>
 *    Sridhar Samudrala	    <sri@us.ibm.com>
 *
 * Any bugs reported given to us we will try to fix... any fixes shared will
 * be incorporated into the next SCTP release.
 */

49 50
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

L
Linus Torvalds 已提交
51 52 53 54 55 56 57 58 59 60 61
#include <linux/skbuff.h>
#include <net/sctp/sctp.h>
#include <net/sctp/sm.h>

static const sctp_sm_table_entry_t
primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES];
static const sctp_sm_table_entry_t
other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES];
static const sctp_sm_table_entry_t
timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES];

62 63
static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net,
							    sctp_cid_t cid,
L
Linus Torvalds 已提交
64 65 66 67 68 69 70 71
							    sctp_state_t state);


static const sctp_sm_table_entry_t bug = {
	.fn = sctp_sf_bug,
	.name = "sctp_sf_bug"
};

72 73 74 75 76 77 78 79 80 81 82 83 84
#define DO_LOOKUP(_max, _type, _table)					\
({									\
	const sctp_sm_table_entry_t *rtn;				\
									\
	if ((event_subtype._type > (_max))) {				\
		pr_warn("table %p possible attack: event %d exceeds max %d\n", \
			_table, event_subtype._type, _max);		\
	        rtn = &bug;						\
	} else								\
		rtn = &_table[event_subtype._type][(int)state];		\
									\
	rtn;								\
})
L
Linus Torvalds 已提交
85

86 87
const sctp_sm_table_entry_t *sctp_sm_lookup_event(struct net *net,
						  sctp_event_t event_type,
L
Linus Torvalds 已提交
88 89 90 91 92
						  sctp_state_t state,
						  sctp_subtype_t event_subtype)
{
	switch (event_type) {
	case SCTP_EVENT_T_CHUNK:
93
		return sctp_chunk_event_lookup(net, event_subtype.chunk, state);
L
Linus Torvalds 已提交
94
	case SCTP_EVENT_T_TIMEOUT:
95 96
		return DO_LOOKUP(SCTP_EVENT_TIMEOUT_MAX, timeout,
				 timeout_event_table);
L
Linus Torvalds 已提交
97
	case SCTP_EVENT_T_OTHER:
98 99
		return DO_LOOKUP(SCTP_EVENT_OTHER_MAX, other,
				 other_event_table);
L
Linus Torvalds 已提交
100
	case SCTP_EVENT_T_PRIMITIVE:
101 102
		return DO_LOOKUP(SCTP_EVENT_PRIMITIVE_MAX, primitive,
				 primitive_event_table);
L
Linus Torvalds 已提交
103 104 105
	default:
		/* Yikes!  We got an illegal event type.  */
		return &bug;
106
	}
L
Linus Torvalds 已提交
107 108
}

109 110
#define TYPE_SCTP_FUNC(func) {.fn = func, .name = #func}

L
Linus Torvalds 已提交
111 112
#define TYPE_SCTP_DATA { \
	/* SCTP_STATE_CLOSED */ \
113
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
114
	/* SCTP_STATE_COOKIE_WAIT */ \
115
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
116
	/* SCTP_STATE_COOKIE_ECHOED */ \
117
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
118
	/* SCTP_STATE_ESTABLISHED */ \
119
	TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
L
Linus Torvalds 已提交
120
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
121
	TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
L
Linus Torvalds 已提交
122
	/* SCTP_STATE_SHUTDOWN_SENT */ \
123
	TYPE_SCTP_FUNC(sctp_sf_eat_data_fast_4_4), \
L
Linus Torvalds 已提交
124
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
125
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
126
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
127
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
128 129 130 131
} /* TYPE_SCTP_DATA */

#define TYPE_SCTP_INIT { \
	/* SCTP_STATE_CLOSED */ \
132
	TYPE_SCTP_FUNC(sctp_sf_do_5_1B_init), \
L
Linus Torvalds 已提交
133
	/* SCTP_STATE_COOKIE_WAIT */ \
134
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
L
Linus Torvalds 已提交
135
	/* SCTP_STATE_COOKIE_ECHOED */ \
136
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
L
Linus Torvalds 已提交
137
	/* SCTP_STATE_ESTABLISHED */ \
138
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
L
Linus Torvalds 已提交
139
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
140
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
L
Linus Torvalds 已提交
141
	/* SCTP_STATE_SHUTDOWN_SENT */ \
142
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
L
Linus Torvalds 已提交
143
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
144
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
L
Linus Torvalds 已提交
145
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
146
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_reshutack), \
L
Linus Torvalds 已提交
147 148 149 150
} /* TYPE_SCTP_INIT */

#define TYPE_SCTP_INIT_ACK { \
	/* SCTP_STATE_CLOSED */ \
151
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_3_initack), \
L
Linus Torvalds 已提交
152
	/* SCTP_STATE_COOKIE_WAIT */ \
153
	TYPE_SCTP_FUNC(sctp_sf_do_5_1C_ack), \
L
Linus Torvalds 已提交
154
	/* SCTP_STATE_COOKIE_ECHOED */ \
155
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
156
	/* SCTP_STATE_ESTABLISHED */ \
157
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
158
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
159
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
160
	/* SCTP_STATE_SHUTDOWN_SENT */ \
161
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
162
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
163
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
164
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
165
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
166 167 168 169
} /* TYPE_SCTP_INIT_ACK */

#define TYPE_SCTP_SACK { \
	/* SCTP_STATE_CLOSED */ \
170
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
171
	/* SCTP_STATE_COOKIE_WAIT */ \
172
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
173
	/* SCTP_STATE_COOKIE_ECHOED */ \
174
	TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
L
Linus Torvalds 已提交
175
	/* SCTP_STATE_ESTABLISHED */ \
176
	TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
L
Linus Torvalds 已提交
177
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
178
	TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
L
Linus Torvalds 已提交
179
	/* SCTP_STATE_SHUTDOWN_SENT */ \
180
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
181
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
182
	TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
L
Linus Torvalds 已提交
183
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
184
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
185 186 187 188
} /* TYPE_SCTP_SACK */

#define TYPE_SCTP_HEARTBEAT { \
	/* SCTP_STATE_CLOSED */ \
189
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
190
	/* SCTP_STATE_COOKIE_WAIT */ \
191
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
192
	/* SCTP_STATE_COOKIE_ECHOED */ \
193
	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
L
Linus Torvalds 已提交
194
	/* SCTP_STATE_ESTABLISHED */ \
195
	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
L
Linus Torvalds 已提交
196
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
197
	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
L
Linus Torvalds 已提交
198
	/* SCTP_STATE_SHUTDOWN_SENT */ \
199
	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
L
Linus Torvalds 已提交
200
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
201
	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
L
Linus Torvalds 已提交
202 203
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
	/* This should not happen, but we are nice.  */ \
204
	TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
L
Linus Torvalds 已提交
205 206 207 208
} /* TYPE_SCTP_HEARTBEAT */

#define TYPE_SCTP_HEARTBEAT_ACK { \
	/* SCTP_STATE_CLOSED */ \
209
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
210
	/* SCTP_STATE_COOKIE_WAIT */ \
211
	TYPE_SCTP_FUNC(sctp_sf_violation), \
L
Linus Torvalds 已提交
212
	/* SCTP_STATE_COOKIE_ECHOED */ \
213
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
214
	/* SCTP_STATE_ESTABLISHED */ \
215
	TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
L
Linus Torvalds 已提交
216
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
217
	TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
L
Linus Torvalds 已提交
218
	/* SCTP_STATE_SHUTDOWN_SENT */ \
219
	TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
L
Linus Torvalds 已提交
220
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
221
	TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
L
Linus Torvalds 已提交
222
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
223
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
224 225 226 227
} /* TYPE_SCTP_HEARTBEAT_ACK */

#define TYPE_SCTP_ABORT { \
	/* SCTP_STATE_CLOSED */ \
228
	TYPE_SCTP_FUNC(sctp_sf_pdiscard), \
L
Linus Torvalds 已提交
229
	/* SCTP_STATE_COOKIE_WAIT */ \
230
	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_abort), \
L
Linus Torvalds 已提交
231
	/* SCTP_STATE_COOKIE_ECHOED */ \
232
	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_abort), \
L
Linus Torvalds 已提交
233
	/* SCTP_STATE_ESTABLISHED */ \
234
	TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
L
Linus Torvalds 已提交
235
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
236
	TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_abort), \
L
Linus Torvalds 已提交
237
	/* SCTP_STATE_SHUTDOWN_SENT */ \
238
	TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_abort), \
L
Linus Torvalds 已提交
239
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
240
	TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
L
Linus Torvalds 已提交
241
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
242
	TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_abort), \
L
Linus Torvalds 已提交
243 244 245 246
} /* TYPE_SCTP_ABORT */

#define TYPE_SCTP_SHUTDOWN { \
	/* SCTP_STATE_CLOSED */ \
247
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
248
	/* SCTP_STATE_COOKIE_WAIT */ \
249
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
250
	/* SCTP_STATE_COOKIE_ECHOED */ \
251
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
252
	/* SCTP_STATE_ESTABLISHED */ \
253
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
L
Linus Torvalds 已提交
254
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
255
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
L
Linus Torvalds 已提交
256
	/* SCTP_STATE_SHUTDOWN_SENT */ \
257
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
L
Linus Torvalds 已提交
258
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
259
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shut_ctsn), \
L
Linus Torvalds 已提交
260
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
261
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
262 263 264 265
} /* TYPE_SCTP_SHUTDOWN */

#define TYPE_SCTP_SHUTDOWN_ACK { \
	/* SCTP_STATE_CLOSED */ \
266
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
267
	/* SCTP_STATE_COOKIE_WAIT */ \
268
	TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
L
Linus Torvalds 已提交
269
	/* SCTP_STATE_COOKIE_ECHOED */ \
270
	TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
L
Linus Torvalds 已提交
271
	/* SCTP_STATE_ESTABLISHED */ \
272
	TYPE_SCTP_FUNC(sctp_sf_violation), \
L
Linus Torvalds 已提交
273
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
274
	TYPE_SCTP_FUNC(sctp_sf_violation), \
L
Linus Torvalds 已提交
275
	/* SCTP_STATE_SHUTDOWN_SENT */ \
276
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
L
Linus Torvalds 已提交
277
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
278
	TYPE_SCTP_FUNC(sctp_sf_violation), \
L
Linus Torvalds 已提交
279
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
280
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
L
Linus Torvalds 已提交
281 282 283 284
} /* TYPE_SCTP_SHUTDOWN_ACK */

#define TYPE_SCTP_ERROR { \
	/* SCTP_STATE_CLOSED */ \
285
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
286
	/* SCTP_STATE_COOKIE_WAIT */ \
287
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
288
	/* SCTP_STATE_COOKIE_ECHOED */ \
289
	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_err), \
L
Linus Torvalds 已提交
290
	/* SCTP_STATE_ESTABLISHED */ \
291
	TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
L
Linus Torvalds 已提交
292
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
293
	TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
L
Linus Torvalds 已提交
294
	/* SCTP_STATE_SHUTDOWN_SENT */ \
295
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
296
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
297
	TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
L
Linus Torvalds 已提交
298
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
299
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
300 301 302 303
} /* TYPE_SCTP_ERROR */

#define TYPE_SCTP_COOKIE_ECHO { \
	/* SCTP_STATE_CLOSED */ \
304
	TYPE_SCTP_FUNC(sctp_sf_do_5_1D_ce), \
L
Linus Torvalds 已提交
305
	/* SCTP_STATE_COOKIE_WAIT */ \
306
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
307
	/* SCTP_STATE_COOKIE_ECHOED */ \
308
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
309
	/* SCTP_STATE_ESTABLISHED */ \
310
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
311
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
312
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
313
	/* SCTP_STATE_SHUTDOWN_SENT */ \
314
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
315
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
316
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
317
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
318
	TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
L
Linus Torvalds 已提交
319 320 321 322
} /* TYPE_SCTP_COOKIE_ECHO */

#define TYPE_SCTP_COOKIE_ACK { \
	/* SCTP_STATE_CLOSED */ \
323
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
324
	/* SCTP_STATE_COOKIE_WAIT */ \
325
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
326
	/* SCTP_STATE_COOKIE_ECHOED */ \
327
	TYPE_SCTP_FUNC(sctp_sf_do_5_1E_ca), \
L
Linus Torvalds 已提交
328
	/* SCTP_STATE_ESTABLISHED */ \
329
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
330
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
331
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
332
	/* SCTP_STATE_SHUTDOWN_SENT */ \
333
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
334
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
335
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
336
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
337
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
338 339 340 341
} /* TYPE_SCTP_COOKIE_ACK */

#define TYPE_SCTP_ECN_ECNE { \
	/* SCTP_STATE_CLOSED */ \
342
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
343
	/* SCTP_STATE_COOKIE_WAIT */ \
344
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
345
	/* SCTP_STATE_COOKIE_ECHOED */ \
346
	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
L
Linus Torvalds 已提交
347
	/* SCTP_STATE_ESTABLISHED */ \
348
	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
L
Linus Torvalds 已提交
349
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
350
	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
L
Linus Torvalds 已提交
351
	/* SCTP_STATE_SHUTDOWN_SENT */ \
352
	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
L
Linus Torvalds 已提交
353
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
354
	TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
L
Linus Torvalds 已提交
355
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
356
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
357 358 359 360
} /* TYPE_SCTP_ECN_ECNE */

#define TYPE_SCTP_ECN_CWR { \
	/* SCTP_STATE_CLOSED */ \
361
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
362
	/* SCTP_STATE_COOKIE_WAIT */ \
363
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
364
	/* SCTP_STATE_COOKIE_ECHOED */ \
365
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
366
	/* SCTP_STATE_ESTABLISHED */ \
367
	TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
L
Linus Torvalds 已提交
368
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
369
	TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
L
Linus Torvalds 已提交
370
	/* SCTP_STATE_SHUTDOWN_SENT */ \
371
	TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
L
Linus Torvalds 已提交
372
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
373
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
374
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
375
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
376 377 378 379
} /* TYPE_SCTP_ECN_CWR */

#define TYPE_SCTP_SHUTDOWN_COMPLETE { \
	/* SCTP_STATE_CLOSED */ \
380
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
381
	/* SCTP_STATE_COOKIE_WAIT */ \
382
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
383
	/* SCTP_STATE_COOKIE_ECHOED */ \
384
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
385
	/* SCTP_STATE_ESTABLISHED */ \
386
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
387
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
388
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
389
	/* SCTP_STATE_SHUTDOWN_SENT */ \
390
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
391
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
392
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
393
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
394
	TYPE_SCTP_FUNC(sctp_sf_do_4_C), \
L
Linus Torvalds 已提交
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
} /* TYPE_SCTP_SHUTDOWN_COMPLETE */

/* The primary index for this table is the chunk type.
 * The secondary index for this table is the state.
 *
 * For base protocol (RFC 2960).
 */
static const sctp_sm_table_entry_t chunk_event_table[SCTP_NUM_BASE_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_DATA,
	TYPE_SCTP_INIT,
	TYPE_SCTP_INIT_ACK,
	TYPE_SCTP_SACK,
	TYPE_SCTP_HEARTBEAT,
	TYPE_SCTP_HEARTBEAT_ACK,
	TYPE_SCTP_ABORT,
	TYPE_SCTP_SHUTDOWN,
	TYPE_SCTP_SHUTDOWN_ACK,
	TYPE_SCTP_ERROR,
	TYPE_SCTP_COOKIE_ECHO,
	TYPE_SCTP_COOKIE_ACK,
	TYPE_SCTP_ECN_ECNE,
	TYPE_SCTP_ECN_CWR,
	TYPE_SCTP_SHUTDOWN_COMPLETE,
}; /* state_fn_t chunk_event_table[][] */

#define TYPE_SCTP_ASCONF { \
	/* SCTP_STATE_CLOSED */ \
422
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
423
	/* SCTP_STATE_COOKIE_WAIT */ \
424
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
425
	/* SCTP_STATE_COOKIE_ECHOED */ \
426
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
427
	/* SCTP_STATE_ESTABLISHED */ \
428
	TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
L
Linus Torvalds 已提交
429
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
430
	TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
L
Linus Torvalds 已提交
431
	/* SCTP_STATE_SHUTDOWN_SENT */ \
432
	TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
L
Linus Torvalds 已提交
433
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
434
	TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
L
Linus Torvalds 已提交
435
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
436
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
437 438 439 440
} /* TYPE_SCTP_ASCONF */

#define TYPE_SCTP_ASCONF_ACK { \
	/* SCTP_STATE_CLOSED */ \
441
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
442
	/* SCTP_STATE_COOKIE_WAIT */ \
443
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
444
	/* SCTP_STATE_COOKIE_ECHOED */ \
445
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
446
	/* SCTP_STATE_ESTABLISHED */ \
447
	TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
L
Linus Torvalds 已提交
448
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
449
	TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
L
Linus Torvalds 已提交
450
	/* SCTP_STATE_SHUTDOWN_SENT */ \
451
	TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
L
Linus Torvalds 已提交
452
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
453
	TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
L
Linus Torvalds 已提交
454
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
455
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
456 457 458 459 460 461 462 463 464 465 466 467
} /* TYPE_SCTP_ASCONF_ACK */

/* The primary index for this table is the chunk type.
 * The secondary index for this table is the state.
 */
static const sctp_sm_table_entry_t addip_chunk_event_table[SCTP_NUM_ADDIP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_ASCONF,
	TYPE_SCTP_ASCONF_ACK,
}; /*state_fn_t addip_chunk_event_table[][] */

#define TYPE_SCTP_FWD_TSN { \
	/* SCTP_STATE_CLOSED */ \
468
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
L
Linus Torvalds 已提交
469
	/* SCTP_STATE_COOKIE_WAIT */ \
470
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
471
	/* SCTP_STATE_COOKIE_ECHOED */ \
472
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
473
	/* SCTP_STATE_ESTABLISHED */ \
474
	TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
L
Linus Torvalds 已提交
475
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
476
	TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
L
Linus Torvalds 已提交
477
	/* SCTP_STATE_SHUTDOWN_SENT */ \
478
	TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn_fast), \
L
Linus Torvalds 已提交
479
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
480
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
481
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
482
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
L
Linus Torvalds 已提交
483 484 485 486 487 488 489 490 491
} /* TYPE_SCTP_FWD_TSN */

/* The primary index for this table is the chunk type.
 * The secondary index for this table is the state.
 */
static const sctp_sm_table_entry_t prsctp_chunk_event_table[SCTP_NUM_PRSCTP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_FWD_TSN,
}; /*state_fn_t prsctp_chunk_event_table[][] */

492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
#define TYPE_SCTP_AUTH { \
	/* SCTP_STATE_CLOSED */ \
	TYPE_SCTP_FUNC(sctp_sf_ootb), \
	/* SCTP_STATE_COOKIE_WAIT */ \
	TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
	/* SCTP_STATE_COOKIE_ECHOED */ \
	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
	/* SCTP_STATE_ESTABLISHED */ \
	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
	/* SCTP_STATE_SHUTDOWN_SENT */ \
	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
	TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
} /* TYPE_SCTP_AUTH */

/* The primary index for this table is the chunk type.
 * The secondary index for this table is the state.
 */
static const sctp_sm_table_entry_t auth_chunk_event_table[SCTP_NUM_AUTH_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_AUTH,
}; /*state_fn_t auth_chunk_event_table[][] */

L
Linus Torvalds 已提交
518 519 520
static const sctp_sm_table_entry_t
chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
	/* SCTP_STATE_CLOSED */
521
	TYPE_SCTP_FUNC(sctp_sf_ootb),
L
Linus Torvalds 已提交
522
	/* SCTP_STATE_COOKIE_WAIT */
523
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
524
	/* SCTP_STATE_COOKIE_ECHOED */
525
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
526
	/* SCTP_STATE_ESTABLISHED */
527
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
528
	/* SCTP_STATE_SHUTDOWN_PENDING */
529
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
530
	/* SCTP_STATE_SHUTDOWN_SENT */
531
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
532
	/* SCTP_STATE_SHUTDOWN_RECEIVED */
533
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
534
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */
535
	TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
L
Linus Torvalds 已提交
536 537 538 539 540
};	/* chunk unknown */


#define TYPE_SCTP_PRIMITIVE_ASSOCIATE  { \
	/* SCTP_STATE_CLOSED */ \
541
	TYPE_SCTP_FUNC(sctp_sf_do_prm_asoc), \
L
Linus Torvalds 已提交
542
	/* SCTP_STATE_COOKIE_WAIT */ \
543
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
544
	/* SCTP_STATE_COOKIE_ECHOED */ \
545
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
546
	/* SCTP_STATE_ESTABLISHED */ \
547
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
548
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
549
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
550
	/* SCTP_STATE_SHUTDOWN_SENT */ \
551
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
552
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
553
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
554
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
555
	TYPE_SCTP_FUNC(sctp_sf_not_impl), \
L
Linus Torvalds 已提交
556 557 558 559
} /* TYPE_SCTP_PRIMITIVE_ASSOCIATE */

#define TYPE_SCTP_PRIMITIVE_SHUTDOWN  { \
	/* SCTP_STATE_CLOSED */ \
560
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
561
	/* SCTP_STATE_COOKIE_WAIT */ \
562
	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_shutdown), \
L
Linus Torvalds 已提交
563
	/* SCTP_STATE_COOKIE_ECHOED */ \
564
	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_shutdown),\
L
Linus Torvalds 已提交
565
	/* SCTP_STATE_ESTABLISHED */ \
566
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_prm_shutdown), \
L
Linus Torvalds 已提交
567
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
568
	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
L
Linus Torvalds 已提交
569
	/* SCTP_STATE_SHUTDOWN_SENT */ \
570
	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
L
Linus Torvalds 已提交
571
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
572
	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
L
Linus Torvalds 已提交
573
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
574
	TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
L
Linus Torvalds 已提交
575 576 577 578
} /* TYPE_SCTP_PRIMITIVE_SHUTDOWN */

#define TYPE_SCTP_PRIMITIVE_ABORT  { \
	/* SCTP_STATE_CLOSED */ \
579
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
580
	/* SCTP_STATE_COOKIE_WAIT */ \
581
	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_abort), \
L
Linus Torvalds 已提交
582
	/* SCTP_STATE_COOKIE_ECHOED */ \
583
	TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_abort), \
L
Linus Torvalds 已提交
584
	/* SCTP_STATE_ESTABLISHED */ \
585
	TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
L
Linus Torvalds 已提交
586
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
587
	TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_prm_abort), \
L
Linus Torvalds 已提交
588
	/* SCTP_STATE_SHUTDOWN_SENT */ \
589
	TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_prm_abort), \
L
Linus Torvalds 已提交
590
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
591
	TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
L
Linus Torvalds 已提交
592
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
593
	TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_prm_abort), \
L
Linus Torvalds 已提交
594 595 596 597
} /* TYPE_SCTP_PRIMITIVE_ABORT */

#define TYPE_SCTP_PRIMITIVE_SEND  { \
	/* SCTP_STATE_CLOSED */ \
598
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
599
	/* SCTP_STATE_COOKIE_WAIT */ \
600
	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
L
Linus Torvalds 已提交
601
	/* SCTP_STATE_COOKIE_ECHOED */ \
602
	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
L
Linus Torvalds 已提交
603
	/* SCTP_STATE_ESTABLISHED */ \
604
	TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
L
Linus Torvalds 已提交
605
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
606
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
607
	/* SCTP_STATE_SHUTDOWN_SENT */ \
608
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
609
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
610
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
611
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
612
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
L
Linus Torvalds 已提交
613 614 615 616
} /* TYPE_SCTP_PRIMITIVE_SEND */

#define TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT  { \
	/* SCTP_STATE_CLOSED */ \
617
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
618
	/* SCTP_STATE_COOKIE_WAIT */ \
619
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
620
	/* SCTP_STATE_COOKIE_ECHOED */ \
621
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
622
	/* SCTP_STATE_ESTABLISHED */ \
623
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
624
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
625
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
626
	/* SCTP_STATE_SHUTDOWN_SENT */ \
627
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
628
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
629
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
630
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
631
	TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat),          \
L
Linus Torvalds 已提交
632 633 634 635
} /* TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT */

#define TYPE_SCTP_PRIMITIVE_ASCONF { \
	/* SCTP_STATE_CLOSED */ \
636
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
637
	/* SCTP_STATE_COOKIE_WAIT */ \
638
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
639
	/* SCTP_STATE_COOKIE_ECHOED */ \
640
	TYPE_SCTP_FUNC(sctp_sf_error_closed), \
L
Linus Torvalds 已提交
641
	/* SCTP_STATE_ESTABLISHED */ \
642
	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
L
Linus Torvalds 已提交
643
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
644
	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
L
Linus Torvalds 已提交
645
	/* SCTP_STATE_SHUTDOWN_SENT */ \
646
	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
L
Linus Torvalds 已提交
647
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
648
	TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
L
Linus Torvalds 已提交
649
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
650
	TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
651
} /* TYPE_SCTP_PRIMITIVE_ASCONF */
L
Linus Torvalds 已提交
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666

/* The primary index for this table is the primitive type.
 * The secondary index for this table is the state.
 */
static const sctp_sm_table_entry_t primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_PRIMITIVE_ASSOCIATE,
	TYPE_SCTP_PRIMITIVE_SHUTDOWN,
	TYPE_SCTP_PRIMITIVE_ABORT,
	TYPE_SCTP_PRIMITIVE_SEND,
	TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT,
	TYPE_SCTP_PRIMITIVE_ASCONF,
};

#define TYPE_SCTP_OTHER_NO_PENDING_TSN  { \
	/* SCTP_STATE_CLOSED */ \
667
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
668
	/* SCTP_STATE_COOKIE_WAIT */ \
669
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
670
	/* SCTP_STATE_COOKIE_ECHOED */ \
671
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
672
	/* SCTP_STATE_ESTABLISHED */ \
673
	TYPE_SCTP_FUNC(sctp_sf_do_no_pending_tsn), \
L
Linus Torvalds 已提交
674
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
675
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_start_shutdown), \
L
Linus Torvalds 已提交
676
	/* SCTP_STATE_SHUTDOWN_SENT */ \
677
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
678
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
679
	TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
L
Linus Torvalds 已提交
680
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
681
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
682 683 684 685
}

#define TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH  { \
	/* SCTP_STATE_CLOSED */ \
686
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
687
	/* SCTP_STATE_COOKIE_WAIT */ \
688
	TYPE_SCTP_FUNC(sctp_sf_cookie_wait_icmp_abort), \
L
Linus Torvalds 已提交
689
	/* SCTP_STATE_COOKIE_ECHOED */ \
690
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
691
	/* SCTP_STATE_ESTABLISHED */ \
692
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
693
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
694
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
695
	/* SCTP_STATE_SHUTDOWN_SENT */ \
696
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
697
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
698
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
699
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
700
	TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
L
Linus Torvalds 已提交
701 702 703 704 705 706 707 708 709
}

static const sctp_sm_table_entry_t other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_OTHER_NO_PENDING_TSN,
	TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH,
};

#define TYPE_SCTP_EVENT_TIMEOUT_NONE { \
	/* SCTP_STATE_CLOSED */ \
710
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
711
	/* SCTP_STATE_COOKIE_WAIT */ \
712
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
713
	/* SCTP_STATE_COOKIE_ECHOED */ \
714
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
715
	/* SCTP_STATE_ESTABLISHED */ \
716
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
717
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
718
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
719
	/* SCTP_STATE_SHUTDOWN_SENT */ \
720
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
721
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
722
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
723
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
724
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
725 726 727 728
}

#define TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE { \
	/* SCTP_STATE_CLOSED */ \
729
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
730
	/* SCTP_STATE_COOKIE_WAIT */ \
731
	TYPE_SCTP_FUNC(sctp_sf_bug), \
L
Linus Torvalds 已提交
732
	/* SCTP_STATE_COOKIE_ECHOED */ \
733
	TYPE_SCTP_FUNC(sctp_sf_t1_cookie_timer_expire), \
L
Linus Torvalds 已提交
734
	/* SCTP_STATE_ESTABLISHED */ \
735
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
736
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
737
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
738
	/* SCTP_STATE_SHUTDOWN_SENT */ \
739
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
740
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
741
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
742
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
743
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
744 745 746 747
}

#define TYPE_SCTP_EVENT_TIMEOUT_T1_INIT { \
	/* SCTP_STATE_CLOSED */ \
748
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
749
	/* SCTP_STATE_COOKIE_WAIT */ \
750
	TYPE_SCTP_FUNC(sctp_sf_t1_init_timer_expire), \
L
Linus Torvalds 已提交
751
	/* SCTP_STATE_COOKIE_ECHOED */ \
752
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
753
	/* SCTP_STATE_ESTABLISHED */ \
754
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
755
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
756
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
757
	/* SCTP_STATE_SHUTDOWN_SENT */ \
758
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
759
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
760
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
761
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
762
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
763 764 765 766
}

#define TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN { \
	/* SCTP_STATE_CLOSED */ \
767
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
768
	/* SCTP_STATE_COOKIE_WAIT */ \
769
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
770
	/* SCTP_STATE_COOKIE_ECHOED */ \
771
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
772
	/* SCTP_STATE_ESTABLISHED */ \
773
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
774
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
775
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
776
	/* SCTP_STATE_SHUTDOWN_SENT */ \
777
	TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
L
Linus Torvalds 已提交
778
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
779
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
780
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
781
	TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
L
Linus Torvalds 已提交
782 783 784 785
}

#define TYPE_SCTP_EVENT_TIMEOUT_T3_RTX { \
	/* SCTP_STATE_CLOSED */ \
786
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
787
	/* SCTP_STATE_COOKIE_WAIT */ \
788
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
789
	/* SCTP_STATE_COOKIE_ECHOED */ \
790
	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
L
Linus Torvalds 已提交
791
	/* SCTP_STATE_ESTABLISHED */ \
792
	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
L
Linus Torvalds 已提交
793
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
794
	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
L
Linus Torvalds 已提交
795
	/* SCTP_STATE_SHUTDOWN_SENT */ \
796
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
797
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
798
	TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
L
Linus Torvalds 已提交
799
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
800
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
801 802 803 804
}

#define TYPE_SCTP_EVENT_TIMEOUT_T4_RTO { \
	/* SCTP_STATE_CLOSED */ \
805
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
806
	/* SCTP_STATE_COOKIE_WAIT */ \
807
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
808
	/* SCTP_STATE_COOKIE_ECHOED */ \
809
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
810
	/* SCTP_STATE_ESTABLISHED */ \
811
	TYPE_SCTP_FUNC(sctp_sf_t4_timer_expire), \
L
Linus Torvalds 已提交
812
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
813
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
814
	/* SCTP_STATE_SHUTDOWN_SENT */ \
815
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
816
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
817
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
818
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
819
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
820 821 822 823
}

#define TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD { \
	/* SCTP_STATE_CLOSED */ \
824
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
825
	/* SCTP_STATE_COOKIE_WAIT */ \
826
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
827
	/* SCTP_STATE_COOKIE_ECHOED */ \
828
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
829
	/* SCTP_STATE_ESTABLISHED */ \
830
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
831
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
832
	TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
L
Linus Torvalds 已提交
833
	/* SCTP_STATE_SHUTDOWN_SENT */ \
834
	TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
L
Linus Torvalds 已提交
835
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
836
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
837
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
838
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
839 840 841 842
}

#define TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT { \
	/* SCTP_STATE_CLOSED */ \
843
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
844
	/* SCTP_STATE_COOKIE_WAIT */ \
845
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
846
	/* SCTP_STATE_COOKIE_ECHOED */ \
847
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
848
	/* SCTP_STATE_ESTABLISHED */ \
849
	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
L
Linus Torvalds 已提交
850
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
851
	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
L
Linus Torvalds 已提交
852
	/* SCTP_STATE_SHUTDOWN_SENT */ \
853
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
854
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
855
	TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
L
Linus Torvalds 已提交
856
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
857
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
858 859 860 861
}

#define TYPE_SCTP_EVENT_TIMEOUT_SACK { \
	/* SCTP_STATE_CLOSED */ \
862
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
863
	/* SCTP_STATE_COOKIE_WAIT */ \
864
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
865
	/* SCTP_STATE_COOKIE_ECHOED */ \
866
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
867
	/* SCTP_STATE_ESTABLISHED */ \
868
	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
L
Linus Torvalds 已提交
869
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
870
	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
L
Linus Torvalds 已提交
871
	/* SCTP_STATE_SHUTDOWN_SENT */ \
872
	TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
L
Linus Torvalds 已提交
873
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
874
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
875
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
876
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
877 878 879 880
}

#define TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE { \
	/* SCTP_STATE_CLOSED */ \
881
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
882
	/* SCTP_STATE_COOKIE_WAIT */ \
883
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
884
	/* SCTP_STATE_COOKIE_ECHOED */ \
885
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
886
	/* SCTP_STATE_ESTABLISHED */ \
887
	TYPE_SCTP_FUNC(sctp_sf_autoclose_timer_expire), \
L
Linus Torvalds 已提交
888
	/* SCTP_STATE_SHUTDOWN_PENDING */ \
889
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
890
	/* SCTP_STATE_SHUTDOWN_SENT */ \
891
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
892
	/* SCTP_STATE_SHUTDOWN_RECEIVED */ \
893
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
894
	/* SCTP_STATE_SHUTDOWN_ACK_SENT */ \
895
	TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
L
Linus Torvalds 已提交
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910
}

static const sctp_sm_table_entry_t timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES] = {
	TYPE_SCTP_EVENT_TIMEOUT_NONE,
	TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE,
	TYPE_SCTP_EVENT_TIMEOUT_T1_INIT,
	TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
	TYPE_SCTP_EVENT_TIMEOUT_T3_RTX,
	TYPE_SCTP_EVENT_TIMEOUT_T4_RTO,
	TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD,
	TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT,
	TYPE_SCTP_EVENT_TIMEOUT_SACK,
	TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE,
};

911 912
static const sctp_sm_table_entry_t *sctp_chunk_event_lookup(struct net *net,
							    sctp_cid_t cid,
L
Linus Torvalds 已提交
913 914 915 916 917
							    sctp_state_t state)
{
	if (state > SCTP_STATE_MAX)
		return &bug;

918
	if (cid <= SCTP_CID_BASE_MAX)
L
Linus Torvalds 已提交
919 920
		return &chunk_event_table[cid][state];

921
	if (net->sctp.prsctp_enable) {
L
Linus Torvalds 已提交
922 923 924 925
		if (cid == SCTP_CID_FWD_TSN)
			return &prsctp_chunk_event_table[0][state];
	}

926
	if (net->sctp.addip_enable) {
L
Linus Torvalds 已提交
927 928 929 930 931 932 933
		if (cid == SCTP_CID_ASCONF)
			return &addip_chunk_event_table[0][state];

		if (cid == SCTP_CID_ASCONF_ACK)
			return &addip_chunk_event_table[1][state];
	}

934
	if (net->sctp.auth_enable) {
935 936 937 938
		if (cid == SCTP_CID_AUTH)
			return &auth_chunk_event_table[0][state];
	}

L
Linus Torvalds 已提交
939 940
	return &chunk_event_table_unknown[state];
}