[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240903152316.GB4792@kernel.org>
Date: Tue, 3 Sep 2024 16:23:16 +0100
From: Simon Horman <horms@...nel.org>
To: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
Cc: Willem de Bruijn <willemb@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, David Ahern <dsahern@...nel.org>,
Jason Xing <kerneljasonxing@...il.com>, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 1/2] net_tstamp: add SCM_TS_OPT_ID to provide
OPT_ID in control message
On Mon, Sep 02, 2024 at 08:35:26PM +0100, Vadim Fedorenko wrote:
> On 02/09/2024 19:38, Simon Horman wrote:
> > On Mon, Sep 02, 2024 at 06:09:35AM -0700, Vadim Fedorenko wrote:
> > > SOF_TIMESTAMPING_OPT_ID socket option flag gives a way to correlate TX
> > > timestamps and packets sent via socket. Unfortunately, there is no way
> > > to reliably predict socket timestamp ID value in case of error returned
> > > by sendmsg. For UDP sockets it's impossible because of lockless
> > > nature of UDP transmit, several threads may send packets in parallel. In
> > > case of RAW sockets MSG_MORE option makes things complicated. More
> > > details are in the conversation [1].
> > > This patch adds new control message type to give user-space
> > > software an opportunity to control the mapping between packets and
> > > values by providing ID with each sendmsg. This works fine for UDP
> > > sockets only, and explicit check is added to control message parser.
> > >
> > > [1] https://lore.kernel.org/netdev/CALCETrU0jB+kg0mhV6A8mrHfTE1D1pr1SD_B9Eaa9aDPfgHdtA@mail.gmail.com/
> > >
> > > Signed-off-by: Vadim Fedorenko <vadfed@...a.com>
> >
> > ...
> >
> > > diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
> >
> > ...
> >
> > > @@ -1543,10 +1546,15 @@ static int __ip6_append_data(struct sock *sk,
> > > flags &= ~MSG_SPLICE_PAGES;
> > > }
> > > - hold_tskey = cork->tx_flags & SKBTX_ANY_TSTAMP &&
> > > - READ_ONCE(sk->sk_tsflags) & SOF_TIMESTAMPING_OPT_ID;
> > > - if (hold_tskey)
> > > - tskey = atomic_inc_return(&sk->sk_tskey) - 1;
> > > + if (cork->tx_flags & SKBTX_ANY_TSTAMP &&
> > > + READ_ONCE(sk->sk_tsflags) & SOF_TIMESTAMPING_OPT_ID) {
> > > + if (cork->flags & IPCORK_TS_OPT_ID) {
> > > + tskey = cork->ts_opt_id;
> > > + } else {
> > > + tskey = atomic_inc_return(&sk->sk_tskey) - 1;
> > > + hold_tskey = true;
> >
> > Hi Vadim,
> >
> > I think that hold_tskey also needs to be assigned a value in
> > the cases where wither of the if conditions above are false.
>
> Hi Simon!
>
> Yes, you are right. I should probably init it with false to avoid
> 'else' statement.
Thanks, I agree that seems like a good approach.
Powered by blists - more mailing lists