diff options
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 | { |