diff options
-rw-r--r-- | net/dccp/ccids/ccid3.c | 6 | ||||
-rw-r--r-- | net/dccp/dccp.h | 3 | ||||
-rw-r--r-- | net/dccp/input.c | 44 |
3 files changed, 19 insertions, 34 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index e16f9bb9eaaf..0bb338be9dd7 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -448,7 +448,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
448 | * Calculate new round trip sample as per [RFC 3448, 4.3] by | 448 | * Calculate new round trip sample as per [RFC 3448, 4.3] by |
449 | * R_sample = (now - t_recvdata) - t_elapsed | 449 | * R_sample = (now - t_recvdata) - t_elapsed |
450 | */ | 450 | */ |
451 | r_sample = dccp_sample_rtt(sk, now, &packet->dccphtx_tstamp); | 451 | r_sample = dccp_sample_rtt(sk, ktime_us_delta(now, packet->dccphtx_tstamp)); |
452 | 452 | ||
453 | /* | 453 | /* |
454 | * Update RTT estimate by | 454 | * Update RTT estimate by |
@@ -881,9 +881,9 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
881 | case DCCP_PKT_DATAACK: | 881 | case DCCP_PKT_DATAACK: |
882 | if (opt_recv->dccpor_timestamp_echo == 0) | 882 | if (opt_recv->dccpor_timestamp_echo == 0) |
883 | break; | 883 | break; |
884 | r_sample = dccp_timestamp() - opt_recv->dccpor_timestamp_echo; | ||
884 | rtt_prev = hcrx->ccid3hcrx_rtt; | 885 | rtt_prev = hcrx->ccid3hcrx_rtt; |
885 | now = ktime_get_real(); | 886 | r_sample = dccp_sample_rtt(sk, 10 * r_sample); |
886 | r_sample = dccp_sample_rtt(sk, now, NULL); | ||
887 | 887 | ||
888 | if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) | 888 | if (hcrx->ccid3hcrx_state == TFRC_RSTATE_NO_DATA) |
889 | hcrx->ccid3hcrx_rtt = r_sample; | 889 | hcrx->ccid3hcrx_rtt = r_sample; |
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index a75c740ae6c0..bd4645b3a36c 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h | |||
@@ -297,8 +297,7 @@ extern int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, | |||
297 | extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code); | 297 | extern int dccp_send_reset(struct sock *sk, enum dccp_reset_codes code); |
298 | extern void dccp_send_close(struct sock *sk, const int active); | 298 | extern void dccp_send_close(struct sock *sk, const int active); |
299 | extern int dccp_invalid_packet(struct sk_buff *skb); | 299 | extern int dccp_invalid_packet(struct sk_buff *skb); |
300 | extern u32 dccp_sample_rtt(struct sock *sk, ktime_t t_recv, | 300 | extern u32 dccp_sample_rtt(struct sock *sk, long delta); |
301 | ktime_t *t_history); | ||
302 | 301 | ||
303 | static inline int dccp_bad_service_code(const struct sock *sk, | 302 | static inline int dccp_bad_service_code(const struct sock *sk, |
304 | const __be32 service) | 303 | const __be32 service) |
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: | |||
585 | EXPORT_SYMBOL_GPL(dccp_rcv_state_process); | 585 | EXPORT_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 | */ |
594 | u32 dccp_sample_rtt(struct sock *sk, ktime_t t_recv, ktime_t *t_hist) | 593 | u32 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 | ||