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