sm_statetable.c 31 KB

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