netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Ido Schimmel <idosch@idosch.org>
Cc: Networking <netdev@vger.kernel.org>,
	David Miller <davem@davemloft.net>,
	Neil Horman <nhorman@tuxdriver.com>, Andrew Lunn <andrew@lunn.ch>,
	Aya Levin <ayal@mellanox.com>,
	mlxsw@mellanox.com, Ido Schimmel <idosch@mellanox.com>
Subject: Re: [PATCH net-next] drop_monitor: Make timestamps y2038 safe
Date: Tue, 27 Aug 2019 15:10:56 +0200	[thread overview]
Message-ID: <CAK8P3a21AeWTvm1+roStbMGHCkK0tWcuWc-Dk-J_5Ea+XTPUMA@mail.gmail.com> (raw)
In-Reply-To: <20190823154721.9927-1-idosch@idosch.org>

On Fri, Aug 23, 2019 at 5:48 PM Ido Schimmel <idosch@idosch.org> wrote:
>
> From: Ido Schimmel <idosch@mellanox.com>
>
> Timestamps are currently communicated to user space as 'struct
> timespec', which is not considered y2038 safe since it uses a 32-bit
> signed value for seconds.
>
> Fix this while the API is still not part of any official kernel release
> by using 64-bit nanoseconds timestamps instead.
>
> Fixes: ca30707dee2b ("drop_monitor: Add packet alert mode")
> Fixes: 5e58109b1ea4 ("drop_monitor: Add support for packet alert mode for hardware drops")
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> ---
> Arnd, I have followed your recommendation to use 64-bit nanoseconds
> timestamps. I would appreciate it if you could review this change.

somewhat late reply:


> @@ -761,8 +759,8 @@ static int net_dm_hw_packet_report_fill(struct sk_buff *msg,
>                         goto nla_put_failure;
>         }
>
> -       if (ktime_to_timespec_cond(skb->tstamp, &ts) &&
> -           nla_put(msg, NET_DM_ATTR_TIMESTAMP, sizeof(ts), &ts))
> +       if (nla_put_u64_64bit(msg, NET_DM_ATTR_TIMESTAMP,
> +                             ktime_to_ns(skb->tstamp), NET_DM_ATTR_PAD))
>                 goto nla_put_failure;
>
>         if (nla_put_u32(msg, NET_DM_ATTR_ORIG_LEN, skb->len))

Yes, this looks reasonable. I guess since we take the skb timestamps
in CLOCK_REALTIME, there is little point in trying to use
CLOCK_MONOTONIC in the user interface.

64-bit nanoseconds are safe for a few hundred years.

       Arnd

      parent reply	other threads:[~2019-08-27 13:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23 15:47 [PATCH net-next] drop_monitor: Make timestamps y2038 safe Ido Schimmel
2019-08-23 16:17 ` Neil Horman
2019-08-23 21:58 ` David Miller
2019-08-27 13:10 ` Arnd Bergmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK8P3a21AeWTvm1+roStbMGHCkK0tWcuWc-Dk-J_5Ea+XTPUMA@mail.gmail.com \
    --to=arnd@arndb.de \
    --cc=andrew@lunn.ch \
    --cc=ayal@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=idosch@idosch.org \
    --cc=idosch@mellanox.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).