[LTP] [PATCH 1/1] lapi/keyctl.h: Fix compilation on old kernel

Petr Vorel pvorel@suse.cz
Mon Sep 21 15:41:11 CEST 2026


> > Hi!
> > > diff --git a/include/lapi/keyctl.h b/include/lapi/keyctl.h
> > > index fdb68d1725..e1e46b7865 100644
> > > --- a/include/lapi/keyctl.h
> > > +++ b/include/lapi/keyctl.h
> > > @@ -69,6 +69,12 @@ struct keyctl_dh_params {
> > >  };
> > >  #endif

> > > +/* Fix for kernel < v4.20 */
> > > +#if defined(HAVE_STRUCT_KEYCTL_DH_PARAMS) && \
> > > +	!defined(HAVE_STRUCT_KEYCTL_DH_PARAMS_PRIV)
> > > +# define priv private
> > > +#endif

> > I do not like this one, we may end up redefining wrong priv and break
> > everything.

> > Given that the private stil exists in the structure for C code:

> > (/usr/include/linux/keyctl.h)
> > /* keyctl structures */
> > struct keyctl_dh_params {
> >         union {
> > #ifndef __cplusplus
> >                 __s32 private;
> > #endif
> >                 __s32 priv;
> >         };
> >         __s32 prime;
> >         __s32 base;
> > };

> > We may as well use private in the tests consistently and update our
> > fallback with the union as well.

> When I looked in the struct in UAPI I considered define better, but indeed
> mirroring UAPI the same way is really better.

> I'll retest it and send v2.

Just the only thing - we will need to have to use our custom struct
e.g.  ltp_keyctl_dh_params (similarly to ltp_statx), because the problem is on
the code which defines struct keyctl_dh_params, but without that fallback.

Kind regards,
Petr

> Kind regards,
> Petr


More information about the ltp mailing list