mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
net: socket infrastructure for SO_TIMESTAMPING
The overlap with the old SO_TIMESTAMP[NS] options is handled so that time stamping in software (net_enable_timestamp()) is enabled when SO_TIMESTAMP[NS] and/or SO_TIMESTAMPING_RX_SOFTWARE is set. It's disabled if all of these are off. Signed-off-by: Patrick Ohly <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
ac45f602ee
commit
20d4947353
4 changed files with 186 additions and 42 deletions
19
net/compat.c
19
net/compat.c
|
|
@ -216,7 +216,7 @@ Efault:
|
|||
int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
|
||||
{
|
||||
struct compat_timeval ctv;
|
||||
struct compat_timespec cts;
|
||||
struct compat_timespec cts[3];
|
||||
struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
|
||||
struct compat_cmsghdr cmhdr;
|
||||
int cmlen;
|
||||
|
|
@ -233,12 +233,17 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
|
|||
data = &ctv;
|
||||
len = sizeof(ctv);
|
||||
}
|
||||
if (level == SOL_SOCKET && type == SCM_TIMESTAMPNS) {
|
||||
if (level == SOL_SOCKET &&
|
||||
(type == SCM_TIMESTAMPNS || type == SCM_TIMESTAMPING)) {
|
||||
int count = type == SCM_TIMESTAMPNS ? 1 : 3;
|
||||
int i;
|
||||
struct timespec *ts = (struct timespec *)data;
|
||||
cts.tv_sec = ts->tv_sec;
|
||||
cts.tv_nsec = ts->tv_nsec;
|
||||
for (i = 0; i < count; i++) {
|
||||
cts[i].tv_sec = ts[i].tv_sec;
|
||||
cts[i].tv_nsec = ts[i].tv_nsec;
|
||||
}
|
||||
data = &cts;
|
||||
len = sizeof(cts);
|
||||
len = sizeof(cts[0]) * count;
|
||||
}
|
||||
|
||||
cmlen = CMSG_COMPAT_LEN(len);
|
||||
|
|
@ -455,7 +460,7 @@ int compat_sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp)
|
|||
struct timeval tv;
|
||||
|
||||
if (!sock_flag(sk, SOCK_TIMESTAMP))
|
||||
sock_enable_timestamp(sk);
|
||||
sock_enable_timestamp(sk, SOCK_TIMESTAMP);
|
||||
tv = ktime_to_timeval(sk->sk_stamp);
|
||||
if (tv.tv_sec == -1)
|
||||
return err;
|
||||
|
|
@ -479,7 +484,7 @@ int compat_sock_get_timestampns(struct sock *sk, struct timespec __user *usersta
|
|||
struct timespec ts;
|
||||
|
||||
if (!sock_flag(sk, SOCK_TIMESTAMP))
|
||||
sock_enable_timestamp(sk);
|
||||
sock_enable_timestamp(sk, SOCK_TIMESTAMP);
|
||||
ts = ktime_to_timespec(sk->sk_stamp);
|
||||
if (ts.tv_sec == -1)
|
||||
return err;
|
||||
|
|
|
|||
Loading…
Reference in a new issue