aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sctp/transport.c')
-rw-r--r--net/sctp/transport.c68
1 files changed, 26 insertions, 42 deletions
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index b827d21dbe54..132046cb82fc 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -48,6 +48,7 @@
48 * be incorporated into the next SCTP release. 48 * be incorporated into the next SCTP release.
49 */ 49 */
50 50
51#include <linux/slab.h>
51#include <linux/types.h> 52#include <linux/types.h>
52#include <linux/random.h> 53#include <linux/random.h>
53#include <net/sctp/sctp.h> 54#include <net/sctp/sctp.h>
@@ -63,9 +64,6 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
63 /* Copy in the address. */ 64 /* Copy in the address. */
64 peer->ipaddr = *addr; 65 peer->ipaddr = *addr;
65 peer->af_specific = sctp_get_af_specific(addr->sa.sa_family); 66 peer->af_specific = sctp_get_af_specific(addr->sa.sa_family);
66 peer->asoc = NULL;
67
68 peer->dst = NULL;
69 memset(&peer->saddr, 0, sizeof(union sctp_addr)); 67 memset(&peer->saddr, 0, sizeof(union sctp_addr));
70 68
71 /* From 6.3.1 RTO Calculation: 69 /* From 6.3.1 RTO Calculation:
@@ -75,52 +73,32 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer,
75 * parameter 'RTO.Initial'. 73 * parameter 'RTO.Initial'.
76 */ 74 */
77 peer->rto = msecs_to_jiffies(sctp_rto_initial); 75 peer->rto = msecs_to_jiffies(sctp_rto_initial);
78 peer->rtt = 0;
79 peer->rttvar = 0;
80 peer->srtt = 0;
81 peer->rto_pending = 0;
82 peer->hb_sent = 0;
83 peer->fast_recovery = 0;
84 76
85 peer->last_time_heard = jiffies; 77 peer->last_time_heard = jiffies;
86 peer->last_time_ecne_reduced = jiffies; 78 peer->last_time_ecne_reduced = jiffies;
87 79
88 peer->init_sent_count = 0;
89
90 peer->param_flags = SPP_HB_DISABLE | 80 peer->param_flags = SPP_HB_DISABLE |
91 SPP_PMTUD_ENABLE | 81 SPP_PMTUD_ENABLE |
92 SPP_SACKDELAY_ENABLE; 82 SPP_SACKDELAY_ENABLE;
93 peer->hbinterval = 0;
94 83
95 /* Initialize the default path max_retrans. */ 84 /* Initialize the default path max_retrans. */
96 peer->pathmaxrxt = sctp_max_retrans_path; 85 peer->pathmaxrxt = sctp_max_retrans_path;
97 peer->error_count = 0;
98 86
99 INIT_LIST_HEAD(&peer->transmitted); 87 INIT_LIST_HEAD(&peer->transmitted);
100 INIT_LIST_HEAD(&peer->send_ready); 88 INIT_LIST_HEAD(&peer->send_ready);
101 INIT_LIST_HEAD(&peer->transports); 89 INIT_LIST_HEAD(&peer->transports);
102 90
103 peer->T3_rtx_timer.expires = 0;
104 peer->hb_timer.expires = 0;
105
106 setup_timer(&peer->T3_rtx_timer, sctp_generate_t3_rtx_event, 91 setup_timer(&peer->T3_rtx_timer, sctp_generate_t3_rtx_event,
107 (unsigned long)peer); 92 (unsigned long)peer);
108 setup_timer(&peer->hb_timer, sctp_generate_heartbeat_event, 93 setup_timer(&peer->hb_timer, sctp_generate_heartbeat_event,
109 (unsigned long)peer); 94 (unsigned long)peer);
95 setup_timer(&peer->proto_unreach_timer,
96 sctp_generate_proto_unreach_event, (unsigned long)peer);
110 97
111 /* Initialize the 64-bit random nonce sent with heartbeat. */ 98 /* Initialize the 64-bit random nonce sent with heartbeat. */
112 get_random_bytes(&peer->hb_nonce, sizeof(peer->hb_nonce)); 99 get_random_bytes(&peer->hb_nonce, sizeof(peer->hb_nonce));
113 100
114 atomic_set(&peer->refcnt, 1); 101 atomic_set(&peer->refcnt, 1);
115 peer->dead = 0;
116
117 peer->malloced = 0;
118
119 /* Initialize the state information for SFR-CACC */
120 peer->cacc.changeover_active = 0;
121 peer->cacc.cycling_changeover = 0;
122 peer->cacc.next_tsn_at_change = 0;
123 peer->cacc.cacc_saw_newack = 0;
124 102
125 return peer; 103 return peer;
126} 104}
@@ -170,6 +148,10 @@ void sctp_transport_free(struct sctp_transport *transport)
170 del_timer(&transport->T3_rtx_timer)) 148 del_timer(&transport->T3_rtx_timer))
171 sctp_transport_put(transport); 149 sctp_transport_put(transport);
172 150
151 /* Delete the ICMP proto unreachable timer if it's active. */
152 if (timer_pending(&transport->proto_unreach_timer) &&
153 del_timer(&transport->proto_unreach_timer))
154 sctp_association_put(transport->asoc);
173 155
174 sctp_transport_put(transport); 156 sctp_transport_put(transport);
175} 157}
@@ -194,7 +176,7 @@ static void sctp_transport_destroy(struct sctp_transport *transport)
194/* Start T3_rtx timer if it is not already running and update the heartbeat 176/* Start T3_rtx timer if it is not already running and update the heartbeat
195 * timer. This routine is called every time a DATA chunk is sent. 177 * timer. This routine is called every time a DATA chunk is sent.
196 */ 178 */
197void sctp_transport_reset_timers(struct sctp_transport *transport, int force) 179void sctp_transport_reset_timers(struct sctp_transport *transport)
198{ 180{
199 /* RFC 2960 6.3.2 Retransmission Timer Rules 181 /* RFC 2960 6.3.2 Retransmission Timer Rules
200 * 182 *
@@ -204,7 +186,7 @@ void sctp_transport_reset_timers(struct sctp_transport *transport, int force)
204 * address. 186 * address.
205 */ 187 */
206 188
207 if (force || !timer_pending(&transport->T3_rtx_timer)) 189 if (!timer_pending(&transport->T3_rtx_timer))
208 if (!mod_timer(&transport->T3_rtx_timer, 190 if (!mod_timer(&transport->T3_rtx_timer,
209 jiffies + transport->rto)) 191 jiffies + transport->rto))
210 sctp_transport_hold(transport); 192 sctp_transport_hold(transport);
@@ -402,15 +384,16 @@ void sctp_transport_update_rto(struct sctp_transport *tp, __u32 rtt)
402void sctp_transport_raise_cwnd(struct sctp_transport *transport, 384void sctp_transport_raise_cwnd(struct sctp_transport *transport,
403 __u32 sack_ctsn, __u32 bytes_acked) 385 __u32 sack_ctsn, __u32 bytes_acked)
404{ 386{
387 struct sctp_association *asoc = transport->asoc;
405 __u32 cwnd, ssthresh, flight_size, pba, pmtu; 388 __u32 cwnd, ssthresh, flight_size, pba, pmtu;
406 389
407 cwnd = transport->cwnd; 390 cwnd = transport->cwnd;
408 flight_size = transport->flight_size; 391 flight_size = transport->flight_size;
409 392
410 /* See if we need to exit Fast Recovery first */ 393 /* See if we need to exit Fast Recovery first */
411 if (transport->fast_recovery && 394 if (asoc->fast_recovery &&
412 TSN_lte(transport->fast_recovery_exit, sack_ctsn)) 395 TSN_lte(asoc->fast_recovery_exit, sack_ctsn))
413 transport->fast_recovery = 0; 396 asoc->fast_recovery = 0;
414 397
415 /* The appropriate cwnd increase algorithm is performed if, and only 398 /* The appropriate cwnd increase algorithm is performed if, and only
416 * if the cumulative TSN whould advanced and the congestion window is 399 * if the cumulative TSN whould advanced and the congestion window is
@@ -439,7 +422,7 @@ void sctp_transport_raise_cwnd(struct sctp_transport *transport,
439 * 2) the destination's path MTU. This upper bound protects 422 * 2) the destination's path MTU. This upper bound protects
440 * against the ACK-Splitting attack outlined in [SAVAGE99]. 423 * against the ACK-Splitting attack outlined in [SAVAGE99].
441 */ 424 */
442 if (transport->fast_recovery) 425 if (asoc->fast_recovery)
443 return; 426 return;
444 427
445 if (bytes_acked > pmtu) 428 if (bytes_acked > pmtu)
@@ -490,6 +473,8 @@ void sctp_transport_raise_cwnd(struct sctp_transport *transport,
490void sctp_transport_lower_cwnd(struct sctp_transport *transport, 473void sctp_transport_lower_cwnd(struct sctp_transport *transport,
491 sctp_lower_cwnd_t reason) 474 sctp_lower_cwnd_t reason)
492{ 475{
476 struct sctp_association *asoc = transport->asoc;
477
493 switch (reason) { 478 switch (reason) {
494 case SCTP_LOWER_CWND_T3_RTX: 479 case SCTP_LOWER_CWND_T3_RTX:
495 /* RFC 2960 Section 7.2.3, sctpimpguide 480 /* RFC 2960 Section 7.2.3, sctpimpguide
@@ -500,11 +485,11 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
500 * partial_bytes_acked = 0 485 * partial_bytes_acked = 0
501 */ 486 */
502 transport->ssthresh = max(transport->cwnd/2, 487 transport->ssthresh = max(transport->cwnd/2,
503 4*transport->asoc->pathmtu); 488 4*asoc->pathmtu);
504 transport->cwnd = transport->asoc->pathmtu; 489 transport->cwnd = asoc->pathmtu;
505 490
506 /* T3-rtx also clears fast recovery on the transport */ 491 /* T3-rtx also clears fast recovery */
507 transport->fast_recovery = 0; 492 asoc->fast_recovery = 0;
508 break; 493 break;
509 494
510 case SCTP_LOWER_CWND_FAST_RTX: 495 case SCTP_LOWER_CWND_FAST_RTX:
@@ -520,15 +505,15 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
520 * cwnd = ssthresh 505 * cwnd = ssthresh
521 * partial_bytes_acked = 0 506 * partial_bytes_acked = 0
522 */ 507 */
523 if (transport->fast_recovery) 508 if (asoc->fast_recovery)
524 return; 509 return;
525 510
526 /* Mark Fast recovery */ 511 /* Mark Fast recovery */
527 transport->fast_recovery = 1; 512 asoc->fast_recovery = 1;
528 transport->fast_recovery_exit = transport->asoc->next_tsn - 1; 513 asoc->fast_recovery_exit = asoc->next_tsn - 1;
529 514
530 transport->ssthresh = max(transport->cwnd/2, 515 transport->ssthresh = max(transport->cwnd/2,
531 4*transport->asoc->pathmtu); 516 4*asoc->pathmtu);
532 transport->cwnd = transport->ssthresh; 517 transport->cwnd = transport->ssthresh;
533 break; 518 break;
534 519
@@ -548,7 +533,7 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
548 if (time_after(jiffies, transport->last_time_ecne_reduced + 533 if (time_after(jiffies, transport->last_time_ecne_reduced +
549 transport->rtt)) { 534 transport->rtt)) {
550 transport->ssthresh = max(transport->cwnd/2, 535 transport->ssthresh = max(transport->cwnd/2,
551 4*transport->asoc->pathmtu); 536 4*asoc->pathmtu);
552 transport->cwnd = transport->ssthresh; 537 transport->cwnd = transport->ssthresh;
553 transport->last_time_ecne_reduced = jiffies; 538 transport->last_time_ecne_reduced = jiffies;
554 } 539 }
@@ -564,7 +549,7 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
564 * interval. 549 * interval.
565 */ 550 */
566 transport->cwnd = max(transport->cwnd/2, 551 transport->cwnd = max(transport->cwnd/2,
567 4*transport->asoc->pathmtu); 552 4*asoc->pathmtu);
568 break; 553 break;
569 } 554 }
570 555
@@ -649,7 +634,6 @@ void sctp_transport_reset(struct sctp_transport *t)
649 t->error_count = 0; 634 t->error_count = 0;
650 t->rto_pending = 0; 635 t->rto_pending = 0;
651 t->hb_sent = 0; 636 t->hb_sent = 0;
652 t->fast_recovery = 0;
653 637
654 /* Initialize the state information for SFR-CACC */ 638 /* Initialize the state information for SFR-CACC */
655 t->cacc.changeover_active = 0; 639 t->cacc.changeover_active = 0;