test_tcp_oos.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958
  1. #include "test_tcp_oos.h"
  2. #include "lwip/tcp_impl.h"
  3. #include "lwip/stats.h"
  4. #include "tcp_helper.h"
  5. #if !LWIP_STATS || !TCP_STATS || !MEMP_STATS
  6. #error "This tests needs TCP- and MEMP-statistics enabled"
  7. #endif
  8. #if !TCP_QUEUE_OOSEQ
  9. #error "This tests needs TCP_QUEUE_OOSEQ enabled"
  10. #endif
  11. /** CHECK_SEGMENTS_ON_OOSEQ:
  12. * 1: check count, seqno and len of segments on pcb->ooseq (strict)
  13. * 0: only check that bytes are received in correct order (less strict) */
  14. #define CHECK_SEGMENTS_ON_OOSEQ 1
  15. #if CHECK_SEGMENTS_ON_OOSEQ
  16. #define EXPECT_OOSEQ(x) EXPECT(x)
  17. #else
  18. #define EXPECT_OOSEQ(x)
  19. #endif
  20. /* helper functions */
  21. /** Get the numbers of segments on the ooseq list */
  22. static int tcp_oos_count(struct tcp_pcb* pcb)
  23. {
  24. int num = 0;
  25. struct tcp_seg* seg = pcb->ooseq;
  26. while(seg != NULL) {
  27. num++;
  28. seg = seg->next;
  29. }
  30. return num;
  31. }
  32. /** Get the numbers of pbufs on the ooseq list */
  33. static int tcp_oos_pbuf_count(struct tcp_pcb* pcb)
  34. {
  35. int num = 0;
  36. struct tcp_seg* seg = pcb->ooseq;
  37. while(seg != NULL) {
  38. num += pbuf_clen(seg->p);
  39. seg = seg->next;
  40. }
  41. return num;
  42. }
  43. /** Get the seqno of a segment (by index) on the ooseq list
  44. *
  45. * @param pcb the pcb to check for ooseq segments
  46. * @param seg_index index of the segment on the ooseq list
  47. * @return seqno of the segment
  48. */
  49. static u32_t
  50. tcp_oos_seg_seqno(struct tcp_pcb* pcb, int seg_index)
  51. {
  52. int num = 0;
  53. struct tcp_seg* seg = pcb->ooseq;
  54. /* then check the actual segment */
  55. while(seg != NULL) {
  56. if(num == seg_index) {
  57. return seg->tcphdr->seqno;
  58. }
  59. num++;
  60. seg = seg->next;
  61. }
  62. fail();
  63. return 0;
  64. }
  65. /** Get the tcplen (datalen + SYN/FIN) of a segment (by index) on the ooseq list
  66. *
  67. * @param pcb the pcb to check for ooseq segments
  68. * @param seg_index index of the segment on the ooseq list
  69. * @return tcplen of the segment
  70. */
  71. static int
  72. tcp_oos_seg_tcplen(struct tcp_pcb* pcb, int seg_index)
  73. {
  74. int num = 0;
  75. struct tcp_seg* seg = pcb->ooseq;
  76. /* then check the actual segment */
  77. while(seg != NULL) {
  78. if(num == seg_index) {
  79. return TCP_TCPLEN(seg);
  80. }
  81. num++;
  82. seg = seg->next;
  83. }
  84. fail();
  85. return -1;
  86. }
  87. /** Get the tcplen (datalen + SYN/FIN) of all segments on the ooseq list
  88. *
  89. * @param pcb the pcb to check for ooseq segments
  90. * @return tcplen of all segment
  91. */
  92. static int
  93. tcp_oos_tcplen(struct tcp_pcb* pcb)
  94. {
  95. int len = 0;
  96. struct tcp_seg* seg = pcb->ooseq;
  97. /* then check the actual segment */
  98. while(seg != NULL) {
  99. len += TCP_TCPLEN(seg);
  100. seg = seg->next;
  101. }
  102. return len;
  103. }
  104. /* Setup/teardown functions */
  105. static void
  106. tcp_oos_setup(void)
  107. {
  108. tcp_remove_all();
  109. }
  110. static void
  111. tcp_oos_teardown(void)
  112. {
  113. tcp_remove_all();
  114. netif_list = NULL;
  115. netif_default = NULL;
  116. }
  117. /* Test functions */
  118. /** create multiple segments and pass them to tcp_input in a wrong
  119. * order to see if ooseq-caching works correctly
  120. * FIN is received in out-of-sequence segments only */
  121. START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
  122. {
  123. struct test_tcp_counters counters;
  124. struct tcp_pcb* pcb;
  125. struct pbuf *p_8_9, *p_4_8, *p_4_10, *p_2_14, *p_fin, *pinseq;
  126. char data[] = {
  127. 1, 2, 3, 4,
  128. 5, 6, 7, 8,
  129. 9, 10, 11, 12,
  130. 13, 14, 15, 16};
  131. ip_addr_t remote_ip, local_ip, netmask;
  132. u16_t data_len;
  133. u16_t remote_port = 0x100, local_port = 0x101;
  134. struct netif netif;
  135. LWIP_UNUSED_ARG(_i);
  136. /* initialize local vars */
  137. memset(&netif, 0, sizeof(netif));
  138. IP4_ADDR(&local_ip, 192, 168, 1, 1);
  139. IP4_ADDR(&remote_ip, 192, 168, 1, 2);
  140. IP4_ADDR(&netmask, 255, 255, 255, 0);
  141. test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
  142. data_len = sizeof(data);
  143. /* initialize counter struct */
  144. memset(&counters, 0, sizeof(counters));
  145. counters.expected_data_len = data_len;
  146. counters.expected_data = data;
  147. /* create and initialize the pcb */
  148. pcb = test_tcp_new_counters_pcb(&counters);
  149. EXPECT_RET(pcb != NULL);
  150. tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
  151. /* create segments */
  152. /* pinseq is sent as last segment! */
  153. pinseq = tcp_create_rx_segment(pcb, &data[0], 4, 0, 0, TCP_ACK);
  154. /* p1: 8 bytes before FIN */
  155. /* seqno: 8..16 */
  156. p_8_9 = tcp_create_rx_segment(pcb, &data[8], 8, 8, 0, TCP_ACK|TCP_FIN);
  157. /* p2: 4 bytes before p1, including the first 4 bytes of p1 (partly duplicate) */
  158. /* seqno: 4..11 */
  159. p_4_8 = tcp_create_rx_segment(pcb, &data[4], 8, 4, 0, TCP_ACK);
  160. /* p3: same as p2 but 2 bytes longer */
  161. /* seqno: 4..13 */
  162. p_4_10 = tcp_create_rx_segment(pcb, &data[4], 10, 4, 0, TCP_ACK);
  163. /* p4: 14 bytes before FIN, includes data from p1 and p2, plus partly from pinseq */
  164. /* seqno: 2..15 */
  165. p_2_14 = tcp_create_rx_segment(pcb, &data[2], 14, 2, 0, TCP_ACK);
  166. /* FIN, seqno 16 */
  167. p_fin = tcp_create_rx_segment(pcb, NULL, 0,16, 0, TCP_ACK|TCP_FIN);
  168. EXPECT(pinseq != NULL);
  169. EXPECT(p_8_9 != NULL);
  170. EXPECT(p_4_8 != NULL);
  171. EXPECT(p_4_10 != NULL);
  172. EXPECT(p_2_14 != NULL);
  173. EXPECT(p_fin != NULL);
  174. if ((pinseq != NULL) && (p_8_9 != NULL) && (p_4_8 != NULL) && (p_4_10 != NULL) && (p_2_14 != NULL) && (p_fin != NULL)) {
  175. /* pass the segment to tcp_input */
  176. test_tcp_input(p_8_9, &netif);
  177. /* check if counters are as expected */
  178. EXPECT(counters.close_calls == 0);
  179. EXPECT(counters.recv_calls == 0);
  180. EXPECT(counters.recved_bytes == 0);
  181. EXPECT(counters.err_calls == 0);
  182. /* check ooseq queue */
  183. EXPECT_OOSEQ(tcp_oos_count(pcb) == 1);
  184. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 8);
  185. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 9); /* includes FIN */
  186. /* pass the segment to tcp_input */
  187. test_tcp_input(p_4_8, &netif);
  188. /* check if counters are as expected */
  189. EXPECT(counters.close_calls == 0);
  190. EXPECT(counters.recv_calls == 0);
  191. EXPECT(counters.recved_bytes == 0);
  192. EXPECT(counters.err_calls == 0);
  193. /* check ooseq queue */
  194. EXPECT_OOSEQ(tcp_oos_count(pcb) == 2);
  195. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 4);
  196. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 4);
  197. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 8);
  198. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */
  199. /* pass the segment to tcp_input */
  200. test_tcp_input(p_4_10, &netif);
  201. /* check if counters are as expected */
  202. EXPECT(counters.close_calls == 0);
  203. EXPECT(counters.recv_calls == 0);
  204. EXPECT(counters.recved_bytes == 0);
  205. EXPECT(counters.err_calls == 0);
  206. /* ooseq queue: unchanged */
  207. EXPECT_OOSEQ(tcp_oos_count(pcb) == 2);
  208. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 4);
  209. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 4);
  210. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 8);
  211. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 9); /* includes FIN */
  212. /* pass the segment to tcp_input */
  213. test_tcp_input(p_2_14, &netif);
  214. /* check if counters are as expected */
  215. EXPECT(counters.close_calls == 0);
  216. EXPECT(counters.recv_calls == 0);
  217. EXPECT(counters.recved_bytes == 0);
  218. EXPECT(counters.err_calls == 0);
  219. /* check ooseq queue */
  220. EXPECT_OOSEQ(tcp_oos_count(pcb) == 1);
  221. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 2);
  222. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */
  223. /* pass the segment to tcp_input */
  224. test_tcp_input(p_fin, &netif);
  225. /* check if counters are as expected */
  226. EXPECT(counters.close_calls == 0);
  227. EXPECT(counters.recv_calls == 0);
  228. EXPECT(counters.recved_bytes == 0);
  229. EXPECT(counters.err_calls == 0);
  230. /* ooseq queue: unchanged */
  231. EXPECT_OOSEQ(tcp_oos_count(pcb) == 1);
  232. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 2);
  233. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 15); /* includes FIN */
  234. /* pass the segment to tcp_input */
  235. test_tcp_input(pinseq, &netif);
  236. /* check if counters are as expected */
  237. EXPECT(counters.close_calls == 1);
  238. EXPECT(counters.recv_calls == 1);
  239. EXPECT(counters.recved_bytes == data_len);
  240. EXPECT(counters.err_calls == 0);
  241. EXPECT(pcb->ooseq == NULL);
  242. }
  243. /* make sure the pcb is freed */
  244. EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
  245. tcp_abort(pcb);
  246. EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
  247. }
  248. END_TEST
  249. /** create multiple segments and pass them to tcp_input in a wrong
  250. * order to see if ooseq-caching works correctly
  251. * FIN is received IN-SEQUENCE at the end */
  252. START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
  253. {
  254. struct test_tcp_counters counters;
  255. struct tcp_pcb* pcb;
  256. struct pbuf *p_1_2, *p_4_8, *p_3_11, *p_2_12, *p_15_1, *p_15_1a, *pinseq, *pinseqFIN;
  257. char data[] = {
  258. 1, 2, 3, 4,
  259. 5, 6, 7, 8,
  260. 9, 10, 11, 12,
  261. 13, 14, 15, 16};
  262. ip_addr_t remote_ip, local_ip, netmask;
  263. u16_t data_len;
  264. u16_t remote_port = 0x100, local_port = 0x101;
  265. struct netif netif;
  266. LWIP_UNUSED_ARG(_i);
  267. /* initialize local vars */
  268. memset(&netif, 0, sizeof(netif));
  269. IP4_ADDR(&local_ip, 192, 168, 1, 1);
  270. IP4_ADDR(&remote_ip, 192, 168, 1, 2);
  271. IP4_ADDR(&netmask, 255, 255, 255, 0);
  272. test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
  273. data_len = sizeof(data);
  274. /* initialize counter struct */
  275. memset(&counters, 0, sizeof(counters));
  276. counters.expected_data_len = data_len;
  277. counters.expected_data = data;
  278. /* create and initialize the pcb */
  279. pcb = test_tcp_new_counters_pcb(&counters);
  280. EXPECT_RET(pcb != NULL);
  281. tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
  282. /* create segments */
  283. /* p1: 7 bytes - 2 before FIN */
  284. /* seqno: 1..2 */
  285. p_1_2 = tcp_create_rx_segment(pcb, &data[1], 2, 1, 0, TCP_ACK);
  286. /* p2: 4 bytes before p1, including the first 4 bytes of p1 (partly duplicate) */
  287. /* seqno: 4..11 */
  288. p_4_8 = tcp_create_rx_segment(pcb, &data[4], 8, 4, 0, TCP_ACK);
  289. /* p3: same as p2 but 2 bytes longer and one byte more at the front */
  290. /* seqno: 3..13 */
  291. p_3_11 = tcp_create_rx_segment(pcb, &data[3], 11, 3, 0, TCP_ACK);
  292. /* p4: 13 bytes - 2 before FIN - should be ignored as contained in p1 and p3 */
  293. /* seqno: 2..13 */
  294. p_2_12 = tcp_create_rx_segment(pcb, &data[2], 12, 2, 0, TCP_ACK);
  295. /* pinseq is the first segment that is held back to create ooseq! */
  296. /* seqno: 0..3 */
  297. pinseq = tcp_create_rx_segment(pcb, &data[0], 4, 0, 0, TCP_ACK);
  298. /* p5: last byte before FIN */
  299. /* seqno: 15 */
  300. p_15_1 = tcp_create_rx_segment(pcb, &data[15], 1, 15, 0, TCP_ACK);
  301. /* p6: same as p5, should be ignored */
  302. p_15_1a= tcp_create_rx_segment(pcb, &data[15], 1, 15, 0, TCP_ACK);
  303. /* pinseqFIN: last 2 bytes plus FIN */
  304. /* only segment containing seqno 14 and FIN */
  305. pinseqFIN = tcp_create_rx_segment(pcb, &data[14], 2, 14, 0, TCP_ACK|TCP_FIN);
  306. EXPECT(pinseq != NULL);
  307. EXPECT(p_1_2 != NULL);
  308. EXPECT(p_4_8 != NULL);
  309. EXPECT(p_3_11 != NULL);
  310. EXPECT(p_2_12 != NULL);
  311. EXPECT(p_15_1 != NULL);
  312. EXPECT(p_15_1a != NULL);
  313. EXPECT(pinseqFIN != NULL);
  314. if ((pinseq != NULL) && (p_1_2 != NULL) && (p_4_8 != NULL) && (p_3_11 != NULL) && (p_2_12 != NULL)
  315. && (p_15_1 != NULL) && (p_15_1a != NULL) && (pinseqFIN != NULL)) {
  316. /* pass the segment to tcp_input */
  317. test_tcp_input(p_1_2, &netif);
  318. /* check if counters are as expected */
  319. EXPECT(counters.close_calls == 0);
  320. EXPECT(counters.recv_calls == 0);
  321. EXPECT(counters.recved_bytes == 0);
  322. EXPECT(counters.err_calls == 0);
  323. /* check ooseq queue */
  324. EXPECT_OOSEQ(tcp_oos_count(pcb) == 1);
  325. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1);
  326. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2);
  327. /* pass the segment to tcp_input */
  328. test_tcp_input(p_4_8, &netif);
  329. /* check if counters are as expected */
  330. EXPECT(counters.close_calls == 0);
  331. EXPECT(counters.recv_calls == 0);
  332. EXPECT(counters.recved_bytes == 0);
  333. EXPECT(counters.err_calls == 0);
  334. /* check ooseq queue */
  335. EXPECT_OOSEQ(tcp_oos_count(pcb) == 2);
  336. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1);
  337. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2);
  338. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 4);
  339. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 8);
  340. /* pass the segment to tcp_input */
  341. test_tcp_input(p_3_11, &netif);
  342. /* check if counters are as expected */
  343. EXPECT(counters.close_calls == 0);
  344. EXPECT(counters.recv_calls == 0);
  345. EXPECT(counters.recved_bytes == 0);
  346. EXPECT(counters.err_calls == 0);
  347. /* check ooseq queue */
  348. EXPECT_OOSEQ(tcp_oos_count(pcb) == 2);
  349. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1);
  350. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 2);
  351. /* p_3_11 has removed p_4_8 from ooseq */
  352. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 3);
  353. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 11);
  354. /* pass the segment to tcp_input */
  355. test_tcp_input(p_2_12, &netif);
  356. /* check if counters are as expected */
  357. EXPECT(counters.close_calls == 0);
  358. EXPECT(counters.recv_calls == 0);
  359. EXPECT(counters.recved_bytes == 0);
  360. EXPECT(counters.err_calls == 0);
  361. /* check ooseq queue */
  362. EXPECT_OOSEQ(tcp_oos_count(pcb) == 2);
  363. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 1);
  364. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1);
  365. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 1) == 2);
  366. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 1) == 12);
  367. /* pass the segment to tcp_input */
  368. test_tcp_input(pinseq, &netif);
  369. /* check if counters are as expected */
  370. EXPECT(counters.close_calls == 0);
  371. EXPECT(counters.recv_calls == 1);
  372. EXPECT(counters.recved_bytes == 14);
  373. EXPECT(counters.err_calls == 0);
  374. EXPECT(pcb->ooseq == NULL);
  375. /* pass the segment to tcp_input */
  376. test_tcp_input(p_15_1, &netif);
  377. /* check if counters are as expected */
  378. EXPECT(counters.close_calls == 0);
  379. EXPECT(counters.recv_calls == 1);
  380. EXPECT(counters.recved_bytes == 14);
  381. EXPECT(counters.err_calls == 0);
  382. /* check ooseq queue */
  383. EXPECT_OOSEQ(tcp_oos_count(pcb) == 1);
  384. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 15);
  385. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1);
  386. /* pass the segment to tcp_input */
  387. test_tcp_input(p_15_1a, &netif);
  388. /* check if counters are as expected */
  389. EXPECT(counters.close_calls == 0);
  390. EXPECT(counters.recv_calls == 1);
  391. EXPECT(counters.recved_bytes == 14);
  392. EXPECT(counters.err_calls == 0);
  393. /* check ooseq queue: unchanged */
  394. EXPECT_OOSEQ(tcp_oos_count(pcb) == 1);
  395. EXPECT_OOSEQ(tcp_oos_seg_seqno(pcb, 0) == 15);
  396. EXPECT_OOSEQ(tcp_oos_seg_tcplen(pcb, 0) == 1);
  397. /* pass the segment to tcp_input */
  398. test_tcp_input(pinseqFIN, &netif);
  399. /* check if counters are as expected */
  400. EXPECT(counters.close_calls == 1);
  401. EXPECT(counters.recv_calls == 2);
  402. EXPECT(counters.recved_bytes == data_len);
  403. EXPECT(counters.err_calls == 0);
  404. EXPECT(pcb->ooseq == NULL);
  405. }
  406. /* make sure the pcb is freed */
  407. EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
  408. tcp_abort(pcb);
  409. EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
  410. }
  411. END_TEST
  412. static char data_full_wnd[TCP_WND];
  413. /** create multiple segments and pass them to tcp_input with the first segment missing
  414. * to simulate overruning the rxwin with ooseq queueing enabled */
  415. START_TEST(test_tcp_recv_ooseq_overrun_rxwin)
  416. {
  417. #if !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS
  418. int i, k;
  419. struct test_tcp_counters counters;
  420. struct tcp_pcb* pcb;
  421. struct pbuf *pinseq, *p_ovr;
  422. ip_addr_t remote_ip, local_ip, netmask;
  423. u16_t remote_port = 0x100, local_port = 0x101;
  424. struct netif netif;
  425. int datalen = 0;
  426. int datalen2;
  427. for(i = 0; i < sizeof(data_full_wnd); i++) {
  428. data_full_wnd[i] = (char)i;
  429. }
  430. /* initialize local vars */
  431. memset(&netif, 0, sizeof(netif));
  432. IP4_ADDR(&local_ip, 192, 168, 1, 1);
  433. IP4_ADDR(&remote_ip, 192, 168, 1, 2);
  434. IP4_ADDR(&netmask, 255, 255, 255, 0);
  435. test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
  436. /* initialize counter struct */
  437. memset(&counters, 0, sizeof(counters));
  438. counters.expected_data_len = TCP_WND;
  439. counters.expected_data = data_full_wnd;
  440. /* create and initialize the pcb */
  441. pcb = test_tcp_new_counters_pcb(&counters);
  442. EXPECT_RET(pcb != NULL);
  443. tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
  444. pcb->rcv_nxt = 0x8000;
  445. /* create segments */
  446. /* pinseq is sent as last segment! */
  447. pinseq = tcp_create_rx_segment(pcb, &data_full_wnd[0], TCP_MSS, 0, 0, TCP_ACK);
  448. for(i = TCP_MSS, k = 0; i < TCP_WND; i += TCP_MSS, k++) {
  449. int count, expected_datalen;
  450. struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)],
  451. TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK);
  452. EXPECT_RET(p != NULL);
  453. /* pass the segment to tcp_input */
  454. test_tcp_input(p, &netif);
  455. /* check if counters are as expected */
  456. EXPECT(counters.close_calls == 0);
  457. EXPECT(counters.recv_calls == 0);
  458. EXPECT(counters.recved_bytes == 0);
  459. EXPECT(counters.err_calls == 0);
  460. /* check ooseq queue */
  461. count = tcp_oos_count(pcb);
  462. EXPECT_OOSEQ(count == k+1);
  463. datalen = tcp_oos_tcplen(pcb);
  464. if (i + TCP_MSS < TCP_WND) {
  465. expected_datalen = (k+1)*TCP_MSS;
  466. } else {
  467. expected_datalen = TCP_WND - TCP_MSS;
  468. }
  469. if (datalen != expected_datalen) {
  470. EXPECT_OOSEQ(datalen == expected_datalen);
  471. }
  472. }
  473. /* pass in one more segment, cleary overrunning the rxwin */
  474. p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS*(k+1)], TCP_MSS, TCP_MSS*(k+1), 0, TCP_ACK);
  475. EXPECT_RET(p_ovr != NULL);
  476. /* pass the segment to tcp_input */
  477. test_tcp_input(p_ovr, &netif);
  478. /* check if counters are as expected */
  479. EXPECT(counters.close_calls == 0);
  480. EXPECT(counters.recv_calls == 0);
  481. EXPECT(counters.recved_bytes == 0);
  482. EXPECT(counters.err_calls == 0);
  483. /* check ooseq queue */
  484. EXPECT_OOSEQ(tcp_oos_count(pcb) == k);
  485. datalen2 = tcp_oos_tcplen(pcb);
  486. EXPECT_OOSEQ(datalen == datalen2);
  487. /* now pass inseq */
  488. test_tcp_input(pinseq, &netif);
  489. EXPECT(pcb->ooseq == NULL);
  490. /* make sure the pcb is freed */
  491. EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
  492. tcp_abort(pcb);
  493. EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
  494. #endif /* !TCP_OOSEQ_MAX_BYTES && !TCP_OOSEQ_MAX_PBUFS */
  495. LWIP_UNUSED_ARG(_i);
  496. }
  497. END_TEST
  498. START_TEST(test_tcp_recv_ooseq_max_bytes)
  499. {
  500. #if TCP_OOSEQ_MAX_BYTES && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))
  501. int i, k;
  502. struct test_tcp_counters counters;
  503. struct tcp_pcb* pcb;
  504. struct pbuf *p_ovr;
  505. ip_addr_t remote_ip, local_ip, netmask;
  506. u16_t remote_port = 0x100, local_port = 0x101;
  507. struct netif netif;
  508. int datalen = 0;
  509. int datalen2;
  510. for(i = 0; i < sizeof(data_full_wnd); i++) {
  511. data_full_wnd[i] = (char)i;
  512. }
  513. /* initialize local vars */
  514. memset(&netif, 0, sizeof(netif));
  515. IP4_ADDR(&local_ip, 192, 168, 1, 1);
  516. IP4_ADDR(&remote_ip, 192, 168, 1, 2);
  517. IP4_ADDR(&netmask, 255, 255, 255, 0);
  518. test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
  519. /* initialize counter struct */
  520. memset(&counters, 0, sizeof(counters));
  521. counters.expected_data_len = TCP_WND;
  522. counters.expected_data = data_full_wnd;
  523. /* create and initialize the pcb */
  524. pcb = test_tcp_new_counters_pcb(&counters);
  525. EXPECT_RET(pcb != NULL);
  526. tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
  527. pcb->rcv_nxt = 0x8000;
  528. /* don't 'recv' the first segment (1 byte) so that all other segments will be ooseq */
  529. /* create segments and 'recv' them */
  530. for(k = 1, i = 1; k < TCP_OOSEQ_MAX_BYTES; k += TCP_MSS, i++) {
  531. int count;
  532. struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[k],
  533. TCP_MSS, k, 0, TCP_ACK);
  534. EXPECT_RET(p != NULL);
  535. EXPECT_RET(p->next == NULL);
  536. /* pass the segment to tcp_input */
  537. test_tcp_input(p, &netif);
  538. /* check if counters are as expected */
  539. EXPECT(counters.close_calls == 0);
  540. EXPECT(counters.recv_calls == 0);
  541. EXPECT(counters.recved_bytes == 0);
  542. EXPECT(counters.err_calls == 0);
  543. /* check ooseq queue */
  544. count = tcp_oos_pbuf_count(pcb);
  545. EXPECT_OOSEQ(count == i);
  546. datalen = tcp_oos_tcplen(pcb);
  547. EXPECT_OOSEQ(datalen == (i * TCP_MSS));
  548. }
  549. /* pass in one more segment, overrunning the limit */
  550. p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[k+1], 1, k+1, 0, TCP_ACK);
  551. EXPECT_RET(p_ovr != NULL);
  552. /* pass the segment to tcp_input */
  553. test_tcp_input(p_ovr, &netif);
  554. /* check if counters are as expected */
  555. EXPECT(counters.close_calls == 0);
  556. EXPECT(counters.recv_calls == 0);
  557. EXPECT(counters.recved_bytes == 0);
  558. EXPECT(counters.err_calls == 0);
  559. /* check ooseq queue (ensure the new segment was not accepted) */
  560. EXPECT_OOSEQ(tcp_oos_count(pcb) == (i-1));
  561. datalen2 = tcp_oos_tcplen(pcb);
  562. EXPECT_OOSEQ(datalen2 == ((i-1) * TCP_MSS));
  563. /* make sure the pcb is freed */
  564. EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
  565. tcp_abort(pcb);
  566. EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
  567. #endif /* TCP_OOSEQ_MAX_BYTES && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) */
  568. LWIP_UNUSED_ARG(_i);
  569. }
  570. END_TEST
  571. START_TEST(test_tcp_recv_ooseq_max_pbufs)
  572. {
  573. #if TCP_OOSEQ_MAX_PBUFS && (TCP_OOSEQ_MAX_PBUFS < ((TCP_WND / TCP_MSS) + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN))
  574. int i;
  575. struct test_tcp_counters counters;
  576. struct tcp_pcb* pcb;
  577. struct pbuf *p_ovr;
  578. ip_addr_t remote_ip, local_ip, netmask;
  579. u16_t remote_port = 0x100, local_port = 0x101;
  580. struct netif netif;
  581. int datalen = 0;
  582. int datalen2;
  583. for(i = 0; i < sizeof(data_full_wnd); i++) {
  584. data_full_wnd[i] = (char)i;
  585. }
  586. /* initialize local vars */
  587. memset(&netif, 0, sizeof(netif));
  588. IP4_ADDR(&local_ip, 192, 168, 1, 1);
  589. IP4_ADDR(&remote_ip, 192, 168, 1, 2);
  590. IP4_ADDR(&netmask, 255, 255, 255, 0);
  591. test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
  592. /* initialize counter struct */
  593. memset(&counters, 0, sizeof(counters));
  594. counters.expected_data_len = TCP_WND;
  595. counters.expected_data = data_full_wnd;
  596. /* create and initialize the pcb */
  597. pcb = test_tcp_new_counters_pcb(&counters);
  598. EXPECT_RET(pcb != NULL);
  599. tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
  600. pcb->rcv_nxt = 0x8000;
  601. /* don't 'recv' the first segment (1 byte) so that all other segments will be ooseq */
  602. /* create segments and 'recv' them */
  603. for(i = 1; i <= TCP_OOSEQ_MAX_PBUFS; i++) {
  604. int count;
  605. struct pbuf *p = tcp_create_rx_segment(pcb, &data_full_wnd[i],
  606. 1, i, 0, TCP_ACK);
  607. EXPECT_RET(p != NULL);
  608. EXPECT_RET(p->next == NULL);
  609. /* pass the segment to tcp_input */
  610. test_tcp_input(p, &netif);
  611. /* check if counters are as expected */
  612. EXPECT(counters.close_calls == 0);
  613. EXPECT(counters.recv_calls == 0);
  614. EXPECT(counters.recved_bytes == 0);
  615. EXPECT(counters.err_calls == 0);
  616. /* check ooseq queue */
  617. count = tcp_oos_pbuf_count(pcb);
  618. EXPECT_OOSEQ(count == i);
  619. datalen = tcp_oos_tcplen(pcb);
  620. EXPECT_OOSEQ(datalen == i);
  621. }
  622. /* pass in one more segment, overrunning the limit */
  623. p_ovr = tcp_create_rx_segment(pcb, &data_full_wnd[i+1], 1, i+1, 0, TCP_ACK);
  624. EXPECT_RET(p_ovr != NULL);
  625. /* pass the segment to tcp_input */
  626. test_tcp_input(p_ovr, &netif);
  627. /* check if counters are as expected */
  628. EXPECT(counters.close_calls == 0);
  629. EXPECT(counters.recv_calls == 0);
  630. EXPECT(counters.recved_bytes == 0);
  631. EXPECT(counters.err_calls == 0);
  632. /* check ooseq queue (ensure the new segment was not accepted) */
  633. EXPECT_OOSEQ(tcp_oos_count(pcb) == (i-1));
  634. datalen2 = tcp_oos_tcplen(pcb);
  635. EXPECT_OOSEQ(datalen2 == (i-1));
  636. /* make sure the pcb is freed */
  637. EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
  638. tcp_abort(pcb);
  639. EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
  640. #endif /* TCP_OOSEQ_MAX_PBUFS && (TCP_OOSEQ_MAX_BYTES < (TCP_WND + 1)) && (PBUF_POOL_BUFSIZE >= (TCP_MSS + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) */
  641. LWIP_UNUSED_ARG(_i);
  642. }
  643. END_TEST
  644. static void
  645. check_rx_counters(struct tcp_pcb *pcb, struct test_tcp_counters *counters, u32_t exp_close_calls, u32_t exp_rx_calls,
  646. u32_t exp_rx_bytes, u32_t exp_err_calls, int exp_oos_count, int exp_oos_len)
  647. {
  648. int oos_len;
  649. EXPECT(counters->close_calls == exp_close_calls);
  650. EXPECT(counters->recv_calls == exp_rx_calls);
  651. EXPECT(counters->recved_bytes == exp_rx_bytes);
  652. EXPECT(counters->err_calls == exp_err_calls);
  653. /* check that pbuf is queued in ooseq */
  654. EXPECT_OOSEQ(tcp_oos_count(pcb) == exp_oos_count);
  655. oos_len = tcp_oos_tcplen(pcb);
  656. EXPECT_OOSEQ(exp_oos_len == oos_len);
  657. }
  658. /* this test uses 4 packets:
  659. * - data (len=TCP_MSS)
  660. * - FIN
  661. * - data after FIN (len=1) (invalid)
  662. * - 2nd FIN (invalid)
  663. *
  664. * the parameter 'delay_packet' is a bitmask that choses which on these packets is ooseq
  665. */
  666. static void test_tcp_recv_ooseq_double_FINs(int delay_packet)
  667. {
  668. int i, k;
  669. struct test_tcp_counters counters;
  670. struct tcp_pcb* pcb;
  671. struct pbuf *p_normal_fin, *p_data_after_fin, *p, *p_2nd_fin_ooseq;
  672. ip_addr_t remote_ip, local_ip, netmask;
  673. u16_t remote_port = 0x100, local_port = 0x101;
  674. struct netif netif;
  675. u32_t exp_rx_calls = 0, exp_rx_bytes = 0, exp_close_calls = 0, exp_oos_pbufs = 0, exp_oos_tcplen = 0;
  676. int first_dropped = 0xff;
  677. int last_dropped = 0;
  678. for(i = 0; i < sizeof(data_full_wnd); i++) {
  679. data_full_wnd[i] = (char)i;
  680. }
  681. /* initialize local vars */
  682. memset(&netif, 0, sizeof(netif));
  683. IP4_ADDR(&local_ip, 192, 168, 1, 1);
  684. IP4_ADDR(&remote_ip, 192, 168, 1, 2);
  685. IP4_ADDR(&netmask, 255, 255, 255, 0);
  686. test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
  687. /* initialize counter struct */
  688. memset(&counters, 0, sizeof(counters));
  689. counters.expected_data_len = TCP_WND;
  690. counters.expected_data = data_full_wnd;
  691. /* create and initialize the pcb */
  692. pcb = test_tcp_new_counters_pcb(&counters);
  693. EXPECT_RET(pcb != NULL);
  694. tcp_set_state(pcb, ESTABLISHED, &local_ip, &remote_ip, local_port, remote_port);
  695. pcb->rcv_nxt = 0x8000;
  696. /* create segments */
  697. p = tcp_create_rx_segment(pcb, &data_full_wnd[0], TCP_MSS, 0, 0, TCP_ACK);
  698. p_normal_fin = tcp_create_rx_segment(pcb, NULL, 0, TCP_MSS, 0, TCP_ACK|TCP_FIN);
  699. k = 1;
  700. p_data_after_fin = tcp_create_rx_segment(pcb, &data_full_wnd[TCP_MSS+1], k, TCP_MSS+1, 0, TCP_ACK);
  701. p_2nd_fin_ooseq = tcp_create_rx_segment(pcb, NULL, 0, TCP_MSS+1+k, 0, TCP_ACK|TCP_FIN);
  702. if(delay_packet & 1) {
  703. /* drop normal data */
  704. first_dropped = 1;
  705. last_dropped = 1;
  706. } else {
  707. /* send normal data */
  708. test_tcp_input(p, &netif);
  709. exp_rx_calls++;
  710. exp_rx_bytes += TCP_MSS;
  711. }
  712. /* check if counters are as expected */
  713. check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
  714. if(delay_packet & 2) {
  715. /* drop FIN */
  716. if(first_dropped > 2) {
  717. first_dropped = 2;
  718. }
  719. last_dropped = 2;
  720. } else {
  721. /* send FIN */
  722. test_tcp_input(p_normal_fin, &netif);
  723. if (first_dropped < 2) {
  724. /* already dropped packets, this one is ooseq */
  725. exp_oos_pbufs++;
  726. exp_oos_tcplen++;
  727. } else {
  728. /* inseq */
  729. exp_close_calls++;
  730. }
  731. }
  732. /* check if counters are as expected */
  733. check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
  734. if(delay_packet & 4) {
  735. /* drop data-after-FIN */
  736. if(first_dropped > 3) {
  737. first_dropped = 3;
  738. }
  739. last_dropped = 3;
  740. } else {
  741. /* send data-after-FIN */
  742. test_tcp_input(p_data_after_fin, &netif);
  743. if (first_dropped < 3) {
  744. /* already dropped packets, this one is ooseq */
  745. if (delay_packet & 2) {
  746. /* correct FIN was ooseq */
  747. exp_oos_pbufs++;
  748. exp_oos_tcplen += k;
  749. }
  750. } else {
  751. /* inseq: no change */
  752. }
  753. }
  754. /* check if counters are as expected */
  755. check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
  756. if(delay_packet & 8) {
  757. /* drop 2nd-FIN */
  758. if(first_dropped > 4) {
  759. first_dropped = 4;
  760. }
  761. last_dropped = 4;
  762. } else {
  763. /* send 2nd-FIN */
  764. test_tcp_input(p_2nd_fin_ooseq, &netif);
  765. if (first_dropped < 3) {
  766. /* already dropped packets, this one is ooseq */
  767. if (delay_packet & 2) {
  768. /* correct FIN was ooseq */
  769. exp_oos_pbufs++;
  770. exp_oos_tcplen++;
  771. }
  772. } else {
  773. /* inseq: no change */
  774. }
  775. }
  776. /* check if counters are as expected */
  777. check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
  778. if(delay_packet & 1) {
  779. /* dropped normal data before */
  780. test_tcp_input(p, &netif);
  781. exp_rx_calls++;
  782. exp_rx_bytes += TCP_MSS;
  783. if((delay_packet & 2) == 0) {
  784. /* normal FIN was NOT delayed */
  785. exp_close_calls++;
  786. exp_oos_pbufs = exp_oos_tcplen = 0;
  787. }
  788. }
  789. /* check if counters are as expected */
  790. check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
  791. if(delay_packet & 2) {
  792. /* dropped normal FIN before */
  793. test_tcp_input(p_normal_fin, &netif);
  794. exp_close_calls++;
  795. exp_oos_pbufs = exp_oos_tcplen = 0;
  796. }
  797. /* check if counters are as expected */
  798. check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
  799. if(delay_packet & 4) {
  800. /* dropped data-after-FIN before */
  801. test_tcp_input(p_data_after_fin, &netif);
  802. }
  803. /* check if counters are as expected */
  804. check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
  805. if(delay_packet & 8) {
  806. /* dropped 2nd-FIN before */
  807. test_tcp_input(p_2nd_fin_ooseq, &netif);
  808. }
  809. /* check if counters are as expected */
  810. check_rx_counters(pcb, &counters, exp_close_calls, exp_rx_calls, exp_rx_bytes, 0, exp_oos_pbufs, exp_oos_tcplen);
  811. /* check that ooseq data has been dumped */
  812. EXPECT(pcb->ooseq == NULL);
  813. /* make sure the pcb is freed */
  814. EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 1);
  815. tcp_abort(pcb);
  816. EXPECT(lwip_stats.memp[MEMP_TCP_PCB].used == 0);
  817. }
  818. /** create multiple segments and pass them to tcp_input with the first segment missing
  819. * to simulate overruning the rxwin with ooseq queueing enabled */
  820. #define FIN_TEST(name, num) \
  821. START_TEST(name) \
  822. { \
  823. LWIP_UNUSED_ARG(_i); \
  824. test_tcp_recv_ooseq_double_FINs(num); \
  825. } \
  826. END_TEST
  827. FIN_TEST(test_tcp_recv_ooseq_double_FIN_0, 0)
  828. FIN_TEST(test_tcp_recv_ooseq_double_FIN_1, 1)
  829. FIN_TEST(test_tcp_recv_ooseq_double_FIN_2, 2)
  830. FIN_TEST(test_tcp_recv_ooseq_double_FIN_3, 3)
  831. FIN_TEST(test_tcp_recv_ooseq_double_FIN_4, 4)
  832. FIN_TEST(test_tcp_recv_ooseq_double_FIN_5, 5)
  833. FIN_TEST(test_tcp_recv_ooseq_double_FIN_6, 6)
  834. FIN_TEST(test_tcp_recv_ooseq_double_FIN_7, 7)
  835. FIN_TEST(test_tcp_recv_ooseq_double_FIN_8, 8)
  836. FIN_TEST(test_tcp_recv_ooseq_double_FIN_9, 9)
  837. FIN_TEST(test_tcp_recv_ooseq_double_FIN_10, 10)
  838. FIN_TEST(test_tcp_recv_ooseq_double_FIN_11, 11)
  839. FIN_TEST(test_tcp_recv_ooseq_double_FIN_12, 12)
  840. FIN_TEST(test_tcp_recv_ooseq_double_FIN_13, 13)
  841. FIN_TEST(test_tcp_recv_ooseq_double_FIN_14, 14)
  842. FIN_TEST(test_tcp_recv_ooseq_double_FIN_15, 15)
  843. /** Create the suite including all tests for this module */
  844. Suite *
  845. tcp_oos_suite(void)
  846. {
  847. testfunc tests[] = {
  848. TESTFUNC(test_tcp_recv_ooseq_FIN_OOSEQ),
  849. TESTFUNC(test_tcp_recv_ooseq_FIN_INSEQ),
  850. TESTFUNC(test_tcp_recv_ooseq_overrun_rxwin),
  851. TESTFUNC(test_tcp_recv_ooseq_max_bytes),
  852. TESTFUNC(test_tcp_recv_ooseq_max_pbufs),
  853. TESTFUNC(test_tcp_recv_ooseq_double_FIN_0),
  854. TESTFUNC(test_tcp_recv_ooseq_double_FIN_1),
  855. TESTFUNC(test_tcp_recv_ooseq_double_FIN_2),
  856. TESTFUNC(test_tcp_recv_ooseq_double_FIN_3),
  857. TESTFUNC(test_tcp_recv_ooseq_double_FIN_4),
  858. TESTFUNC(test_tcp_recv_ooseq_double_FIN_5),
  859. TESTFUNC(test_tcp_recv_ooseq_double_FIN_6),
  860. TESTFUNC(test_tcp_recv_ooseq_double_FIN_7),
  861. TESTFUNC(test_tcp_recv_ooseq_double_FIN_8),
  862. TESTFUNC(test_tcp_recv_ooseq_double_FIN_9),
  863. TESTFUNC(test_tcp_recv_ooseq_double_FIN_10),
  864. TESTFUNC(test_tcp_recv_ooseq_double_FIN_11),
  865. TESTFUNC(test_tcp_recv_ooseq_double_FIN_12),
  866. TESTFUNC(test_tcp_recv_ooseq_double_FIN_13),
  867. TESTFUNC(test_tcp_recv_ooseq_double_FIN_14),
  868. TESTFUNC(test_tcp_recv_ooseq_double_FIN_15)
  869. };
  870. return create_suite("TCP_OOS", tests, sizeof(tests)/sizeof(testfunc), tcp_oos_setup, tcp_oos_teardown);
  871. }