Re: [PATCH 8/8] socket: Add SO_TIMESTAMPING_NEW

From
Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date
2018-11-25 04:00:50
Also in
linux-alpha, linux-arch, linux-mips, linux-s390, lkml, sparclinux
Reply to
Deepa Dinamani, 2018-11-24
On Sat, Nov 24, 2018 at 3:58 AM Deepa Dinamani [off-list ref] wrote:
Add SO_TIMESTAMPING_NEW variant of socket timestamp options.
This is the y2038 safe versions of the SO_TIMESTAMPING_OLD
for all architectures.

Signed-off-by: Deepa Dinamani <redacted>
Cc: chris@zankel.net
Cc: <redacted>
Cc: <redacted>
Cc: <redacted>
Cc: <redacted>
Cc: <redacted>
Cc: <redacted>
Cc: <redacted>
Cc: <redacted>
Cc: <redacted>
Cc: <redacted>
Cc: <redacted>
---
quoted hunk ↗ jump to hunk
 /*
  * called from sock_recv_timestamp() if sock_flag(sk, SOCK_RCVTSTAMP)
  * or sock_flag(sk, SOCK_RCVTSTAMPNS)
@@ -739,8 +740,8 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
        struct sk_buff *skb)
 {
        int need_software_tstamp = sock_flag(sk, SOCK_RCVTSTAMP) || sock_flag(sk, SOCK_RCVTSTAMPNS);
-       struct scm_timestamping tss;
-       int empty = 1, false_tstamp = 0;
+       struct scm_timestamping_internal tss;
+       int empty = 1, false_tstamp = 0, new_tstamp = 0;
        struct skb_shared_hwtstamps *shhwtstamps =
                skb_hwtstamps(skb);
@@ -756,20 +757,23 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,

        memset(&tss, 0, sizeof(tss));
        if ((sk->sk_tsflags & SOF_TIMESTAMPING_SOFTWARE) &&
-           ktime_to_timespec_cond(skb->tstamp, tss.ts + 0))
+           ktime_to_timespec64_cond(skb->tstamp, tss.ts + 0))
                empty = 0;
        if (shhwtstamps &&
            (sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE) &&
            !skb_is_swtx_tstamp(skb, false_tstamp) &&
-           ktime_to_timespec_cond(shhwtstamps->hwtstamp, tss.ts + 2)) {
+           ktime_to_timespec64_cond(shhwtstamps->hwtstamp, tss.ts + 2)) {
                empty = 0;
                if ((sk->sk_tsflags & SOF_TIMESTAMPING_OPT_PKTINFO) &&
                    !skb_is_err_queue(skb))
                        put_ts_pktinfo(msg, skb);
        }
        if (!empty) {
-               put_cmsg(msg, SOL_SOCKET,
-                        SO_TIMESTAMPING_OLD, sizeof(tss), &tss);
+               new_tstamp = sock_flag(sk, SOCK_TSTAMP_NEW);
+               if (new_tstamp)
nit: no need for explicit variable
+                       put_cmsg_scm_timestamping64(msg, &tss);
+               else
+                       put_cmsg_scm_timestamping(msg, &tss);

                if (skb_is_err_queue(skb) && skb->len &&
                    SKB_EXT_ERR(skb)->opt_stats)
--
2.17.1
Thread (35 messages) 35 messages, 4 authors, last reply 2018-11-30
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help