transport.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. /* SCTP kernel implementation
  2. * Copyright (c) 1999-2000 Cisco, Inc.
  3. * Copyright (c) 1999-2001 Motorola, Inc.
  4. * Copyright (c) 2001-2003 International Business Machines Corp.
  5. * Copyright (c) 2001 Intel Corp.
  6. * Copyright (c) 2001 La Monte H.P. Yarroll
  7. *
  8. * This file is part of the SCTP kernel implementation
  9. *
  10. * This module provides the abstraction for an SCTP tranport representing
  11. * a remote transport address. For local transport addresses, we just use
  12. * union sctp_addr.
  13. *
  14. * This SCTP implementation is free software;
  15. * you can redistribute it and/or modify it under the terms of
  16. * the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2, or (at your option)
  18. * any later version.
  19. *
  20. * This SCTP implementation is distributed in the hope that it
  21. * will be useful, but WITHOUT ANY WARRANTY; without even the implied
  22. * ************************
  23. * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  24. * See the GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with GNU CC; see the file COPYING. If not, write to
  28. * the Free Software Foundation, 59 Temple Place - Suite 330,
  29. * Boston, MA 02111-1307, USA.
  30. *
  31. * Please send any bug reports or fixes you make to the
  32. * email address(es):
  33. * lksctp developers <lksctp-developers@lists.sourceforge.net>
  34. *
  35. * Or submit a bug report through the following website:
  36. * http://www.sf.net/projects/lksctp
  37. *
  38. * Written or modified by:
  39. * La Monte H.P. Yarroll <piggy@acm.org>
  40. * Karl Knutson <karl@athena.chicago.il.us>
  41. * Jon Grimm <jgrimm@us.ibm.com>
  42. * Xingang Guo <xingang.guo@intel.com>
  43. * Hui Huang <hui.huang@nokia.com>
  44. * Sridhar Samudrala <sri@us.ibm.com>
  45. * Ardelle Fan <ardelle.fan@intel.com>
  46. *
  47. * Any bugs reported given to us we will try to fix... any fixes shared will
  48. * be incorporated into the next SCTP release.
  49. */
  50. #include <linux/types.h>
  51. #include <linux/random.h>
  52. #include <net/sctp/sctp.h>
  53. #include <net/sctp/sm.h>
  54. /* 1st Level Abstractions. */
  55. /* Initialize a new transport from provided memory. */
  56. static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
  57. const union sctp_addr *addr,
  58. gfp_t gfp)
  59. {
  60. /* Copy in the address. */
  61. peer->ipaddr = *addr;
  62. peer->af_specific = sctp_get_af_specific(addr->sa.sa_family);
  63. peer->asoc = NULL;
  64. peer->dst = NULL;
  65. memset(&peer->saddr, 0, sizeof(union sctp_addr));
  66. /* From 6.3.1 RTO Calculation:
  67. *
  68. * C1) Until an RTT measurement has been made for a packet sent to the
  69. * given destination transport address, set RTO to the protocol
  70. * parameter 'RTO.Initial'.
  71. */
  72. peer->last_rto = peer->rto = msecs_to_jiffies(sctp_rto_initial);
  73. peer->rtt = 0;
  74. peer->rttvar = 0;
  75. peer->srtt = 0;
  76. peer->rto_pending = 0;
  77. peer->fast_recovery = 0;
  78. peer->last_time_heard = jiffies;
  79. peer->last_time_used = jiffies;
  80. peer->last_time_ecne_reduced = jiffies;
  81. peer->init_sent_count = 0;
  82. peer->param_flags = SPP_HB_DISABLE |
  83. SPP_PMTUD_ENABLE |
  84. SPP_SACKDELAY_ENABLE;
  85. peer->hbinterval = 0;
  86. /* Initialize the default path max_retrans. */
  87. peer->pathmaxrxt = sctp_max_retrans_path;
  88. peer->error_count = 0;
  89. INIT_LIST_HEAD(&peer->transmitted);
  90. INIT_LIST_HEAD(&peer->send_ready);
  91. INIT_LIST_HEAD(&peer->transports);
  92. setup_timer(&peer->T3_rtx_timer, sctp_generate_t3_rtx_event,
  93. (unsigned long)peer);
  94. setup_timer(&peer->hb_timer, sctp_generate_heartbeat_event,
  95. (unsigned long)peer);
  96. /* Initialize the 64-bit random nonce sent with heartbeat. */
  97. get_random_bytes(&peer->hb_nonce, sizeof(peer->hb_nonce));
  98. atomic_set(&peer->refcnt, 1);
  99. peer->dead = 0;
  100. peer->malloced = 0;
  101. /* Initialize the state information for SFR-CACC */
  102. peer->cacc.changeover_active = 0;
  103. peer->cacc.cycling_changeover = 0;
  104. peer->cacc.next_tsn_at_change = 0;
  105. peer->cacc.cacc_saw_newack = 0;
  106. return peer;
  107. }
  108. /* Allocate and initialize a new transport. */
  109. struct sctp_transport *sctp_transport_new(const union sctp_addr *addr,
  110. gfp_t gfp)
  111. {
  112. struct sctp_transport *transport;
  113. transport = t_new(struct sctp_transport, gfp);
  114. if (!transport)
  115. goto fail;
  116. if (!sctp_transport_init(transport, addr, gfp))
  117. goto fail_init;
  118. transport->malloced = 1;
  119. SCTP_DBG_OBJCNT_INC(transport);
  120. return transport;
  121. fail_init:
  122. kfree(transport);
  123. fail:
  124. return NULL;
  125. }
  126. /* This transport is no longer needed. Free up if possible, or
  127. * delay until it last reference count.
  128. */
  129. void sctp_transport_free(struct sctp_transport *transport)
  130. {
  131. transport->dead = 1;
  132. /* Try to delete the heartbeat timer. */
  133. if (del_timer(&transport->hb_timer))
  134. sctp_transport_put(transport);
  135. /* Delete the T3_rtx timer if it's active.
  136. * There is no point in not doing this now and letting
  137. * structure hang around in memory since we know
  138. * the tranport is going away.
  139. */
  140. if (timer_pending(&transport->T3_rtx_timer) &&
  141. del_timer(&transport->T3_rtx_timer))
  142. sctp_transport_put(transport);
  143. sctp_transport_put(transport);
  144. }
  145. /* Destroy the transport data structure.
  146. * Assumes there are no more users of this structure.
  147. */
  148. static void sctp_transport_destroy(struct sctp_transport *transport)
  149. {
  150. SCTP_ASSERT(transport->dead, "Transport is not dead", return);
  151. if (transport->asoc)
  152. sctp_association_put(transport->asoc);
  153. sctp_packet_free(&transport->packet);
  154. dst_release(transport->dst);
  155. kfree(transport);
  156. SCTP_DBG_OBJCNT_DEC(transport);
  157. }
  158. /* Start T3_rtx timer if it is not already running and update the heartbeat
  159. * timer. This routine is called every time a DATA chunk is sent.
  160. */
  161. void sctp_transport_reset_timers(struct sctp_transport *transport, int force)
  162. {
  163. /* RFC 2960 6.3.2 Retransmission Timer Rules
  164. *
  165. * R1) Every time a DATA chunk is sent to any address(including a
  166. * retransmission), if the T3-rtx timer of that address is not running
  167. * start it running so that it will expire after the RTO of that
  168. * address.
  169. */
  170. if (force || !timer_pending(&transport->T3_rtx_timer))
  171. if (!mod_timer(&transport->T3_rtx_timer,
  172. jiffies + transport->rto))
  173. sctp_transport_hold(transport);
  174. /* When a data chunk is sent, reset the heartbeat interval. */
  175. if (!mod_timer(&transport->hb_timer,
  176. sctp_transport_timeout(transport)))
  177. sctp_transport_hold(transport);
  178. }
  179. /* This transport has been assigned to an association.
  180. * Initialize fields from the association or from the sock itself.
  181. * Register the reference count in the association.
  182. */
  183. void sctp_transport_set_owner(struct sctp_transport *transport,
  184. struct sctp_association *asoc)
  185. {
  186. transport->asoc = asoc;
  187. sctp_association_hold(asoc);
  188. }
  189. /* Initialize the pmtu of a transport. */
  190. void sctp_transport_pmtu(struct sctp_transport *transport)
  191. {
  192. struct dst_entry *dst;
  193. dst = transport->af_specific->get_dst(NULL, &transport->ipaddr, NULL);
  194. if (dst) {
  195. transport->pathmtu = dst_mtu(dst);
  196. dst_release(dst);
  197. } else
  198. transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT;
  199. }
  200. /* this is a complete rip-off from __sk_dst_check
  201. * the cookie is always 0 since this is how it's used in the
  202. * pmtu code
  203. */
  204. static struct dst_entry *sctp_transport_dst_check(struct sctp_transport *t)
  205. {
  206. struct dst_entry *dst = t->dst;
  207. if (dst && dst->obsolete && dst->ops->check(dst, 0) == NULL) {
  208. dst_release(t->dst);
  209. t->dst = NULL;
  210. return NULL;
  211. }
  212. return dst;
  213. }
  214. void sctp_transport_update_pmtu(struct sctp_transport *t, u32 pmtu)
  215. {
  216. struct dst_entry *dst;
  217. if (unlikely(pmtu < SCTP_DEFAULT_MINSEGMENT)) {
  218. printk(KERN_WARNING "%s: Reported pmtu %d too low, "
  219. "using default minimum of %d\n",
  220. __func__, pmtu,
  221. SCTP_DEFAULT_MINSEGMENT);
  222. /* Use default minimum segment size and disable
  223. * pmtu discovery on this transport.
  224. */
  225. t->pathmtu = SCTP_DEFAULT_MINSEGMENT;
  226. } else {
  227. t->pathmtu = pmtu;
  228. }
  229. dst = sctp_transport_dst_check(t);
  230. if (dst)
  231. dst->ops->update_pmtu(dst, pmtu);
  232. }
  233. /* Caches the dst entry and source address for a transport's destination
  234. * address.
  235. */
  236. void sctp_transport_route(struct sctp_transport *transport,
  237. union sctp_addr *saddr, struct sctp_sock *opt)
  238. {
  239. struct sctp_association *asoc = transport->asoc;
  240. struct sctp_af *af = transport->af_specific;
  241. union sctp_addr *daddr = &transport->ipaddr;
  242. struct dst_entry *dst;
  243. dst = af->get_dst(asoc, daddr, saddr);
  244. if (saddr)
  245. memcpy(&transport->saddr, saddr, sizeof(union sctp_addr));
  246. else
  247. af->get_saddr(opt, asoc, dst, daddr, &transport->saddr);
  248. transport->dst = dst;
  249. if ((transport->param_flags & SPP_PMTUD_DISABLE) && transport->pathmtu) {
  250. return;
  251. }
  252. if (dst) {
  253. transport->pathmtu = dst_mtu(dst);
  254. /* Initialize sk->sk_rcv_saddr, if the transport is the
  255. * association's active path for getsockname().
  256. */
  257. if (asoc && (transport == asoc->peer.active_path))
  258. opt->pf->af->to_sk_saddr(&transport->saddr,
  259. asoc->base.sk);
  260. } else
  261. transport->pathmtu = SCTP_DEFAULT_MAXSEGMENT;
  262. }
  263. /* Hold a reference to a transport. */
  264. void sctp_transport_hold(struct sctp_transport *transport)
  265. {
  266. atomic_inc(&transport->refcnt);
  267. }
  268. /* Release a reference to a transport and clean up
  269. * if there are no more references.
  270. */
  271. void sctp_transport_put(struct sctp_transport *transport)
  272. {
  273. if (atomic_dec_and_test(&transport->refcnt))
  274. sctp_transport_destroy(transport);
  275. }
  276. /* Update transport's RTO based on the newly calculated RTT. */
  277. void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt)
  278. {
  279. /* Check for valid transport. */
  280. SCTP_ASSERT(tp, "NULL transport", return);
  281. /* We should not be doing any RTO updates unless rto_pending is set. */
  282. SCTP_ASSERT(tp->rto_pending, "rto_pending not set", return);
  283. if (tp->rttvar || tp->srtt) {
  284. /* 6.3.1 C3) When a new RTT measurement R' is made, set
  285. * RTTVAR <- (1 - RTO.Beta) * RTTVAR + RTO.Beta * |SRTT - R'|
  286. * SRTT <- (1 - RTO.Alpha) * SRTT + RTO.Alpha * R'
  287. */
  288. /* Note: The above algorithm has been rewritten to
  289. * express rto_beta and rto_alpha as inverse powers
  290. * of two.
  291. * For example, assuming the default value of RTO.Alpha of
  292. * 1/8, rto_alpha would be expressed as 3.
  293. */
  294. tp->rttvar = tp->rttvar - (tp->rttvar >> sctp_rto_beta)
  295. + ((abs(tp->srtt - rtt)) >> sctp_rto_beta);
  296. tp->srtt = tp->srtt - (tp->srtt >> sctp_rto_alpha)
  297. + (rtt >> sctp_rto_alpha);
  298. } else {
  299. /* 6.3.1 C2) When the first RTT measurement R is made, set
  300. * SRTT <- R, RTTVAR <- R/2.
  301. */
  302. tp->srtt = rtt;
  303. tp->rttvar = rtt >> 1;
  304. }
  305. /* 6.3.1 G1) Whenever RTTVAR is computed, if RTTVAR = 0, then
  306. * adjust RTTVAR <- G, where G is the CLOCK GRANULARITY.
  307. */
  308. if (tp->rttvar == 0)
  309. tp->rttvar = SCTP_CLOCK_GRANULARITY;
  310. /* 6.3.1 C3) After the computation, update RTO <- SRTT + 4 * RTTVAR. */
  311. tp->rto = tp->srtt + (tp->rttvar << 2);
  312. /* 6.3.1 C6) Whenever RTO is computed, if it is less than RTO.Min
  313. * seconds then it is rounded up to RTO.Min seconds.
  314. */
  315. if (tp->rto < tp->asoc->rto_min)
  316. tp->rto = tp->asoc->rto_min;
  317. /* 6.3.1 C7) A maximum value may be placed on RTO provided it is
  318. * at least RTO.max seconds.
  319. */
  320. if (tp->rto > tp->asoc->rto_max)
  321. tp->rto = tp->asoc->rto_max;
  322. tp->rtt = rtt;
  323. tp->last_rto = tp->rto;
  324. /* Reset rto_pending so that a new RTT measurement is started when a
  325. * new data chunk is sent.
  326. */
  327. tp->rto_pending = 0;
  328. SCTP_DEBUG_PRINTK("%s: transport: %p, rtt: %d, srtt: %d "
  329. "rttvar: %d, rto: %ld\n", __func__,
  330. tp, rtt, tp->srtt, tp->rttvar, tp->rto);
  331. }
  332. /* This routine updates the transport's cwnd and partial_bytes_acked
  333. * parameters based on the bytes acked in the received SACK.
  334. */
  335. void sctp_transport_raise_cwnd(struct sctp_transport *transport,
  336. __u32 sack_ctsn, __u32 bytes_acked)
  337. {
  338. __u32 cwnd, ssthresh, flight_size, pba, pmtu;
  339. cwnd = transport->cwnd;
  340. flight_size = transport->flight_size;
  341. /* See if we need to exit Fast Recovery first */
  342. if (transport->fast_recovery &&
  343. TSN_lte(transport->fast_recovery_exit, sack_ctsn))
  344. transport->fast_recovery = 0;
  345. /* The appropriate cwnd increase algorithm is performed if, and only
  346. * if the cumulative TSN whould advanced and the congestion window is
  347. * being fully utilized.
  348. */
  349. if (TSN_lte(sack_ctsn, transport->asoc->ctsn_ack_point) ||
  350. (flight_size < cwnd))
  351. return;
  352. ssthresh = transport->ssthresh;
  353. pba = transport->partial_bytes_acked;
  354. pmtu = transport->asoc->pathmtu;
  355. if (cwnd <= ssthresh) {
  356. /* RFC 4960 7.2.1
  357. * o When cwnd is less than or equal to ssthresh, an SCTP
  358. * endpoint MUST use the slow-start algorithm to increase
  359. * cwnd only if the current congestion window is being fully
  360. * utilized, an incoming SACK advances the Cumulative TSN
  361. * Ack Point, and the data sender is not in Fast Recovery.
  362. * Only when these three conditions are met can the cwnd be
  363. * increased; otherwise, the cwnd MUST not be increased.
  364. * If these conditions are met, then cwnd MUST be increased
  365. * by, at most, the lesser of 1) the total size of the
  366. * previously outstanding DATA chunk(s) acknowledged, and
  367. * 2) the destination's path MTU. This upper bound protects
  368. * against the ACK-Splitting attack outlined in [SAVAGE99].
  369. */
  370. if (transport->fast_recovery)
  371. return;
  372. if (bytes_acked > pmtu)
  373. cwnd += pmtu;
  374. else
  375. cwnd += bytes_acked;
  376. SCTP_DEBUG_PRINTK("%s: SLOW START: transport: %p, "
  377. "bytes_acked: %d, cwnd: %d, ssthresh: %d, "
  378. "flight_size: %d, pba: %d\n",
  379. __func__,
  380. transport, bytes_acked, cwnd,
  381. ssthresh, flight_size, pba);
  382. } else {
  383. /* RFC 2960 7.2.2 Whenever cwnd is greater than ssthresh,
  384. * upon each SACK arrival that advances the Cumulative TSN Ack
  385. * Point, increase partial_bytes_acked by the total number of
  386. * bytes of all new chunks acknowledged in that SACK including
  387. * chunks acknowledged by the new Cumulative TSN Ack and by
  388. * Gap Ack Blocks.
  389. *
  390. * When partial_bytes_acked is equal to or greater than cwnd
  391. * and before the arrival of the SACK the sender had cwnd or
  392. * more bytes of data outstanding (i.e., before arrival of the
  393. * SACK, flightsize was greater than or equal to cwnd),
  394. * increase cwnd by MTU, and reset partial_bytes_acked to
  395. * (partial_bytes_acked - cwnd).
  396. */
  397. pba += bytes_acked;
  398. if (pba >= cwnd) {
  399. cwnd += pmtu;
  400. pba = ((cwnd < pba) ? (pba - cwnd) : 0);
  401. }
  402. SCTP_DEBUG_PRINTK("%s: CONGESTION AVOIDANCE: "
  403. "transport: %p, bytes_acked: %d, cwnd: %d, "
  404. "ssthresh: %d, flight_size: %d, pba: %d\n",
  405. __func__,
  406. transport, bytes_acked, cwnd,
  407. ssthresh, flight_size, pba);
  408. }
  409. transport->cwnd = cwnd;
  410. transport->partial_bytes_acked = pba;
  411. }
  412. /* This routine is used to lower the transport's cwnd when congestion is
  413. * detected.
  414. */
  415. void sctp_transport_lower_cwnd(struct sctp_transport *transport,
  416. sctp_lower_cwnd_t reason)
  417. {
  418. switch (reason) {
  419. case SCTP_LOWER_CWND_T3_RTX:
  420. /* RFC 2960 Section 7.2.3, sctpimpguide
  421. * When the T3-rtx timer expires on an address, SCTP should
  422. * perform slow start by:
  423. * ssthresh = max(cwnd/2, 4*MTU)
  424. * cwnd = 1*MTU
  425. * partial_bytes_acked = 0
  426. */
  427. transport->ssthresh = max(transport->cwnd/2,
  428. 4*transport->asoc->pathmtu);
  429. transport->cwnd = transport->asoc->pathmtu;
  430. break;
  431. case SCTP_LOWER_CWND_FAST_RTX:
  432. /* RFC 2960 7.2.4 Adjust the ssthresh and cwnd of the
  433. * destination address(es) to which the missing DATA chunks
  434. * were last sent, according to the formula described in
  435. * Section 7.2.3.
  436. *
  437. * RFC 2960 7.2.3, sctpimpguide Upon detection of packet
  438. * losses from SACK (see Section 7.2.4), An endpoint
  439. * should do the following:
  440. * ssthresh = max(cwnd/2, 4*MTU)
  441. * cwnd = ssthresh
  442. * partial_bytes_acked = 0
  443. */
  444. if (transport->fast_recovery)
  445. return;
  446. /* Mark Fast recovery */
  447. transport->fast_recovery = 1;
  448. transport->fast_recovery_exit = transport->asoc->next_tsn - 1;
  449. transport->ssthresh = max(transport->cwnd/2,
  450. 4*transport->asoc->pathmtu);
  451. transport->cwnd = transport->ssthresh;
  452. break;
  453. case SCTP_LOWER_CWND_ECNE:
  454. /* RFC 2481 Section 6.1.2.
  455. * If the sender receives an ECN-Echo ACK packet
  456. * then the sender knows that congestion was encountered in the
  457. * network on the path from the sender to the receiver. The
  458. * indication of congestion should be treated just as a
  459. * congestion loss in non-ECN Capable TCP. That is, the TCP
  460. * source halves the congestion window "cwnd" and reduces the
  461. * slow start threshold "ssthresh".
  462. * A critical condition is that TCP does not react to
  463. * congestion indications more than once every window of
  464. * data (or more loosely more than once every round-trip time).
  465. */
  466. if ((jiffies - transport->last_time_ecne_reduced) >
  467. transport->rtt) {
  468. transport->ssthresh = max(transport->cwnd/2,
  469. 4*transport->asoc->pathmtu);
  470. transport->cwnd = transport->ssthresh;
  471. transport->last_time_ecne_reduced = jiffies;
  472. }
  473. break;
  474. case SCTP_LOWER_CWND_INACTIVE:
  475. /* RFC 2960 Section 7.2.1, sctpimpguide
  476. * When the endpoint does not transmit data on a given
  477. * transport address, the cwnd of the transport address
  478. * should be adjusted to max(cwnd/2, 4*MTU) per RTO.
  479. * NOTE: Although the draft recommends that this check needs
  480. * to be done every RTO interval, we do it every hearbeat
  481. * interval.
  482. */
  483. if ((jiffies - transport->last_time_used) > transport->rto)
  484. transport->cwnd = max(transport->cwnd/2,
  485. 4*transport->asoc->pathmtu);
  486. break;
  487. }
  488. transport->partial_bytes_acked = 0;
  489. SCTP_DEBUG_PRINTK("%s: transport: %p reason: %d cwnd: "
  490. "%d ssthresh: %d\n", __func__,
  491. transport, reason,
  492. transport->cwnd, transport->ssthresh);
  493. }
  494. /* What is the next timeout value for this transport? */
  495. unsigned long sctp_transport_timeout(struct sctp_transport *t)
  496. {
  497. unsigned long timeout;
  498. timeout = t->rto + sctp_jitter(t->rto);
  499. if (t->state != SCTP_UNCONFIRMED)
  500. timeout += t->hbinterval;
  501. timeout += jiffies;
  502. return timeout;
  503. }
  504. /* Reset transport variables to their initial values */
  505. void sctp_transport_reset(struct sctp_transport *t)
  506. {
  507. struct sctp_association *asoc = t->asoc;
  508. /* RFC 2960 (bis), Section 5.2.4
  509. * All the congestion control parameters (e.g., cwnd, ssthresh)
  510. * related to this peer MUST be reset to their initial values
  511. * (see Section 6.2.1)
  512. */
  513. t->cwnd = min(4*asoc->pathmtu, max_t(__u32, 2*asoc->pathmtu, 4380));
  514. t->ssthresh = asoc->peer.i.a_rwnd;
  515. t->last_rto = t->rto = asoc->rto_initial;
  516. t->rtt = 0;
  517. t->srtt = 0;
  518. t->rttvar = 0;
  519. /* Reset these additional varibles so that we have a clean
  520. * slate.
  521. */
  522. t->partial_bytes_acked = 0;
  523. t->flight_size = 0;
  524. t->error_count = 0;
  525. t->rto_pending = 0;
  526. t->fast_recovery = 0;
  527. /* Initialize the state information for SFR-CACC */
  528. t->cacc.changeover_active = 0;
  529. t->cacc.cycling_changeover = 0;
  530. t->cacc.next_tsn_at_change = 0;
  531. t->cacc.cacc_saw_newack = 0;
  532. }