From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E57DC433E0 for ; Thu, 4 Feb 2021 02:29:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F8D364E40 for ; Thu, 4 Feb 2021 02:29:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234005AbhBDC3B (ORCPT ); Wed, 3 Feb 2021 21:29:01 -0500 Received: from smtp.uniroma2.it ([160.80.6.16]:47085 "EHLO smtp.uniroma2.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232762AbhBDC27 (ORCPT ); Wed, 3 Feb 2021 21:28:59 -0500 Received: from smtpauth-2019-1.uniroma2.it (smtpauth.uniroma2.it [160.80.5.46]) by smtp-2015.uniroma2.it (8.14.4/8.14.4/Debian-8) with ESMTP id 1142RWaa010460; Thu, 4 Feb 2021 03:27:37 +0100 Received: from lubuntu-18.04 (unknown [160.80.103.126]) by smtpauth-2019-1.uniroma2.it (Postfix) with ESMTPSA id 9388512287D; Thu, 4 Feb 2021 03:27:27 +0100 (CET) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=uniroma2.it; s=ed201904; t=1612405648; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BBzNtFmeR8mXuxoqjeFWbcuolAywphiZEEztgpv3tK8=; b=YHMRh3qCcMMur84PeqRWUt4FBxoMcJJ6Gs8Agi2OaitoubZErgfTdkpTsXyBO+S4JQg7Nd EC9JZ81jKUtzvrBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniroma2.it; s=rsa201904; t=1612405648; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BBzNtFmeR8mXuxoqjeFWbcuolAywphiZEEztgpv3tK8=; b=fp5tyQWiYjxfPSHnNp85GtpIUMD8dI62n/3W9gKQNL4F0zTmoTCkjr4YhtFc3+2X2Z8PGI Mx5JLdP1AHrrGznDBxGzgMAju28ucknmH1vKmS0OVB27mH5S8dhqpZK/ZnMCSQIWjlbh24 +rzUQMbN1BVNdPepWwgpJo5dfLakBlfFqODZMdjqo96YnF+oYV1MwP3cKZpDoozDcIoVwU x1wvuc3Nlbljgvc8sv8C3yKWc1tCakjyLdz+km/nJ4uolaIy4emho1MLHibhOjzUxBVWhy EWsSftTGQC7ezh+OrYklu2iZHB+2P4TED69rIh91hJ2jMleO92DZGm/rYluGdg== Date: Thu, 4 Feb 2021 03:27:27 +0100 From: Andrea Mayer To: David Ahern Cc: "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Colin Ian King , Stefano Salsano , Paolo Lungaroni , Ahmed Abdelsalam , Andrea Mayer Subject: Re: [PATCH net-next] seg6: fool-proof the processing of SRv6 behavior attributes Message-Id: <20210204032727.ffd2c1ae3410147ba7598d78@uniroma2.it> In-Reply-To: <6fe3beb2-4306-11cd-83ce-66072db81346@gmail.com> References: <20210202185648.11654-1-andrea.mayer@uniroma2.it> <6fe3beb2-4306-11cd-83ce-66072db81346@gmail.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.100.0 at smtp-2015 X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi David, thanks for your time. On Wed, 3 Feb 2021 08:59:40 -0700 David Ahern 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 > > #include > > > > +#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