[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>
This commit is contained in:
parent
cb69cc5236
commit
ae40eb1ef3
37 changed files with 146 additions and 22 deletions
|
@ -1567,6 +1567,22 @@ int sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp)
|
|||
}
|
||||
EXPORT_SYMBOL(sock_get_timestamp);
|
||||
|
||||
int sock_get_timestampns(struct sock *sk, struct timespec __user *userstamp)
|
||||
{
|
||||
struct timespec ts;
|
||||
if (!sock_flag(sk, SOCK_TIMESTAMP))
|
||||
sock_enable_timestamp(sk);
|
||||
ts = ktime_to_timespec(sk->sk_stamp);
|
||||
if (ts.tv_sec == -1)
|
||||
return -ENOENT;
|
||||
if (ts.tv_sec == 0) {
|
||||
sk->sk_stamp = ktime_get_real();
|
||||
ts = ktime_to_timespec(sk->sk_stamp);
|
||||
}
|
||||
return copy_to_user(userstamp, &ts, sizeof(ts)) ? -EFAULT : 0;
|
||||
}
|
||||
EXPORT_SYMBOL(sock_get_timestampns);
|
||||
|
||||
void sock_enable_timestamp(struct sock *sk)
|
||||
{
|
||||
if (!sock_flag(sk, SOCK_TIMESTAMP)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue