outqueue.c 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795
  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-2003 Intel Corp.
  6. *
  7. * This file is part of the SCTP kernel implementation
  8. *
  9. * These functions implement the sctp_outq class. The outqueue handles
  10. * bundling and queueing of outgoing SCTP chunks.
  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, write to
  26. * the Free Software Foundation, 59 Temple Place - Suite 330,
  27. * Boston, MA 02111-1307, USA.
  28. *
  29. * Please send any bug reports or fixes you make to the
  30. * email address(es):
  31. * lksctp developers <lksctp-developers@lists.sourceforge.net>
  32. *
  33. * Or submit a bug report through the following website:
  34. * http://www.sf.net/projects/lksctp
  35. *
  36. * Written or modified by:
  37. * La Monte H.P. Yarroll <piggy@acm.org>
  38. * Karl Knutson <karl@athena.chicago.il.us>
  39. * Perry Melange <pmelange@null.cc.uic.edu>
  40. * Xingang Guo <xingang.guo@intel.com>
  41. * Hui Huang <hui.huang@nokia.com>
  42. * Sridhar Samudrala <sri@us.ibm.com>
  43. * Jon Grimm <jgrimm@us.ibm.com>
  44. *
  45. * Any bugs reported given to us we will try to fix... any fixes shared will
  46. * be incorporated into the next SCTP release.
  47. */
  48. #include <linux/types.h>
  49. #include <linux/list.h> /* For struct list_head */
  50. #include <linux/socket.h>
  51. #include <linux/ip.h>
  52. #include <net/sock.h> /* For skb_set_owner_w */
  53. #include <net/sctp/sctp.h>
  54. #include <net/sctp/sm.h>
  55. /* Declare internal functions here. */
  56. static int sctp_acked(struct sctp_sackhdr *sack, __u32 tsn);
  57. static void sctp_check_transmitted(struct sctp_outq *q,
  58. struct list_head *transmitted_queue,
  59. struct sctp_transport *transport,
  60. struct sctp_sackhdr *sack,
  61. __u32 highest_new_tsn);
  62. static void sctp_mark_missing(struct sctp_outq *q,
  63. struct list_head *transmitted_queue,
  64. struct sctp_transport *transport,
  65. __u32 highest_new_tsn,
  66. int count_of_newacks);
  67. static void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 sack_ctsn);
  68. /* Add data to the front of the queue. */
  69. static inline void sctp_outq_head_data(struct sctp_outq *q,
  70. struct sctp_chunk *ch)
  71. {
  72. list_add(&ch->list, &q->out_chunk_list);
  73. q->out_qlen += ch->skb->len;
  74. return;
  75. }
  76. /* Take data from the front of the queue. */
  77. static inline struct sctp_chunk *sctp_outq_dequeue_data(struct sctp_outq *q)
  78. {
  79. struct sctp_chunk *ch = NULL;
  80. if (!list_empty(&q->out_chunk_list)) {
  81. struct list_head *entry = q->out_chunk_list.next;
  82. ch = list_entry(entry, struct sctp_chunk, list);
  83. list_del_init(entry);
  84. q->out_qlen -= ch->skb->len;
  85. }
  86. return ch;
  87. }
  88. /* Add data chunk to the end of the queue. */
  89. static inline void sctp_outq_tail_data(struct sctp_outq *q,
  90. struct sctp_chunk *ch)
  91. {
  92. list_add_tail(&ch->list, &q->out_chunk_list);
  93. q->out_qlen += ch->skb->len;
  94. return;
  95. }
  96. /*
  97. * SFR-CACC algorithm:
  98. * D) If count_of_newacks is greater than or equal to 2
  99. * and t was not sent to the current primary then the
  100. * sender MUST NOT increment missing report count for t.
  101. */
  102. static inline int sctp_cacc_skip_3_1_d(struct sctp_transport *primary,
  103. struct sctp_transport *transport,
  104. int count_of_newacks)
  105. {
  106. if (count_of_newacks >=2 && transport != primary)
  107. return 1;
  108. return 0;
  109. }
  110. /*
  111. * SFR-CACC algorithm:
  112. * F) If count_of_newacks is less than 2, let d be the
  113. * destination to which t was sent. If cacc_saw_newack
  114. * is 0 for destination d, then the sender MUST NOT
  115. * increment missing report count for t.
  116. */
  117. static inline int sctp_cacc_skip_3_1_f(struct sctp_transport *transport,
  118. int count_of_newacks)
  119. {
  120. if (count_of_newacks < 2 && !transport->cacc.cacc_saw_newack)
  121. return 1;
  122. return 0;
  123. }
  124. /*
  125. * SFR-CACC algorithm:
  126. * 3.1) If CYCLING_CHANGEOVER is 0, the sender SHOULD
  127. * execute steps C, D, F.
  128. *
  129. * C has been implemented in sctp_outq_sack
  130. */
  131. static inline int sctp_cacc_skip_3_1(struct sctp_transport *primary,
  132. struct sctp_transport *transport,
  133. int count_of_newacks)
  134. {
  135. if (!primary->cacc.cycling_changeover) {
  136. if (sctp_cacc_skip_3_1_d(primary, transport, count_of_newacks))
  137. return 1;
  138. if (sctp_cacc_skip_3_1_f(transport, count_of_newacks))
  139. return 1;
  140. return 0;
  141. }
  142. return 0;
  143. }
  144. /*
  145. * SFR-CACC algorithm:
  146. * 3.2) Else if CYCLING_CHANGEOVER is 1, and t is less
  147. * than next_tsn_at_change of the current primary, then
  148. * the sender MUST NOT increment missing report count
  149. * for t.
  150. */
  151. static inline int sctp_cacc_skip_3_2(struct sctp_transport *primary, __u32 tsn)
  152. {
  153. if (primary->cacc.cycling_changeover &&
  154. TSN_lt(tsn, primary->cacc.next_tsn_at_change))
  155. return 1;
  156. return 0;
  157. }
  158. /*
  159. * SFR-CACC algorithm:
  160. * 3) If the missing report count for TSN t is to be
  161. * incremented according to [RFC2960] and
  162. * [SCTP_STEWART-2002], and CHANGEOVER_ACTIVE is set,
  163. * then the sender MUST futher execute steps 3.1 and
  164. * 3.2 to determine if the missing report count for
  165. * TSN t SHOULD NOT be incremented.
  166. *
  167. * 3.3) If 3.1 and 3.2 do not dictate that the missing
  168. * report count for t should not be incremented, then
  169. * the sender SOULD increment missing report count for
  170. * t (according to [RFC2960] and [SCTP_STEWART_2002]).
  171. */
  172. static inline int sctp_cacc_skip(struct sctp_transport *primary,
  173. struct sctp_transport *transport,
  174. int count_of_newacks,
  175. __u32 tsn)
  176. {
  177. if (primary->cacc.changeover_active &&
  178. (sctp_cacc_skip_3_1(primary, transport, count_of_newacks)
  179. || sctp_cacc_skip_3_2(primary, tsn)))
  180. return 1;
  181. return 0;
  182. }
  183. /* Initialize an existing sctp_outq. This does the boring stuff.
  184. * You still need to define handlers if you really want to DO
  185. * something with this structure...
  186. */
  187. void sctp_outq_init(struct sctp_association *asoc, struct sctp_outq *q)
  188. {
  189. q->asoc = asoc;
  190. INIT_LIST_HEAD(&q->out_chunk_list);
  191. INIT_LIST_HEAD(&q->control_chunk_list);
  192. INIT_LIST_HEAD(&q->retransmit);
  193. INIT_LIST_HEAD(&q->sacked);
  194. INIT_LIST_HEAD(&q->abandoned);
  195. q->outstanding_bytes = 0;
  196. q->empty = 1;
  197. q->cork = 0;
  198. q->malloced = 0;
  199. q->out_qlen = 0;
  200. }
  201. /* Free the outqueue structure and any related pending chunks.
  202. */
  203. void sctp_outq_teardown(struct sctp_outq *q)
  204. {
  205. struct sctp_transport *transport;
  206. struct list_head *lchunk, *temp;
  207. struct sctp_chunk *chunk, *tmp;
  208. /* Throw away unacknowledged chunks. */
  209. list_for_each_entry(transport, &q->asoc->peer.transport_addr_list,
  210. transports) {
  211. while ((lchunk = sctp_list_dequeue(&transport->transmitted)) != NULL) {
  212. chunk = list_entry(lchunk, struct sctp_chunk,
  213. transmitted_list);
  214. /* Mark as part of a failed message. */
  215. sctp_chunk_fail(chunk, q->error);
  216. sctp_chunk_free(chunk);
  217. }
  218. }
  219. /* Throw away chunks that have been gap ACKed. */
  220. list_for_each_safe(lchunk, temp, &q->sacked) {
  221. list_del_init(lchunk);
  222. chunk = list_entry(lchunk, struct sctp_chunk,
  223. transmitted_list);
  224. sctp_chunk_fail(chunk, q->error);
  225. sctp_chunk_free(chunk);
  226. }
  227. /* Throw away any chunks in the retransmit queue. */
  228. list_for_each_safe(lchunk, temp, &q->retransmit) {
  229. list_del_init(lchunk);
  230. chunk = list_entry(lchunk, struct sctp_chunk,
  231. transmitted_list);
  232. sctp_chunk_fail(chunk, q->error);
  233. sctp_chunk_free(chunk);
  234. }
  235. /* Throw away any chunks that are in the abandoned queue. */
  236. list_for_each_safe(lchunk, temp, &q->abandoned) {
  237. list_del_init(lchunk);
  238. chunk = list_entry(lchunk, struct sctp_chunk,
  239. transmitted_list);
  240. sctp_chunk_fail(chunk, q->error);
  241. sctp_chunk_free(chunk);
  242. }
  243. /* Throw away any leftover data chunks. */
  244. while ((chunk = sctp_outq_dequeue_data(q)) != NULL) {
  245. /* Mark as send failure. */
  246. sctp_chunk_fail(chunk, q->error);
  247. sctp_chunk_free(chunk);
  248. }
  249. q->error = 0;
  250. /* Throw away any leftover control chunks. */
  251. list_for_each_entry_safe(chunk, tmp, &q->control_chunk_list, list) {
  252. list_del_init(&chunk->list);
  253. sctp_chunk_free(chunk);
  254. }
  255. }
  256. /* Free the outqueue structure and any related pending chunks. */
  257. void sctp_outq_free(struct sctp_outq *q)
  258. {
  259. /* Throw away leftover chunks. */
  260. sctp_outq_teardown(q);
  261. /* If we were kmalloc()'d, free the memory. */
  262. if (q->malloced)
  263. kfree(q);
  264. }
  265. /* Put a new chunk in an sctp_outq. */
  266. int sctp_outq_tail(struct sctp_outq *q, struct sctp_chunk *chunk)
  267. {
  268. int error = 0;
  269. SCTP_DEBUG_PRINTK("sctp_outq_tail(%p, %p[%s])\n",
  270. q, chunk, chunk && chunk->chunk_hdr ?
  271. sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type))
  272. : "Illegal Chunk");
  273. /* If it is data, queue it up, otherwise, send it
  274. * immediately.
  275. */
  276. if (SCTP_CID_DATA == chunk->chunk_hdr->type) {
  277. /* Is it OK to queue data chunks? */
  278. /* From 9. Termination of Association
  279. *
  280. * When either endpoint performs a shutdown, the
  281. * association on each peer will stop accepting new
  282. * data from its user and only deliver data in queue
  283. * at the time of sending or receiving the SHUTDOWN
  284. * chunk.
  285. */
  286. switch (q->asoc->state) {
  287. case SCTP_STATE_EMPTY:
  288. case SCTP_STATE_CLOSED:
  289. case SCTP_STATE_SHUTDOWN_PENDING:
  290. case SCTP_STATE_SHUTDOWN_SENT:
  291. case SCTP_STATE_SHUTDOWN_RECEIVED:
  292. case SCTP_STATE_SHUTDOWN_ACK_SENT:
  293. /* Cannot send after transport endpoint shutdown */
  294. error = -ESHUTDOWN;
  295. break;
  296. default:
  297. SCTP_DEBUG_PRINTK("outqueueing (%p, %p[%s])\n",
  298. q, chunk, chunk && chunk->chunk_hdr ?
  299. sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type))
  300. : "Illegal Chunk");
  301. sctp_outq_tail_data(q, chunk);
  302. if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED)
  303. SCTP_INC_STATS(SCTP_MIB_OUTUNORDERCHUNKS);
  304. else
  305. SCTP_INC_STATS(SCTP_MIB_OUTORDERCHUNKS);
  306. q->empty = 0;
  307. break;
  308. }
  309. } else {
  310. list_add_tail(&chunk->list, &q->control_chunk_list);
  311. SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS);
  312. }
  313. if (error < 0)
  314. return error;
  315. if (!q->cork)
  316. error = sctp_outq_flush(q, 0);
  317. return error;
  318. }
  319. /* Insert a chunk into the sorted list based on the TSNs. The retransmit list
  320. * and the abandoned list are in ascending order.
  321. */
  322. static void sctp_insert_list(struct list_head *head, struct list_head *new)
  323. {
  324. struct list_head *pos;
  325. struct sctp_chunk *nchunk, *lchunk;
  326. __u32 ntsn, ltsn;
  327. int done = 0;
  328. nchunk = list_entry(new, struct sctp_chunk, transmitted_list);
  329. ntsn = ntohl(nchunk->subh.data_hdr->tsn);
  330. list_for_each(pos, head) {
  331. lchunk = list_entry(pos, struct sctp_chunk, transmitted_list);
  332. ltsn = ntohl(lchunk->subh.data_hdr->tsn);
  333. if (TSN_lt(ntsn, ltsn)) {
  334. list_add(new, pos->prev);
  335. done = 1;
  336. break;
  337. }
  338. }
  339. if (!done)
  340. list_add_tail(new, head);
  341. }
  342. /* Mark all the eligible packets on a transport for retransmission. */
  343. void sctp_retransmit_mark(struct sctp_outq *q,
  344. struct sctp_transport *transport,
  345. __u8 reason)
  346. {
  347. struct list_head *lchunk, *ltemp;
  348. struct sctp_chunk *chunk;
  349. /* Walk through the specified transmitted queue. */
  350. list_for_each_safe(lchunk, ltemp, &transport->transmitted) {
  351. chunk = list_entry(lchunk, struct sctp_chunk,
  352. transmitted_list);
  353. /* If the chunk is abandoned, move it to abandoned list. */
  354. if (sctp_chunk_abandoned(chunk)) {
  355. list_del_init(lchunk);
  356. sctp_insert_list(&q->abandoned, lchunk);
  357. /* If this chunk has not been previousely acked,
  358. * stop considering it 'outstanding'. Our peer
  359. * will most likely never see it since it will
  360. * not be retransmitted
  361. */
  362. if (!chunk->tsn_gap_acked) {
  363. chunk->transport->flight_size -=
  364. sctp_data_size(chunk);
  365. q->outstanding_bytes -= sctp_data_size(chunk);
  366. q->asoc->peer.rwnd += (sctp_data_size(chunk) +
  367. sizeof(struct sk_buff));
  368. }
  369. continue;
  370. }
  371. /* If we are doing retransmission due to a timeout or pmtu
  372. * discovery, only the chunks that are not yet acked should
  373. * be added to the retransmit queue.
  374. */
  375. if ((reason == SCTP_RTXR_FAST_RTX &&
  376. (chunk->fast_retransmit > 0)) ||
  377. (reason != SCTP_RTXR_FAST_RTX && !chunk->tsn_gap_acked)) {
  378. /* If this chunk was sent less then 1 rto ago, do not
  379. * retransmit this chunk, but give the peer time
  380. * to acknowlege it. Do this only when
  381. * retransmitting due to T3 timeout.
  382. */
  383. if (reason == SCTP_RTXR_T3_RTX &&
  384. (jiffies - chunk->sent_at) < transport->last_rto)
  385. continue;
  386. /* RFC 2960 6.2.1 Processing a Received SACK
  387. *
  388. * C) Any time a DATA chunk is marked for
  389. * retransmission (via either T3-rtx timer expiration
  390. * (Section 6.3.3) or via fast retransmit
  391. * (Section 7.2.4)), add the data size of those
  392. * chunks to the rwnd.
  393. */
  394. q->asoc->peer.rwnd += (sctp_data_size(chunk) +
  395. sizeof(struct sk_buff));
  396. q->outstanding_bytes -= sctp_data_size(chunk);
  397. transport->flight_size -= sctp_data_size(chunk);
  398. /* sctpimpguide-05 Section 2.8.2
  399. * M5) If a T3-rtx timer expires, the
  400. * 'TSN.Missing.Report' of all affected TSNs is set
  401. * to 0.
  402. */
  403. chunk->tsn_missing_report = 0;
  404. /* If a chunk that is being used for RTT measurement
  405. * has to be retransmitted, we cannot use this chunk
  406. * anymore for RTT measurements. Reset rto_pending so
  407. * that a new RTT measurement is started when a new
  408. * data chunk is sent.
  409. */
  410. if (chunk->rtt_in_progress) {
  411. chunk->rtt_in_progress = 0;
  412. transport->rto_pending = 0;
  413. }
  414. /* Move the chunk to the retransmit queue. The chunks
  415. * on the retransmit queue are always kept in order.
  416. */
  417. list_del_init(lchunk);
  418. sctp_insert_list(&q->retransmit, lchunk);
  419. }
  420. }
  421. SCTP_DEBUG_PRINTK("%s: transport: %p, reason: %d, "
  422. "cwnd: %d, ssthresh: %d, flight_size: %d, "
  423. "pba: %d\n", __func__,
  424. transport, reason,
  425. transport->cwnd, transport->ssthresh,
  426. transport->flight_size,
  427. transport->partial_bytes_acked);
  428. }
  429. /* Mark all the eligible packets on a transport for retransmission and force
  430. * one packet out.
  431. */
  432. void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport,
  433. sctp_retransmit_reason_t reason)
  434. {
  435. int error = 0;
  436. switch(reason) {
  437. case SCTP_RTXR_T3_RTX:
  438. SCTP_INC_STATS(SCTP_MIB_T3_RETRANSMITS);
  439. sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_T3_RTX);
  440. /* Update the retran path if the T3-rtx timer has expired for
  441. * the current retran path.
  442. */
  443. if (transport == transport->asoc->peer.retran_path)
  444. sctp_assoc_update_retran_path(transport->asoc);
  445. transport->asoc->rtx_data_chunks +=
  446. transport->asoc->unack_data;
  447. break;
  448. case SCTP_RTXR_FAST_RTX:
  449. SCTP_INC_STATS(SCTP_MIB_FAST_RETRANSMITS);
  450. sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_FAST_RTX);
  451. break;
  452. case SCTP_RTXR_PMTUD:
  453. SCTP_INC_STATS(SCTP_MIB_PMTUD_RETRANSMITS);
  454. break;
  455. case SCTP_RTXR_T1_RTX:
  456. SCTP_INC_STATS(SCTP_MIB_T1_RETRANSMITS);
  457. transport->asoc->init_retries++;
  458. break;
  459. default:
  460. BUG();
  461. }
  462. sctp_retransmit_mark(q, transport, reason);
  463. /* PR-SCTP A5) Any time the T3-rtx timer expires, on any destination,
  464. * the sender SHOULD try to advance the "Advanced.Peer.Ack.Point" by
  465. * following the procedures outlined in C1 - C5.
  466. */
  467. sctp_generate_fwdtsn(q, q->asoc->ctsn_ack_point);
  468. error = sctp_outq_flush(q, /* rtx_timeout */ 1);
  469. if (error)
  470. q->asoc->base.sk->sk_err = -error;
  471. }
  472. /*
  473. * Transmit DATA chunks on the retransmit queue. Upon return from
  474. * sctp_outq_flush_rtx() the packet 'pkt' may contain chunks which
  475. * need to be transmitted by the caller.
  476. * We assume that pkt->transport has already been set.
  477. *
  478. * The return value is a normal kernel error return value.
  479. */
  480. static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
  481. int rtx_timeout, int *start_timer)
  482. {
  483. struct list_head *lqueue;
  484. struct list_head *lchunk;
  485. struct sctp_transport *transport = pkt->transport;
  486. sctp_xmit_t status;
  487. struct sctp_chunk *chunk, *chunk1;
  488. struct sctp_association *asoc;
  489. int error = 0;
  490. asoc = q->asoc;
  491. lqueue = &q->retransmit;
  492. /* RFC 2960 6.3.3 Handle T3-rtx Expiration
  493. *
  494. * E3) Determine how many of the earliest (i.e., lowest TSN)
  495. * outstanding DATA chunks for the address for which the
  496. * T3-rtx has expired will fit into a single packet, subject
  497. * to the MTU constraint for the path corresponding to the
  498. * destination transport address to which the retransmission
  499. * is being sent (this may be different from the address for
  500. * which the timer expires [see Section 6.4]). Call this value
  501. * K. Bundle and retransmit those K DATA chunks in a single
  502. * packet to the destination endpoint.
  503. *
  504. * [Just to be painfully clear, if we are retransmitting
  505. * because a timeout just happened, we should send only ONE
  506. * packet of retransmitted data.]
  507. */
  508. lchunk = sctp_list_dequeue(lqueue);
  509. while (lchunk) {
  510. chunk = list_entry(lchunk, struct sctp_chunk,
  511. transmitted_list);
  512. /* Make sure that Gap Acked TSNs are not retransmitted. A
  513. * simple approach is just to move such TSNs out of the
  514. * way and into a 'transmitted' queue and skip to the
  515. * next chunk.
  516. */
  517. if (chunk->tsn_gap_acked) {
  518. list_add_tail(lchunk, &transport->transmitted);
  519. lchunk = sctp_list_dequeue(lqueue);
  520. continue;
  521. }
  522. /* Attempt to append this chunk to the packet. */
  523. status = sctp_packet_append_chunk(pkt, chunk);
  524. switch (status) {
  525. case SCTP_XMIT_PMTU_FULL:
  526. /* Send this packet. */
  527. if ((error = sctp_packet_transmit(pkt)) == 0)
  528. *start_timer = 1;
  529. /* If we are retransmitting, we should only
  530. * send a single packet.
  531. */
  532. if (rtx_timeout) {
  533. list_add(lchunk, lqueue);
  534. lchunk = NULL;
  535. }
  536. /* Bundle lchunk in the next round. */
  537. break;
  538. case SCTP_XMIT_RWND_FULL:
  539. /* Send this packet. */
  540. if ((error = sctp_packet_transmit(pkt)) == 0)
  541. *start_timer = 1;
  542. /* Stop sending DATA as there is no more room
  543. * at the receiver.
  544. */
  545. list_add(lchunk, lqueue);
  546. lchunk = NULL;
  547. break;
  548. case SCTP_XMIT_NAGLE_DELAY:
  549. /* Send this packet. */
  550. if ((error = sctp_packet_transmit(pkt)) == 0)
  551. *start_timer = 1;
  552. /* Stop sending DATA because of nagle delay. */
  553. list_add(lchunk, lqueue);
  554. lchunk = NULL;
  555. break;
  556. default:
  557. /* The append was successful, so add this chunk to
  558. * the transmitted list.
  559. */
  560. list_add_tail(lchunk, &transport->transmitted);
  561. /* Mark the chunk as ineligible for fast retransmit
  562. * after it is retransmitted.
  563. */
  564. if (chunk->fast_retransmit > 0)
  565. chunk->fast_retransmit = -1;
  566. *start_timer = 1;
  567. q->empty = 0;
  568. /* Retrieve a new chunk to bundle. */
  569. lchunk = sctp_list_dequeue(lqueue);
  570. break;
  571. }
  572. /* If we are here due to a retransmit timeout or a fast
  573. * retransmit and if there are any chunks left in the retransmit
  574. * queue that could not fit in the PMTU sized packet, they need
  575. * to be marked as ineligible for a subsequent fast retransmit.
  576. */
  577. if (rtx_timeout && !lchunk) {
  578. list_for_each_entry(chunk1, lqueue, transmitted_list) {
  579. if (chunk1->fast_retransmit > 0)
  580. chunk1->fast_retransmit = -1;
  581. }
  582. }
  583. }
  584. return error;
  585. }
  586. /* Cork the outqueue so queued chunks are really queued. */
  587. int sctp_outq_uncork(struct sctp_outq *q)
  588. {
  589. int error = 0;
  590. if (q->cork)
  591. q->cork = 0;
  592. error = sctp_outq_flush(q, 0);
  593. return error;
  594. }
  595. /*
  596. * Try to flush an outqueue.
  597. *
  598. * Description: Send everything in q which we legally can, subject to
  599. * congestion limitations.
  600. * * Note: This function can be called from multiple contexts so appropriate
  601. * locking concerns must be made. Today we use the sock lock to protect
  602. * this function.
  603. */
  604. int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
  605. {
  606. struct sctp_packet *packet;
  607. struct sctp_packet singleton;
  608. struct sctp_association *asoc = q->asoc;
  609. __u16 sport = asoc->base.bind_addr.port;
  610. __u16 dport = asoc->peer.port;
  611. __u32 vtag = asoc->peer.i.init_tag;
  612. struct sctp_transport *transport = NULL;
  613. struct sctp_transport *new_transport;
  614. struct sctp_chunk *chunk, *tmp;
  615. sctp_xmit_t status;
  616. int error = 0;
  617. int start_timer = 0;
  618. /* These transports have chunks to send. */
  619. struct list_head transport_list;
  620. struct list_head *ltransport;
  621. INIT_LIST_HEAD(&transport_list);
  622. packet = NULL;
  623. /*
  624. * 6.10 Bundling
  625. * ...
  626. * When bundling control chunks with DATA chunks, an
  627. * endpoint MUST place control chunks first in the outbound
  628. * SCTP packet. The transmitter MUST transmit DATA chunks
  629. * within a SCTP packet in increasing order of TSN.
  630. * ...
  631. */
  632. list_for_each_entry_safe(chunk, tmp, &q->control_chunk_list, list) {
  633. list_del_init(&chunk->list);
  634. /* Pick the right transport to use. */
  635. new_transport = chunk->transport;
  636. if (!new_transport) {
  637. /*
  638. * If we have a prior transport pointer, see if
  639. * the destination address of the chunk
  640. * matches the destination address of the
  641. * current transport. If not a match, then
  642. * try to look up the transport with a given
  643. * destination address. We do this because
  644. * after processing ASCONFs, we may have new
  645. * transports created.
  646. */
  647. if (transport &&
  648. sctp_cmp_addr_exact(&chunk->dest,
  649. &transport->ipaddr))
  650. new_transport = transport;
  651. else
  652. new_transport = sctp_assoc_lookup_paddr(asoc,
  653. &chunk->dest);
  654. /* if we still don't have a new transport, then
  655. * use the current active path.
  656. */
  657. if (!new_transport)
  658. new_transport = asoc->peer.active_path;
  659. } else if ((new_transport->state == SCTP_INACTIVE) ||
  660. (new_transport->state == SCTP_UNCONFIRMED)) {
  661. /* If the chunk is Heartbeat or Heartbeat Ack,
  662. * send it to chunk->transport, even if it's
  663. * inactive.
  664. *
  665. * 3.3.6 Heartbeat Acknowledgement:
  666. * ...
  667. * A HEARTBEAT ACK is always sent to the source IP
  668. * address of the IP datagram containing the
  669. * HEARTBEAT chunk to which this ack is responding.
  670. * ...
  671. *
  672. * ASCONF_ACKs also must be sent to the source.
  673. */
  674. if (chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT &&
  675. chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT_ACK &&
  676. chunk->chunk_hdr->type != SCTP_CID_ASCONF_ACK)
  677. new_transport = asoc->peer.active_path;
  678. }
  679. /* Are we switching transports?
  680. * Take care of transport locks.
  681. */
  682. if (new_transport != transport) {
  683. transport = new_transport;
  684. if (list_empty(&transport->send_ready)) {
  685. list_add_tail(&transport->send_ready,
  686. &transport_list);
  687. }
  688. packet = &transport->packet;
  689. sctp_packet_config(packet, vtag,
  690. asoc->peer.ecn_capable);
  691. }
  692. switch (chunk->chunk_hdr->type) {
  693. /*
  694. * 6.10 Bundling
  695. * ...
  696. * An endpoint MUST NOT bundle INIT, INIT ACK or SHUTDOWN
  697. * COMPLETE with any other chunks. [Send them immediately.]
  698. */
  699. case SCTP_CID_INIT:
  700. case SCTP_CID_INIT_ACK:
  701. case SCTP_CID_SHUTDOWN_COMPLETE:
  702. sctp_packet_init(&singleton, transport, sport, dport);
  703. sctp_packet_config(&singleton, vtag, 0);
  704. sctp_packet_append_chunk(&singleton, chunk);
  705. error = sctp_packet_transmit(&singleton);
  706. if (error < 0)
  707. return error;
  708. break;
  709. case SCTP_CID_ABORT:
  710. if (sctp_test_T_bit(chunk)) {
  711. packet->vtag = asoc->c.my_vtag;
  712. }
  713. case SCTP_CID_SACK:
  714. case SCTP_CID_HEARTBEAT:
  715. case SCTP_CID_HEARTBEAT_ACK:
  716. case SCTP_CID_SHUTDOWN:
  717. case SCTP_CID_SHUTDOWN_ACK:
  718. case SCTP_CID_ERROR:
  719. case SCTP_CID_COOKIE_ECHO:
  720. case SCTP_CID_COOKIE_ACK:
  721. case SCTP_CID_ECN_ECNE:
  722. case SCTP_CID_ECN_CWR:
  723. case SCTP_CID_ASCONF:
  724. case SCTP_CID_ASCONF_ACK:
  725. case SCTP_CID_FWD_TSN:
  726. sctp_packet_transmit_chunk(packet, chunk);
  727. break;
  728. default:
  729. /* We built a chunk with an illegal type! */
  730. BUG();
  731. }
  732. }
  733. /* Is it OK to send data chunks? */
  734. switch (asoc->state) {
  735. case SCTP_STATE_COOKIE_ECHOED:
  736. /* Only allow bundling when this packet has a COOKIE-ECHO
  737. * chunk.
  738. */
  739. if (!packet || !packet->has_cookie_echo)
  740. break;
  741. /* fallthru */
  742. case SCTP_STATE_ESTABLISHED:
  743. case SCTP_STATE_SHUTDOWN_PENDING:
  744. case SCTP_STATE_SHUTDOWN_RECEIVED:
  745. /*
  746. * RFC 2960 6.1 Transmission of DATA Chunks
  747. *
  748. * C) When the time comes for the sender to transmit,
  749. * before sending new DATA chunks, the sender MUST
  750. * first transmit any outstanding DATA chunks which
  751. * are marked for retransmission (limited by the
  752. * current cwnd).
  753. */
  754. if (!list_empty(&q->retransmit)) {
  755. if (transport == asoc->peer.retran_path)
  756. goto retran;
  757. /* Switch transports & prepare the packet. */
  758. transport = asoc->peer.retran_path;
  759. if (list_empty(&transport->send_ready)) {
  760. list_add_tail(&transport->send_ready,
  761. &transport_list);
  762. }
  763. packet = &transport->packet;
  764. sctp_packet_config(packet, vtag,
  765. asoc->peer.ecn_capable);
  766. retran:
  767. error = sctp_outq_flush_rtx(q, packet,
  768. rtx_timeout, &start_timer);
  769. if (start_timer)
  770. sctp_transport_reset_timers(transport);
  771. /* This can happen on COOKIE-ECHO resend. Only
  772. * one chunk can get bundled with a COOKIE-ECHO.
  773. */
  774. if (packet->has_cookie_echo)
  775. goto sctp_flush_out;
  776. /* Don't send new data if there is still data
  777. * waiting to retransmit.
  778. */
  779. if (!list_empty(&q->retransmit))
  780. goto sctp_flush_out;
  781. }
  782. /* Finally, transmit new packets. */
  783. start_timer = 0;
  784. while ((chunk = sctp_outq_dequeue_data(q)) != NULL) {
  785. /* RFC 2960 6.5 Every DATA chunk MUST carry a valid
  786. * stream identifier.
  787. */
  788. if (chunk->sinfo.sinfo_stream >=
  789. asoc->c.sinit_num_ostreams) {
  790. /* Mark as failed send. */
  791. sctp_chunk_fail(chunk, SCTP_ERROR_INV_STRM);
  792. sctp_chunk_free(chunk);
  793. continue;
  794. }
  795. /* Has this chunk expired? */
  796. if (sctp_chunk_abandoned(chunk)) {
  797. sctp_chunk_fail(chunk, 0);
  798. sctp_chunk_free(chunk);
  799. continue;
  800. }
  801. /* If there is a specified transport, use it.
  802. * Otherwise, we want to use the active path.
  803. */
  804. new_transport = chunk->transport;
  805. if (!new_transport ||
  806. ((new_transport->state == SCTP_INACTIVE) ||
  807. (new_transport->state == SCTP_UNCONFIRMED)))
  808. new_transport = asoc->peer.active_path;
  809. /* Change packets if necessary. */
  810. if (new_transport != transport) {
  811. transport = new_transport;
  812. /* Schedule to have this transport's
  813. * packet flushed.
  814. */
  815. if (list_empty(&transport->send_ready)) {
  816. list_add_tail(&transport->send_ready,
  817. &transport_list);
  818. }
  819. packet = &transport->packet;
  820. sctp_packet_config(packet, vtag,
  821. asoc->peer.ecn_capable);
  822. }
  823. SCTP_DEBUG_PRINTK("sctp_outq_flush(%p, %p[%s]), ",
  824. q, chunk,
  825. chunk && chunk->chunk_hdr ?
  826. sctp_cname(SCTP_ST_CHUNK(
  827. chunk->chunk_hdr->type))
  828. : "Illegal Chunk");
  829. SCTP_DEBUG_PRINTK("TX TSN 0x%x skb->head "
  830. "%p skb->users %d.\n",
  831. ntohl(chunk->subh.data_hdr->tsn),
  832. chunk->skb ?chunk->skb->head : NULL,
  833. chunk->skb ?
  834. atomic_read(&chunk->skb->users) : -1);
  835. /* Add the chunk to the packet. */
  836. status = sctp_packet_transmit_chunk(packet, chunk);
  837. switch (status) {
  838. case SCTP_XMIT_PMTU_FULL:
  839. case SCTP_XMIT_RWND_FULL:
  840. case SCTP_XMIT_NAGLE_DELAY:
  841. /* We could not append this chunk, so put
  842. * the chunk back on the output queue.
  843. */
  844. SCTP_DEBUG_PRINTK("sctp_outq_flush: could "
  845. "not transmit TSN: 0x%x, status: %d\n",
  846. ntohl(chunk->subh.data_hdr->tsn),
  847. status);
  848. sctp_outq_head_data(q, chunk);
  849. goto sctp_flush_out;
  850. break;
  851. case SCTP_XMIT_OK:
  852. break;
  853. default:
  854. BUG();
  855. }
  856. /* BUG: We assume that the sctp_packet_transmit()
  857. * call below will succeed all the time and add the
  858. * chunk to the transmitted list and restart the
  859. * timers.
  860. * It is possible that the call can fail under OOM
  861. * conditions.
  862. *
  863. * Is this really a problem? Won't this behave
  864. * like a lost TSN?
  865. */
  866. list_add_tail(&chunk->transmitted_list,
  867. &transport->transmitted);
  868. sctp_transport_reset_timers(transport);
  869. q->empty = 0;
  870. /* Only let one DATA chunk get bundled with a
  871. * COOKIE-ECHO chunk.
  872. */
  873. if (packet->has_cookie_echo)
  874. goto sctp_flush_out;
  875. }
  876. break;
  877. default:
  878. /* Do nothing. */
  879. break;
  880. }
  881. sctp_flush_out:
  882. /* Before returning, examine all the transports touched in
  883. * this call. Right now, we bluntly force clear all the
  884. * transports. Things might change after we implement Nagle.
  885. * But such an examination is still required.
  886. *
  887. * --xguo
  888. */
  889. while ((ltransport = sctp_list_dequeue(&transport_list)) != NULL ) {
  890. struct sctp_transport *t = list_entry(ltransport,
  891. struct sctp_transport,
  892. send_ready);
  893. packet = &t->packet;
  894. if (!sctp_packet_empty(packet))
  895. error = sctp_packet_transmit(packet);
  896. }
  897. return error;
  898. }
  899. /* Update unack_data based on the incoming SACK chunk */
  900. static void sctp_sack_update_unack_data(struct sctp_association *assoc,
  901. struct sctp_sackhdr *sack)
  902. {
  903. sctp_sack_variable_t *frags;
  904. __u16 unack_data;
  905. int i;
  906. unack_data = assoc->next_tsn - assoc->ctsn_ack_point - 1;
  907. frags = sack->variable;
  908. for (i = 0; i < ntohs(sack->num_gap_ack_blocks); i++) {
  909. unack_data -= ((ntohs(frags[i].gab.end) -
  910. ntohs(frags[i].gab.start) + 1));
  911. }
  912. assoc->unack_data = unack_data;
  913. }
  914. /* Return the highest new tsn that is acknowledged by the given SACK chunk. */
  915. static __u32 sctp_highest_new_tsn(struct sctp_sackhdr *sack,
  916. struct sctp_association *asoc)
  917. {
  918. struct sctp_transport *transport;
  919. struct sctp_chunk *chunk;
  920. __u32 highest_new_tsn, tsn;
  921. struct list_head *transport_list = &asoc->peer.transport_addr_list;
  922. highest_new_tsn = ntohl(sack->cum_tsn_ack);
  923. list_for_each_entry(transport, transport_list, transports) {
  924. list_for_each_entry(chunk, &transport->transmitted,
  925. transmitted_list) {
  926. tsn = ntohl(chunk->subh.data_hdr->tsn);
  927. if (!chunk->tsn_gap_acked &&
  928. TSN_lt(highest_new_tsn, tsn) &&
  929. sctp_acked(sack, tsn))
  930. highest_new_tsn = tsn;
  931. }
  932. }
  933. return highest_new_tsn;
  934. }
  935. /* This is where we REALLY process a SACK.
  936. *
  937. * Process the SACK against the outqueue. Mostly, this just frees
  938. * things off the transmitted queue.
  939. */
  940. int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack)
  941. {
  942. struct sctp_association *asoc = q->asoc;
  943. struct sctp_transport *transport;
  944. struct sctp_chunk *tchunk = NULL;
  945. struct list_head *lchunk, *transport_list, *temp;
  946. sctp_sack_variable_t *frags = sack->variable;
  947. __u32 sack_ctsn, ctsn, tsn;
  948. __u32 highest_tsn, highest_new_tsn;
  949. __u32 sack_a_rwnd;
  950. unsigned outstanding;
  951. struct sctp_transport *primary = asoc->peer.primary_path;
  952. int count_of_newacks = 0;
  953. /* Grab the association's destination address list. */
  954. transport_list = &asoc->peer.transport_addr_list;
  955. sack_ctsn = ntohl(sack->cum_tsn_ack);
  956. /*
  957. * SFR-CACC algorithm:
  958. * On receipt of a SACK the sender SHOULD execute the
  959. * following statements.
  960. *
  961. * 1) If the cumulative ack in the SACK passes next tsn_at_change
  962. * on the current primary, the CHANGEOVER_ACTIVE flag SHOULD be
  963. * cleared. The CYCLING_CHANGEOVER flag SHOULD also be cleared for
  964. * all destinations.
  965. */
  966. if (TSN_lte(primary->cacc.next_tsn_at_change, sack_ctsn)) {
  967. primary->cacc.changeover_active = 0;
  968. list_for_each_entry(transport, transport_list,
  969. transports) {
  970. transport->cacc.cycling_changeover = 0;
  971. }
  972. }
  973. /*
  974. * SFR-CACC algorithm:
  975. * 2) If the SACK contains gap acks and the flag CHANGEOVER_ACTIVE
  976. * is set the receiver of the SACK MUST take the following actions:
  977. *
  978. * A) Initialize the cacc_saw_newack to 0 for all destination
  979. * addresses.
  980. */
  981. if (sack->num_gap_ack_blocks &&
  982. primary->cacc.changeover_active) {
  983. list_for_each_entry(transport, transport_list, transports) {
  984. transport->cacc.cacc_saw_newack = 0;
  985. }
  986. }
  987. /* Get the highest TSN in the sack. */
  988. highest_tsn = sack_ctsn;
  989. if (sack->num_gap_ack_blocks)
  990. highest_tsn +=
  991. ntohs(frags[ntohs(sack->num_gap_ack_blocks) - 1].gab.end);
  992. if (TSN_lt(asoc->highest_sacked, highest_tsn)) {
  993. highest_new_tsn = highest_tsn;
  994. asoc->highest_sacked = highest_tsn;
  995. } else {
  996. highest_new_tsn = sctp_highest_new_tsn(sack, asoc);
  997. }
  998. /* Run through the retransmit queue. Credit bytes received
  999. * and free those chunks that we can.
  1000. */
  1001. sctp_check_transmitted(q, &q->retransmit, NULL, sack, highest_new_tsn);
  1002. sctp_mark_missing(q, &q->retransmit, NULL, highest_new_tsn, 0);
  1003. /* Run through the transmitted queue.
  1004. * Credit bytes received and free those chunks which we can.
  1005. *
  1006. * This is a MASSIVE candidate for optimization.
  1007. */
  1008. list_for_each_entry(transport, transport_list, transports) {
  1009. sctp_check_transmitted(q, &transport->transmitted,
  1010. transport, sack, highest_new_tsn);
  1011. /*
  1012. * SFR-CACC algorithm:
  1013. * C) Let count_of_newacks be the number of
  1014. * destinations for which cacc_saw_newack is set.
  1015. */
  1016. if (transport->cacc.cacc_saw_newack)
  1017. count_of_newacks ++;
  1018. }
  1019. list_for_each_entry(transport, transport_list, transports) {
  1020. sctp_mark_missing(q, &transport->transmitted, transport,
  1021. highest_new_tsn, count_of_newacks);
  1022. }
  1023. /* Move the Cumulative TSN Ack Point if appropriate. */
  1024. if (TSN_lt(asoc->ctsn_ack_point, sack_ctsn))
  1025. asoc->ctsn_ack_point = sack_ctsn;
  1026. /* Update unack_data field in the assoc. */
  1027. sctp_sack_update_unack_data(asoc, sack);
  1028. ctsn = asoc->ctsn_ack_point;
  1029. /* Throw away stuff rotting on the sack queue. */
  1030. list_for_each_safe(lchunk, temp, &q->sacked) {
  1031. tchunk = list_entry(lchunk, struct sctp_chunk,
  1032. transmitted_list);
  1033. tsn = ntohl(tchunk->subh.data_hdr->tsn);
  1034. if (TSN_lte(tsn, ctsn)) {
  1035. list_del_init(&tchunk->transmitted_list);
  1036. sctp_chunk_free(tchunk);
  1037. }
  1038. }
  1039. /* ii) Set rwnd equal to the newly received a_rwnd minus the
  1040. * number of bytes still outstanding after processing the
  1041. * Cumulative TSN Ack and the Gap Ack Blocks.
  1042. */
  1043. sack_a_rwnd = ntohl(sack->a_rwnd);
  1044. outstanding = q->outstanding_bytes;
  1045. if (outstanding < sack_a_rwnd)
  1046. sack_a_rwnd -= outstanding;
  1047. else
  1048. sack_a_rwnd = 0;
  1049. asoc->peer.rwnd = sack_a_rwnd;
  1050. sctp_generate_fwdtsn(q, sack_ctsn);
  1051. SCTP_DEBUG_PRINTK("%s: sack Cumulative TSN Ack is 0x%x.\n",
  1052. __func__, sack_ctsn);
  1053. SCTP_DEBUG_PRINTK("%s: Cumulative TSN Ack of association, "
  1054. "%p is 0x%x. Adv peer ack point: 0x%x\n",
  1055. __func__, asoc, ctsn, asoc->adv_peer_ack_point);
  1056. /* See if all chunks are acked.
  1057. * Make sure the empty queue handler will get run later.
  1058. */
  1059. q->empty = (list_empty(&q->out_chunk_list) &&
  1060. list_empty(&q->control_chunk_list) &&
  1061. list_empty(&q->retransmit));
  1062. if (!q->empty)
  1063. goto finish;
  1064. list_for_each_entry(transport, transport_list, transports) {
  1065. q->empty = q->empty && list_empty(&transport->transmitted);
  1066. if (!q->empty)
  1067. goto finish;
  1068. }
  1069. SCTP_DEBUG_PRINTK("sack queue is empty.\n");
  1070. finish:
  1071. return q->empty;
  1072. }
  1073. /* Is the outqueue empty? */
  1074. int sctp_outq_is_empty(const struct sctp_outq *q)
  1075. {
  1076. return q->empty;
  1077. }
  1078. /********************************************************************
  1079. * 2nd Level Abstractions
  1080. ********************************************************************/
  1081. /* Go through a transport's transmitted list or the association's retransmit
  1082. * list and move chunks that are acked by the Cumulative TSN Ack to q->sacked.
  1083. * The retransmit list will not have an associated transport.
  1084. *
  1085. * I added coherent debug information output. --xguo
  1086. *
  1087. * Instead of printing 'sacked' or 'kept' for each TSN on the
  1088. * transmitted_queue, we print a range: SACKED: TSN1-TSN2, TSN3, TSN4-TSN5.
  1089. * KEPT TSN6-TSN7, etc.
  1090. */
  1091. static void sctp_check_transmitted(struct sctp_outq *q,
  1092. struct list_head *transmitted_queue,
  1093. struct sctp_transport *transport,
  1094. struct sctp_sackhdr *sack,
  1095. __u32 highest_new_tsn_in_sack)
  1096. {
  1097. struct list_head *lchunk;
  1098. struct sctp_chunk *tchunk;
  1099. struct list_head tlist;
  1100. __u32 tsn;
  1101. __u32 sack_ctsn;
  1102. __u32 rtt;
  1103. __u8 restart_timer = 0;
  1104. int bytes_acked = 0;
  1105. /* These state variables are for coherent debug output. --xguo */
  1106. #if SCTP_DEBUG
  1107. __u32 dbg_ack_tsn = 0; /* An ACKed TSN range starts here... */
  1108. __u32 dbg_last_ack_tsn = 0; /* ...and finishes here. */
  1109. __u32 dbg_kept_tsn = 0; /* An un-ACKed range starts here... */
  1110. __u32 dbg_last_kept_tsn = 0; /* ...and finishes here. */
  1111. /* 0 : The last TSN was ACKed.
  1112. * 1 : The last TSN was NOT ACKed (i.e. KEPT).
  1113. * -1: We need to initialize.
  1114. */
  1115. int dbg_prt_state = -1;
  1116. #endif /* SCTP_DEBUG */
  1117. sack_ctsn = ntohl(sack->cum_tsn_ack);
  1118. INIT_LIST_HEAD(&tlist);
  1119. /* The while loop will skip empty transmitted queues. */
  1120. while (NULL != (lchunk = sctp_list_dequeue(transmitted_queue))) {
  1121. tchunk = list_entry(lchunk, struct sctp_chunk,
  1122. transmitted_list);
  1123. if (sctp_chunk_abandoned(tchunk)) {
  1124. /* Move the chunk to abandoned list. */
  1125. sctp_insert_list(&q->abandoned, lchunk);
  1126. /* If this chunk has not been acked, stop
  1127. * considering it as 'outstanding'.
  1128. */
  1129. if (!tchunk->tsn_gap_acked) {
  1130. tchunk->transport->flight_size -=
  1131. sctp_data_size(tchunk);
  1132. q->outstanding_bytes -= sctp_data_size(tchunk);
  1133. }
  1134. continue;
  1135. }
  1136. tsn = ntohl(tchunk->subh.data_hdr->tsn);
  1137. if (sctp_acked(sack, tsn)) {
  1138. /* If this queue is the retransmit queue, the
  1139. * retransmit timer has already reclaimed
  1140. * the outstanding bytes for this chunk, so only
  1141. * count bytes associated with a transport.
  1142. */
  1143. if (transport) {
  1144. /* If this chunk is being used for RTT
  1145. * measurement, calculate the RTT and update
  1146. * the RTO using this value.
  1147. *
  1148. * 6.3.1 C5) Karn's algorithm: RTT measurements
  1149. * MUST NOT be made using packets that were
  1150. * retransmitted (and thus for which it is
  1151. * ambiguous whether the reply was for the
  1152. * first instance of the packet or a later
  1153. * instance).
  1154. */
  1155. if (!tchunk->tsn_gap_acked &&
  1156. !tchunk->resent &&
  1157. tchunk->rtt_in_progress) {
  1158. tchunk->rtt_in_progress = 0;
  1159. rtt = jiffies - tchunk->sent_at;
  1160. sctp_transport_update_rto(transport,
  1161. rtt);
  1162. }
  1163. }
  1164. if (TSN_lte(tsn, sack_ctsn)) {
  1165. /* RFC 2960 6.3.2 Retransmission Timer Rules
  1166. *
  1167. * R3) Whenever a SACK is received
  1168. * that acknowledges the DATA chunk
  1169. * with the earliest outstanding TSN
  1170. * for that address, restart T3-rtx
  1171. * timer for that address with its
  1172. * current RTO.
  1173. */
  1174. restart_timer = 1;
  1175. if (!tchunk->tsn_gap_acked) {
  1176. tchunk->tsn_gap_acked = 1;
  1177. bytes_acked += sctp_data_size(tchunk);
  1178. /*
  1179. * SFR-CACC algorithm:
  1180. * 2) If the SACK contains gap acks
  1181. * and the flag CHANGEOVER_ACTIVE is
  1182. * set the receiver of the SACK MUST
  1183. * take the following action:
  1184. *
  1185. * B) For each TSN t being acked that
  1186. * has not been acked in any SACK so
  1187. * far, set cacc_saw_newack to 1 for
  1188. * the destination that the TSN was
  1189. * sent to.
  1190. */
  1191. if (transport &&
  1192. sack->num_gap_ack_blocks &&
  1193. q->asoc->peer.primary_path->cacc.
  1194. changeover_active)
  1195. transport->cacc.cacc_saw_newack
  1196. = 1;
  1197. }
  1198. list_add_tail(&tchunk->transmitted_list,
  1199. &q->sacked);
  1200. } else {
  1201. /* RFC2960 7.2.4, sctpimpguide-05 2.8.2
  1202. * M2) Each time a SACK arrives reporting
  1203. * 'Stray DATA chunk(s)' record the highest TSN
  1204. * reported as newly acknowledged, call this
  1205. * value 'HighestTSNinSack'. A newly
  1206. * acknowledged DATA chunk is one not
  1207. * previously acknowledged in a SACK.
  1208. *
  1209. * When the SCTP sender of data receives a SACK
  1210. * chunk that acknowledges, for the first time,
  1211. * the receipt of a DATA chunk, all the still
  1212. * unacknowledged DATA chunks whose TSN is
  1213. * older than that newly acknowledged DATA
  1214. * chunk, are qualified as 'Stray DATA chunks'.
  1215. */
  1216. if (!tchunk->tsn_gap_acked) {
  1217. tchunk->tsn_gap_acked = 1;
  1218. bytes_acked += sctp_data_size(tchunk);
  1219. }
  1220. list_add_tail(lchunk, &tlist);
  1221. }
  1222. #if SCTP_DEBUG
  1223. switch (dbg_prt_state) {
  1224. case 0: /* last TSN was ACKed */
  1225. if (dbg_last_ack_tsn + 1 == tsn) {
  1226. /* This TSN belongs to the
  1227. * current ACK range.
  1228. */
  1229. break;
  1230. }
  1231. if (dbg_last_ack_tsn != dbg_ack_tsn) {
  1232. /* Display the end of the
  1233. * current range.
  1234. */
  1235. SCTP_DEBUG_PRINTK("-%08x",
  1236. dbg_last_ack_tsn);
  1237. }
  1238. /* Start a new range. */
  1239. SCTP_DEBUG_PRINTK(",%08x", tsn);
  1240. dbg_ack_tsn = tsn;
  1241. break;
  1242. case 1: /* The last TSN was NOT ACKed. */
  1243. if (dbg_last_kept_tsn != dbg_kept_tsn) {
  1244. /* Display the end of current range. */
  1245. SCTP_DEBUG_PRINTK("-%08x",
  1246. dbg_last_kept_tsn);
  1247. }
  1248. SCTP_DEBUG_PRINTK("\n");
  1249. /* FALL THROUGH... */
  1250. default:
  1251. /* This is the first-ever TSN we examined. */
  1252. /* Start a new range of ACK-ed TSNs. */
  1253. SCTP_DEBUG_PRINTK("ACKed: %08x", tsn);
  1254. dbg_prt_state = 0;
  1255. dbg_ack_tsn = tsn;
  1256. }
  1257. dbg_last_ack_tsn = tsn;
  1258. #endif /* SCTP_DEBUG */
  1259. } else {
  1260. if (tchunk->tsn_gap_acked) {
  1261. SCTP_DEBUG_PRINTK("%s: Receiver reneged on "
  1262. "data TSN: 0x%x\n",
  1263. __func__,
  1264. tsn);
  1265. tchunk->tsn_gap_acked = 0;
  1266. bytes_acked -= sctp_data_size(tchunk);
  1267. /* RFC 2960 6.3.2 Retransmission Timer Rules
  1268. *
  1269. * R4) Whenever a SACK is received missing a
  1270. * TSN that was previously acknowledged via a
  1271. * Gap Ack Block, start T3-rtx for the
  1272. * destination address to which the DATA
  1273. * chunk was originally
  1274. * transmitted if it is not already running.
  1275. */
  1276. restart_timer = 1;
  1277. }
  1278. list_add_tail(lchunk, &tlist);
  1279. #if SCTP_DEBUG
  1280. /* See the above comments on ACK-ed TSNs. */
  1281. switch (dbg_prt_state) {
  1282. case 1:
  1283. if (dbg_last_kept_tsn + 1 == tsn)
  1284. break;
  1285. if (dbg_last_kept_tsn != dbg_kept_tsn)
  1286. SCTP_DEBUG_PRINTK("-%08x",
  1287. dbg_last_kept_tsn);
  1288. SCTP_DEBUG_PRINTK(",%08x", tsn);
  1289. dbg_kept_tsn = tsn;
  1290. break;
  1291. case 0:
  1292. if (dbg_last_ack_tsn != dbg_ack_tsn)
  1293. SCTP_DEBUG_PRINTK("-%08x",
  1294. dbg_last_ack_tsn);
  1295. SCTP_DEBUG_PRINTK("\n");
  1296. /* FALL THROUGH... */
  1297. default:
  1298. SCTP_DEBUG_PRINTK("KEPT: %08x",tsn);
  1299. dbg_prt_state = 1;
  1300. dbg_kept_tsn = tsn;
  1301. }
  1302. dbg_last_kept_tsn = tsn;
  1303. #endif /* SCTP_DEBUG */
  1304. }
  1305. }
  1306. #if SCTP_DEBUG
  1307. /* Finish off the last range, displaying its ending TSN. */
  1308. switch (dbg_prt_state) {
  1309. case 0:
  1310. if (dbg_last_ack_tsn != dbg_ack_tsn) {
  1311. SCTP_DEBUG_PRINTK("-%08x\n", dbg_last_ack_tsn);
  1312. } else {
  1313. SCTP_DEBUG_PRINTK("\n");
  1314. }
  1315. break;
  1316. case 1:
  1317. if (dbg_last_kept_tsn != dbg_kept_tsn) {
  1318. SCTP_DEBUG_PRINTK("-%08x\n", dbg_last_kept_tsn);
  1319. } else {
  1320. SCTP_DEBUG_PRINTK("\n");
  1321. }
  1322. }
  1323. #endif /* SCTP_DEBUG */
  1324. if (transport) {
  1325. if (bytes_acked) {
  1326. /* 8.2. When an outstanding TSN is acknowledged,
  1327. * the endpoint shall clear the error counter of
  1328. * the destination transport address to which the
  1329. * DATA chunk was last sent.
  1330. * The association's overall error counter is
  1331. * also cleared.
  1332. */
  1333. transport->error_count = 0;
  1334. transport->asoc->overall_error_count = 0;
  1335. /* Mark the destination transport address as
  1336. * active if it is not so marked.
  1337. */
  1338. if ((transport->state == SCTP_INACTIVE) ||
  1339. (transport->state == SCTP_UNCONFIRMED)) {
  1340. sctp_assoc_control_transport(
  1341. transport->asoc,
  1342. transport,
  1343. SCTP_TRANSPORT_UP,
  1344. SCTP_RECEIVED_SACK);
  1345. }
  1346. sctp_transport_raise_cwnd(transport, sack_ctsn,
  1347. bytes_acked);
  1348. transport->flight_size -= bytes_acked;
  1349. if (transport->flight_size == 0)
  1350. transport->partial_bytes_acked = 0;
  1351. q->outstanding_bytes -= bytes_acked;
  1352. } else {
  1353. /* RFC 2960 6.1, sctpimpguide-06 2.15.2
  1354. * When a sender is doing zero window probing, it
  1355. * should not timeout the association if it continues
  1356. * to receive new packets from the receiver. The
  1357. * reason is that the receiver MAY keep its window
  1358. * closed for an indefinite time.
  1359. * A sender is doing zero window probing when the
  1360. * receiver's advertised window is zero, and there is
  1361. * only one data chunk in flight to the receiver.
  1362. */
  1363. if (!q->asoc->peer.rwnd &&
  1364. !list_empty(&tlist) &&
  1365. (sack_ctsn+2 == q->asoc->next_tsn)) {
  1366. SCTP_DEBUG_PRINTK("%s: SACK received for zero "
  1367. "window probe: %u\n",
  1368. __func__, sack_ctsn);
  1369. q->asoc->overall_error_count = 0;
  1370. transport->error_count = 0;
  1371. }
  1372. }
  1373. /* RFC 2960 6.3.2 Retransmission Timer Rules
  1374. *
  1375. * R2) Whenever all outstanding data sent to an address have
  1376. * been acknowledged, turn off the T3-rtx timer of that
  1377. * address.
  1378. */
  1379. if (!transport->flight_size) {
  1380. if (timer_pending(&transport->T3_rtx_timer) &&
  1381. del_timer(&transport->T3_rtx_timer)) {
  1382. sctp_transport_put(transport);
  1383. }
  1384. } else if (restart_timer) {
  1385. if (!mod_timer(&transport->T3_rtx_timer,
  1386. jiffies + transport->rto))
  1387. sctp_transport_hold(transport);
  1388. }
  1389. }
  1390. list_splice(&tlist, transmitted_queue);
  1391. }
  1392. /* Mark chunks as missing and consequently may get retransmitted. */
  1393. static void sctp_mark_missing(struct sctp_outq *q,
  1394. struct list_head *transmitted_queue,
  1395. struct sctp_transport *transport,
  1396. __u32 highest_new_tsn_in_sack,
  1397. int count_of_newacks)
  1398. {
  1399. struct sctp_chunk *chunk;
  1400. __u32 tsn;
  1401. char do_fast_retransmit = 0;
  1402. struct sctp_transport *primary = q->asoc->peer.primary_path;
  1403. list_for_each_entry(chunk, transmitted_queue, transmitted_list) {
  1404. tsn = ntohl(chunk->subh.data_hdr->tsn);
  1405. /* RFC 2960 7.2.4, sctpimpguide-05 2.8.2 M3) Examine all
  1406. * 'Unacknowledged TSN's', if the TSN number of an
  1407. * 'Unacknowledged TSN' is smaller than the 'HighestTSNinSack'
  1408. * value, increment the 'TSN.Missing.Report' count on that
  1409. * chunk if it has NOT been fast retransmitted or marked for
  1410. * fast retransmit already.
  1411. */
  1412. if (!chunk->fast_retransmit &&
  1413. !chunk->tsn_gap_acked &&
  1414. TSN_lt(tsn, highest_new_tsn_in_sack)) {
  1415. /* SFR-CACC may require us to skip marking
  1416. * this chunk as missing.
  1417. */
  1418. if (!transport || !sctp_cacc_skip(primary, transport,
  1419. count_of_newacks, tsn)) {
  1420. chunk->tsn_missing_report++;
  1421. SCTP_DEBUG_PRINTK(
  1422. "%s: TSN 0x%x missing counter: %d\n",
  1423. __func__, tsn,
  1424. chunk->tsn_missing_report);
  1425. }
  1426. }
  1427. /*
  1428. * M4) If any DATA chunk is found to have a
  1429. * 'TSN.Missing.Report'
  1430. * value larger than or equal to 3, mark that chunk for
  1431. * retransmission and start the fast retransmit procedure.
  1432. */
  1433. if (chunk->tsn_missing_report >= 3) {
  1434. chunk->fast_retransmit = 1;
  1435. do_fast_retransmit = 1;
  1436. }
  1437. }
  1438. if (transport) {
  1439. if (do_fast_retransmit)
  1440. sctp_retransmit(q, transport, SCTP_RTXR_FAST_RTX);
  1441. SCTP_DEBUG_PRINTK("%s: transport: %p, cwnd: %d, "
  1442. "ssthresh: %d, flight_size: %d, pba: %d\n",
  1443. __func__, transport, transport->cwnd,
  1444. transport->ssthresh, transport->flight_size,
  1445. transport->partial_bytes_acked);
  1446. }
  1447. }
  1448. /* Is the given TSN acked by this packet? */
  1449. static int sctp_acked(struct sctp_sackhdr *sack, __u32 tsn)
  1450. {
  1451. int i;
  1452. sctp_sack_variable_t *frags;
  1453. __u16 gap;
  1454. __u32 ctsn = ntohl(sack->cum_tsn_ack);
  1455. if (TSN_lte(tsn, ctsn))
  1456. goto pass;
  1457. /* 3.3.4 Selective Acknowledgement (SACK) (3):
  1458. *
  1459. * Gap Ack Blocks:
  1460. * These fields contain the Gap Ack Blocks. They are repeated
  1461. * for each Gap Ack Block up to the number of Gap Ack Blocks
  1462. * defined in the Number of Gap Ack Blocks field. All DATA
  1463. * chunks with TSNs greater than or equal to (Cumulative TSN
  1464. * Ack + Gap Ack Block Start) and less than or equal to
  1465. * (Cumulative TSN Ack + Gap Ack Block End) of each Gap Ack
  1466. * Block are assumed to have been received correctly.
  1467. */
  1468. frags = sack->variable;
  1469. gap = tsn - ctsn;
  1470. for (i = 0; i < ntohs(sack->num_gap_ack_blocks); ++i) {
  1471. if (TSN_lte(ntohs(frags[i].gab.start), gap) &&
  1472. TSN_lte(gap, ntohs(frags[i].gab.end)))
  1473. goto pass;
  1474. }
  1475. return 0;
  1476. pass:
  1477. return 1;
  1478. }
  1479. static inline int sctp_get_skip_pos(struct sctp_fwdtsn_skip *skiplist,
  1480. int nskips, __be16 stream)
  1481. {
  1482. int i;
  1483. for (i = 0; i < nskips; i++) {
  1484. if (skiplist[i].stream == stream)
  1485. return i;
  1486. }
  1487. return i;
  1488. }
  1489. /* Create and add a fwdtsn chunk to the outq's control queue if needed. */
  1490. static void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 ctsn)
  1491. {
  1492. struct sctp_association *asoc = q->asoc;
  1493. struct sctp_chunk *ftsn_chunk = NULL;
  1494. struct sctp_fwdtsn_skip ftsn_skip_arr[10];
  1495. int nskips = 0;
  1496. int skip_pos = 0;
  1497. __u32 tsn;
  1498. struct sctp_chunk *chunk;
  1499. struct list_head *lchunk, *temp;
  1500. /* PR-SCTP C1) Let SackCumAck be the Cumulative TSN ACK carried in the
  1501. * received SACK.
  1502. *
  1503. * If (Advanced.Peer.Ack.Point < SackCumAck), then update
  1504. * Advanced.Peer.Ack.Point to be equal to SackCumAck.
  1505. */
  1506. if (TSN_lt(asoc->adv_peer_ack_point, ctsn))
  1507. asoc->adv_peer_ack_point = ctsn;
  1508. /* PR-SCTP C2) Try to further advance the "Advanced.Peer.Ack.Point"
  1509. * locally, that is, to move "Advanced.Peer.Ack.Point" up as long as
  1510. * the chunk next in the out-queue space is marked as "abandoned" as
  1511. * shown in the following example:
  1512. *
  1513. * Assuming that a SACK arrived with the Cumulative TSN ACK 102
  1514. * and the Advanced.Peer.Ack.Point is updated to this value:
  1515. *
  1516. * out-queue at the end of ==> out-queue after Adv.Ack.Point
  1517. * normal SACK processing local advancement
  1518. * ... ...
  1519. * Adv.Ack.Pt-> 102 acked 102 acked
  1520. * 103 abandoned 103 abandoned
  1521. * 104 abandoned Adv.Ack.P-> 104 abandoned
  1522. * 105 105
  1523. * 106 acked 106 acked
  1524. * ... ...
  1525. *
  1526. * In this example, the data sender successfully advanced the
  1527. * "Advanced.Peer.Ack.Point" from 102 to 104 locally.
  1528. */
  1529. list_for_each_safe(lchunk, temp, &q->abandoned) {
  1530. chunk = list_entry(lchunk, struct sctp_chunk,
  1531. transmitted_list);
  1532. tsn = ntohl(chunk->subh.data_hdr->tsn);
  1533. /* Remove any chunks in the abandoned queue that are acked by
  1534. * the ctsn.
  1535. */
  1536. if (TSN_lte(tsn, ctsn)) {
  1537. list_del_init(lchunk);
  1538. sctp_chunk_free(chunk);
  1539. } else {
  1540. if (TSN_lte(tsn, asoc->adv_peer_ack_point+1)) {
  1541. asoc->adv_peer_ack_point = tsn;
  1542. if (chunk->chunk_hdr->flags &
  1543. SCTP_DATA_UNORDERED)
  1544. continue;
  1545. skip_pos = sctp_get_skip_pos(&ftsn_skip_arr[0],
  1546. nskips,
  1547. chunk->subh.data_hdr->stream);
  1548. ftsn_skip_arr[skip_pos].stream =
  1549. chunk->subh.data_hdr->stream;
  1550. ftsn_skip_arr[skip_pos].ssn =
  1551. chunk->subh.data_hdr->ssn;
  1552. if (skip_pos == nskips)
  1553. nskips++;
  1554. if (nskips == 10)
  1555. break;
  1556. } else
  1557. break;
  1558. }
  1559. }
  1560. /* PR-SCTP C3) If, after step C1 and C2, the "Advanced.Peer.Ack.Point"
  1561. * is greater than the Cumulative TSN ACK carried in the received
  1562. * SACK, the data sender MUST send the data receiver a FORWARD TSN
  1563. * chunk containing the latest value of the
  1564. * "Advanced.Peer.Ack.Point".
  1565. *
  1566. * C4) For each "abandoned" TSN the sender of the FORWARD TSN SHOULD
  1567. * list each stream and sequence number in the forwarded TSN. This
  1568. * information will enable the receiver to easily find any
  1569. * stranded TSN's waiting on stream reorder queues. Each stream
  1570. * SHOULD only be reported once; this means that if multiple
  1571. * abandoned messages occur in the same stream then only the
  1572. * highest abandoned stream sequence number is reported. If the
  1573. * total size of the FORWARD TSN does NOT fit in a single MTU then
  1574. * the sender of the FORWARD TSN SHOULD lower the
  1575. * Advanced.Peer.Ack.Point to the last TSN that will fit in a
  1576. * single MTU.
  1577. */
  1578. if (asoc->adv_peer_ack_point > ctsn)
  1579. ftsn_chunk = sctp_make_fwdtsn(asoc, asoc->adv_peer_ack_point,
  1580. nskips, &ftsn_skip_arr[0]);
  1581. if (ftsn_chunk) {
  1582. list_add_tail(&ftsn_chunk->list, &q->control_chunk_list);
  1583. SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS);
  1584. }
  1585. }