Commit 3f66116e89521ef71ab0d63dc07a639def88a577

Authored by Alban Crequy
Committed by David S. Miller
1 parent d6bf781712

AF_UNIX: Implement SO_TIMESTAMP and SO_TIMETAMPNS on Unix sockets

Userspace applications can already request to receive timestamps with:
setsockopt(sockfd, SOL_SOCKET, SO_TIMESTAMP, ...)

Although setsockopt() returns zero (success), timestamps are not added to the
ancillary data. This patch fixes that on SOCK_DGRAM and SOCK_SEQPACKET Unix
sockets.

Signed-off-by: Alban Crequy <alban.crequy@collabora.co.uk>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 5 additions and 0 deletions Side-by-side Diff

... ... @@ -1511,6 +1511,8 @@
1511 1511 goto restart;
1512 1512 }
1513 1513  
  1514 + if (sock_flag(other, SOCK_RCVTSTAMP))
  1515 + __net_timestamp(skb);
1514 1516 skb_queue_tail(&other->sk_receive_queue, skb);
1515 1517 unix_state_unlock(other);
1516 1518 other->sk_data_ready(other, len);
... ... @@ -1721,6 +1723,9 @@
1721 1723 err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, size);
1722 1724 if (err)
1723 1725 goto out_free;
  1726 +
  1727 + if (sock_flag(sk, SOCK_RCVTSTAMP))
  1728 + __sock_recv_timestamp(msg, sk, skb);
1724 1729  
1725 1730 if (!siocb->scm) {
1726 1731 siocb->scm = &tmp_scm;