Netdev List
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Vadim Fedorenko <vadfed@meta.com>,
	 Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	 Willem de Bruijn <willemb@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,
	 David Ahern <dsahern@kernel.org>,
	 Jason Xing <kerneljasonxing@gmail.com>,
	 Simon Horman <horms@kernel.org>
Cc: Vadim Fedorenko <vadfed@meta.com>,  netdev@vger.kernel.org
Subject: Re: [PATCH net-next v4 1/3] net_tstamp: add SCM_TS_OPT_ID to provide OPT_ID in control message
Date: Mon, 09 Sep 2024 13:48:15 -0400	[thread overview]
Message-ID: <66df34df9812d_3d030294d6@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <20240909165046.644417-2-vadfed@meta.com>

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 for UDP sockets.
> The documentation is also added in this patch.
> 
> [1] https://lore.kernel.org/netdev/CALCETrU0jB+kg0mhV6A8mrHfTE1D1pr1SD_B9Eaa9aDPfgHdtA@mail.gmail.com/
> 
> Signed-off-by: Vadim Fedorenko <vadfed@meta.com>

Reviewed-by: Willem de Bruijn <willemb@google.com>

Two small points if have to respin for other reasons.

> +++ b/include/net/sock.h
> @@ -952,6 +952,12 @@ enum sock_flags {
>  };
>  
>  #define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE))
> +#define SOCKCM_FLAG_TS_OPT_ID	BIT(31)
> +/*
> + * The highest bit of sk_tsflags is reserved for kernel-internal
> + * SOCKCM_FLAG_TS_OPT_ID. This check is to control that SOF_TIMESTAMPING*
> + * values do not reach this reserved area
> + */

nit: odd to add comment below statement. Also, there is no check here.

>  
>  static inline void sock_copy_flags(struct sock *nsk, const struct sock *osk)
>  {
> @@ -1794,6 +1800,7 @@ struct sockcm_cookie {
>  	u64 transmit_time;
>  	u32 mark;
>  	u32 tsflags;
> +	u32 ts_opt_id;
>  };
>  
>  static inline void sockcm_init(struct sockcm_cookie *sockc,
> diff --git a/include/uapi/asm-generic/socket.h b/include/uapi/asm-generic/socket.h
> index 8ce8a39a1e5f..db3df3e74b01 100644
> --- a/include/uapi/asm-generic/socket.h
> +++ b/include/uapi/asm-generic/socket.h
> @@ -135,6 +135,8 @@
>  #define SO_PASSPIDFD		76
>  #define SO_PEERPIDFD		77
>  
> +#define SCM_TS_OPT_ID		78
> +
>  #if !defined(__KERNEL__)
>  
>  #if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__))
> diff --git a/net/core/sock.c b/net/core/sock.c
> index 468b1239606c..d2a01eaf6731 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -2831,6 +2831,9 @@ int __sock_cmsg_send(struct sock *sk, struct cmsghdr *cmsg,
>  {
>  	u32 tsflags;
>  
> +	BUILD_BUG_ON_MSG(SOF_TIMESTAMPING_LAST == (1 << 31),
> +			 "SOF_TIMESTAMPING* cannot use BIT(31) because it's reserved for SOCKCM_FLAG_TS_OPT_ID");
> +

nit: No need for song a long line. Regular BUILD_BUG_ON will do.



  reply	other threads:[~2024-09-09 17:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-09 16:50 [PATCH net-next v4 0/3] Add option to provide OPT_ID value via cmsg Vadim Fedorenko
2024-09-09 16:50 ` [PATCH net-next v4 1/3] net_tstamp: add SCM_TS_OPT_ID to provide OPT_ID in control message Vadim Fedorenko
2024-09-09 17:48   ` Willem de Bruijn [this message]
2024-09-09 16:50 ` [PATCH net-next v4 2/3] net_tstamp: add SCM_TS_OPT_ID for RAW sockets Vadim Fedorenko
2024-09-09 17:48   ` Willem de Bruijn
2024-09-10  7:05   ` kernel test robot
2024-09-10  7:47   ` kernel test robot
2024-09-09 16:50 ` [PATCH net-next v4 3/3] selftests: txtimestamp: add SCM_TS_OPT_ID test Vadim Fedorenko
2024-09-09 17:50   ` Willem de Bruijn
2024-09-09 19:59     ` Vadim Fedorenko
2024-09-09 20:31       ` Willem de Bruijn
2024-09-09 20:37         ` Vadim Fedorenko

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=66df34df9812d_3d030294d6@willemb.c.googlers.com.notmuch \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=horms@kernel.org \
    --cc=kerneljasonxing@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vadfed@meta.com \
    --cc=vadim.fedorenko@linux.dev \
    --cc=willemb@google.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