Subject: Re: [PATCH net-next 1/8] inet: preserve const qualifier in inet_sk()

From: Jakub Kicinski <[email-masked]>
Date: Wed, 15 Mar 2023 14:28:41 -0700

On Wed, 15 Mar 2023 15:42:38 +0000 Eric Dumazet wrote:
> -static inline struct inet_sock *inet_sk(const struct sock *sk)
> -{
> -	return (struct inet_sock *)sk;
> -}
> +#define inet_sk(sk) \
> +       _Generic(sk,                                          		\
> +                const struct sock * : ((const struct inet_sock *)(sk)),	\
> +                struct sock * : ((struct inet_sock *)(sk))		\
> +       )

Could we possibly use container_of_const() or define a new common
macro for this downcast? I'm worried it will spread and it's a bit
verbose.

(I think Greg is constifying things too so let me add him and Linus.)