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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 15 Dec 2018 12:56:07 -0800
From:   Deepa Dinamani <deepa.kernel@...il.com>
To:     willemdebruijn.kernel@...il.com
Cc:     "David S. Miller" <davem@...emloft.net>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Linux Network Devel Mailing List <netdev@...r.kernel.org>,
        Arnd Bergmann <arnd@...db.de>,
        y2038 Mailman List <y2038@...ts.linaro.org>,
        "James E.J. Bottomley" <jejb@...isc-linux.org>,
        Ralf Baechle <ralf@...ux-mips.org>, rth@...ddle.net,
        linux-alpha@...r.kernel.org,
        "open list:RALINK MIPS ARCHITECTURE" <linux-mips@...ux-mips.org>,
        Parisc List <linux-parisc@...r.kernel.org>,
        linux-rdma@...r.kernel.org, sparclinux <sparclinux@...r.kernel.org>
Subject: Re: [PATCH v2 6/8] socket: Add SO_TIMESTAMP[NS]_NEW

> > Also for the other comment. The reason the conditionals were not
> > consistent is because they were not consistent to begin with.
>
> The only difference I see is an inversion of the test. Nesting order
> is the same:
>
>         int need_software_tstamp = sock_flag(sk, SOCK_RCVTSTAMP);
>         ...
>         if (need_software_tstamp) {
>                 if (!sock_flag(sk, SOCK_RCVTSTAMPNS)) {
>                 } else {
>                 }
>         }
>
> vs
>
>                 if (sock_flag(sk, SOCK_RCVTSTAMP)) {
>                         if (sock_flag(sk, SOCK_RCVTSTAMPNS)) {
>                         } else {
>                         }
>                 }
>
> I suggest just adding something like
>
>         if (need_software_tstamp) {
> +              if (sock_uses_new_tstamp(sk) {
> +                   __sock_recv_timestamp_new(msg, sk,
> ktime_to_timespec64(skb->tstamp));
> +              } else if (!sock_flag(sk, SOCK_RCVTSTAMPNS)) {
> -               if (!sock_flag(sk, SOCK_RCVTSTAMPNS)) {
>                 } else {
>                 }
>
> and
>
>                 if (sock_flag(sk, SOCK_RCVTSTAMP)) {
> +                      if (sock_uses_new_tstamp(sk) {
> +                           __sock_recv_timestamp_new(msg, sk, ts);
> +                      else if (sock_flag(sk, SOCK_RCVTSTAMPNS)) {
> -                       if (sock_flag(sk, SOCK_RCVTSTAMPNS)) {
>                         } else {
>                         }
>
> I think we can use the same helper for both the sock and tcp variant.
> The only intended difference between the two functions, as described
> in the tcp_recv_timestamp function comment, is the absence of an skb
> in the tcp case. That is immaterial at this level.

I will just not refactor things into a function: __sock_rescv_timestamp_new().
I will just add new conditionals for the new timestamps.
When you guys refactor the other timestamp stuff like you mentioned
below maybe you can move the new timestamps to a new funtcion as you
see fit.

The helper functions in skbuff.h might first need to be refactored
first. But I again leave this to you guys.

> Note also (2) tentative helper function sock_uses_new_tstamp(const
> struct sock *sk) instead of testing sock_flag(sk, SOCK_TSTAMP_NEW)
> directly. Since the .._NEW variants are equivalent to .._OLD on 64-bit,
> I wonder if we can just compile out the branch. Something like
>
>     static inline bool sock_uses_new_tstamp(const struct sock *sk) {
>             return (sizeof(time_t) != sizeof(__kernel_long_t)) &&
>                        sock_flag(sk, SOCK_TSTAMP_NEW);
>     }
>

You could just ifdef CONFIG_64BIT if you are worried about branching.
Note that SO_TIMESTAMP is by default SO_TIMESTAMP_OLD on 64 bit machines.
But, I will again leave the optimization to you. I will implement in a
straight forward way and you guys can deicde how you want to optimize
the fast path or what should it even be.

-Deepa

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ