diff options
author | Eric Dumazet <dada1@cosmosbay.com> | 2007-03-26 01:14:49 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:24:21 -0400 |
commit | 92f37fd2ee805aa77925c1e64fd56088b46094fc (patch) | |
tree | 8251c38b83ab362116dac89d94412ce229b42831 /include/net | |
parent | c7a3c5da35055e2fa97ed4f0da3eec4bd0ef4c38 (diff) |
[NET]: Adding SO_TIMESTAMPNS / SCM_TIMESTAMPNS support
Now that network timestamps use ktime_t infrastructure, we can add a new
SOL_SOCKET sockopt SO_TIMESTAMPNS.
This command is similar to SO_TIMESTAMP, but permits transmission of
a 'timespec struct' instead of a 'timeval struct' control message.
(nanosecond resolution instead of microsecond)
Control message is labelled SCM_TIMESTAMPNS instead of SCM_TIMESTAMP
A socket cannot mix SO_TIMESTAMP and SO_TIMESTAMPNS : the two modes are
mutually exclusive.
sock_recv_timestamp() became too big to be fully inlined so I added a
__sock_recv_timestamp() helper function.
Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
CC: linux-arch@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/sock.h | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 51246579592e..390c04700590 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -390,6 +390,7 @@ enum sock_flags { | |||
390 | SOCK_USE_WRITE_QUEUE, /* whether to call sk->sk_write_space in sock_wfree */ | 390 | SOCK_USE_WRITE_QUEUE, /* whether to call sk->sk_write_space in sock_wfree */ |
391 | SOCK_DBG, /* %SO_DEBUG setting */ | 391 | SOCK_DBG, /* %SO_DEBUG setting */ |
392 | SOCK_RCVTSTAMP, /* %SO_TIMESTAMP setting */ | 392 | SOCK_RCVTSTAMP, /* %SO_TIMESTAMP setting */ |
393 | SOCK_RCVTSTAMPNS, /* %SO_TIMESTAMPNS setting */ | ||
393 | SOCK_LOCALROUTE, /* route locally only, %SO_DONTROUTE setting */ | 394 | SOCK_LOCALROUTE, /* route locally only, %SO_DONTROUTE setting */ |
394 | SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */ | 395 | SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */ |
395 | }; | 396 | }; |
@@ -1283,21 +1284,17 @@ static inline int sock_intr_errno(long timeo) | |||
1283 | return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR; | 1284 | return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR; |
1284 | } | 1285 | } |
1285 | 1286 | ||
1287 | extern void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, | ||
1288 | struct sk_buff *skb); | ||
1289 | |||
1286 | static __inline__ void | 1290 | static __inline__ void |
1287 | sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) | 1291 | sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) |
1288 | { | 1292 | { |
1289 | ktime_t kt = skb->tstamp; | 1293 | ktime_t kt = skb->tstamp; |
1290 | 1294 | ||
1291 | if (sock_flag(sk, SOCK_RCVTSTAMP)) { | 1295 | if (sock_flag(sk, SOCK_RCVTSTAMP)) |
1292 | struct timeval tv; | 1296 | __sock_recv_timestamp(msg, sk, skb); |
1293 | /* Race occurred between timestamp enabling and packet | 1297 | else |
1294 | receiving. Fill in the current time for now. */ | ||
1295 | if (kt.tv64 == 0) | ||
1296 | kt = ktime_get_real(); | ||
1297 | skb->tstamp = kt; | ||
1298 | tv = ktime_to_timeval(kt); | ||
1299 | put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP, sizeof(tv), &tv); | ||
1300 | } else | ||
1301 | sk->sk_stamp = kt; | 1298 | sk->sk_stamp = kt; |
1302 | } | 1299 | } |
1303 | 1300 | ||