Commit f25c3d61 authored by YOSHIFUJI Hideaki's avatar YOSHIFUJI Hideaki Committed by David S. Miller

[IPV4]: Convert do_gettimeofday() to getnstimeofday().

What do_gettimeofday() does is to call getnstimeofday() and
to convert the result from timespec{} to timeval{}.
After that, these callers convert the result again to msec.
Use getnstimeofday() and convert the units at once.
Signed-off-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 263173af
...@@ -847,7 +847,7 @@ static void icmp_echo(struct sk_buff *skb) ...@@ -847,7 +847,7 @@ static void icmp_echo(struct sk_buff *skb)
*/ */
static void icmp_timestamp(struct sk_buff *skb) static void icmp_timestamp(struct sk_buff *skb)
{ {
struct timeval tv; struct timespec tv;
struct icmp_bxm icmp_param; struct icmp_bxm icmp_param;
/* /*
* Too short. * Too short.
...@@ -858,9 +858,9 @@ static void icmp_timestamp(struct sk_buff *skb) ...@@ -858,9 +858,9 @@ static void icmp_timestamp(struct sk_buff *skb)
/* /*
* Fill in the current time as ms since midnight UT: * Fill in the current time as ms since midnight UT:
*/ */
do_gettimeofday(&tv); getnstimeofday(&tv);
icmp_param.data.times[1] = htonl((tv.tv_sec % 86400) * 1000 + icmp_param.data.times[1] = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC +
tv.tv_usec / 1000); tv.tv_nsec / NSEC_PER_MSEC);
icmp_param.data.times[2] = icmp_param.data.times[1]; icmp_param.data.times[2] = icmp_param.data.times[1];
if (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4)) if (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4))
BUG(); BUG();
......
...@@ -55,10 +55,10 @@ void ip_options_build(struct sk_buff * skb, struct ip_options * opt, ...@@ -55,10 +55,10 @@ void ip_options_build(struct sk_buff * skb, struct ip_options * opt,
if (opt->ts_needaddr) if (opt->ts_needaddr)
ip_rt_get_source(iph+opt->ts+iph[opt->ts+2]-9, rt); ip_rt_get_source(iph+opt->ts+iph[opt->ts+2]-9, rt);
if (opt->ts_needtime) { if (opt->ts_needtime) {
struct timeval tv; struct timespec tv;
__be32 midtime; __be32 midtime;
do_gettimeofday(&tv); getnstimeofday(&tv);
midtime = htonl((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000); midtime = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC + tv.tv_nsec / NSEC_PER_MSEC);
memcpy(iph+opt->ts+iph[opt->ts+2]-5, &midtime, 4); memcpy(iph+opt->ts+iph[opt->ts+2]-5, &midtime, 4);
} }
return; return;
...@@ -406,10 +406,10 @@ int ip_options_compile(struct net *net, ...@@ -406,10 +406,10 @@ int ip_options_compile(struct net *net,
break; break;
} }
if (timeptr) { if (timeptr) {
struct timeval tv; struct timespec tv;
__be32 midtime; __be32 midtime;
do_gettimeofday(&tv); getnstimeofday(&tv);
midtime = htonl((tv.tv_sec % 86400) * 1000 + tv.tv_usec / 1000); midtime = htonl((tv.tv_sec % 86400) * MSEC_PER_SEC + tv.tv_nsec / NSEC_PER_MSEC);
memcpy(timeptr, &midtime, sizeof(__be32)); memcpy(timeptr, &midtime, sizeof(__be32));
opt->is_changed = 1; opt->is_changed = 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment