mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-06 06:21:31 +00:00
[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>
This commit is contained in:
parent
c7a3c5da35
commit
92f37fd2ee
25 changed files with 101 additions and 13 deletions
|
@ -390,6 +390,7 @@ enum sock_flags {
|
|||
SOCK_USE_WRITE_QUEUE, /* whether to call sk->sk_write_space in sock_wfree */
|
||||
SOCK_DBG, /* %SO_DEBUG setting */
|
||||
SOCK_RCVTSTAMP, /* %SO_TIMESTAMP setting */
|
||||
SOCK_RCVTSTAMPNS, /* %SO_TIMESTAMPNS setting */
|
||||
SOCK_LOCALROUTE, /* route locally only, %SO_DONTROUTE setting */
|
||||
SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */
|
||||
};
|
||||
|
@ -1283,21 +1284,17 @@ static inline int sock_intr_errno(long timeo)
|
|||
return timeo == MAX_SCHEDULE_TIMEOUT ? -ERESTARTSYS : -EINTR;
|
||||
}
|
||||
|
||||
extern void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
|
||||
struct sk_buff *skb);
|
||||
|
||||
static __inline__ void
|
||||
sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
ktime_t kt = skb->tstamp;
|
||||
|
||||
if (sock_flag(sk, SOCK_RCVTSTAMP)) {
|
||||
struct timeval tv;
|
||||
/* Race occurred between timestamp enabling and packet
|
||||
receiving. Fill in the current time for now. */
|
||||
if (kt.tv64 == 0)
|
||||
kt = ktime_get_real();
|
||||
skb->tstamp = kt;
|
||||
tv = ktime_to_timeval(kt);
|
||||
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP, sizeof(tv), &tv);
|
||||
} else
|
||||
if (sock_flag(sk, SOCK_RCVTSTAMP))
|
||||
__sock_recv_timestamp(msg, sk, skb);
|
||||
else
|
||||
sk->sk_stamp = kt;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue