[LTP] lapi: Add pkt_cls.h fallback

Cyril Hrubis chrubis@suse.cz
Tue Jul 7 16:53:48 CEST 2026


Hi!
>   TCA_PEDIT_UNSPEC  = 0
>   TCA_PEDIT_TM      = 1
>   TCA_PEDIT_PARMS   = 2
>   TCA_PEDIT_PAD     = 3   <-- 3 is PAD, not KEY_EX
>   TCA_PEDIT_PARMS_EX = 4
>   TCA_PEDIT_KEYS_EX  = 5
>   TCA_PEDIT_KEY_EX   = 6  <-- should be 6
> 
> With value 3 the kernel would receive a TCA_PEDIT_PAD attribute where
> TCA_PEDIT_KEY_EX is expected and reject the filter with "Unknown
> attribute, expected extended key".
> 
> This also breaks the test in patch 4/4 which uses TCA_PEDIT_KEY_EX
> as a netlink attribute type.
> 
> > +#ifndef TCA_PEDIT_PARMS_EX
> > +# define TCA_PEDIT_PARMS_EX		4
> > +#endif
> > +
> > +#ifndef TCA_PEDIT_KEYS_EX
> > +# define TCA_PEDIT_KEYS_EX		5
> > +#endif
> > +
> > +#ifndef TCA_PEDIT_KEY_EX
> > +# define TCA_PEDIT_KEY_EX		3
> > +#endif
> > +
> > +#ifndef TCA_PEDIT_KEY_EX_HTYPE
> > +# define TCA_PEDIT_KEY_EX_HTYPE		1
> > +#endif
> > +
> > +#ifndef TCA_PEDIT_KEY_EX_CMD
> > +# define TCA_PEDIT_KEY_EX_CMD		2
> > +#endif
> 
> All five of these are anonymous enum values in the kernel header, not
> preprocessor macros. A #ifndef guard tests the preprocessor symbol
> table, which does not include enum constants. So every one of these
> #define lines executes unconditionally even on systems that already
> have the full kernel header -- the enum values are silently shadowed
> by the macros.
> 
> For the four correctly-valued ones this has no observable impact
> today, but the guard gives a false sense of safety. For
> TCA_PEDIT_KEY_EX the wrong value makes the situation permanent on
> every system.
> 
> The correct approach for enum-valued constants is to use
> AC_CHECK_DECLS in configure.ac, the same way this patch already uses
> AC_CHECK_TYPES for the two enum types:
> 
>   AC_CHECK_DECLS([TCA_PEDIT_PARMS_EX, TCA_PEDIT_KEYS_EX,
>                   TCA_PEDIT_KEY_EX, TCA_PEDIT_KEY_EX_HTYPE,
>                   TCA_PEDIT_KEY_EX_CMD],,,[
>   #include <linux/tc_act/tc_pedit.h>])

Maybe we can use the TCA_PEDIT_MAX:

#if !defined(TCA_PEDI_MAX) || TCA_PEDIT_MAX < 4
# define TCA_PEDIT_PARMS_EX 4
#endif

#if !defined(TCA_PEDI_MAX) || TCA_PEDIT_MAX < 5
# define TCA_PEDIT_KEYS_EX 5
#endif

And we can use the same pattern with the rest of the enums. 

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list