test_tcp_oos.c 31 KB

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