Re: [PATCH net-next] seg6: fool-proof the processing of SRv6 behavior attributes

From: David Ahern
Date: Wed Feb 03 2021 - 11:02:02 EST


On 2/2/21 11:56 AM, Andrea Mayer wrote:
> diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
> index b07f7c1c82a4..7cc50d506902 100644
> --- a/net/ipv6/seg6_local.c
> +++ b/net/ipv6/seg6_local.c
> @@ -31,6 +31,9 @@
> #include <linux/etherdevice.h>
> #include <linux/bpf.h>
>
> +#define SEG6_F_ATTR(i) BIT(i)
> +#define SEG6_LOCAL_MAX_SUPP 32
> +

SEG6_LOCAL_MAX_SUPP should not be needed; it can be derived from the type:

BUILD_BUG_ON(BITS_PER_TYPE(unsigned long) > SEG6_LOCAL_MAX)

The use of BIT() looks fine.