aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/net/sctp/transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sctp/transport.c')
-rw-r--r--net/sctp/transport.c62
1 files changed, 37 insertions, 25 deletions
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index 721eeebfcd8a..80a97c8501a7 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -99,7 +99,7 @@ static struct sctp_transport *sctp_transport_init(struct net *net,
/* Initialize the 64-bit random nonce sent with heartbeat. */
get_random_bytes(&peer->hb_nonce, sizeof(peer->hb_nonce));
- atomic_set(&peer->refcnt, 1);
+ refcount_set(&peer->refcnt, 1);
return peer;
}
@@ -172,7 +172,7 @@ static void sctp_transport_destroy_rcu(struct rcu_head *head)
*/
static void sctp_transport_destroy(struct sctp_transport *transport)
{
- if (unlikely(atomic_read(&transport->refcnt))) {
+ if (unlikely(refcount_read(&transport->refcnt))) {
WARN(1, "Attempt to destroy undead transport %p!\n", transport);
return;
}
@@ -311,7 +311,7 @@ void sctp_transport_route(struct sctp_transport *transport,
/* Hold a reference to a transport. */
int sctp_transport_hold(struct sctp_transport *transport)
{
- return atomic_add_unless(&transport->refcnt, 1, 0);
+ return refcount_inc_not_zero(&transport->refcnt);
}
/* Release a reference to a transport and clean up
@@ -319,7 +319,7 @@ int sctp_transport_hold(struct sctp_transport *transport)
*/
void sctp_transport_put(struct sctp_transport *transport)
{
- if (atomic_dec_and_test(&transport->refcnt))
+ if (refcount_dec_and_test(&transport->refcnt))
sctp_transport_destroy(transport);
}
@@ -405,14 +405,6 @@ void sctp_transport_raise_cwnd(struct sctp_transport *transport,
TSN_lte(asoc->fast_recovery_exit, sack_ctsn))
asoc->fast_recovery = 0;
- /* The appropriate cwnd increase algorithm is performed if, and only
- * if the cumulative TSN whould advanced and the congestion window is
- * being fully utilized.
- */
- if (TSN_lte(sack_ctsn, transport->asoc->ctsn_ack_point) ||
- (flight_size < cwnd))
- return;
-
ssthresh = transport->ssthresh;
pba = transport->partial_bytes_acked;
pmtu = transport->asoc->pathmtu;
@@ -435,6 +427,14 @@ void sctp_transport_raise_cwnd(struct sctp_transport *transport,
if (asoc->fast_recovery)
return;
+ /* The appropriate cwnd increase algorithm is performed
+ * if, and only if the congestion window is being fully
+ * utilized. Note that RFC4960 Errata 3.22 removed the
+ * other condition on ctsn moving.
+ */
+ if (flight_size < cwnd)
+ return;
+
if (bytes_acked > pmtu)
cwnd += pmtu;
else
@@ -446,23 +446,33 @@ void sctp_transport_raise_cwnd(struct sctp_transport *transport,
flight_size, pba);
} else {
/* RFC 2960 7.2.2 Whenever cwnd is greater than ssthresh,
- * upon each SACK arrival that advances the Cumulative TSN Ack
- * Point, increase partial_bytes_acked by the total number of
- * bytes of all new chunks acknowledged in that SACK including
- * chunks acknowledged by the new Cumulative TSN Ack and by
- * Gap Ack Blocks.
+ * upon each SACK arrival, increase partial_bytes_acked
+ * by the total number of bytes of all new chunks
+ * acknowledged in that SACK including chunks
+ * acknowledged by the new Cumulative TSN Ack and by Gap
+ * Ack Blocks. (updated by RFC4960 Errata 3.22)
+ *
+ * When partial_bytes_acked is greater than cwnd and
+ * before the arrival of the SACK the sender had less
+ * bytes of data outstanding than cwnd (i.e., before
+ * arrival of the SACK, flightsize was less than cwnd),
+ * reset partial_bytes_acked to cwnd. (RFC 4960 Errata
+ * 3.26)
*
- * When partial_bytes_acked is equal to or greater than cwnd
- * and before the arrival of the SACK the sender had cwnd or
- * more bytes of data outstanding (i.e., before arrival of the
- * SACK, flightsize was greater than or equal to cwnd),
- * increase cwnd by MTU, and reset partial_bytes_acked to
- * (partial_bytes_acked - cwnd).
+ * When partial_bytes_acked is equal to or greater than
+ * cwnd and before the arrival of the SACK the sender
+ * had cwnd or more bytes of data outstanding (i.e.,
+ * before arrival of the SACK, flightsize was greater
+ * than or equal to cwnd), partial_bytes_acked is reset
+ * to (partial_bytes_acked - cwnd). Next, cwnd is
+ * increased by MTU. (RFC 4960 Errata 3.12)
*/
pba += bytes_acked;
- if (pba >= cwnd) {
+ if (pba > cwnd && flight_size < cwnd)
+ pba = cwnd;
+ if (pba >= cwnd && flight_size >= cwnd) {
+ pba = pba - cwnd;
cwnd += pmtu;
- pba = ((cwnd < pba) ? (pba - cwnd) : 0);
}
pr_debug("%s: congestion avoidance: transport:%p, "
@@ -559,6 +569,8 @@ void sctp_transport_lower_cwnd(struct sctp_transport *transport,
*/
transport->cwnd = max(transport->cwnd/2,
4*asoc->pathmtu);
+ /* RFC 4960 Errata 3.27.2: also adjust sshthresh */
+ transport->ssthresh = transport->cwnd;
break;
}