aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2007-03-18 20:33:16 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:24:04 -0400
commitae40eb1ef30ab4120bd3c8b7e3da99ee53d27a23 (patch)
treeb5ae288b3c27d13bde9648c41d7db3cfe1884bc2 /net/core
parentcb69cc52364690d7789940c480b3a9490784b680 (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/core')
-rw-r--r--net/core/sock.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index 6ddb3664b993..cb48fa0e1249 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1567,6 +1567,22 @@ int sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp)
1567} 1567}
1568EXPORT_SYMBOL(sock_get_timestamp); 1568EXPORT_SYMBOL(sock_get_timestamp);
1569 1569
1570int sock_get_timestampns(struct sock *sk, struct timespec __user *userstamp)
1571{
1572 struct timespec ts;
1573 if (!sock_flag(sk, SOCK_TIMESTAMP))
1574 sock_enable_timestamp(sk);
1575 ts = ktime_to_timespec(sk->sk_stamp);
1576 if (ts.tv_sec == -1)
1577 return -ENOENT;
1578 if (ts.tv_sec == 0) {
1579 sk->sk_stamp = ktime_get_real();
1580 ts = ktime_to_timespec(sk->sk_stamp);
1581 }
1582 return copy_to_user(userstamp, &ts, sizeof(ts)) ? -EFAULT : 0;
1583}
1584EXPORT_SYMBOL(sock_get_timestampns);
1585
1570void sock_enable_timestamp(struct sock *sk) 1586void sock_enable_timestamp(struct sock *sk)
1571{ 1587{
1572 if (!sock_flag(sk, SOCK_TIMESTAMP)) { 1588 if (!sock_flag(sk, SOCK_TIMESTAMP)) {