Re: [PATCH v2 bpf-next 1/3] bpf: Add casts to keep sparse quiet.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 4, 2024 at 1:00 AM Sebastian Andrzej Siewior
<bigeasy@xxxxxxxxxxxxx> wrote:
>
> On 2024-07-03 14:39:16 [-0700], Alexei Starovoitov wrote:
> > > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> > > index 25ea393cf084b..f45b03706e4e9 100644
> > > --- a/include/uapi/linux/bpf.h
> > > +++ b/include/uapi/linux/bpf.h
> > > @@ -6290,12 +6290,12 @@ struct bpf_tunnel_key {
> > >   */
> > >  struct bpf_xfrm_state {
> > >         __u32 reqid;
> > > -       __u32 spi;      /* Stored in network byte order */
> > > +       __be32 spi;     /* Stored in network byte order */
> > >         __u16 family;
> > >         __u16 ext;      /* Padding, future use. */
> > >         union {
> > > -               __u32 remote_ipv4;      /* Stored in network byte order */
> > > -               __u32 remote_ipv6[4];   /* Stored in network byte order */
> > > +               __be32 remote_ipv4;     /* Stored in network byte order */
> > > +               __be32 remote_ipv6[4];  /* Stored in network byte order */
> > >         };
> > >  };
> >
> > I don't think we should be changing uapi because of sparse.
> > I would ignore the warnings.
>
> There are other struct member within this bpf.h which use __be32 so it
> is known to userland (in terms of the compiler won't complain about an
> unknown type due to missing include). The type is essentially the same
> since the __bitwise attribute is empty except for sparse (which defines
> __CHECKER_).
> Therefore I wouldn't say this changes the uapi in an incompatible way.

There are two remote_ipv[46] fields in uapi/bpf.h added in 2016 and 2018
with __u32. We're not going to change one them to __be32 now,
because you noticed a sparse warn on the _kernel_ side.

In general, sparse warn is never a reason to change uapi.
If you want to shut up sparse, adjust the kernel side only,
or better yet ignore it.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux