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

From: Arnd Bergmann
Date: Tue Dec 18 2018 - 11:16:40 EST


On Wed, Dec 12, 2018 at 4:25 PM Willem de Bruijn
<willemdebruijn.kernel@xxxxxxxxx> wrote:
> On Tue, Dec 11, 2018 at 3:30 PM Deepa Dinamani <deepa.kernel@xxxxxxxxx> wrote:

> > @@ -851,39 +890,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
> > break;
> >
> > case SO_TIMESTAMPING_OLD:
> > - if (val & ~SOF_TIMESTAMPING_MASK) {
> > - ret = -EINVAL;
> > - break;
> > - }
> > -
> > - if (val & SOF_TIMESTAMPING_OPT_ID &&
> > - !(sk->sk_tsflags & SOF_TIMESTAMPING_OPT_ID)) {
> > - if (sk->sk_protocol == IPPROTO_TCP &&
> > - sk->sk_type == SOCK_STREAM) {
> > - if ((1 << sk->sk_state) &
> > - (TCPF_CLOSE | TCPF_LISTEN)) {
> > - ret = -EINVAL;
> > - break;
> > - }
> > - sk->sk_tskey = tcp_sk(sk)->snd_una;
> > - } else {
> > - sk->sk_tskey = 0;
> > - }
> > - }
> > -
> > - if (val & SOF_TIMESTAMPING_OPT_STATS &&
> > - !(val & SOF_TIMESTAMPING_OPT_TSONLY)) {
> > - ret = -EINVAL;
> > - break;
> > - }
> > -
> > - sk->sk_tsflags = val;
> > - if (val & SOF_TIMESTAMPING_RX_SOFTWARE)
> > - sock_enable_timestamp(sk,
> > - SOCK_TIMESTAMPING_RX_SOFTWARE);
> > - else
> > - sock_disable_timestamp(sk,
> > - (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE));
> > + ret = setsockopt_timestamping(sk, optname, val);
>
> Once again a lot of needless code churn. The only functional change is adding

I think moving the code out into a separate function is a useful cleanup,
but if we want to do that, it may be better done in another patch, to
make it easier to review.

Arnd