Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3442116pxb; Sun, 7 Feb 2021 09:30:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxHh+modb7RFDB3hu3l6L3f5QFQY5xPlmMFSx2NtVpEjtXYlIxZia+N5oTghGU5Yp/Bvc03 X-Received: by 2002:a05:6402:1641:: with SMTP id s1mr13847566edx.238.1612719054395; Sun, 07 Feb 2021 09:30:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612719054; cv=none; d=google.com; s=arc-20160816; b=ukU0AAaHfjzoD6uKKDxFzM12EaNWWMGQZBETnL/2rY2cA/yNR9F44uNGeZi7l7aoQW ZF47oyEVMrhEU74IFrW6xmMTV4pRH2tu4kLwWuUtJg3VgTOxwPZqvbrhyhlOTXWGtk+M qdkyNQyKaLEA8IP5aRBdnAosQ4ne3gkIgK6m5ftN0EMDoRV2tahgJDFzPOkGxSwup5oU cqa19M7S3nK0qAdwavh0BDxfrL65EwYX2mGvC3Xik8qlpo+ok0vE30Olu2wHu+ijnqhv 7epdt5syhL354Ewjv2PyvCA3lD4IXLPtopRTS7G88QVdj3eLURgKeLgA/iDc6RCLPJxq Qn4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=4FrHVEoL2SrgwPK2nga5GVuXp913oHGtE/bnQAcFKfs=; b=JKyquBOA1DMTDqV2sAPsJKq9jRo9h5f6zASziU9V/1ju6lXc6IlcrDRgI23artD2Rd ly/qs4KbLEMIie5XPpU+RR30EtiPPPjwcESgyu4uuytRcFVrQYE+6KcrgKfhOYK1mcyQ adhOr2oxPuu6sQcD4pXcbZFxF3rxlIvqGYnGAnWMlFBQt7CAbqZ+OaNdFgHrD1yXIYNf P5tWckei9ReNp1ZaiviLoJbaW9ibFpkgnqqOIE08OWaY4NqcLCu+FifcRrDmTOTaqzl2 bVcXh1yAvzvazqVLk6i0qOBlxsjowidbh/MzgnUfu9iYcRIOEXphVhTZrLczzY5WjwLj XBAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WGd8pAET; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a26si4181903edx.311.2021.02.07.09.30.30; Sun, 07 Feb 2021 09:30:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WGd8pAET; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229684AbhBGRZM (ORCPT + 99 others); Sun, 7 Feb 2021 12:25:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhBGRZL (ORCPT ); Sun, 7 Feb 2021 12:25:11 -0500 Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25ACDC06174A; Sun, 7 Feb 2021 09:24:31 -0800 (PST) Received: by mail-oo1-xc35.google.com with SMTP id f1so60929oou.0; Sun, 07 Feb 2021 09:24:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=4FrHVEoL2SrgwPK2nga5GVuXp913oHGtE/bnQAcFKfs=; b=WGd8pAETtBVCozNf0y1Mbt1QHLm8jwsumSW3/pdDxxeRftyEMDUgZLVm5K/uXWGf/3 omG8Btb6uLNE/CB3SrDwI271AJFS8EwLs8gIVUy7DtrP1dyDcFeh1Sv7UtoNqwgPoLoI 3731VQyTv5e1khUp5Xk0YzDRbyfdR+ue+wYkiIv9Ug87t3JHSYk+SU0hulm6+hWbKDSm IYzBr/FKjn8G9uzItnYMu0rbrBMDrLa5RBrNnogUmAMX57L0uASW/TSyfe1DI/L3AXru iHZpM2tgRROZV3ZN9SEO/sxwgAZFdvqsA9IviSoxpPsi+dJq1PcE3GNU0z1PZx//pnat 62Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4FrHVEoL2SrgwPK2nga5GVuXp913oHGtE/bnQAcFKfs=; b=QWBM/sCGdFIIGd/6gFE577srQQ3tCnOxY+aDeBrz3RiFxMSRKLQtN7TLbx9qy6siov +vs0K8jNgFZsffWsFkNVMbpfZN0vi3gJ40Z42eeeKfU3q0MfW4hXRKjBRznc/xNVe2Us Oxx6O1DYRLxMgl1QyJA6EVBaov/CPaDShZHABrTnGWx3FVJBm6sY6OUfN69TnneM8qNZ +jBs0vlC7ovfzEBpo77u9LL/5xAuFvW5SbUgKVORREW1dcplR2/wImMISQX4jivl8tfD 4fLH4Si+hUNjvH2AWCUZKMz+UNRPr+NCOuonPqaEA8xWebyZGPZcQ2nJpJit+P9dIwOc zWGw== X-Gm-Message-State: AOAM5316XVyLKkW6IZNLAYpT7Y//Q9o1PRKoySZq8tQtyG2UnxKGvV4X 4BZen7B3x9GBI79K6H0q5qKd6FDIykQ= X-Received: by 2002:a4a:e383:: with SMTP id l3mr2237423oov.66.1612718670270; Sun, 07 Feb 2021 09:24:30 -0800 (PST) Received: from Davids-MacBook-Pro.local ([8.48.134.33]) by smtp.googlemail.com with ESMTPSA id x7sm3138899oot.15.2021.02.07.09.24.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 Feb 2021 09:24:29 -0800 (PST) Subject: Re: [PATCH net-next v2] seg6: fool-proof the processing of SRv6 behavior attributes To: Andrea Mayer , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Colin Ian King , Stefano Salsano , Paolo Lungaroni , Ahmed Abdelsalam References: <20210206170934.5982-1-andrea.mayer@uniroma2.it> From: David Ahern Message-ID: <5c51d022-a374-500c-04ca-941a4f439fab@gmail.com> Date: Sun, 7 Feb 2021 10:24:27 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210206170934.5982-1-andrea.mayer@uniroma2.it> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/6/21 10:09 AM, Andrea Mayer wrote: > The set of required attributes for a given SRv6 behavior is identified > using a bitmap stored in an unsigned long, since the initial design of SRv6 > networking in Linux. Recently the same approach has been used for > identifying the optional attributes. > > However, the number of attributes supported by SRv6 behaviors depends on > the size of the unsigned long type which changes with the architecture. > Indeed, on a 64-bit architecture, an SRv6 behavior can support up to 64 > attributes while on a 32-bit architecture it can support at most 32 > attributes. > > To fool-proof the processing of SRv6 behaviors we verify, at compile time, > that the set of all supported SRv6 attributes can be encoded into a bitmap > stored in an unsigned long. Otherwise, kernel build fails forcing > developers to reconsider adding a new attribute or extend the total > number of supported attributes by the SRv6 behaviors. > > Moreover, we replace all patterns (1 << i) with the macro SEG6_F_ATTR(i) in > order to address potential overflow issues caused by 32-bit signed > arithmetic. > > Thanks to Colin Ian King for catching the overflow problem, providing a > solution and inspiring this patch. > Thanks to Jakub Kicinski for his useful suggestions during the design of > this patch. > > v2: > - remove the SEG6_LOCAL_MAX_SUPP which is not strictly needed: it can > be derived from the unsigned long type. Thanks to David Ahern for > pointing it out. > > Signed-off-by: Andrea Mayer > --- > net/ipv6/seg6_local.c | 67 +++++++++++++++++++++++++------------------ > 1 file changed, 39 insertions(+), 28 deletions(-) > Reviewed-by: David Ahern