Skip to content

Commit 5d0dbc4

Browse files
Gerrit RenkerDavid S. Miller
authored andcommitted
[DCCP] ccid3: Consolidate handling of t_RTO
This patch * removes setting t_RTO in ccid3_hc_tx_init (per [RFC 3448, 4.2], t_RTO is undefined until feedback has been received); * makes some trivial changes (updates of comments); * performs a small optimisation by exploiting that the feedback timeout uses the value of t_ipi. The way it is done is safe, because the timeouts appear after the changes to t_ipi, ensuring that up-to-date values are used; * in ccid3_hc_tx_packet_recv, moves the t_rto statement closer to the calculation of the next_tmout. This makes the code clearer to read and is also safe, since t_rto is not updated until the next call of ccid3_hc_tx_packet_recv, and is not read by the functions called via ccid_wait_for_ccid(); * removes a `max' statement in sk_reset_timer, this is not needed since the timeout value is always greater than 1E6 microseconds. * adds `XXX'es to highlight that currently the nofeedback timer is set in a non-standard way Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz> Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
1 parent 17893bc commit 5d0dbc4

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

‎net/dccp/ccids/ccid3.c‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,10 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data)
228228
}
229229
/*
230230
* Schedule no feedback timer to expire in
231-
* max(4 * R, 2 * s / X)
231+
* max(4 * t_RTO, 2 * s/X) = max(4 * t_RTO, 2 * t_ipi)
232+
* XXX This is non-standard, RFC 3448, 4.3 uses 4 * R
232233
*/
233-
next_tmout = max_t(u32, hctx->ccid3hctx_t_rto,
234-
2 * usecs_div(hctx->ccid3hctx_s,
235-
hctx->ccid3hctx_x));
234+
next_tmout = max(hctx->ccid3hctx_t_rto, 2*hctx->ccid3hctx_t_ipi);
236235
break;
237236
case TFRC_SSTATE_NO_SENT:
238237
DCCP_BUG("Illegal %s state NO_SENT, sk=%p", dccp_role(sk), sk);
@@ -460,10 +459,6 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
460459
"r_sample=%us\n", dccp_role(sk), sk,
461460
hctx->ccid3hctx_rtt, r_sample);
462461

463-
/* Update timeout interval */
464-
hctx->ccid3hctx_t_rto = max_t(u32, 4 * hctx->ccid3hctx_rtt,
465-
USEC_PER_SEC);
466-
467462
/* Update receive rate */
468463
hctx->ccid3hctx_x_recv = x_recv;/* X_recv in bytes per sec */
469464

@@ -491,25 +486,30 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
491486
&hctx->ccid3hctx_hist, packet);
492487
/*
493488
* As we have calculated new ipi, delta, t_nom it is possible that
494-
* we now can send a packet, so wake up dccp_wait_for_ccids.
489+
* we now can send a packet, so wake up dccp_wait_for_ccid
495490
*/
496491
sk->sk_write_space(sk);
497492

493+
494+
/* Update timeout interval. We use the alternative variant of
495+
* [RFC 3448, 3.1] which sets the upper bound of t_rto to one
496+
* second, as it is suggested for TCP (see RFC 2988, 2.4). */
497+
hctx->ccid3hctx_t_rto = max_t(u32, 4 * hctx->ccid3hctx_rtt,
498+
USEC_PER_SEC );
498499
/*
499500
* Schedule no feedback timer to expire in
500-
* max(4 * R, 2 * s / X)
501+
* max(4 * t_RTO, 2 * s/X) = max(4 * t_RTO, 2 * t_ipi)
502+
* XXX This is non-standard, RFC 3448, 4.3 uses 4 * R
501503
*/
502-
next_tmout = max(hctx->ccid3hctx_t_rto,
503-
2 * usecs_div(hctx->ccid3hctx_s,
504-
hctx->ccid3hctx_x));
504+
next_tmout = max(hctx->ccid3hctx_t_rto, 2*hctx->ccid3hctx_t_ipi);
505505

506506
ccid3_pr_debug("%s, sk=%p, Scheduled no feedback timer to "
507507
"expire in %lu jiffies (%luus)\n",
508508
dccp_role(sk), sk,
509509
usecs_to_jiffies(next_tmout), next_tmout);
510510

511511
sk_reset_timer(sk, &hctx->ccid3hctx_no_feedback_timer,
512-
jiffies + max_t(u32, 1, usecs_to_jiffies(next_tmout)));
512+
jiffies + usecs_to_jiffies(next_tmout));
513513

514514
/* set idle flag */
515515
hctx->ccid3hctx_idle = 1;
@@ -607,7 +607,6 @@ static int ccid3_hc_tx_init(struct ccid *ccid, struct sock *sk)
607607

608608
/* Set transmission rate to 1 packet per second */
609609
hctx->ccid3hctx_x = hctx->ccid3hctx_s;
610-
hctx->ccid3hctx_t_rto = USEC_PER_SEC;
611610
hctx->ccid3hctx_state = TFRC_SSTATE_NO_SENT;
612611
INIT_LIST_HEAD(&hctx->ccid3hctx_hist);
613612

0 commit comments

Comments
 (0)