0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0028
0029 #include <linux/skbuff.h>
0030 #include <net/sctp/sctp.h>
0031 #include <net/sctp/sm.h>
0032
0033 static const struct sctp_sm_table_entry
0034 primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES];
0035 static const struct sctp_sm_table_entry
0036 other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES];
0037 static const struct sctp_sm_table_entry
0038 timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES];
0039
0040 static const struct sctp_sm_table_entry *sctp_chunk_event_lookup(
0041 struct net *net,
0042 enum sctp_cid cid,
0043 enum sctp_state state);
0044
0045
0046 static const struct sctp_sm_table_entry bug = {
0047 .fn = sctp_sf_bug,
0048 .name = "sctp_sf_bug"
0049 };
0050
0051 #define DO_LOOKUP(_max, _type, _table) \
0052 ({ \
0053 const struct sctp_sm_table_entry *rtn; \
0054 \
0055 if ((event_subtype._type > (_max))) { \
0056 pr_warn("table %p possible attack: event %d exceeds max %d\n", \
0057 _table, event_subtype._type, _max); \
0058 rtn = &bug; \
0059 } else \
0060 rtn = &_table[event_subtype._type][(int)state]; \
0061 \
0062 rtn; \
0063 })
0064
0065 const struct sctp_sm_table_entry *sctp_sm_lookup_event(
0066 struct net *net,
0067 enum sctp_event_type event_type,
0068 enum sctp_state state,
0069 union sctp_subtype event_subtype)
0070 {
0071 switch (event_type) {
0072 case SCTP_EVENT_T_CHUNK:
0073 return sctp_chunk_event_lookup(net, event_subtype.chunk, state);
0074 case SCTP_EVENT_T_TIMEOUT:
0075 return DO_LOOKUP(SCTP_EVENT_TIMEOUT_MAX, timeout,
0076 timeout_event_table);
0077 case SCTP_EVENT_T_OTHER:
0078 return DO_LOOKUP(SCTP_EVENT_OTHER_MAX, other,
0079 other_event_table);
0080 case SCTP_EVENT_T_PRIMITIVE:
0081 return DO_LOOKUP(SCTP_EVENT_PRIMITIVE_MAX, primitive,
0082 primitive_event_table);
0083 default:
0084
0085 return &bug;
0086 }
0087 }
0088
0089 #define TYPE_SCTP_FUNC(func) {.fn = func, .name = #func}
0090
0091 #define TYPE_SCTP_DATA { \
0092 \
0093 TYPE_SCTP_FUNC(sctp_sf_ootb), \
0094 \
0095 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0096 \
0097 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0098 \
0099 TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
0100 \
0101 TYPE_SCTP_FUNC(sctp_sf_eat_data_6_2), \
0102 \
0103 TYPE_SCTP_FUNC(sctp_sf_eat_data_fast_4_4), \
0104 \
0105 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0106 \
0107 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0108 }
0109
0110 #define TYPE_SCTP_INIT { \
0111 \
0112 TYPE_SCTP_FUNC(sctp_sf_do_5_1B_init), \
0113 \
0114 TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
0115 \
0116 TYPE_SCTP_FUNC(sctp_sf_do_5_2_1_siminit), \
0117 \
0118 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
0119 \
0120 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
0121 \
0122 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
0123 \
0124 TYPE_SCTP_FUNC(sctp_sf_do_5_2_2_dupinit), \
0125 \
0126 TYPE_SCTP_FUNC(sctp_sf_do_9_2_reshutack), \
0127 }
0128
0129 #define TYPE_SCTP_INIT_ACK { \
0130 \
0131 TYPE_SCTP_FUNC(sctp_sf_do_5_2_3_initack), \
0132 \
0133 TYPE_SCTP_FUNC(sctp_sf_do_5_1C_ack), \
0134 \
0135 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0136 \
0137 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0138 \
0139 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0140 \
0141 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0142 \
0143 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0144 \
0145 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0146 }
0147
0148 #define TYPE_SCTP_SACK { \
0149 \
0150 TYPE_SCTP_FUNC(sctp_sf_ootb), \
0151 \
0152 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0153 \
0154 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
0155 \
0156 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
0157 \
0158 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
0159 \
0160 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0161 \
0162 TYPE_SCTP_FUNC(sctp_sf_eat_sack_6_2), \
0163 \
0164 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0165 }
0166
0167 #define TYPE_SCTP_HEARTBEAT { \
0168 \
0169 TYPE_SCTP_FUNC(sctp_sf_ootb), \
0170 \
0171 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0172 \
0173 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
0174 \
0175 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
0176 \
0177 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
0178 \
0179 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
0180 \
0181 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
0182 \
0183 \
0184 TYPE_SCTP_FUNC(sctp_sf_beat_8_3), \
0185 }
0186
0187 #define TYPE_SCTP_HEARTBEAT_ACK { \
0188 \
0189 TYPE_SCTP_FUNC(sctp_sf_ootb), \
0190 \
0191 TYPE_SCTP_FUNC(sctp_sf_violation), \
0192 \
0193 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0194 \
0195 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
0196 \
0197 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
0198 \
0199 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
0200 \
0201 TYPE_SCTP_FUNC(sctp_sf_backbeat_8_3), \
0202 \
0203 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0204 }
0205
0206 #define TYPE_SCTP_ABORT { \
0207 \
0208 TYPE_SCTP_FUNC(sctp_sf_pdiscard), \
0209 \
0210 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_abort), \
0211 \
0212 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_abort), \
0213 \
0214 TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
0215 \
0216 TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_abort), \
0217 \
0218 TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_abort), \
0219 \
0220 TYPE_SCTP_FUNC(sctp_sf_do_9_1_abort), \
0221 \
0222 TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_abort), \
0223 }
0224
0225 #define TYPE_SCTP_SHUTDOWN { \
0226 \
0227 TYPE_SCTP_FUNC(sctp_sf_ootb), \
0228 \
0229 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0230 \
0231 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0232 \
0233 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
0234 \
0235 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown), \
0236 \
0237 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
0238 \
0239 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shut_ctsn), \
0240 \
0241 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0242 }
0243
0244 #define TYPE_SCTP_SHUTDOWN_ACK { \
0245 \
0246 TYPE_SCTP_FUNC(sctp_sf_ootb), \
0247 \
0248 TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
0249 \
0250 TYPE_SCTP_FUNC(sctp_sf_do_8_5_1_E_sa), \
0251 \
0252 TYPE_SCTP_FUNC(sctp_sf_violation), \
0253 \
0254 TYPE_SCTP_FUNC(sctp_sf_violation), \
0255 \
0256 TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
0257 \
0258 TYPE_SCTP_FUNC(sctp_sf_violation), \
0259 \
0260 TYPE_SCTP_FUNC(sctp_sf_do_9_2_final), \
0261 }
0262
0263 #define TYPE_SCTP_ERROR { \
0264 \
0265 TYPE_SCTP_FUNC(sctp_sf_ootb), \
0266 \
0267 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0268 \
0269 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_err), \
0270 \
0271 TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
0272 \
0273 TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
0274 \
0275 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0276 \
0277 TYPE_SCTP_FUNC(sctp_sf_operr_notify), \
0278 \
0279 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0280 }
0281
0282 #define TYPE_SCTP_COOKIE_ECHO { \
0283 \
0284 TYPE_SCTP_FUNC(sctp_sf_do_5_1D_ce), \
0285 \
0286 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
0287 \
0288 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
0289 \
0290 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
0291 \
0292 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
0293 \
0294 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
0295 \
0296 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
0297 \
0298 TYPE_SCTP_FUNC(sctp_sf_do_5_2_4_dupcook), \
0299 }
0300
0301 #define TYPE_SCTP_COOKIE_ACK { \
0302 \
0303 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0304 \
0305 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0306 \
0307 TYPE_SCTP_FUNC(sctp_sf_do_5_1E_ca), \
0308 \
0309 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0310 \
0311 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0312 \
0313 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0314 \
0315 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0316 \
0317 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0318 }
0319
0320 #define TYPE_SCTP_ECN_ECNE { \
0321 \
0322 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0323 \
0324 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0325 \
0326 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
0327 \
0328 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
0329 \
0330 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
0331 \
0332 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
0333 \
0334 TYPE_SCTP_FUNC(sctp_sf_do_ecne), \
0335 \
0336 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0337 }
0338
0339 #define TYPE_SCTP_ECN_CWR { \
0340 \
0341 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0342 \
0343 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0344 \
0345 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0346 \
0347 TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
0348 \
0349 TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
0350 \
0351 TYPE_SCTP_FUNC(sctp_sf_do_ecn_cwr), \
0352 \
0353 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0354 \
0355 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0356 }
0357
0358 #define TYPE_SCTP_SHUTDOWN_COMPLETE { \
0359 \
0360 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0361 \
0362 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0363 \
0364 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0365 \
0366 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0367 \
0368 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0369 \
0370 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0371 \
0372 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0373 \
0374 TYPE_SCTP_FUNC(sctp_sf_do_4_C), \
0375 }
0376
0377
0378
0379
0380
0381
0382 static const struct sctp_sm_table_entry
0383 chunk_event_table[SCTP_NUM_BASE_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
0384 TYPE_SCTP_DATA,
0385 TYPE_SCTP_INIT,
0386 TYPE_SCTP_INIT_ACK,
0387 TYPE_SCTP_SACK,
0388 TYPE_SCTP_HEARTBEAT,
0389 TYPE_SCTP_HEARTBEAT_ACK,
0390 TYPE_SCTP_ABORT,
0391 TYPE_SCTP_SHUTDOWN,
0392 TYPE_SCTP_SHUTDOWN_ACK,
0393 TYPE_SCTP_ERROR,
0394 TYPE_SCTP_COOKIE_ECHO,
0395 TYPE_SCTP_COOKIE_ACK,
0396 TYPE_SCTP_ECN_ECNE,
0397 TYPE_SCTP_ECN_CWR,
0398 TYPE_SCTP_SHUTDOWN_COMPLETE,
0399 };
0400
0401 #define TYPE_SCTP_ASCONF { \
0402 \
0403 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0404 \
0405 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0406 \
0407 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0408 \
0409 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
0410 \
0411 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
0412 \
0413 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
0414 \
0415 TYPE_SCTP_FUNC(sctp_sf_do_asconf), \
0416 \
0417 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0418 }
0419
0420 #define TYPE_SCTP_ASCONF_ACK { \
0421 \
0422 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0423 \
0424 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0425 \
0426 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0427 \
0428 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
0429 \
0430 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
0431 \
0432 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
0433 \
0434 TYPE_SCTP_FUNC(sctp_sf_do_asconf_ack), \
0435 \
0436 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0437 }
0438
0439
0440
0441
0442 static const struct sctp_sm_table_entry
0443 addip_chunk_event_table[SCTP_NUM_ADDIP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
0444 TYPE_SCTP_ASCONF,
0445 TYPE_SCTP_ASCONF_ACK,
0446 };
0447
0448 #define TYPE_SCTP_FWD_TSN { \
0449 \
0450 TYPE_SCTP_FUNC(sctp_sf_ootb), \
0451 \
0452 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0453 \
0454 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0455 \
0456 TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
0457 \
0458 TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn), \
0459 \
0460 TYPE_SCTP_FUNC(sctp_sf_eat_fwd_tsn_fast), \
0461 \
0462 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0463 \
0464 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0465 }
0466
0467
0468
0469
0470 static const struct sctp_sm_table_entry
0471 prsctp_chunk_event_table[SCTP_NUM_PRSCTP_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
0472 TYPE_SCTP_FWD_TSN,
0473 };
0474
0475 #define TYPE_SCTP_RECONF { \
0476 \
0477 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0478 \
0479 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0480 \
0481 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0482 \
0483 TYPE_SCTP_FUNC(sctp_sf_do_reconf), \
0484 \
0485 TYPE_SCTP_FUNC(sctp_sf_do_reconf), \
0486 \
0487 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0488 \
0489 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0490 \
0491 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0492 }
0493
0494
0495
0496
0497 static const struct sctp_sm_table_entry
0498 reconf_chunk_event_table[SCTP_NUM_RECONF_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
0499 TYPE_SCTP_RECONF,
0500 };
0501
0502 #define TYPE_SCTP_AUTH { \
0503 \
0504 TYPE_SCTP_FUNC(sctp_sf_ootb), \
0505 \
0506 TYPE_SCTP_FUNC(sctp_sf_discard_chunk), \
0507 \
0508 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
0509 \
0510 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
0511 \
0512 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
0513 \
0514 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
0515 \
0516 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
0517 \
0518 TYPE_SCTP_FUNC(sctp_sf_eat_auth), \
0519 }
0520
0521
0522
0523
0524 static const struct sctp_sm_table_entry
0525 auth_chunk_event_table[SCTP_NUM_AUTH_CHUNK_TYPES][SCTP_STATE_NUM_STATES] = {
0526 TYPE_SCTP_AUTH,
0527 };
0528
0529 static const struct sctp_sm_table_entry
0530 pad_chunk_event_table[SCTP_STATE_NUM_STATES] = {
0531
0532 TYPE_SCTP_FUNC(sctp_sf_discard_chunk),
0533
0534 TYPE_SCTP_FUNC(sctp_sf_discard_chunk),
0535
0536 TYPE_SCTP_FUNC(sctp_sf_discard_chunk),
0537
0538 TYPE_SCTP_FUNC(sctp_sf_discard_chunk),
0539
0540 TYPE_SCTP_FUNC(sctp_sf_discard_chunk),
0541
0542 TYPE_SCTP_FUNC(sctp_sf_discard_chunk),
0543
0544 TYPE_SCTP_FUNC(sctp_sf_discard_chunk),
0545
0546 TYPE_SCTP_FUNC(sctp_sf_discard_chunk),
0547 };
0548
0549 static const struct sctp_sm_table_entry
0550 chunk_event_table_unknown[SCTP_STATE_NUM_STATES] = {
0551
0552 TYPE_SCTP_FUNC(sctp_sf_ootb),
0553
0554 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
0555
0556 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
0557
0558 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
0559
0560 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
0561
0562 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
0563
0564 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
0565
0566 TYPE_SCTP_FUNC(sctp_sf_unk_chunk),
0567 };
0568
0569
0570 #define TYPE_SCTP_PRIMITIVE_ASSOCIATE { \
0571 \
0572 TYPE_SCTP_FUNC(sctp_sf_do_prm_asoc), \
0573 \
0574 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
0575 \
0576 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
0577 \
0578 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
0579 \
0580 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
0581 \
0582 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
0583 \
0584 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
0585 \
0586 TYPE_SCTP_FUNC(sctp_sf_not_impl), \
0587 }
0588
0589 #define TYPE_SCTP_PRIMITIVE_SHUTDOWN { \
0590 \
0591 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
0592 \
0593 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_shutdown), \
0594 \
0595 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_shutdown),\
0596 \
0597 TYPE_SCTP_FUNC(sctp_sf_do_9_2_prm_shutdown), \
0598 \
0599 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
0600 \
0601 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
0602 \
0603 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
0604 \
0605 TYPE_SCTP_FUNC(sctp_sf_ignore_primitive), \
0606 }
0607
0608 #define TYPE_SCTP_PRIMITIVE_ABORT { \
0609 \
0610 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
0611 \
0612 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_prm_abort), \
0613 \
0614 TYPE_SCTP_FUNC(sctp_sf_cookie_echoed_prm_abort), \
0615 \
0616 TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
0617 \
0618 TYPE_SCTP_FUNC(sctp_sf_shutdown_pending_prm_abort), \
0619 \
0620 TYPE_SCTP_FUNC(sctp_sf_shutdown_sent_prm_abort), \
0621 \
0622 TYPE_SCTP_FUNC(sctp_sf_do_9_1_prm_abort), \
0623 \
0624 TYPE_SCTP_FUNC(sctp_sf_shutdown_ack_sent_prm_abort), \
0625 }
0626
0627 #define TYPE_SCTP_PRIMITIVE_SEND { \
0628 \
0629 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
0630 \
0631 TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
0632 \
0633 TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
0634 \
0635 TYPE_SCTP_FUNC(sctp_sf_do_prm_send), \
0636 \
0637 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
0638 \
0639 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
0640 \
0641 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
0642 \
0643 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
0644 }
0645
0646 #define TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT { \
0647 \
0648 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
0649 \
0650 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
0651 \
0652 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
0653 \
0654 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
0655 \
0656 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
0657 \
0658 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
0659 \
0660 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
0661 \
0662 TYPE_SCTP_FUNC(sctp_sf_do_prm_requestheartbeat), \
0663 }
0664
0665 #define TYPE_SCTP_PRIMITIVE_ASCONF { \
0666 \
0667 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
0668 \
0669 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
0670 \
0671 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
0672 \
0673 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
0674 \
0675 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
0676 \
0677 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
0678 \
0679 TYPE_SCTP_FUNC(sctp_sf_do_prm_asconf), \
0680 \
0681 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
0682 }
0683
0684 #define TYPE_SCTP_PRIMITIVE_RECONF { \
0685 \
0686 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
0687 \
0688 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
0689 \
0690 TYPE_SCTP_FUNC(sctp_sf_error_closed), \
0691 \
0692 TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
0693 \
0694 TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
0695 \
0696 TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
0697 \
0698 TYPE_SCTP_FUNC(sctp_sf_do_prm_reconf), \
0699 \
0700 TYPE_SCTP_FUNC(sctp_sf_error_shutdown), \
0701 }
0702
0703
0704
0705
0706 static const struct sctp_sm_table_entry
0707 primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES] = {
0708 TYPE_SCTP_PRIMITIVE_ASSOCIATE,
0709 TYPE_SCTP_PRIMITIVE_SHUTDOWN,
0710 TYPE_SCTP_PRIMITIVE_ABORT,
0711 TYPE_SCTP_PRIMITIVE_SEND,
0712 TYPE_SCTP_PRIMITIVE_REQUESTHEARTBEAT,
0713 TYPE_SCTP_PRIMITIVE_ASCONF,
0714 TYPE_SCTP_PRIMITIVE_RECONF,
0715 };
0716
0717 #define TYPE_SCTP_OTHER_NO_PENDING_TSN { \
0718 \
0719 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
0720 \
0721 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
0722 \
0723 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
0724 \
0725 TYPE_SCTP_FUNC(sctp_sf_do_no_pending_tsn), \
0726 \
0727 TYPE_SCTP_FUNC(sctp_sf_do_9_2_start_shutdown), \
0728 \
0729 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
0730 \
0731 TYPE_SCTP_FUNC(sctp_sf_do_9_2_shutdown_ack), \
0732 \
0733 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
0734 }
0735
0736 #define TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH { \
0737 \
0738 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
0739 \
0740 TYPE_SCTP_FUNC(sctp_sf_cookie_wait_icmp_abort), \
0741 \
0742 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
0743 \
0744 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
0745 \
0746 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
0747 \
0748 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
0749 \
0750 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
0751 \
0752 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \
0753 }
0754
0755 static const struct sctp_sm_table_entry
0756 other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES] = {
0757 TYPE_SCTP_OTHER_NO_PENDING_TSN,
0758 TYPE_SCTP_OTHER_ICMP_PROTO_UNREACH,
0759 };
0760
0761 #define TYPE_SCTP_EVENT_TIMEOUT_NONE { \
0762 \
0763 TYPE_SCTP_FUNC(sctp_sf_bug), \
0764 \
0765 TYPE_SCTP_FUNC(sctp_sf_bug), \
0766 \
0767 TYPE_SCTP_FUNC(sctp_sf_bug), \
0768 \
0769 TYPE_SCTP_FUNC(sctp_sf_bug), \
0770 \
0771 TYPE_SCTP_FUNC(sctp_sf_bug), \
0772 \
0773 TYPE_SCTP_FUNC(sctp_sf_bug), \
0774 \
0775 TYPE_SCTP_FUNC(sctp_sf_bug), \
0776 \
0777 TYPE_SCTP_FUNC(sctp_sf_bug), \
0778 }
0779
0780 #define TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE { \
0781 \
0782 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0783 \
0784 TYPE_SCTP_FUNC(sctp_sf_bug), \
0785 \
0786 TYPE_SCTP_FUNC(sctp_sf_t1_cookie_timer_expire), \
0787 \
0788 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0789 \
0790 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0791 \
0792 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0793 \
0794 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0795 \
0796 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0797 }
0798
0799 #define TYPE_SCTP_EVENT_TIMEOUT_T1_INIT { \
0800 \
0801 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0802 \
0803 TYPE_SCTP_FUNC(sctp_sf_t1_init_timer_expire), \
0804 \
0805 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0806 \
0807 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0808 \
0809 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0810 \
0811 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0812 \
0813 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0814 \
0815 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0816 }
0817
0818 #define TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN { \
0819 \
0820 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0821 \
0822 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0823 \
0824 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0825 \
0826 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0827 \
0828 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0829 \
0830 TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
0831 \
0832 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0833 \
0834 TYPE_SCTP_FUNC(sctp_sf_t2_timer_expire), \
0835 }
0836
0837 #define TYPE_SCTP_EVENT_TIMEOUT_T3_RTX { \
0838 \
0839 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0840 \
0841 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0842 \
0843 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
0844 \
0845 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
0846 \
0847 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
0848 \
0849 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0850 \
0851 TYPE_SCTP_FUNC(sctp_sf_do_6_3_3_rtx), \
0852 \
0853 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0854 }
0855
0856 #define TYPE_SCTP_EVENT_TIMEOUT_T4_RTO { \
0857 \
0858 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0859 \
0860 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0861 \
0862 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0863 \
0864 TYPE_SCTP_FUNC(sctp_sf_t4_timer_expire), \
0865 \
0866 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0867 \
0868 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0869 \
0870 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0871 \
0872 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0873 }
0874
0875 #define TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD { \
0876 \
0877 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0878 \
0879 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0880 \
0881 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0882 \
0883 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0884 \
0885 TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
0886 \
0887 TYPE_SCTP_FUNC(sctp_sf_t5_timer_expire), \
0888 \
0889 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0890 \
0891 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0892 }
0893
0894 #define TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT { \
0895 \
0896 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0897 \
0898 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0899 \
0900 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0901 \
0902 TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
0903 \
0904 TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
0905 \
0906 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0907 \
0908 TYPE_SCTP_FUNC(sctp_sf_sendbeat_8_3), \
0909 \
0910 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0911 }
0912
0913 #define TYPE_SCTP_EVENT_TIMEOUT_SACK { \
0914 \
0915 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0916 \
0917 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0918 \
0919 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0920 \
0921 TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
0922 \
0923 TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
0924 \
0925 TYPE_SCTP_FUNC(sctp_sf_do_6_2_sack), \
0926 \
0927 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0928 \
0929 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0930 }
0931
0932 #define TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE { \
0933 \
0934 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0935 \
0936 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0937 \
0938 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0939 \
0940 TYPE_SCTP_FUNC(sctp_sf_autoclose_timer_expire), \
0941 \
0942 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0943 \
0944 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0945 \
0946 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0947 \
0948 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0949 }
0950
0951 #define TYPE_SCTP_EVENT_TIMEOUT_RECONF { \
0952 \
0953 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0954 \
0955 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0956 \
0957 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0958 \
0959 TYPE_SCTP_FUNC(sctp_sf_send_reconf), \
0960 \
0961 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0962 \
0963 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0964 \
0965 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0966 \
0967 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0968 }
0969
0970 #define TYPE_SCTP_EVENT_TIMEOUT_PROBE { \
0971 \
0972 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0973 \
0974 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0975 \
0976 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0977 \
0978 TYPE_SCTP_FUNC(sctp_sf_send_probe), \
0979 \
0980 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0981 \
0982 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0983 \
0984 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0985 \
0986 TYPE_SCTP_FUNC(sctp_sf_timer_ignore), \
0987 }
0988
0989 static const struct sctp_sm_table_entry
0990 timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES] = {
0991 TYPE_SCTP_EVENT_TIMEOUT_NONE,
0992 TYPE_SCTP_EVENT_TIMEOUT_T1_COOKIE,
0993 TYPE_SCTP_EVENT_TIMEOUT_T1_INIT,
0994 TYPE_SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
0995 TYPE_SCTP_EVENT_TIMEOUT_T3_RTX,
0996 TYPE_SCTP_EVENT_TIMEOUT_T4_RTO,
0997 TYPE_SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD,
0998 TYPE_SCTP_EVENT_TIMEOUT_HEARTBEAT,
0999 TYPE_SCTP_EVENT_TIMEOUT_RECONF,
1000 TYPE_SCTP_EVENT_TIMEOUT_PROBE,
1001 TYPE_SCTP_EVENT_TIMEOUT_SACK,
1002 TYPE_SCTP_EVENT_TIMEOUT_AUTOCLOSE,
1003 };
1004
1005 static const struct sctp_sm_table_entry *sctp_chunk_event_lookup(
1006 struct net *net,
1007 enum sctp_cid cid,
1008 enum sctp_state state)
1009 {
1010 if (state > SCTP_STATE_MAX)
1011 return &bug;
1012
1013 if (cid == SCTP_CID_I_DATA)
1014 cid = SCTP_CID_DATA;
1015
1016 if (cid <= SCTP_CID_BASE_MAX)
1017 return &chunk_event_table[cid][state];
1018
1019 switch ((u16)cid) {
1020 case SCTP_CID_FWD_TSN:
1021 case SCTP_CID_I_FWD_TSN:
1022 return &prsctp_chunk_event_table[0][state];
1023
1024 case SCTP_CID_ASCONF:
1025 return &addip_chunk_event_table[0][state];
1026
1027 case SCTP_CID_ASCONF_ACK:
1028 return &addip_chunk_event_table[1][state];
1029
1030 case SCTP_CID_RECONF:
1031 return &reconf_chunk_event_table[0][state];
1032
1033 case SCTP_CID_AUTH:
1034 return &auth_chunk_event_table[0][state];
1035
1036 case SCTP_CID_PAD:
1037 return &pad_chunk_event_table[state];
1038 }
1039
1040 return &chunk_event_table_unknown[state];
1041 }