aboutsummaryrefslogtreecommitdiffstats
path: root/net/socket.c
diff options
context:
space:
mode:
authorDeepa Dinamani <deepa.kernel@gmail.com>2019-02-02 10:34:50 -0500
committerDavid S. Miller <davem@davemloft.net>2019-02-03 14:17:31 -0500
commit887feae36aee6c08e0dafcdaa5ba921abbb2c56b (patch)
tree1c34072c8057e8d5babf22242ec8b1a383998ce0 /net/socket.c
parent98bb03c865d7ddf7a9a2eb80f9a0dd5f261c56ad (diff)
socket: Add SO_TIMESTAMP[NS]_NEW
Add SO_TIMESTAMP_NEW and SO_TIMESTAMPNS_NEW variants of socket timestamp options. These are the y2038 safe versions of the SO_TIMESTAMP_OLD and SO_TIMESTAMPNS_OLD for all architectures. Note that the format of scm_timestamping.ts[0] is not changed in this patch. Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com> Acked-by: Willem de Bruijn <willemb@google.com> Cc: jejb@parisc-linux.org Cc: ralf@linux-mips.org Cc: rth@twiddle.net Cc: linux-alpha@vger.kernel.org Cc: linux-mips@linux-mips.org Cc: linux-parisc@vger.kernel.org Cc: linux-rdma@vger.kernel.org Cc: netdev@vger.kernel.org Cc: sparclinux@vger.kernel.org Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/socket.c')
-rw-r--r--net/socket.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/net/socket.c b/net/socket.c
index 9cc281cdb9d9..1de96abd78d3 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -705,6 +705,7 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
705 struct sk_buff *skb) 705 struct sk_buff *skb)
706{ 706{
707 int need_software_tstamp = sock_flag(sk, SOCK_RCVTSTAMP); 707 int need_software_tstamp = sock_flag(sk, SOCK_RCVTSTAMP);
708 int new_tstamp = sock_flag(sk, SOCK_TSTAMP_NEW);
708 struct scm_timestamping tss; 709 struct scm_timestamping tss;
709 int empty = 1, false_tstamp = 0; 710 int empty = 1, false_tstamp = 0;
710 struct skb_shared_hwtstamps *shhwtstamps = 711 struct skb_shared_hwtstamps *shhwtstamps =
@@ -719,15 +720,33 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
719 720
720 if (need_software_tstamp) { 721 if (need_software_tstamp) {
721 if (!sock_flag(sk, SOCK_RCVTSTAMPNS)) { 722 if (!sock_flag(sk, SOCK_RCVTSTAMPNS)) {
722 struct __kernel_old_timeval tv; 723 if (new_tstamp) {
723 skb_get_timestamp(skb, &tv); 724 struct __kernel_sock_timeval tv;
724 put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_OLD, 725
725 sizeof(tv), &tv); 726 skb_get_new_timestamp(skb, &tv);
727 put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_NEW,
728 sizeof(tv), &tv);
729 } else {
730 struct __kernel_old_timeval tv;
731
732 skb_get_timestamp(skb, &tv);
733 put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_OLD,
734 sizeof(tv), &tv);
735 }
726 } else { 736 } else {
727 struct timespec ts; 737 if (new_tstamp) {
728 skb_get_timestampns(skb, &ts); 738 struct __kernel_timespec ts;
729 put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_OLD, 739
730 sizeof(ts), &ts); 740 skb_get_new_timestampns(skb, &ts);
741 put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_NEW,
742 sizeof(ts), &ts);
743 } else {
744 struct timespec ts;
745
746 skb_get_timestampns(skb, &ts);
747 put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_OLD,
748 sizeof(ts), &ts);
749 }
731 } 750 }
732 } 751 }
733 752