Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3607855ioo; Wed, 25 May 2022 04:31:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4kbICIjO5rtIrBI1PmACjy8kSMN/h9WQzyzsIso23WYp0t6d9ivHK3vcDRbpmRJ0Srf47 X-Received: by 2002:a17:902:b18e:b0:15f:b2c:6ca with SMTP id s14-20020a170902b18e00b0015f0b2c06camr32354961plr.84.1653478307165; Wed, 25 May 2022 04:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653478307; cv=none; d=google.com; s=arc-20160816; b=e6b6fQBm1EiKNvib2kseEyQ/FeS6kve5RvYCqkY6hIO0nt/zWGl0aOk8eNeKCI5jbZ 1SKwBEKYNkuNS+U3dLYbG0v2EOsbhPPRylfDmY+0dNrmKSsM6z8eiIRgAU/ZrXw/T+19 IE8UxZNpm1vodtiJCRF16963AueWmbR5WNox03a+S7zZP7mEI2YQqFkN0m8UOh9WqVJh aoGEc1kSbapGw/Uw5vJsk2JMBvnTAjiyV27leLz2O/vtqO0eVlMi8Na9OVs9UMhZbY5r v/PgMsF3srCJ6lCDlvV0lDkQJ6AV5ODcAP5u384z+V0hfphPxkHAQ4SnRc9ahegipCnm Alxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=cVq7pwXv2//Gfr1cHlRRSEheHaq4li61MQakSnDYkHk=; b=oyvd9vJ/MUkgbxUw2N1/rDsMpbLh3UQDzm7xUCmPVCc4f/y8ZAGTMumw/HQav13RgE eYtJPgxLf+1/txN6mDxnsOjvshPM1mbtkf3SuqIT2incHT7i85rXBm+js0sI30eGMN5D uT2vpyJ3u1qfypUNFxtYXS9DRymOEmfFodcU+Yara7zLr8+yN/cQSjtP2aXK9th3xNCh PbX4M6xr4ltOs0LfNkKzO3oBFAcnae6JHPU39pEn5BBHHy0HO4upfWiMW1puW7rlU2c9 3rr0QdO3YVFKe5iIYbt3U8l4kfktMjtl4DWbzWiQ9b2fwsST2demzSsijDBtZ2GmItP/ OLNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@blackwall-org.20210112.gappssmtp.com header.s=20210112 header.b=NSbOEN1k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nl6-20020a17090b384600b001df2b1d9d3dsi896454pjb.123.2022.05.25.04.31.30; Wed, 25 May 2022 04:31:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@blackwall-org.20210112.gappssmtp.com header.s=20210112 header.b=NSbOEN1k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234958AbiEYIG7 (ORCPT + 99 others); Wed, 25 May 2022 04:06:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235484AbiEYIGy (ORCPT ); Wed, 25 May 2022 04:06:54 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE58B814A9 for ; Wed, 25 May 2022 01:06:48 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id e28so28347627wra.10 for ; Wed, 25 May 2022 01:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=cVq7pwXv2//Gfr1cHlRRSEheHaq4li61MQakSnDYkHk=; b=NSbOEN1kEirXXcI0n+Rf9Sy90jmua25IOlwq3lBlny6ebWLJYupmHvohFiRfMPOYyq 4F5ikMXUckwPZMYV4cy1mkymCR7C/+/APrT91TE45m53C/G8or+AB0C7YnLnAmuFqZxj a/5bJX+7SKQT+s4uAyqsGz5KEfN+/60UTN5yTFZEQNyAHD1BVJT73zQdK0VlccjJONE9 6R2aYtGZx2oDjYvCVCmv2sLZ5HSRUx3w3LKH4wb4s0fzsiBa9yitlqNtoveAi/tXQGzZ HxQ1a1kqvyEtO1SgEEEkCr31sl8DHd8EzzaECAtIi2qlVGJgviVNf+Z4TdWIH4CvIbxt nT8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=cVq7pwXv2//Gfr1cHlRRSEheHaq4li61MQakSnDYkHk=; b=xaxQ+e/qQuPmvgk97/IgtJnfE6wNjEP0rhFW+axCD0WKKhdkhlfV1E1BUuv+aYjwr3 RGpRo+hHTX918z8nEpmT+PrrO0lbgFJwKxILBSIyLTGgfjIdnibESxDeZuqeFRyQxqXf 8doGCze5N3b1Kzq473lM3pKI6zu+prwYNAWPW6+xeBlcxQ/w/chc/g2pPRuxXr52Cua3 DFmmjeaMNHjr8zvkEoMEIsT4hb2jWokZ/6SFwNE9OyuMEjZhdCpGJtNtgbXLG/UndhJY Gg/zSc3Jfi5YWZYC/FQwwbCZTuuhEntF5AjNCoN2/H5wQg2/Hj7L6OLuoYVsn7n/ql/u TQiw== X-Gm-Message-State: AOAM533K5/sN7r8VeLxhoimQrOHNlDKK8VmlF8iBLHOaAOGJcWdOpdlA A0Xqsud9vr5wb280dRqcdD3ghw== X-Received: by 2002:adf:d1a8:0:b0:20f:f808:2ac8 with SMTP id w8-20020adfd1a8000000b0020ff8082ac8mr4694627wrc.495.1653466007320; Wed, 25 May 2022 01:06:47 -0700 (PDT) Received: from [192.168.0.111] (87-243-81-1.ip.btc-net.bg. [87.243.81.1]) by smtp.gmail.com with ESMTPSA id x8-20020a7bc208000000b0039765a7add4sm1038032wmi.29.2022.05.25.01.06.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 01:06:46 -0700 (PDT) Message-ID: Date: Wed, 25 May 2022 11:06:44 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH V3 net-next 1/4] net: bridge: add fdb flag to extent locked port feature Content-Language: en-US To: Hans Schultz , davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Eric Dumazet , Paolo Abeni , Jiri Pirko , Ivan Vecera , Roopa Prabhu , Shuah Khan , Daniel Borkmann , Ido Schimmel , linux-kernel@vger.kernel.org, bridge@lists.linux-foundation.org, linux-kselftest@vger.kernel.org References: <20220524152144.40527-1-schultz.hans+netdev@gmail.com> <20220524152144.40527-2-schultz.hans+netdev@gmail.com> <01e6e35c-f5c9-9776-1263-058f84014ed9@blackwall.org> <86zgj6oqa9.fsf@gmail.com> From: Nikolay Aleksandrov In-Reply-To: <86zgj6oqa9.fsf@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/05/2022 19:21, Hans Schultz wrote: >> >> Hi Hans, >> So this approach has a fundamental problem, f->dst is changed without any synchronization >> you cannot rely on it and thus you cannot account for these entries properly. We must be very >> careful if we try to add any new synchronization not to affect performance as well. >> More below... >> >>> @@ -319,6 +326,9 @@ static void fdb_delete(struct net_bridge *br, struct net_bridge_fdb_entry *f, >>> if (test_bit(BR_FDB_STATIC, &f->flags)) >>> fdb_del_hw_addr(br, f->key.addr.addr); >>> >>> + if (test_bit(BR_FDB_ENTRY_LOCKED, &f->flags) && !test_bit(BR_FDB_OFFLOADED, &f->flags)) >>> + atomic_dec(&f->dst->locked_entry_cnt); >> >> Sorry but you cannot do this for multiple reasons: >> - f->dst can be NULL >> - f->dst changes without any synchronization >> - there is no synchronization between fdb's flags and its ->dst >> >> Cheers, >> Nik > > Hi Nik, > > if a port is decoupled from the bridge, the locked entries would of > course be invalid, so maybe if adding and removing a port is accounted > for wrt locked entries and the count of locked entries, would that not > work? > > Best, > Hans Hi Hans, Unfortunately you need the correct amount of locked entries per-port if you want to limit their number per-port, instead of globally. So you need a consistent fdb view with all its attributes when changing its dst in this case, which would require new locking because you have multiple dependent struct fields and it will kill roaming/learning scalability. I don't think this use case is worth the complexity it will bring, so I'd suggest an alternative - you can monitor the number of locked entries per-port from a user-space agent and disable port learning or some similar solution that doesn't require any complex kernel changes. Is the limit a requirement to add the feature? I have an idea how to do it and to minimize the performance hit if it really is needed but it'll add a lot of complexity which I'd like to avoid if possible. Cheers, Nik