diff options
| -rw-r--r-- | include/linux/dccp.h | 1 | ||||
| -rw-r--r-- | net/dccp/ccids/ccid3.c | 27 | ||||
| -rw-r--r-- | net/dccp/ccids/ccid3.h | 2 | ||||
| -rw-r--r-- | net/dccp/ccids/lib/packet_history.h | 3 | ||||
| -rw-r--r-- | net/dccp/dccp.h | 16 | ||||
| -rw-r--r-- | net/dccp/input.c | 4 | ||||
| -rw-r--r-- | net/dccp/ipv4.c | 1 | ||||
| -rw-r--r-- | net/dccp/minisocks.c | 1 | ||||
| -rw-r--r-- | net/dccp/options.c | 45 |
9 files changed, 61 insertions, 39 deletions
diff --git a/include/linux/dccp.h b/include/linux/dccp.h index 5e0af0d08a93..8bf4bacb5051 100644 --- a/include/linux/dccp.h +++ b/include/linux/dccp.h | |||
| @@ -432,6 +432,7 @@ struct dccp_sock { | |||
| 432 | struct ccid *dccps_hc_rx_ccid; | 432 | struct ccid *dccps_hc_rx_ccid; |
| 433 | struct ccid *dccps_hc_tx_ccid; | 433 | struct ccid *dccps_hc_tx_ccid; |
| 434 | struct dccp_options_received dccps_options_received; | 434 | struct dccp_options_received dccps_options_received; |
| 435 | struct timeval dccps_epoch; | ||
| 435 | enum dccp_role dccps_role:2; | 436 | enum dccp_role dccps_role:2; |
| 436 | __u8 dccps_hc_rx_insert_options:1; | 437 | __u8 dccps_hc_rx_insert_options:1; |
| 437 | __u8 dccps_hc_tx_insert_options:1; | 438 | __u8 dccps_hc_tx_insert_options:1; |
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index 145aafafe4e2..348e6fb262c3 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
| @@ -169,7 +169,7 @@ static void ccid3_hc_tx_update_x(struct sock *sk) | |||
| 169 | } else { | 169 | } else { |
| 170 | struct timeval now; | 170 | struct timeval now; |
| 171 | 171 | ||
| 172 | do_gettimeofday(&now); | 172 | dccp_timestamp(sk, &now); |
| 173 | if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >= | 173 | if (timeval_delta(&now, &hctx->ccid3hctx_t_ld) >= |
| 174 | hctx->ccid3hctx_rtt) { | 174 | hctx->ccid3hctx_rtt) { |
| 175 | hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv, | 175 | hctx->ccid3hctx_x = max_t(u32, min_t(u32, hctx->ccid3hctx_x_recv, |
| @@ -317,7 +317,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
| 317 | dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); | 317 | dccp_tx_hist_add_entry(&hctx->ccid3hctx_hist, new_packet); |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | do_gettimeofday(&now); | 320 | dccp_timestamp(sk, &now); |
| 321 | 321 | ||
| 322 | switch (hctx->ccid3hctx_state) { | 322 | switch (hctx->ccid3hctx_state) { |
| 323 | case TFRC_SSTATE_NO_SENT: | 323 | case TFRC_SSTATE_NO_SENT: |
| @@ -382,7 +382,7 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) | |||
| 382 | return; | 382 | return; |
| 383 | } | 383 | } |
| 384 | 384 | ||
| 385 | do_gettimeofday(&now); | 385 | dccp_timestamp(sk, &now); |
| 386 | 386 | ||
| 387 | /* check if we have sent a data packet */ | 387 | /* check if we have sent a data packet */ |
| 388 | if (len > 0) { | 388 | if (len > 0) { |
| @@ -461,6 +461,7 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
| 461 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; | 461 | struct ccid3_hc_tx_sock *hctx = dp->dccps_hc_tx_ccid_private; |
| 462 | struct ccid3_options_received *opt_recv; | 462 | struct ccid3_options_received *opt_recv; |
| 463 | struct dccp_tx_hist_entry *packet; | 463 | struct dccp_tx_hist_entry *packet; |
| 464 | struct timeval now; | ||
| 464 | unsigned long next_tmout; | 465 | unsigned long next_tmout; |
| 465 | u32 t_elapsed; | 466 | u32 t_elapsed; |
| 466 | u32 pinv; | 467 | u32 pinv; |
| @@ -508,7 +509,8 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
| 508 | } | 509 | } |
| 509 | 510 | ||
| 510 | /* Update RTT */ | 511 | /* Update RTT */ |
| 511 | r_sample = timeval_now_delta(&packet->dccphtx_tstamp); | 512 | dccp_timestamp(sk, &now); |
| 513 | r_sample = timeval_delta(&now, &packet->dccphtx_tstamp); | ||
| 512 | if (unlikely(r_sample <= t_elapsed)) | 514 | if (unlikely(r_sample <= t_elapsed)) |
| 513 | LIMIT_NETDEBUG(KERN_WARNING | 515 | LIMIT_NETDEBUG(KERN_WARNING |
| 514 | "%s: r_sample=%uus, t_elapsed=%uus\n", | 516 | "%s: r_sample=%uus, t_elapsed=%uus\n", |
| @@ -774,7 +776,7 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) | |||
| 774 | 776 | ||
| 775 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); | 777 | ccid3_pr_debug("%s, sk=%p\n", dccp_role(sk), sk); |
| 776 | 778 | ||
| 777 | do_gettimeofday(&now); | 779 | dccp_timestamp(sk, &now); |
| 778 | 780 | ||
| 779 | switch (hcrx->ccid3hcrx_state) { | 781 | switch (hcrx->ccid3hcrx_state) { |
| 780 | case TFRC_RSTATE_NO_DATA: | 782 | case TFRC_RSTATE_NO_DATA: |
| @@ -903,10 +905,9 @@ found: | |||
| 903 | if (rtt == 0) | 905 | if (rtt == 0) |
| 904 | rtt = 1; | 906 | rtt = 1; |
| 905 | 907 | ||
| 906 | delta = timeval_now_delta(&hcrx->ccid3hcrx_tstamp_last_feedback); | 908 | dccp_timestamp(sk, &tstamp); |
| 907 | x_recv = hcrx->ccid3hcrx_bytes_recv * USEC_PER_SEC; | 909 | delta = timeval_delta(&tstamp, &hcrx->ccid3hcrx_tstamp_last_feedback); |
| 908 | if (likely(delta > 1)) | 910 | x_recv = usecs_div(hcrx->ccid3hcrx_bytes_recv, delta); |
| 909 | x_recv /= delta; | ||
| 910 | 911 | ||
| 911 | tmp1 = (u64)x_recv * (u64)rtt; | 912 | tmp1 = (u64)x_recv * (u64)rtt; |
| 912 | do_div(tmp1,10000000); | 913 | do_div(tmp1,10000000); |
| @@ -981,7 +982,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
| 981 | if (opt_recv->dccpor_timestamp_echo == 0) | 982 | if (opt_recv->dccpor_timestamp_echo == 0) |
| 982 | break; | 983 | break; |
| 983 | p_prev = hcrx->ccid3hcrx_rtt; | 984 | p_prev = hcrx->ccid3hcrx_rtt; |
| 984 | do_gettimeofday(&now); | 985 | dccp_timestamp(sk, &now); |
| 985 | timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10); | 986 | timeval_sub_usecs(&now, opt_recv->dccpor_timestamp_echo * 10); |
| 986 | r_sample = timeval_usecs(&now); | 987 | r_sample = timeval_usecs(&now); |
| 987 | t_elapsed = opt_recv->dccpor_elapsed_time * 10; | 988 | t_elapsed = opt_recv->dccpor_elapsed_time * 10; |
| @@ -1013,7 +1014,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
| 1013 | return; | 1014 | return; |
| 1014 | } | 1015 | } |
| 1015 | 1016 | ||
| 1016 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, opt_recv->dccpor_ndp, | 1017 | packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp, |
| 1017 | skb, SLAB_ATOMIC); | 1018 | skb, SLAB_ATOMIC); |
| 1018 | if (packet == NULL) { | 1019 | if (packet == NULL) { |
| 1019 | ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet " | 1020 | ccid3_pr_debug("%s, sk=%p, Not enough mem to add rx packet " |
| @@ -1045,7 +1046,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
| 1045 | if (ins != 0) | 1046 | if (ins != 0) |
| 1046 | break; | 1047 | break; |
| 1047 | 1048 | ||
| 1048 | do_gettimeofday(&now); | 1049 | dccp_timestamp(sk, &now); |
| 1049 | if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >= | 1050 | if (timeval_delta(&now, &hcrx->ccid3hcrx_tstamp_last_ack) >= |
| 1050 | hcrx->ccid3hcrx_rtt) { | 1051 | hcrx->ccid3hcrx_rtt) { |
| 1051 | hcrx->ccid3hcrx_tstamp_last_ack = now; | 1052 | hcrx->ccid3hcrx_tstamp_last_ack = now; |
| @@ -1100,7 +1101,7 @@ static int ccid3_hc_rx_init(struct sock *sk) | |||
| 1100 | hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; | 1101 | hcrx->ccid3hcrx_state = TFRC_RSTATE_NO_DATA; |
| 1101 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); | 1102 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_hist); |
| 1102 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); | 1103 | INIT_LIST_HEAD(&hcrx->ccid3hcrx_li_hist); |
| 1103 | do_gettimeofday(&hcrx->ccid3hcrx_tstamp_last_ack); | 1104 | dccp_timestamp(sk, &hcrx->ccid3hcrx_tstamp_last_ack); |
| 1104 | hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack; | 1105 | hcrx->ccid3hcrx_tstamp_last_feedback = hcrx->ccid3hcrx_tstamp_last_ack; |
| 1105 | hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */ | 1106 | hcrx->ccid3hcrx_rtt = 5000; /* XXX 5ms for now... */ |
| 1106 | return 0; | 1107 | return 0; |
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h index ee8cbace6630..58be6125b695 100644 --- a/net/dccp/ccids/ccid3.h +++ b/net/dccp/ccids/ccid3.h | |||
| @@ -115,7 +115,7 @@ struct ccid3_hc_rx_sock { | |||
| 115 | u64 ccid3hcrx_seqno_last_counter:48, | 115 | u64 ccid3hcrx_seqno_last_counter:48, |
| 116 | ccid3hcrx_state:8, | 116 | ccid3hcrx_state:8, |
| 117 | ccid3hcrx_last_counter:4; | 117 | ccid3hcrx_last_counter:4; |
| 118 | unsigned long ccid3hcrx_rtt; | 118 | u32 ccid3hcrx_rtt; |
| 119 | u32 ccid3hcrx_p; | 119 | u32 ccid3hcrx_p; |
| 120 | u32 ccid3hcrx_bytes_recv; | 120 | u32 ccid3hcrx_bytes_recv; |
| 121 | struct timeval ccid3hcrx_tstamp_last_feedback; | 121 | struct timeval ccid3hcrx_tstamp_last_feedback; |
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h index fb90a91aa93d..b375ebdb7dcf 100644 --- a/net/dccp/ccids/lib/packet_history.h +++ b/net/dccp/ccids/lib/packet_history.h | |||
| @@ -134,6 +134,7 @@ static inline struct dccp_tx_hist_entry * | |||
| 134 | 134 | ||
| 135 | static inline struct dccp_rx_hist_entry * | 135 | static inline struct dccp_rx_hist_entry * |
| 136 | dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, | 136 | dccp_rx_hist_entry_new(struct dccp_rx_hist *hist, |
| 137 | const struct sock *sk, | ||
| 137 | const u32 ndp, | 138 | const u32 ndp, |
| 138 | const struct sk_buff *skb, | 139 | const struct sk_buff *skb, |
| 139 | const unsigned int __nocast prio) | 140 | const unsigned int __nocast prio) |
| @@ -148,7 +149,7 @@ static inline struct dccp_rx_hist_entry * | |||
| 148 | entry->dccphrx_ccval = dh->dccph_ccval; | 149 | entry->dccphrx_ccval = dh->dccph_ccval; |
| 149 | entry->dccphrx_type = dh->dccph_type; | 150 | entry->dccphrx_type = dh->dccph_type; |
| 150 | entry->dccphrx_ndp = ndp; | 151 | entry->dccphrx_ndp = ndp; |
| 151 | do_gettimeofday(&(entry->dccphrx_tstamp)); | 152 | dccp_timestamp(sk, &entry->dccphrx_tstamp); |
| 152 | } | 153 | } |
| 153 | 154 | ||
| 154 | return entry; | 155 | return entry; |
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 33456c0d5937..95c4630b3b18 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h | |||
| @@ -426,10 +426,13 @@ extern struct dccp_ackpkts * | |||
| 426 | dccp_ackpkts_alloc(unsigned int len, | 426 | dccp_ackpkts_alloc(unsigned int len, |
| 427 | const unsigned int __nocast priority); | 427 | const unsigned int __nocast priority); |
| 428 | extern void dccp_ackpkts_free(struct dccp_ackpkts *ap); | 428 | extern void dccp_ackpkts_free(struct dccp_ackpkts *ap); |
| 429 | extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state); | 429 | extern int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk, |
| 430 | u64 ackno, u8 state); | ||
| 430 | extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, | 431 | extern void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, |
| 431 | struct sock *sk, u64 ackno); | 432 | struct sock *sk, u64 ackno); |
| 432 | 433 | ||
| 434 | extern void dccp_timestamp(const struct sock *sk, struct timeval *tv); | ||
| 435 | |||
| 433 | static inline suseconds_t timeval_usecs(const struct timeval *tv) | 436 | static inline suseconds_t timeval_usecs(const struct timeval *tv) |
| 434 | { | 437 | { |
| 435 | return tv->tv_sec * USEC_PER_SEC + tv->tv_usec; | 438 | return tv->tv_sec * USEC_PER_SEC + tv->tv_usec; |
| @@ -468,17 +471,6 @@ static inline void timeval_sub_usecs(struct timeval *tv, | |||
| 468 | } | 471 | } |
| 469 | } | 472 | } |
| 470 | 473 | ||
| 471 | /* | ||
| 472 | * Returns the difference in usecs between timeval | ||
| 473 | * passed in and current time | ||
| 474 | */ | ||
| 475 | static inline suseconds_t timeval_now_delta(const struct timeval *tv) | ||
| 476 | { | ||
| 477 | struct timeval now; | ||
| 478 | do_gettimeofday(&now); | ||
| 479 | return timeval_delta(&now, tv); | ||
| 480 | } | ||
| 481 | |||
| 482 | #ifdef CONFIG_IP_DCCP_DEBUG | 474 | #ifdef CONFIG_IP_DCCP_DEBUG |
| 483 | extern void dccp_ackvector_print(const u64 ackno, | 475 | extern void dccp_ackvector_print(const u64 ackno, |
| 484 | const unsigned char *vector, int len); | 476 | const unsigned char *vector, int len); |
diff --git a/net/dccp/input.c b/net/dccp/input.c index ef29cef1dafe..c60bc3433f5e 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c | |||
| @@ -170,7 +170,7 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, | |||
| 170 | if (dp->dccps_options.dccpo_send_ack_vector) { | 170 | if (dp->dccps_options.dccpo_send_ack_vector) { |
| 171 | struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; | 171 | struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; |
| 172 | 172 | ||
| 173 | if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, | 173 | if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk, |
| 174 | DCCP_SKB_CB(skb)->dccpd_seq, | 174 | DCCP_SKB_CB(skb)->dccpd_seq, |
| 175 | DCCP_ACKPKTS_STATE_RECEIVED)) { | 175 | DCCP_ACKPKTS_STATE_RECEIVED)) { |
| 176 | LIMIT_NETDEBUG(KERN_WARNING "DCCP: acknowledgeable " | 176 | LIMIT_NETDEBUG(KERN_WARNING "DCCP: acknowledgeable " |
| @@ -498,7 +498,7 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | |||
| 498 | * DCCP_ACKPKTS_STATE_ECN_MARKED | 498 | * DCCP_ACKPKTS_STATE_ECN_MARKED |
| 499 | */ | 499 | */ |
| 500 | if (dp->dccps_options.dccpo_send_ack_vector) { | 500 | if (dp->dccps_options.dccpo_send_ack_vector) { |
| 501 | if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, | 501 | if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, sk, |
| 502 | DCCP_SKB_CB(skb)->dccpd_seq, | 502 | DCCP_SKB_CB(skb)->dccpd_seq, |
| 503 | DCCP_ACKPKTS_STATE_RECEIVED)) | 503 | DCCP_ACKPKTS_STATE_RECEIVED)) |
| 504 | goto discard; | 504 | goto discard; |
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 3fc75dbee4b8..fee9a8c3777b 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
| @@ -1243,6 +1243,7 @@ static int dccp_v4_init_sock(struct sock *sk) | |||
| 1243 | static int dccp_ctl_socket_init = 1; | 1243 | static int dccp_ctl_socket_init = 1; |
| 1244 | 1244 | ||
| 1245 | dccp_options_init(&dp->dccps_options); | 1245 | dccp_options_init(&dp->dccps_options); |
| 1246 | do_gettimeofday(&dp->dccps_epoch); | ||
| 1246 | 1247 | ||
| 1247 | if (dp->dccps_options.dccpo_send_ack_vector) { | 1248 | if (dp->dccps_options.dccpo_send_ack_vector) { |
| 1248 | dp->dccps_hc_rx_ackpkts = | 1249 | dp->dccps_hc_rx_ackpkts = |
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index ce5dff4ac22e..18461bc04cbe 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c | |||
| @@ -96,6 +96,7 @@ struct sock *dccp_create_openreq_child(struct sock *sk, | |||
| 96 | newdp->dccps_hc_rx_ackpkts = NULL; | 96 | newdp->dccps_hc_rx_ackpkts = NULL; |
| 97 | newdp->dccps_role = DCCP_ROLE_SERVER; | 97 | newdp->dccps_role = DCCP_ROLE_SERVER; |
| 98 | newicsk->icsk_rto = DCCP_TIMEOUT_INIT; | 98 | newicsk->icsk_rto = DCCP_TIMEOUT_INIT; |
| 99 | do_gettimeofday(&newdp->dccps_epoch); | ||
| 99 | 100 | ||
| 100 | if (newdp->dccps_options.dccpo_send_ack_vector) { | 101 | if (newdp->dccps_options.dccpo_send_ack_vector) { |
| 101 | newdp->dccps_hc_rx_ackpkts = | 102 | newdp->dccps_hc_rx_ackpkts = |
diff --git a/net/dccp/options.c b/net/dccp/options.c index 34b230a00875..d4c4242d8dd7 100644 --- a/net/dccp/options.c +++ b/net/dccp/options.c | |||
| @@ -140,7 +140,7 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) | |||
| 140 | opt_recv->dccpor_timestamp = ntohl(*(u32 *)value); | 140 | opt_recv->dccpor_timestamp = ntohl(*(u32 *)value); |
| 141 | 141 | ||
| 142 | dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp; | 142 | dp->dccps_timestamp_echo = opt_recv->dccpor_timestamp; |
| 143 | do_gettimeofday(&dp->dccps_timestamp_time); | 143 | dccp_timestamp(sk, &dp->dccps_timestamp_time); |
| 144 | 144 | ||
| 145 | dccp_pr_debug("%sTIMESTAMP=%u, ackno=%llu\n", | 145 | dccp_pr_debug("%sTIMESTAMP=%u, ackno=%llu\n", |
| 146 | debug_prefix, opt_recv->dccpor_timestamp, | 146 | debug_prefix, opt_recv->dccpor_timestamp, |
| @@ -361,9 +361,13 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) | |||
| 361 | #endif | 361 | #endif |
| 362 | struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; | 362 | struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; |
| 363 | int len = ap->dccpap_buf_vector_len + 2; | 363 | int len = ap->dccpap_buf_vector_len + 2; |
| 364 | const u32 elapsed_time = timeval_now_delta(&ap->dccpap_time) / 10; | 364 | struct timeval now; |
| 365 | u32 elapsed_time; | ||
| 365 | unsigned char *to, *from; | 366 | unsigned char *to, *from; |
| 366 | 367 | ||
| 368 | dccp_timestamp(sk, &now); | ||
| 369 | elapsed_time = timeval_delta(&now, &ap->dccpap_time) / 10; | ||
| 370 | |||
| 367 | if (elapsed_time != 0) | 371 | if (elapsed_time != 0) |
| 368 | dccp_insert_option_elapsed_time(sk, skb, elapsed_time); | 372 | dccp_insert_option_elapsed_time(sk, skb, elapsed_time); |
| 369 | 373 | ||
| @@ -428,13 +432,29 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) | |||
| 428 | (unsigned long long) ap->dccpap_ack_ackno); | 432 | (unsigned long long) ap->dccpap_ack_ackno); |
| 429 | } | 433 | } |
| 430 | 434 | ||
| 435 | void dccp_timestamp(const struct sock *sk, struct timeval *tv) | ||
| 436 | { | ||
| 437 | const struct dccp_sock *dp = dccp_sk(sk); | ||
| 438 | |||
| 439 | do_gettimeofday(tv); | ||
| 440 | tv->tv_sec -= dp->dccps_epoch.tv_sec; | ||
| 441 | tv->tv_usec -= dp->dccps_epoch.tv_usec; | ||
| 442 | |||
| 443 | while (tv->tv_usec < 0) { | ||
| 444 | tv->tv_sec--; | ||
| 445 | tv->tv_usec += USEC_PER_SEC; | ||
| 446 | } | ||
| 447 | } | ||
| 448 | |||
| 449 | EXPORT_SYMBOL_GPL(dccp_timestamp); | ||
| 450 | |||
| 431 | void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb) | 451 | void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb) |
| 432 | { | 452 | { |
| 433 | struct timeval tv; | 453 | struct timeval tv; |
| 434 | u32 now; | 454 | u32 now; |
| 435 | 455 | ||
| 436 | do_gettimeofday(&tv); | 456 | dccp_timestamp(sk, &tv); |
| 437 | now = (tv.tv_sec * USEC_PER_SEC + tv.tv_usec) / 10; | 457 | now = timeval_usecs(&tv) / 10; |
| 438 | /* yes this will overflow but that is the point as we want a | 458 | /* yes this will overflow but that is the point as we want a |
| 439 | * 10 usec 32 bit timer which mean it wraps every 11.9 hours */ | 459 | * 10 usec 32 bit timer which mean it wraps every 11.9 hours */ |
| 440 | 460 | ||
| @@ -452,13 +472,17 @@ static void dccp_insert_option_timestamp_echo(struct sock *sk, | |||
| 452 | const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? | 472 | const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? |
| 453 | "CLIENT TX opt: " : "server TX opt: "; | 473 | "CLIENT TX opt: " : "server TX opt: "; |
| 454 | #endif | 474 | #endif |
| 475 | struct timeval now; | ||
| 455 | u32 tstamp_echo; | 476 | u32 tstamp_echo; |
| 456 | const u32 elapsed_time = | 477 | u32 elapsed_time; |
| 457 | timeval_now_delta(&dp->dccps_timestamp_time) / 10; | 478 | int len, elapsed_time_len; |
| 458 | const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time); | ||
| 459 | const int len = 6 + elapsed_time_len; | ||
| 460 | unsigned char *to; | 479 | unsigned char *to; |
| 461 | 480 | ||
| 481 | dccp_timestamp(sk, &now); | ||
| 482 | elapsed_time = timeval_delta(&now, &dp->dccps_timestamp_time) / 10; | ||
| 483 | elapsed_time_len = dccp_elapsed_time_len(elapsed_time); | ||
| 484 | len = 6 + elapsed_time_len; | ||
| 485 | |||
| 462 | if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { | 486 | if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { |
| 463 | LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert " | 487 | LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert " |
| 464 | "timestamp echo!\n"); | 488 | "timestamp echo!\n"); |
| @@ -623,7 +647,8 @@ static inline int dccp_ackpkts_set_buf_head_state(struct dccp_ackpkts *ap, | |||
| 623 | /* | 647 | /* |
| 624 | * Implements the draft-ietf-dccp-spec-11.txt Appendix A | 648 | * Implements the draft-ietf-dccp-spec-11.txt Appendix A |
| 625 | */ | 649 | */ |
| 626 | int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) | 650 | int dccp_ackpkts_add(struct dccp_ackpkts *ap, const struct sock *sk, |
| 651 | u64 ackno, u8 state) | ||
| 627 | { | 652 | { |
| 628 | /* | 653 | /* |
| 629 | * Check at the right places if the buffer is full, if it is, tell the | 654 | * Check at the right places if the buffer is full, if it is, tell the |
| @@ -704,7 +729,7 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) | |||
| 704 | } | 729 | } |
| 705 | 730 | ||
| 706 | ap->dccpap_buf_ackno = ackno; | 731 | ap->dccpap_buf_ackno = ackno; |
| 707 | do_gettimeofday(&ap->dccpap_time); | 732 | dccp_timestamp(sk, &ap->dccpap_time); |
| 708 | out: | 733 | out: |
| 709 | dccp_pr_debug(""); | 734 | dccp_pr_debug(""); |
| 710 | dccp_ackpkts_print(ap); | 735 | dccp_ackpkts_print(ap); |
