diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2007-03-18 20:33:16 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:24:04 -0400 |
commit | ae40eb1ef30ab4120bd3c8b7e3da99ee53d27a23 (patch) | |
tree | b5ae288b3c27d13bde9648c41d7db3cfe1884bc2 /net/compat.c | |
parent | cb69cc52364690d7789940c480b3a9490784b680 (diff) |
[NET]: Introduce SIOCGSTAMPNS ioctl to get timestamps with nanosec resolution
Now network timestamps use ktime_t infrastructure, we can add a new
ioctl() SIOCGSTAMPNS command to get timestamps in 'struct timespec'.
User programs can thus access to nanosecond resolution.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
CC: Stephen Hemminger <shemminger@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/compat.c')
-rw-r--r-- | net/compat.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/net/compat.c b/net/compat.c index 17c2710b2b93..2fc6d9bb622b 100644 --- a/net/compat.c +++ b/net/compat.c | |||
@@ -564,6 +564,30 @@ int compat_sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp) | |||
564 | } | 564 | } |
565 | EXPORT_SYMBOL(compat_sock_get_timestamp); | 565 | EXPORT_SYMBOL(compat_sock_get_timestamp); |
566 | 566 | ||
567 | int compat_sock_get_timestampns(struct sock *sk, struct timespec __user *userstamp) | ||
568 | { | ||
569 | struct compat_timespec __user *ctv = | ||
570 | (struct compat_timespec __user*) userstamp; | ||
571 | int err = -ENOENT; | ||
572 | struct timespec ts; | ||
573 | |||
574 | if (!sock_flag(sk, SOCK_TIMESTAMP)) | ||
575 | sock_enable_timestamp(sk); | ||
576 | ts = ktime_to_timespec(sk->sk_stamp); | ||
577 | if (ts.tv_sec == -1) | ||
578 | return err; | ||
579 | if (ts.tv_sec == 0) { | ||
580 | sk->sk_stamp = ktime_get_real(); | ||
581 | ts = ktime_to_timespec(sk->sk_stamp); | ||
582 | } | ||
583 | err = 0; | ||
584 | if (put_user(ts.tv_sec, &ctv->tv_sec) || | ||
585 | put_user(ts.tv_nsec, &ctv->tv_nsec)) | ||
586 | err = -EFAULT; | ||
587 | return err; | ||
588 | } | ||
589 | EXPORT_SYMBOL(compat_sock_get_timestampns); | ||
590 | |||
567 | asmlinkage long compat_sys_getsockopt(int fd, int level, int optname, | 591 | asmlinkage long compat_sys_getsockopt(int fd, int level, int optname, |
568 | char __user *optval, int __user *optlen) | 592 | char __user *optval, int __user *optlen) |
569 | { | 593 | { |