aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/dccp/dccp.h2
-rw-r--r--net/dccp/options.c2
-rw-r--r--net/dccp/proto.c2
-rw-r--r--net/dccp/timer.c21
4 files changed, 26 insertions, 1 deletions
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index ddacc23be5e8..a75c740ae6c0 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -396,6 +396,8 @@ extern int dccp_insert_options(struct sock *sk, struct sk_buff *skb);
396extern int dccp_insert_option_elapsed_time(struct sock *sk, 396extern int dccp_insert_option_elapsed_time(struct sock *sk,
397 struct sk_buff *skb, 397 struct sk_buff *skb,
398 u32 elapsed_time); 398 u32 elapsed_time);
399extern u32 dccp_timestamp(void);
400extern void dccp_timestamping_init(void);
399extern int dccp_insert_option_timestamp(struct sock *sk, 401extern int dccp_insert_option_timestamp(struct sock *sk,
400 struct sk_buff *skb); 402 struct sk_buff *skb);
401extern int dccp_insert_option(struct sock *sk, struct sk_buff *skb, 403extern int dccp_insert_option(struct sock *sk, struct sk_buff *skb,
diff --git a/net/dccp/options.c b/net/dccp/options.c
index 167415677a75..a57fcbd7d03c 100644
--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -372,7 +372,7 @@ EXPORT_SYMBOL_GPL(dccp_insert_option_elapsed_time);
372 372
373int dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb) 373int dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb)
374{ 374{
375 __be32 now = htonl(((suseconds_t)ktime_to_us(ktime_get_real())) / 10); 375 __be32 now = htonl(dccp_timestamp());
376 /* yes this will overflow but that is the point as we want a 376 /* yes this will overflow but that is the point as we want a
377 * 10 usec 32 bit timer which mean it wraps every 11.9 hours */ 377 * 10 usec 32 bit timer which mean it wraps every 11.9 hours */
378 378
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 8d545da35262..14ec1d21452c 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -1076,6 +1076,8 @@ static int __init dccp_init(void)
1076 rc = dccp_sysctl_init(); 1076 rc = dccp_sysctl_init();
1077 if (rc) 1077 if (rc)
1078 goto out_ackvec_exit; 1078 goto out_ackvec_exit;
1079
1080 dccp_timestamping_init();
1079out: 1081out:
1080 return rc; 1082 return rc;
1081out_ackvec_exit: 1083out_ackvec_exit:
diff --git a/net/dccp/timer.c b/net/dccp/timer.c
index 0197a41c256a..3af067354bd4 100644
--- a/net/dccp/timer.c
+++ b/net/dccp/timer.c
@@ -291,3 +291,24 @@ void dccp_init_xmit_timers(struct sock *sk)
291 inet_csk_init_xmit_timers(sk, &dccp_write_timer, &dccp_delack_timer, 291 inet_csk_init_xmit_timers(sk, &dccp_write_timer, &dccp_delack_timer,
292 &dccp_keepalive_timer); 292 &dccp_keepalive_timer);
293} 293}
294
295static ktime_t dccp_timestamp_seed;
296/**
297 * dccp_timestamp - 10s of microseconds time source
298 * Returns the number of 10s of microseconds since loading DCCP. This is native
299 * DCCP time difference format (RFC 4340, sec. 13).
300 * Please note: This will wrap around about circa every 11.9 hours.
301 */
302u32 dccp_timestamp(void)
303{
304 s64 delta = ktime_us_delta(ktime_get_real(), dccp_timestamp_seed);
305
306 do_div(delta, 10);
307 return delta;
308}
309EXPORT_SYMBOL_GPL(dccp_timestamp);
310
311void __init dccp_timestamping_init(void)
312{
313 dccp_timestamp_seed = ktime_get_real();
314}