aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/input.c
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2007-09-26 01:40:44 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:52:35 -0400
commit3393da8241ae3a53e183ba15f8bd822995ec97cd (patch)
tree28e6d2823d901976844982319e4c53b76a55967c /net/dccp/input.c
parent4c70f383e0c0273c4092c4efdb414be0966978b7 (diff)
[DCCP]: Simplify interface of dccp_sample_rtt
The third parameter of dccp_sample_rtt now becomes useless and is removed. Also combined the subtraction of the timestamp echo and the elapsed time. This is safe, since (a) presence of timestamp echo is tested first and (b) elapsed time is either present and non-zero or it is not set and equals 0 due to the memset in dccp_parse_options. To avoid measuring option-processing time, the timestamp for measuring the initial Request/Response RTT sample is taken directly when the function is called (the Linux implementation always adds a timestamp on the Request, so there is no loss in doing this). Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz> Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/input.c')
-rw-r--r--net/dccp/input.c44
1 files changed, 15 insertions, 29 deletions
diff --git a/net/dccp/input.c b/net/dccp/input.c
index 782cdb7292fa..3b651701cfe4 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -280,6 +280,7 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
280 if (dh->dccph_type == DCCP_PKT_RESPONSE) { 280 if (dh->dccph_type == DCCP_PKT_RESPONSE) {
281 const struct inet_connection_sock *icsk = inet_csk(sk); 281 const struct inet_connection_sock *icsk = inet_csk(sk);
282 struct dccp_sock *dp = dccp_sk(sk); 282 struct dccp_sock *dp = dccp_sk(sk);
283 long tstamp = dccp_timestamp();
283 284
284 /* Stop the REQUEST timer */ 285 /* Stop the REQUEST timer */
285 inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); 286 inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS);
@@ -300,11 +301,10 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
300 if (dccp_parse_options(sk, skb)) 301 if (dccp_parse_options(sk, skb))
301 goto out_invalid_packet; 302 goto out_invalid_packet;
302 303
303 /* Obtain RTT sample from SYN exchange (used by CCID 3) */ 304 /* Obtain usec RTT sample from SYN exchange (used by CCID 3) */
304 if (dp->dccps_options_received.dccpor_timestamp_echo) 305 if (likely(dp->dccps_options_received.dccpor_timestamp_echo))
305 dp->dccps_syn_rtt = dccp_sample_rtt(sk, 306 dp->dccps_syn_rtt = dccp_sample_rtt(sk, 10 * (tstamp -
306 ktime_get_real(), 307 dp->dccps_options_received.dccpor_timestamp_echo));
307 NULL);
308 308
309 if (dccp_msk(sk)->dccpms_send_ack_vector && 309 if (dccp_msk(sk)->dccpms_send_ack_vector &&
310 dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk, 310 dccp_ackvec_add(dp->dccps_hc_rx_ackvec, sk,
@@ -585,36 +585,22 @@ discard:
585EXPORT_SYMBOL_GPL(dccp_rcv_state_process); 585EXPORT_SYMBOL_GPL(dccp_rcv_state_process);
586 586
587/** 587/**
588 * dccp_sample_rtt - Sample RTT from packet exchange 588 * dccp_sample_rtt - Validate and finalise computation of RTT sample
589 * 589 * @delta: number of microseconds between packet and acknowledgment
590 * @sk: connected dccp_sock 590 * The routine is kept generic to work in different contexts. It should be
591 * @t_recv: receive timestamp of packet with timestamp echo 591 * called immediately when the ACK used for the RTT sample arrives.
592 * @t_hist: packet history timestamp or NULL
593 */ 592 */
594u32 dccp_sample_rtt(struct sock *sk, ktime_t t_recv, ktime_t *t_hist) 593u32 dccp_sample_rtt(struct sock *sk, long delta)
595{ 594{
596 struct dccp_sock *dp = dccp_sk(sk); 595 /* dccpor_elapsed_time is either zeroed out or set and > 0 */
597 struct dccp_options_received *or = &dp->dccps_options_received; 596 delta -= dccp_sk(sk)->dccps_options_received.dccpor_elapsed_time * 10;
598 s64 delta;
599
600 if (t_hist == NULL) {
601 if (!or->dccpor_timestamp_echo) {
602 DCCP_WARN("packet without timestamp echo\n");
603 return DCCP_SANE_RTT_MAX;
604 }
605 ktime_sub_us(t_recv, or->dccpor_timestamp_echo * 10);
606 delta = ktime_to_us(t_recv);
607 } else
608 delta = ktime_us_delta(t_recv, *t_hist);
609
610 delta -= or->dccpor_elapsed_time * 10; /* either set or 0 */
611 597
612 if (unlikely(delta <= 0)) { 598 if (unlikely(delta <= 0)) {
613 DCCP_WARN("unusable RTT sample %ld, using min\n", (long)delta); 599 DCCP_WARN("unusable RTT sample %ld, using min\n", delta);
614 return DCCP_SANE_RTT_MIN; 600 return DCCP_SANE_RTT_MIN;
615 } 601 }
616 if (unlikely(delta - (s64)DCCP_SANE_RTT_MAX > 0)) { 602 if (unlikely(delta > DCCP_SANE_RTT_MAX)) {
617 DCCP_WARN("RTT sample %ld too large, using max\n", (long)delta); 603 DCCP_WARN("RTT sample %ld too large, using max\n", delta);
618 return DCCP_SANE_RTT_MAX; 604 return DCCP_SANE_RTT_MAX;
619 } 605 }
620 606