[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210204032727.ffd2c1ae3410147ba7598d78@uniroma2.it>
Date: Thu, 4 Feb 2021 03:27:27 +0100
From: Andrea Mayer <andrea.mayer@...roma2.it>
To: David Ahern <dsahern@...il.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
David Ahern <dsahern@...nel.org>,
Jakub Kicinski <kuba@...nel.org>, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, Colin Ian King <colin.king@...onical.com>,
Stefano Salsano <stefano.salsano@...roma2.it>,
Paolo Lungaroni <paolo.lungaroni@...t.it>,
Ahmed Abdelsalam <ahabdels.dev@...il.com>,
Andrea Mayer <andrea.mayer@...roma2.it>
Subject: Re: [PATCH net-next] seg6: fool-proof the processing of SRv6
behavior attributes
Hi David,
thanks for your time.
On Wed, 3 Feb 2021 08:59:40 -0700
David Ahern <dsahern@...il.com> wrote:
> 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:
>
Yes, we can avoid the SEG6_LOCAL_MAX_SUPP. Using the BITS_PER_TYPE macro seems
better to me and it avoids nailing the value 32 as the limit. At compile time,
the kernel build will fail if the total number of SRv6 attributes will exceed
the number of bits available in the unsigned long bitmap (whatever is the
reference architecture). Therefore, I'm going to follow your suggestion!
> BUILD_BUG_ON(BITS_PER_TYPE(unsigned long) > SEG6_LOCAL_MAX)
>
I think there is an issue here because BITS_PER_TYPE(unsigned long) is greater
than the SEG6_LOCAL_MAX (currently = 9).
I think it should be like this:
BUILD_BUG_ON(SEG6_LOCAL_MAX + 1 > BITS_PER_TYPE(unsigned long))
I will send a v2 with the changes discussed so far.
Thank you,
Andrea
Powered by blists - more mailing lists