outqueue.c 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778
  1. /* SCTP kernel reference 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 reference Implementation
  8. *
  9. * These functions implement the sctp_outq class. The outqueue handles
  10. * bundling and queueing of outgoing SCTP chunks.
  11. *
  12. * The SCTP reference 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. * The SCTP reference 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, *pos, *temp;
  207. struct sctp_chunk *chunk, *tmp;
  208. /* Throw away unacknowledged chunks. */
  209. list_for_each(pos, &q->asoc->peer.transport_addr_list) {
  210. transport = list_entry(pos, struct sctp_transport, 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", __FUNCTION__,
  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. break;
  446. case SCTP_RTXR_FAST_RTX:
  447. SCTP_INC_STATS(SCTP_MIB_FAST_RETRANSMITS);
  448. sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_FAST_RTX);
  449. break;
  450. case SCTP_RTXR_PMTUD:
  451. SCTP_INC_STATS(SCTP_MIB_PMTUD_RETRANSMITS);
  452. break;
  453. case SCTP_RTXR_T1_RTX:
  454. SCTP_INC_STATS(SCTP_MIB_T1_RETRANSMITS);
  455. break;
  456. default:
  457. BUG();
  458. }
  459. sctp_retransmit_mark(q, transport, reason);
  460. /* PR-SCTP A5) Any time the T3-rtx timer expires, on any destination,
  461. * the sender SHOULD try to advance the "Advanced.Peer.Ack.Point" by
  462. * following the procedures outlined in C1 - C5.
  463. */
  464. sctp_generate_fwdtsn(q, q->asoc->ctsn_ack_point);
  465. error = sctp_outq_flush(q, /* rtx_timeout */ 1);
  466. if (error)
  467. q->asoc->base.sk->sk_err = -error;
  468. }
  469. /*
  470. * Transmit DATA chunks on the retransmit queue. Upon return from
  471. * sctp_outq_flush_rtx() the packet 'pkt' may contain chunks which
  472. * need to be transmitted by the caller.
  473. * We assume that pkt->transport has already been set.
  474. *
  475. * The return value is a normal kernel error return value.
  476. */
  477. static int sctp_outq_flush_rtx(struct sctp_outq *q, struct sctp_packet *pkt,
  478. int rtx_timeout, int *start_timer)
  479. {
  480. struct list_head *lqueue;
  481. struct list_head *lchunk, *lchunk1;
  482. struct sctp_transport *transport = pkt->transport;
  483. sctp_xmit_t status;
  484. struct sctp_chunk *chunk, *chunk1;
  485. struct sctp_association *asoc;
  486. int error = 0;
  487. asoc = q->asoc;
  488. lqueue = &q->retransmit;
  489. /* RFC 2960 6.3.3 Handle T3-rtx Expiration
  490. *
  491. * E3) Determine how many of the earliest (i.e., lowest TSN)
  492. * outstanding DATA chunks for the address for which the
  493. * T3-rtx has expired will fit into a single packet, subject
  494. * to the MTU constraint for the path corresponding to the
  495. * destination transport address to which the retransmission
  496. * is being sent (this may be different from the address for
  497. * which the timer expires [see Section 6.4]). Call this value
  498. * K. Bundle and retransmit those K DATA chunks in a single
  499. * packet to the destination endpoint.
  500. *
  501. * [Just to be painfully clear, if we are retransmitting
  502. * because a timeout just happened, we should send only ONE
  503. * packet of retransmitted data.]
  504. */
  505. lchunk = sctp_list_dequeue(lqueue);
  506. while (lchunk) {
  507. chunk = list_entry(lchunk, struct sctp_chunk,
  508. transmitted_list);
  509. /* Make sure that Gap Acked TSNs are not retransmitted. A
  510. * simple approach is just to move such TSNs out of the
  511. * way and into a 'transmitted' queue and skip to the
  512. * next chunk.
  513. */
  514. if (chunk->tsn_gap_acked) {
  515. list_add_tail(lchunk, &transport->transmitted);
  516. lchunk = sctp_list_dequeue(lqueue);
  517. continue;
  518. }
  519. /* Attempt to append this chunk to the packet. */
  520. status = sctp_packet_append_chunk(pkt, chunk);
  521. switch (status) {
  522. case SCTP_XMIT_PMTU_FULL:
  523. /* Send this packet. */
  524. if ((error = sctp_packet_transmit(pkt)) == 0)
  525. *start_timer = 1;
  526. /* If we are retransmitting, we should only
  527. * send a single packet.
  528. */
  529. if (rtx_timeout) {
  530. list_add(lchunk, lqueue);
  531. lchunk = NULL;
  532. }
  533. /* Bundle lchunk in the next round. */
  534. break;
  535. case SCTP_XMIT_RWND_FULL:
  536. /* Send this packet. */
  537. if ((error = sctp_packet_transmit(pkt)) == 0)
  538. *start_timer = 1;
  539. /* Stop sending DATA as there is no more room
  540. * at the receiver.
  541. */
  542. list_add(lchunk, lqueue);
  543. lchunk = NULL;
  544. break;
  545. case SCTP_XMIT_NAGLE_DELAY:
  546. /* Send this packet. */
  547. if ((error = sctp_packet_transmit(pkt)) == 0)
  548. *start_timer = 1;
  549. /* Stop sending DATA because of nagle delay. */
  550. list_add(lchunk, lqueue);
  551. lchunk = NULL;
  552. break;
  553. default:
  554. /* The append was successful, so add this chunk to
  555. * the transmitted list.
  556. */
  557. list_add_tail(lchunk, &transport->transmitted);
  558. /* Mark the chunk as ineligible for fast retransmit
  559. * after it is retransmitted.
  560. */
  561. if (chunk->fast_retransmit > 0)
  562. chunk->fast_retransmit = -1;
  563. *start_timer = 1;
  564. q->empty = 0;
  565. /* Retrieve a new chunk to bundle. */
  566. lchunk = sctp_list_dequeue(lqueue);
  567. break;
  568. }
  569. /* If we are here due to a retransmit timeout or a fast
  570. * retransmit and if there are any chunks left in the retransmit
  571. * queue that could not fit in the PMTU sized packet, they need
  572. * to be marked as ineligible for a subsequent fast retransmit.
  573. */
  574. if (rtx_timeout && !lchunk) {
  575. list_for_each(lchunk1, lqueue) {
  576. chunk1 = list_entry(lchunk1, struct sctp_chunk,
  577. transmitted_list);
  578. if (chunk1->fast_retransmit > 0)
  579. chunk1->fast_retransmit = -1;
  580. }
  581. }
  582. }
  583. return error;
  584. }
  585. /* Cork the outqueue so queued chunks are really queued. */
  586. int sctp_outq_uncork(struct sctp_outq *q)
  587. {
  588. int error = 0;
  589. if (q->cork) {
  590. q->cork = 0;
  591. error = sctp_outq_flush(q, 0);
  592. }
  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. new_transport = asoc->peer.active_path;
  638. } else if ((new_transport->state == SCTP_INACTIVE) ||
  639. (new_transport->state == SCTP_UNCONFIRMED)) {
  640. /* If the chunk is Heartbeat or Heartbeat Ack,
  641. * send it to chunk->transport, even if it's
  642. * inactive.
  643. *
  644. * 3.3.6 Heartbeat Acknowledgement:
  645. * ...
  646. * A HEARTBEAT ACK is always sent to the source IP
  647. * address of the IP datagram containing the
  648. * HEARTBEAT chunk to which this ack is responding.
  649. * ...
  650. */
  651. if (chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT &&
  652. chunk->chunk_hdr->type != SCTP_CID_HEARTBEAT_ACK)
  653. new_transport = asoc->peer.active_path;
  654. }
  655. /* Are we switching transports?
  656. * Take care of transport locks.
  657. */
  658. if (new_transport != transport) {
  659. transport = new_transport;
  660. if (list_empty(&transport->send_ready)) {
  661. list_add_tail(&transport->send_ready,
  662. &transport_list);
  663. }
  664. packet = &transport->packet;
  665. sctp_packet_config(packet, vtag,
  666. asoc->peer.ecn_capable);
  667. }
  668. switch (chunk->chunk_hdr->type) {
  669. /*
  670. * 6.10 Bundling
  671. * ...
  672. * An endpoint MUST NOT bundle INIT, INIT ACK or SHUTDOWN
  673. * COMPLETE with any other chunks. [Send them immediately.]
  674. */
  675. case SCTP_CID_INIT:
  676. case SCTP_CID_INIT_ACK:
  677. case SCTP_CID_SHUTDOWN_COMPLETE:
  678. sctp_packet_init(&singleton, transport, sport, dport);
  679. sctp_packet_config(&singleton, vtag, 0);
  680. sctp_packet_append_chunk(&singleton, chunk);
  681. error = sctp_packet_transmit(&singleton);
  682. if (error < 0)
  683. return error;
  684. break;
  685. case SCTP_CID_ABORT:
  686. case SCTP_CID_SACK:
  687. case SCTP_CID_HEARTBEAT:
  688. case SCTP_CID_HEARTBEAT_ACK:
  689. case SCTP_CID_SHUTDOWN:
  690. case SCTP_CID_SHUTDOWN_ACK:
  691. case SCTP_CID_ERROR:
  692. case SCTP_CID_COOKIE_ECHO:
  693. case SCTP_CID_COOKIE_ACK:
  694. case SCTP_CID_ECN_ECNE:
  695. case SCTP_CID_ECN_CWR:
  696. case SCTP_CID_ASCONF:
  697. case SCTP_CID_ASCONF_ACK:
  698. case SCTP_CID_FWD_TSN:
  699. sctp_packet_transmit_chunk(packet, chunk);
  700. break;
  701. default:
  702. /* We built a chunk with an illegal type! */
  703. BUG();
  704. }
  705. }
  706. /* Is it OK to send data chunks? */
  707. switch (asoc->state) {
  708. case SCTP_STATE_COOKIE_ECHOED:
  709. /* Only allow bundling when this packet has a COOKIE-ECHO
  710. * chunk.
  711. */
  712. if (!packet || !packet->has_cookie_echo)
  713. break;
  714. /* fallthru */
  715. case SCTP_STATE_ESTABLISHED:
  716. case SCTP_STATE_SHUTDOWN_PENDING:
  717. case SCTP_STATE_SHUTDOWN_RECEIVED:
  718. /*
  719. * RFC 2960 6.1 Transmission of DATA Chunks
  720. *
  721. * C) When the time comes for the sender to transmit,
  722. * before sending new DATA chunks, the sender MUST
  723. * first transmit any outstanding DATA chunks which
  724. * are marked for retransmission (limited by the
  725. * current cwnd).
  726. */
  727. if (!list_empty(&q->retransmit)) {
  728. if (transport == asoc->peer.retran_path)
  729. goto retran;
  730. /* Switch transports & prepare the packet. */
  731. transport = asoc->peer.retran_path;
  732. if (list_empty(&transport->send_ready)) {
  733. list_add_tail(&transport->send_ready,
  734. &transport_list);
  735. }
  736. packet = &transport->packet;
  737. sctp_packet_config(packet, vtag,
  738. asoc->peer.ecn_capable);
  739. retran:
  740. error = sctp_outq_flush_rtx(q, packet,
  741. rtx_timeout, &start_timer);
  742. if (start_timer)
  743. sctp_transport_reset_timers(transport);
  744. /* This can happen on COOKIE-ECHO resend. Only
  745. * one chunk can get bundled with a COOKIE-ECHO.
  746. */
  747. if (packet->has_cookie_echo)
  748. goto sctp_flush_out;
  749. /* Don't send new data if there is still data
  750. * waiting to retransmit.
  751. */
  752. if (!list_empty(&q->retransmit))
  753. goto sctp_flush_out;
  754. }
  755. /* Finally, transmit new packets. */
  756. start_timer = 0;
  757. while ((chunk = sctp_outq_dequeue_data(q)) != NULL) {
  758. /* RFC 2960 6.5 Every DATA chunk MUST carry a valid
  759. * stream identifier.
  760. */
  761. if (chunk->sinfo.sinfo_stream >=
  762. asoc->c.sinit_num_ostreams) {
  763. /* Mark as failed send. */
  764. sctp_chunk_fail(chunk, SCTP_ERROR_INV_STRM);
  765. sctp_chunk_free(chunk);
  766. continue;
  767. }
  768. /* Has this chunk expired? */
  769. if (sctp_chunk_abandoned(chunk)) {
  770. sctp_chunk_fail(chunk, 0);
  771. sctp_chunk_free(chunk);
  772. continue;
  773. }
  774. /* If there is a specified transport, use it.
  775. * Otherwise, we want to use the active path.
  776. */
  777. new_transport = chunk->transport;
  778. if (!new_transport ||
  779. ((new_transport->state == SCTP_INACTIVE) ||
  780. (new_transport->state == SCTP_UNCONFIRMED)))
  781. new_transport = asoc->peer.active_path;
  782. /* Change packets if necessary. */
  783. if (new_transport != transport) {
  784. transport = new_transport;
  785. /* Schedule to have this transport's
  786. * packet flushed.
  787. */
  788. if (list_empty(&transport->send_ready)) {
  789. list_add_tail(&transport->send_ready,
  790. &transport_list);
  791. }
  792. packet = &transport->packet;
  793. sctp_packet_config(packet, vtag,
  794. asoc->peer.ecn_capable);
  795. }
  796. SCTP_DEBUG_PRINTK("sctp_outq_flush(%p, %p[%s]), ",
  797. q, chunk,
  798. chunk && chunk->chunk_hdr ?
  799. sctp_cname(SCTP_ST_CHUNK(
  800. chunk->chunk_hdr->type))
  801. : "Illegal Chunk");
  802. SCTP_DEBUG_PRINTK("TX TSN 0x%x skb->head "
  803. "%p skb->users %d.\n",
  804. ntohl(chunk->subh.data_hdr->tsn),
  805. chunk->skb ?chunk->skb->head : NULL,
  806. chunk->skb ?
  807. atomic_read(&chunk->skb->users) : -1);
  808. /* Add the chunk to the packet. */
  809. status = sctp_packet_transmit_chunk(packet, chunk);
  810. switch (status) {
  811. case SCTP_XMIT_PMTU_FULL:
  812. case SCTP_XMIT_RWND_FULL:
  813. case SCTP_XMIT_NAGLE_DELAY:
  814. /* We could not append this chunk, so put
  815. * the chunk back on the output queue.
  816. */
  817. SCTP_DEBUG_PRINTK("sctp_outq_flush: could "
  818. "not transmit TSN: 0x%x, status: %d\n",
  819. ntohl(chunk->subh.data_hdr->tsn),
  820. status);
  821. sctp_outq_head_data(q, chunk);
  822. goto sctp_flush_out;
  823. break;
  824. case SCTP_XMIT_OK:
  825. break;
  826. default:
  827. BUG();
  828. }
  829. /* BUG: We assume that the sctp_packet_transmit()
  830. * call below will succeed all the time and add the
  831. * chunk to the transmitted list and restart the
  832. * timers.
  833. * It is possible that the call can fail under OOM
  834. * conditions.
  835. *
  836. * Is this really a problem? Won't this behave
  837. * like a lost TSN?
  838. */
  839. list_add_tail(&chunk->transmitted_list,
  840. &transport->transmitted);
  841. sctp_transport_reset_timers(transport);
  842. q->empty = 0;
  843. /* Only let one DATA chunk get bundled with a
  844. * COOKIE-ECHO chunk.
  845. */
  846. if (packet->has_cookie_echo)
  847. goto sctp_flush_out;
  848. }
  849. break;
  850. default:
  851. /* Do nothing. */
  852. break;
  853. }
  854. sctp_flush_out:
  855. /* Before returning, examine all the transports touched in
  856. * this call. Right now, we bluntly force clear all the
  857. * transports. Things might change after we implement Nagle.
  858. * But such an examination is still required.
  859. *
  860. * --xguo
  861. */
  862. while ((ltransport = sctp_list_dequeue(&transport_list)) != NULL ) {
  863. struct sctp_transport *t = list_entry(ltransport,
  864. struct sctp_transport,
  865. send_ready);
  866. packet = &t->packet;
  867. if (!sctp_packet_empty(packet))
  868. error = sctp_packet_transmit(packet);
  869. }
  870. return error;
  871. }
  872. /* Update unack_data based on the incoming SACK chunk */
  873. static void sctp_sack_update_unack_data(struct sctp_association *assoc,
  874. struct sctp_sackhdr *sack)
  875. {
  876. sctp_sack_variable_t *frags;
  877. __u16 unack_data;
  878. int i;
  879. unack_data = assoc->next_tsn - assoc->ctsn_ack_point - 1;
  880. frags = sack->variable;
  881. for (i = 0; i < ntohs(sack->num_gap_ack_blocks); i++) {
  882. unack_data -= ((ntohs(frags[i].gab.end) -
  883. ntohs(frags[i].gab.start) + 1));
  884. }
  885. assoc->unack_data = unack_data;
  886. }
  887. /* Return the highest new tsn that is acknowledged by the given SACK chunk. */
  888. static __u32 sctp_highest_new_tsn(struct sctp_sackhdr *sack,
  889. struct sctp_association *asoc)
  890. {
  891. struct list_head *ltransport, *lchunk;
  892. struct sctp_transport *transport;
  893. struct sctp_chunk *chunk;
  894. __u32 highest_new_tsn, tsn;
  895. struct list_head *transport_list = &asoc->peer.transport_addr_list;
  896. highest_new_tsn = ntohl(sack->cum_tsn_ack);
  897. list_for_each(ltransport, transport_list) {
  898. transport = list_entry(ltransport, struct sctp_transport,
  899. transports);
  900. list_for_each(lchunk, &transport->transmitted) {
  901. chunk = list_entry(lchunk, struct sctp_chunk,
  902. transmitted_list);
  903. tsn = ntohl(chunk->subh.data_hdr->tsn);
  904. if (!chunk->tsn_gap_acked &&
  905. TSN_lt(highest_new_tsn, tsn) &&
  906. sctp_acked(sack, tsn))
  907. highest_new_tsn = tsn;
  908. }
  909. }
  910. return highest_new_tsn;
  911. }
  912. /* This is where we REALLY process a SACK.
  913. *
  914. * Process the SACK against the outqueue. Mostly, this just frees
  915. * things off the transmitted queue.
  916. */
  917. int sctp_outq_sack(struct sctp_outq *q, struct sctp_sackhdr *sack)
  918. {
  919. struct sctp_association *asoc = q->asoc;
  920. struct sctp_transport *transport;
  921. struct sctp_chunk *tchunk = NULL;
  922. struct list_head *lchunk, *transport_list, *pos, *temp;
  923. sctp_sack_variable_t *frags = sack->variable;
  924. __u32 sack_ctsn, ctsn, tsn;
  925. __u32 highest_tsn, highest_new_tsn;
  926. __u32 sack_a_rwnd;
  927. unsigned outstanding;
  928. struct sctp_transport *primary = asoc->peer.primary_path;
  929. int count_of_newacks = 0;
  930. /* Grab the association's destination address list. */
  931. transport_list = &asoc->peer.transport_addr_list;
  932. sack_ctsn = ntohl(sack->cum_tsn_ack);
  933. /*
  934. * SFR-CACC algorithm:
  935. * On receipt of a SACK the sender SHOULD execute the
  936. * following statements.
  937. *
  938. * 1) If the cumulative ack in the SACK passes next tsn_at_change
  939. * on the current primary, the CHANGEOVER_ACTIVE flag SHOULD be
  940. * cleared. The CYCLING_CHANGEOVER flag SHOULD also be cleared for
  941. * all destinations.
  942. */
  943. if (TSN_lte(primary->cacc.next_tsn_at_change, sack_ctsn)) {
  944. primary->cacc.changeover_active = 0;
  945. list_for_each(pos, transport_list) {
  946. transport = list_entry(pos, struct sctp_transport,
  947. transports);
  948. transport->cacc.cycling_changeover = 0;
  949. }
  950. }
  951. /*
  952. * SFR-CACC algorithm:
  953. * 2) If the SACK contains gap acks and the flag CHANGEOVER_ACTIVE
  954. * is set the receiver of the SACK MUST take the following actions:
  955. *
  956. * A) Initialize the cacc_saw_newack to 0 for all destination
  957. * addresses.
  958. */
  959. if (sack->num_gap_ack_blocks &&
  960. primary->cacc.changeover_active) {
  961. list_for_each(pos, transport_list) {
  962. transport = list_entry(pos, struct sctp_transport,
  963. transports);
  964. transport->cacc.cacc_saw_newack = 0;
  965. }
  966. }
  967. /* Get the highest TSN in the sack. */
  968. highest_tsn = sack_ctsn;
  969. if (sack->num_gap_ack_blocks)
  970. highest_tsn +=
  971. ntohs(frags[ntohs(sack->num_gap_ack_blocks) - 1].gab.end);
  972. if (TSN_lt(asoc->highest_sacked, highest_tsn)) {
  973. highest_new_tsn = highest_tsn;
  974. asoc->highest_sacked = highest_tsn;
  975. } else {
  976. highest_new_tsn = sctp_highest_new_tsn(sack, asoc);
  977. }
  978. /* Run through the retransmit queue. Credit bytes received
  979. * and free those chunks that we can.
  980. */
  981. sctp_check_transmitted(q, &q->retransmit, NULL, sack, highest_new_tsn);
  982. sctp_mark_missing(q, &q->retransmit, NULL, highest_new_tsn, 0);
  983. /* Run through the transmitted queue.
  984. * Credit bytes received and free those chunks which we can.
  985. *
  986. * This is a MASSIVE candidate for optimization.
  987. */
  988. list_for_each(pos, transport_list) {
  989. transport = list_entry(pos, struct sctp_transport,
  990. transports);
  991. sctp_check_transmitted(q, &transport->transmitted,
  992. transport, sack, highest_new_tsn);
  993. /*
  994. * SFR-CACC algorithm:
  995. * C) Let count_of_newacks be the number of
  996. * destinations for which cacc_saw_newack is set.
  997. */
  998. if (transport->cacc.cacc_saw_newack)
  999. count_of_newacks ++;
  1000. }
  1001. list_for_each(pos, transport_list) {
  1002. transport = list_entry(pos, struct sctp_transport,
  1003. transports);
  1004. sctp_mark_missing(q, &transport->transmitted, transport,
  1005. highest_new_tsn, count_of_newacks);
  1006. }
  1007. /* Move the Cumulative TSN Ack Point if appropriate. */
  1008. if (TSN_lt(asoc->ctsn_ack_point, sack_ctsn))
  1009. asoc->ctsn_ack_point = sack_ctsn;
  1010. /* Update unack_data field in the assoc. */
  1011. sctp_sack_update_unack_data(asoc, sack);
  1012. ctsn = asoc->ctsn_ack_point;
  1013. /* Throw away stuff rotting on the sack queue. */
  1014. list_for_each_safe(lchunk, temp, &q->sacked) {
  1015. tchunk = list_entry(lchunk, struct sctp_chunk,
  1016. transmitted_list);
  1017. tsn = ntohl(tchunk->subh.data_hdr->tsn);
  1018. if (TSN_lte(tsn, ctsn))
  1019. sctp_chunk_free(tchunk);
  1020. }
  1021. /* ii) Set rwnd equal to the newly received a_rwnd minus the
  1022. * number of bytes still outstanding after processing the
  1023. * Cumulative TSN Ack and the Gap Ack Blocks.
  1024. */
  1025. sack_a_rwnd = ntohl(sack->a_rwnd);
  1026. outstanding = q->outstanding_bytes;
  1027. if (outstanding < sack_a_rwnd)
  1028. sack_a_rwnd -= outstanding;
  1029. else
  1030. sack_a_rwnd = 0;
  1031. asoc->peer.rwnd = sack_a_rwnd;
  1032. sctp_generate_fwdtsn(q, sack_ctsn);
  1033. SCTP_DEBUG_PRINTK("%s: sack Cumulative TSN Ack is 0x%x.\n",
  1034. __FUNCTION__, sack_ctsn);
  1035. SCTP_DEBUG_PRINTK("%s: Cumulative TSN Ack of association, "
  1036. "%p is 0x%x. Adv peer ack point: 0x%x\n",
  1037. __FUNCTION__, asoc, ctsn, asoc->adv_peer_ack_point);
  1038. /* See if all chunks are acked.
  1039. * Make sure the empty queue handler will get run later.
  1040. */
  1041. q->empty = (list_empty(&q->out_chunk_list) &&
  1042. list_empty(&q->control_chunk_list) &&
  1043. list_empty(&q->retransmit));
  1044. if (!q->empty)
  1045. goto finish;
  1046. list_for_each(pos, transport_list) {
  1047. transport = list_entry(pos, struct sctp_transport,
  1048. transports);
  1049. q->empty = q->empty && list_empty(&transport->transmitted);
  1050. if (!q->empty)
  1051. goto finish;
  1052. }
  1053. SCTP_DEBUG_PRINTK("sack queue is empty.\n");
  1054. finish:
  1055. return q->empty;
  1056. }
  1057. /* Is the outqueue empty? */
  1058. int sctp_outq_is_empty(const struct sctp_outq *q)
  1059. {
  1060. return q->empty;
  1061. }
  1062. /********************************************************************
  1063. * 2nd Level Abstractions
  1064. ********************************************************************/
  1065. /* Go through a transport's transmitted list or the association's retransmit
  1066. * list and move chunks that are acked by the Cumulative TSN Ack to q->sacked.
  1067. * The retransmit list will not have an associated transport.
  1068. *
  1069. * I added coherent debug information output. --xguo
  1070. *
  1071. * Instead of printing 'sacked' or 'kept' for each TSN on the
  1072. * transmitted_queue, we print a range: SACKED: TSN1-TSN2, TSN3, TSN4-TSN5.
  1073. * KEPT TSN6-TSN7, etc.
  1074. */
  1075. static void sctp_check_transmitted(struct sctp_outq *q,
  1076. struct list_head *transmitted_queue,
  1077. struct sctp_transport *transport,
  1078. struct sctp_sackhdr *sack,
  1079. __u32 highest_new_tsn_in_sack)
  1080. {
  1081. struct list_head *lchunk;
  1082. struct sctp_chunk *tchunk;
  1083. struct list_head tlist;
  1084. __u32 tsn;
  1085. __u32 sack_ctsn;
  1086. __u32 rtt;
  1087. __u8 restart_timer = 0;
  1088. int bytes_acked = 0;
  1089. /* These state variables are for coherent debug output. --xguo */
  1090. #if SCTP_DEBUG
  1091. __u32 dbg_ack_tsn = 0; /* An ACKed TSN range starts here... */
  1092. __u32 dbg_last_ack_tsn = 0; /* ...and finishes here. */
  1093. __u32 dbg_kept_tsn = 0; /* An un-ACKed range starts here... */
  1094. __u32 dbg_last_kept_tsn = 0; /* ...and finishes here. */
  1095. /* 0 : The last TSN was ACKed.
  1096. * 1 : The last TSN was NOT ACKed (i.e. KEPT).
  1097. * -1: We need to initialize.
  1098. */
  1099. int dbg_prt_state = -1;
  1100. #endif /* SCTP_DEBUG */
  1101. sack_ctsn = ntohl(sack->cum_tsn_ack);
  1102. INIT_LIST_HEAD(&tlist);
  1103. /* The while loop will skip empty transmitted queues. */
  1104. while (NULL != (lchunk = sctp_list_dequeue(transmitted_queue))) {
  1105. tchunk = list_entry(lchunk, struct sctp_chunk,
  1106. transmitted_list);
  1107. if (sctp_chunk_abandoned(tchunk)) {
  1108. /* Move the chunk to abandoned list. */
  1109. sctp_insert_list(&q->abandoned, lchunk);
  1110. /* If this chunk has not been acked, stop
  1111. * considering it as 'outstanding'.
  1112. */
  1113. if (!tchunk->tsn_gap_acked) {
  1114. tchunk->transport->flight_size -=
  1115. sctp_data_size(tchunk);
  1116. q->outstanding_bytes -= sctp_data_size(tchunk);
  1117. }
  1118. continue;
  1119. }
  1120. tsn = ntohl(tchunk->subh.data_hdr->tsn);
  1121. if (sctp_acked(sack, tsn)) {
  1122. /* If this queue is the retransmit queue, the
  1123. * retransmit timer has already reclaimed
  1124. * the outstanding bytes for this chunk, so only
  1125. * count bytes associated with a transport.
  1126. */
  1127. if (transport) {
  1128. /* If this chunk is being used for RTT
  1129. * measurement, calculate the RTT and update
  1130. * the RTO using this value.
  1131. *
  1132. * 6.3.1 C5) Karn's algorithm: RTT measurements
  1133. * MUST NOT be made using packets that were
  1134. * retransmitted (and thus for which it is
  1135. * ambiguous whether the reply was for the
  1136. * first instance of the packet or a later
  1137. * instance).
  1138. */
  1139. if (!tchunk->tsn_gap_acked &&
  1140. !tchunk->resent &&
  1141. tchunk->rtt_in_progress) {
  1142. tchunk->rtt_in_progress = 0;
  1143. rtt = jiffies - tchunk->sent_at;
  1144. sctp_transport_update_rto(transport,
  1145. rtt);
  1146. }
  1147. }
  1148. if (TSN_lte(tsn, sack_ctsn)) {
  1149. /* RFC 2960 6.3.2 Retransmission Timer Rules
  1150. *
  1151. * R3) Whenever a SACK is received
  1152. * that acknowledges the DATA chunk
  1153. * with the earliest outstanding TSN
  1154. * for that address, restart T3-rtx
  1155. * timer for that address with its
  1156. * current RTO.
  1157. */
  1158. restart_timer = 1;
  1159. if (!tchunk->tsn_gap_acked) {
  1160. tchunk->tsn_gap_acked = 1;
  1161. bytes_acked += sctp_data_size(tchunk);
  1162. /*
  1163. * SFR-CACC algorithm:
  1164. * 2) If the SACK contains gap acks
  1165. * and the flag CHANGEOVER_ACTIVE is
  1166. * set the receiver of the SACK MUST
  1167. * take the following action:
  1168. *
  1169. * B) For each TSN t being acked that
  1170. * has not been acked in any SACK so
  1171. * far, set cacc_saw_newack to 1 for
  1172. * the destination that the TSN was
  1173. * sent to.
  1174. */
  1175. if (transport &&
  1176. sack->num_gap_ack_blocks &&
  1177. q->asoc->peer.primary_path->cacc.
  1178. changeover_active)
  1179. transport->cacc.cacc_saw_newack
  1180. = 1;
  1181. }
  1182. list_add_tail(&tchunk->transmitted_list,
  1183. &q->sacked);
  1184. } else {
  1185. /* RFC2960 7.2.4, sctpimpguide-05 2.8.2
  1186. * M2) Each time a SACK arrives reporting
  1187. * 'Stray DATA chunk(s)' record the highest TSN
  1188. * reported as newly acknowledged, call this
  1189. * value 'HighestTSNinSack'. A newly
  1190. * acknowledged DATA chunk is one not
  1191. * previously acknowledged in a SACK.
  1192. *
  1193. * When the SCTP sender of data receives a SACK
  1194. * chunk that acknowledges, for the first time,
  1195. * the receipt of a DATA chunk, all the still
  1196. * unacknowledged DATA chunks whose TSN is
  1197. * older than that newly acknowledged DATA
  1198. * chunk, are qualified as 'Stray DATA chunks'.
  1199. */
  1200. if (!tchunk->tsn_gap_acked) {
  1201. tchunk->tsn_gap_acked = 1;
  1202. bytes_acked += sctp_data_size(tchunk);
  1203. }
  1204. list_add_tail(lchunk, &tlist);
  1205. }
  1206. #if SCTP_DEBUG
  1207. switch (dbg_prt_state) {
  1208. case 0: /* last TSN was ACKed */
  1209. if (dbg_last_ack_tsn + 1 == tsn) {
  1210. /* This TSN belongs to the
  1211. * current ACK range.
  1212. */
  1213. break;
  1214. }
  1215. if (dbg_last_ack_tsn != dbg_ack_tsn) {
  1216. /* Display the end of the
  1217. * current range.
  1218. */
  1219. SCTP_DEBUG_PRINTK("-%08x",
  1220. dbg_last_ack_tsn);
  1221. }
  1222. /* Start a new range. */
  1223. SCTP_DEBUG_PRINTK(",%08x", tsn);
  1224. dbg_ack_tsn = tsn;
  1225. break;
  1226. case 1: /* The last TSN was NOT ACKed. */
  1227. if (dbg_last_kept_tsn != dbg_kept_tsn) {
  1228. /* Display the end of current range. */
  1229. SCTP_DEBUG_PRINTK("-%08x",
  1230. dbg_last_kept_tsn);
  1231. }
  1232. SCTP_DEBUG_PRINTK("\n");
  1233. /* FALL THROUGH... */
  1234. default:
  1235. /* This is the first-ever TSN we examined. */
  1236. /* Start a new range of ACK-ed TSNs. */
  1237. SCTP_DEBUG_PRINTK("ACKed: %08x", tsn);
  1238. dbg_prt_state = 0;
  1239. dbg_ack_tsn = tsn;
  1240. }
  1241. dbg_last_ack_tsn = tsn;
  1242. #endif /* SCTP_DEBUG */
  1243. } else {
  1244. if (tchunk->tsn_gap_acked) {
  1245. SCTP_DEBUG_PRINTK("%s: Receiver reneged on "
  1246. "data TSN: 0x%x\n",
  1247. __FUNCTION__,
  1248. tsn);
  1249. tchunk->tsn_gap_acked = 0;
  1250. bytes_acked -= sctp_data_size(tchunk);
  1251. /* RFC 2960 6.3.2 Retransmission Timer Rules
  1252. *
  1253. * R4) Whenever a SACK is received missing a
  1254. * TSN that was previously acknowledged via a
  1255. * Gap Ack Block, start T3-rtx for the
  1256. * destination address to which the DATA
  1257. * chunk was originally
  1258. * transmitted if it is not already running.
  1259. */
  1260. restart_timer = 1;
  1261. }
  1262. list_add_tail(lchunk, &tlist);
  1263. #if SCTP_DEBUG
  1264. /* See the above comments on ACK-ed TSNs. */
  1265. switch (dbg_prt_state) {
  1266. case 1:
  1267. if (dbg_last_kept_tsn + 1 == tsn)
  1268. break;
  1269. if (dbg_last_kept_tsn != dbg_kept_tsn)
  1270. SCTP_DEBUG_PRINTK("-%08x",
  1271. dbg_last_kept_tsn);
  1272. SCTP_DEBUG_PRINTK(",%08x", tsn);
  1273. dbg_kept_tsn = tsn;
  1274. break;
  1275. case 0:
  1276. if (dbg_last_ack_tsn != dbg_ack_tsn)
  1277. SCTP_DEBUG_PRINTK("-%08x",
  1278. dbg_last_ack_tsn);
  1279. SCTP_DEBUG_PRINTK("\n");
  1280. /* FALL THROUGH... */
  1281. default:
  1282. SCTP_DEBUG_PRINTK("KEPT: %08x",tsn);
  1283. dbg_prt_state = 1;
  1284. dbg_kept_tsn = tsn;
  1285. }
  1286. dbg_last_kept_tsn = tsn;
  1287. #endif /* SCTP_DEBUG */
  1288. }
  1289. }
  1290. #if SCTP_DEBUG
  1291. /* Finish off the last range, displaying its ending TSN. */
  1292. switch (dbg_prt_state) {
  1293. case 0:
  1294. if (dbg_last_ack_tsn != dbg_ack_tsn) {
  1295. SCTP_DEBUG_PRINTK("-%08x\n", dbg_last_ack_tsn);
  1296. } else {
  1297. SCTP_DEBUG_PRINTK("\n");
  1298. }
  1299. break;
  1300. case 1:
  1301. if (dbg_last_kept_tsn != dbg_kept_tsn) {
  1302. SCTP_DEBUG_PRINTK("-%08x\n", dbg_last_kept_tsn);
  1303. } else {
  1304. SCTP_DEBUG_PRINTK("\n");
  1305. }
  1306. }
  1307. #endif /* SCTP_DEBUG */
  1308. if (transport) {
  1309. if (bytes_acked) {
  1310. /* 8.2. When an outstanding TSN is acknowledged,
  1311. * the endpoint shall clear the error counter of
  1312. * the destination transport address to which the
  1313. * DATA chunk was last sent.
  1314. * The association's overall error counter is
  1315. * also cleared.
  1316. */
  1317. transport->error_count = 0;
  1318. transport->asoc->overall_error_count = 0;
  1319. /* Mark the destination transport address as
  1320. * active if it is not so marked.
  1321. */
  1322. if ((transport->state == SCTP_INACTIVE) ||
  1323. (transport->state == SCTP_UNCONFIRMED)) {
  1324. sctp_assoc_control_transport(
  1325. transport->asoc,
  1326. transport,
  1327. SCTP_TRANSPORT_UP,
  1328. SCTP_RECEIVED_SACK);
  1329. }
  1330. sctp_transport_raise_cwnd(transport, sack_ctsn,
  1331. bytes_acked);
  1332. transport->flight_size -= bytes_acked;
  1333. q->outstanding_bytes -= bytes_acked;
  1334. } else {
  1335. /* RFC 2960 6.1, sctpimpguide-06 2.15.2
  1336. * When a sender is doing zero window probing, it
  1337. * should not timeout the association if it continues
  1338. * to receive new packets from the receiver. The
  1339. * reason is that the receiver MAY keep its window
  1340. * closed for an indefinite time.
  1341. * A sender is doing zero window probing when the
  1342. * receiver's advertised window is zero, and there is
  1343. * only one data chunk in flight to the receiver.
  1344. */
  1345. if (!q->asoc->peer.rwnd &&
  1346. !list_empty(&tlist) &&
  1347. (sack_ctsn+2 == q->asoc->next_tsn)) {
  1348. SCTP_DEBUG_PRINTK("%s: SACK received for zero "
  1349. "window probe: %u\n",
  1350. __FUNCTION__, sack_ctsn);
  1351. q->asoc->overall_error_count = 0;
  1352. transport->error_count = 0;
  1353. }
  1354. }
  1355. /* RFC 2960 6.3.2 Retransmission Timer Rules
  1356. *
  1357. * R2) Whenever all outstanding data sent to an address have
  1358. * been acknowledged, turn off the T3-rtx timer of that
  1359. * address.
  1360. */
  1361. if (!transport->flight_size) {
  1362. if (timer_pending(&transport->T3_rtx_timer) &&
  1363. del_timer(&transport->T3_rtx_timer)) {
  1364. sctp_transport_put(transport);
  1365. }
  1366. } else if (restart_timer) {
  1367. if (!mod_timer(&transport->T3_rtx_timer,
  1368. jiffies + transport->rto))
  1369. sctp_transport_hold(transport);
  1370. }
  1371. }
  1372. list_splice(&tlist, transmitted_queue);
  1373. }
  1374. /* Mark chunks as missing and consequently may get retransmitted. */
  1375. static void sctp_mark_missing(struct sctp_outq *q,
  1376. struct list_head *transmitted_queue,
  1377. struct sctp_transport *transport,
  1378. __u32 highest_new_tsn_in_sack,
  1379. int count_of_newacks)
  1380. {
  1381. struct sctp_chunk *chunk;
  1382. struct list_head *pos;
  1383. __u32 tsn;
  1384. char do_fast_retransmit = 0;
  1385. struct sctp_transport *primary = q->asoc->peer.primary_path;
  1386. list_for_each(pos, transmitted_queue) {
  1387. chunk = list_entry(pos, struct sctp_chunk, transmitted_list);
  1388. tsn = ntohl(chunk->subh.data_hdr->tsn);
  1389. /* RFC 2960 7.2.4, sctpimpguide-05 2.8.2 M3) Examine all
  1390. * 'Unacknowledged TSN's', if the TSN number of an
  1391. * 'Unacknowledged TSN' is smaller than the 'HighestTSNinSack'
  1392. * value, increment the 'TSN.Missing.Report' count on that
  1393. * chunk if it has NOT been fast retransmitted or marked for
  1394. * fast retransmit already.
  1395. */
  1396. if (!chunk->fast_retransmit &&
  1397. !chunk->tsn_gap_acked &&
  1398. TSN_lt(tsn, highest_new_tsn_in_sack)) {
  1399. /* SFR-CACC may require us to skip marking
  1400. * this chunk as missing.
  1401. */
  1402. if (!transport || !sctp_cacc_skip(primary, transport,
  1403. count_of_newacks, tsn)) {
  1404. chunk->tsn_missing_report++;
  1405. SCTP_DEBUG_PRINTK(
  1406. "%s: TSN 0x%x missing counter: %d\n",
  1407. __FUNCTION__, tsn,
  1408. chunk->tsn_missing_report);
  1409. }
  1410. }
  1411. /*
  1412. * M4) If any DATA chunk is found to have a
  1413. * 'TSN.Missing.Report'
  1414. * value larger than or equal to 3, mark that chunk for
  1415. * retransmission and start the fast retransmit procedure.
  1416. */
  1417. if (chunk->tsn_missing_report >= 3) {
  1418. chunk->fast_retransmit = 1;
  1419. do_fast_retransmit = 1;
  1420. }
  1421. }
  1422. if (transport) {
  1423. if (do_fast_retransmit)
  1424. sctp_retransmit(q, transport, SCTP_RTXR_FAST_RTX);
  1425. SCTP_DEBUG_PRINTK("%s: transport: %p, cwnd: %d, "
  1426. "ssthresh: %d, flight_size: %d, pba: %d\n",
  1427. __FUNCTION__, transport, transport->cwnd,
  1428. transport->ssthresh, transport->flight_size,
  1429. transport->partial_bytes_acked);
  1430. }
  1431. }
  1432. /* Is the given TSN acked by this packet? */
  1433. static int sctp_acked(struct sctp_sackhdr *sack, __u32 tsn)
  1434. {
  1435. int i;
  1436. sctp_sack_variable_t *frags;
  1437. __u16 gap;
  1438. __u32 ctsn = ntohl(sack->cum_tsn_ack);
  1439. if (TSN_lte(tsn, ctsn))
  1440. goto pass;
  1441. /* 3.3.4 Selective Acknowledgement (SACK) (3):
  1442. *
  1443. * Gap Ack Blocks:
  1444. * These fields contain the Gap Ack Blocks. They are repeated
  1445. * for each Gap Ack Block up to the number of Gap Ack Blocks
  1446. * defined in the Number of Gap Ack Blocks field. All DATA
  1447. * chunks with TSNs greater than or equal to (Cumulative TSN
  1448. * Ack + Gap Ack Block Start) and less than or equal to
  1449. * (Cumulative TSN Ack + Gap Ack Block End) of each Gap Ack
  1450. * Block are assumed to have been received correctly.
  1451. */
  1452. frags = sack->variable;
  1453. gap = tsn - ctsn;
  1454. for (i = 0; i < ntohs(sack->num_gap_ack_blocks); ++i) {
  1455. if (TSN_lte(ntohs(frags[i].gab.start), gap) &&
  1456. TSN_lte(gap, ntohs(frags[i].gab.end)))
  1457. goto pass;
  1458. }
  1459. return 0;
  1460. pass:
  1461. return 1;
  1462. }
  1463. static inline int sctp_get_skip_pos(struct sctp_fwdtsn_skip *skiplist,
  1464. int nskips, __be16 stream)
  1465. {
  1466. int i;
  1467. for (i = 0; i < nskips; i++) {
  1468. if (skiplist[i].stream == stream)
  1469. return i;
  1470. }
  1471. return i;
  1472. }
  1473. /* Create and add a fwdtsn chunk to the outq's control queue if needed. */
  1474. static void sctp_generate_fwdtsn(struct sctp_outq *q, __u32 ctsn)
  1475. {
  1476. struct sctp_association *asoc = q->asoc;
  1477. struct sctp_chunk *ftsn_chunk = NULL;
  1478. struct sctp_fwdtsn_skip ftsn_skip_arr[10];
  1479. int nskips = 0;
  1480. int skip_pos = 0;
  1481. __u32 tsn;
  1482. struct sctp_chunk *chunk;
  1483. struct list_head *lchunk, *temp;
  1484. /* PR-SCTP C1) Let SackCumAck be the Cumulative TSN ACK carried in the
  1485. * received SACK.
  1486. *
  1487. * If (Advanced.Peer.Ack.Point < SackCumAck), then update
  1488. * Advanced.Peer.Ack.Point to be equal to SackCumAck.
  1489. */
  1490. if (TSN_lt(asoc->adv_peer_ack_point, ctsn))
  1491. asoc->adv_peer_ack_point = ctsn;
  1492. /* PR-SCTP C2) Try to further advance the "Advanced.Peer.Ack.Point"
  1493. * locally, that is, to move "Advanced.Peer.Ack.Point" up as long as
  1494. * the chunk next in the out-queue space is marked as "abandoned" as
  1495. * shown in the following example:
  1496. *
  1497. * Assuming that a SACK arrived with the Cumulative TSN ACK 102
  1498. * and the Advanced.Peer.Ack.Point is updated to this value:
  1499. *
  1500. * out-queue at the end of ==> out-queue after Adv.Ack.Point
  1501. * normal SACK processing local advancement
  1502. * ... ...
  1503. * Adv.Ack.Pt-> 102 acked 102 acked
  1504. * 103 abandoned 103 abandoned
  1505. * 104 abandoned Adv.Ack.P-> 104 abandoned
  1506. * 105 105
  1507. * 106 acked 106 acked
  1508. * ... ...
  1509. *
  1510. * In this example, the data sender successfully advanced the
  1511. * "Advanced.Peer.Ack.Point" from 102 to 104 locally.
  1512. */
  1513. list_for_each_safe(lchunk, temp, &q->abandoned) {
  1514. chunk = list_entry(lchunk, struct sctp_chunk,
  1515. transmitted_list);
  1516. tsn = ntohl(chunk->subh.data_hdr->tsn);
  1517. /* Remove any chunks in the abandoned queue that are acked by
  1518. * the ctsn.
  1519. */
  1520. if (TSN_lte(tsn, ctsn)) {
  1521. list_del_init(lchunk);
  1522. sctp_chunk_free(chunk);
  1523. } else {
  1524. if (TSN_lte(tsn, asoc->adv_peer_ack_point+1)) {
  1525. asoc->adv_peer_ack_point = tsn;
  1526. if (chunk->chunk_hdr->flags &
  1527. SCTP_DATA_UNORDERED)
  1528. continue;
  1529. skip_pos = sctp_get_skip_pos(&ftsn_skip_arr[0],
  1530. nskips,
  1531. chunk->subh.data_hdr->stream);
  1532. ftsn_skip_arr[skip_pos].stream =
  1533. chunk->subh.data_hdr->stream;
  1534. ftsn_skip_arr[skip_pos].ssn =
  1535. chunk->subh.data_hdr->ssn;
  1536. if (skip_pos == nskips)
  1537. nskips++;
  1538. if (nskips == 10)
  1539. break;
  1540. } else
  1541. break;
  1542. }
  1543. }
  1544. /* PR-SCTP C3) If, after step C1 and C2, the "Advanced.Peer.Ack.Point"
  1545. * is greater than the Cumulative TSN ACK carried in the received
  1546. * SACK, the data sender MUST send the data receiver a FORWARD TSN
  1547. * chunk containing the latest value of the
  1548. * "Advanced.Peer.Ack.Point".
  1549. *
  1550. * C4) For each "abandoned" TSN the sender of the FORWARD TSN SHOULD
  1551. * list each stream and sequence number in the forwarded TSN. This
  1552. * information will enable the receiver to easily find any
  1553. * stranded TSN's waiting on stream reorder queues. Each stream
  1554. * SHOULD only be reported once; this means that if multiple
  1555. * abandoned messages occur in the same stream then only the
  1556. * highest abandoned stream sequence number is reported. If the
  1557. * total size of the FORWARD TSN does NOT fit in a single MTU then
  1558. * the sender of the FORWARD TSN SHOULD lower the
  1559. * Advanced.Peer.Ack.Point to the last TSN that will fit in a
  1560. * single MTU.
  1561. */
  1562. if (asoc->adv_peer_ack_point > ctsn)
  1563. ftsn_chunk = sctp_make_fwdtsn(asoc, asoc->adv_peer_ack_point,
  1564. nskips, &ftsn_skip_arr[0]);
  1565. if (ftsn_chunk) {
  1566. list_add_tail(&ftsn_chunk->list, &q->control_chunk_list);
  1567. SCTP_INC_STATS(SCTP_MIB_OUTCTRLCHUNKS);
  1568. }
  1569. }