On Wed, 12 Jun 2019 11:49:17 +0200, Toke Høiland-Jørgensen wrote:
> Jakub Kicinski <[email protected]> writes:
>
> > On Tue, 11 Jun 2019 17:44:00 +0200, Toke Høiland-Jørgensen wrote:
> >> +#define XDP_REDIRECT_INVALID_MASK (XDP_ABORTED | XDP_DROP | XDP_PASS |
> >> XDP_TX)
> >
> > It feels a little strange to OR in values which are not bits, even if
> > it happens to work today (since those are values of 0, 1, 2, 3)...
>
> Yeah, I agree. But it also nicely expresses the extent in code.
> Otherwise that would need to be in a comment, like
>
> // we allow return codes of ABORTED/DROP/PASS/TX
> #define XDP_REDIRECT_INVALID_MASK 3
>
>
> Or do you have a better idea?
flags > XDP_TX
In the future when we add more fields in flags:
if (flags & ~XDP_REDIRECT_FLAGS_MASK)
return -EBLA;
if ((flags & XDP_REDIRECT_RETCODE_MASK) > XDP_TX))
return -EFOO;
?