lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 13 May 2019 11:31:17 -0400
From:   Willem de Bruijn <willemdebruijn.kernel@...il.com>
To:     David Ahern <dsahern@...nel.org>
Cc:     David Miller <davem@...emloft.net>,
        Network Development <netdev@...r.kernel.org>,
        Eric Dumazet <eric.dumazet@...il.com>,
        David Ahern <dsahern@...il.com>
Subject: Re: [PATCH RFC net-next] netlink: Add support for timestamping messages

On Thu, May 9, 2019 at 11:57 AM David Ahern <dsahern@...nel.org> wrote:
>
> From: David Ahern <dsahern@...il.com>
>
> Add support for timestamping netlink messages. If a socket wants a
> timestamp, it is added when the skb clone is queued to the socket.
>
> Allow userspace to know the actual time an event happened. In a
> busy system there can be a long lag between when the event happened
> and when the message is read from the socket. Further, this allows
> separate netlink sockets for various RTNLGRP's where the timestamp
> can be used to sort the messages if needed.
>
> Signed-off-by: David Ahern <dsahern@...il.com>
> ---
> one question I have is whether it would be better to add the timestamp
> when the skb is created so it is the same for all sockets as opposed to
> setting the time per socket.
>
>  net/netlink/af_netlink.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>
> +/* based on tcp_recv_timestamp */

Which itself is based on __sock_recv_timestamp. Which this resembles
even more closely, as both pass an skb. Instead of duplicating the
core code yet again, we can probably factor out and reuse it. Netlink
only does not need the SOF_TIMESTAMPING part.


> +static void netlink_cmsg_timestamp(struct msghdr *msg, struct sk_buff *skb,
> +                                  struct sock *sk)
> +{
> +       int new_tstamp;
> +
> +       if (!skb_get_ktime(skb))
> +               return;
> +
> +       new_tstamp = sock_flag(sk, SOCK_TSTAMP_NEW);
> +       if (sock_flag(sk, SOCK_RCVTSTAMPNS)) {
> +               if (new_tstamp) {
> +                       struct __kernel_timespec kts;
> +
> +                       skb_get_new_timestampns(skb, &kts);
> +                       put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_NEW,
> +                                sizeof(kts), &kts);
> +               } else {
> +                       struct timespec ts;
> +
> +                       skb_get_timestampns(skb, &ts);
> +                       put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPNS_OLD,
> +                                sizeof(ts), &ts);
> +               }
> +       } else {
> +               if (new_tstamp) {
> +                       struct __kernel_sock_timeval stv;
> +
> +                       skb_get_new_timestamp(skb, &stv);
> +                       put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_NEW,
> +                                sizeof(stv), &stv);
> +               } else {
> +                       struct __kernel_old_timeval tv;
> +
> +                       skb_get_timestamp(skb, &tv);
> +                       put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP_OLD,
> +                                sizeof(tv), &tv);
> +               }
> +       }
> +}

Powered by blists - more mailing lists