[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iKiVQXC1briKcmKd2Fs77f+rBW_WuqCD9z_WViAWipzhg@mail.gmail.com>
Date: Wed, 15 Mar 2023 16:56:19 -0700
From: Eric Dumazet <edumazet@...gle.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Jakub Kicinski <kuba@...nel.org>,
"David S . Miller" <davem@...emloft.net>,
Paolo Abeni <pabeni@...hat.com>,
David Ahern <dsahern@...nel.org>, netdev@...r.kernel.org,
eric.dumazet@...il.com,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH net-next 1/8] inet: preserve const qualifier in inet_sk()
On Wed, Mar 15, 2023 at 4:54 PM Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> On Wed, Mar 15, 2023 at 4:46 PM Eric Dumazet <edumazet@...gle.com> wrote:
> >
> > Note that my v1 proposed this thing:
> >
> > #define inet_sk(sk) \
> > + _Generic(sk, \
> > + const struct sock * : ((const struct inet_sock *)(sk)), \
> > + struct sock * : ((struct inet_sock *)(sk)) \
> > + )
>
> Right. That was better.
>
> But:
>
> > Jakub feedback was to instead use a common helper, and CCed you on the
> > discussion.
> > I do not see yet how to do this 'without cast'
>
> That's _exactly_ what container_of_const() does.
>
> I actually would want to make "container_of()" itself do that
> correctly, but we clearly have too many broken cases as-is, so
> 'container_of_const' it is.
container_of_const() does not detect this bug at compile time, does it ?
struct sk_buff *skb = ...;
struct inet_sk *inet = inet_sk(skb);
Powered by blists - more mailing lists