From patchwork Tue Oct 18 16:56:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Schultz X-Patchwork-Id: 5705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp395299wrs; Wed, 19 Oct 2022 08:42:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM47OTKGJhsGVpbFv0Odd/rSMYlcNAqXTDwg7lx2YRj+YpiHU7tY33tb6y+o2oSSP2cLbb1T X-Received: by 2002:a17:907:3d9e:b0:791:8933:f9fc with SMTP id he30-20020a1709073d9e00b007918933f9fcmr7407267ejc.111.1666194178349; Wed, 19 Oct 2022 08:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666194178; cv=none; d=google.com; s=arc-20160816; b=GYIvAtCK53FovyWWYEguNiWGUmu8t/8/wuT5kgLiaTarsrsfFB8Ockkq5HCpjvt9Ux zhlrraM4fupHLX5qlIw1sNUC7q+WcS4UWu51QxCUiM73UUWmHERLlLKCr8bNMXPcVfXw r1MbmZW1ypCTDvvTFkG6SeiJucBbdKhwtlyDS70O1o0GlX80P1EWUgKSR0OGSQFa70KJ LAqnTGRYn2IinwEzSPnHZOOgfyN7V1iNznClMXlv3YMZhsljIKM+GyN3nwrkiFDmRRO8 edxvnk3DNCDYcdXvEZzVglsl6ch1NeseW6nqsdY3FKyupvAhZcnTo0Ukw7XmRNmbX//j O2Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=5mfxddiS9x7O6kd9Tu/C/XKbvCklYHSadwI8gHJ2HgU=; b=Z/Ye3Ytmck/j7C+pZEuAkDfWyRK1E6d94C0JKuTKpegEZagpvtUvr4OKB8EBRuKFMd ean0Jl/OUIQdBExigUJHT0nla0f9cR5JcmY3G/JRYkV33MdJj+Ke/BmEgFfJm0OVzx+5 CpjSO7SxS7ApMhkUV3kv5FK5HhprgMCrZgNLRRTO+iOSaahTOnt66UCNkxPLNzrd6hf7 YfeCuH1/9AIkj95S4oDRDw8cxnLXZVV4ezELZtmbD/C1/kjxQ0s3t8dYnC6AL6mFhmDW eMdUHcvRcHyE1MCrGZ6E26B+21zN+6AukiIoqH92OC8ytONEaXO01BQEI+NBk/BJzLtl zIdw== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b7-20020a056402084700b0045d39f946b4si14100824edz.20.2022.10.19.08.42.33; Wed, 19 Oct 2022 08:42:58 -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; 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 S231573AbiJSPc2 (ORCPT + 99 others); Wed, 19 Oct 2022 11:32:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230063AbiJSPb4 (ORCPT ); Wed, 19 Oct 2022 11:31:56 -0400 Received: from mailout-taastrup.gigahost.dk (mailout-taastrup.gigahost.dk [46.183.139.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C42334E1A0; Wed, 19 Oct 2022 08:25:13 -0700 (PDT) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-taastrup.gigahost.dk (Postfix) with ESMTP id 5B1C41884AE0; Wed, 19 Oct 2022 15:12:49 +0000 (UTC) Received: from smtp.gigahost.dk (smtp.gigahost.dk [89.186.169.109]) by mailout.gigahost.dk (Postfix) with ESMTP id 2273C2500615; Wed, 19 Oct 2022 15:12:49 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 0) id E908E9EC0009; Wed, 19 Oct 2022 15:12:48 +0000 (UTC) X-Screener-Id: 413d8c6ce5bf6eab4824d0abaab02863e8e3f662 Received: from fujitsu.vestervang (2-104-116-184-cable.dk.customer.tdc.net [2.104.116.184]) by smtp.gigahost.dk (Postfix) with ESMTPSA id 9D9799EC0007; Tue, 18 Oct 2022 16:56:58 +0000 (UTC) From: "Hans J. Schultz" To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, "Hans J. Schultz" , Florian Fainelli , Andrew Lunn , Vivien Didelot , Vladimir Oltean , Eric Dumazet , Paolo Abeni , Kurt Kanzenbach , Hauke Mehrtens , Woojung Huh , UNGLinuxDriver@microchip.com, Sean Wang , Landen Chao , DENG Qingfang , Matthias Brugger , Claudiu Manoil , Alexandre Belloni , Jiri Pirko , Ivan Vecera , Roopa Prabhu , Nikolay Aleksandrov , Shuah Khan , Russell King , Christian Marangi , Daniel Borkmann , Yuwei Wang , Petr Machata , Ido Schimmel , Florent Fourcot , Hans Schultz , Joachim Wiberg , Amit Cohen , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, bridge@lists.linux-foundation.org, linux-kselftest@vger.kernel.org Subject: [PATCH v8 net-next 07/12] net: dsa: send the blackhole flag down through the DSA layer Date: Tue, 18 Oct 2022 18:56:14 +0200 Message-Id: <20221018165619.134535-8-netdev@kapio-technology.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018165619.134535-1-netdev@kapio-technology.com> References: <20221018165619.134535-1-netdev@kapio-technology.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747131226721159694?= X-GMAIL-MSGID: =?utf-8?q?1747131226721159694?= Propagate blackhole FDB entries through the DSA layer towards the drivers, remembering that these entries are local entries. Signed-off-by: Hans J. Schultz --- include/net/dsa.h | 1 + net/dsa/dsa_priv.h | 4 ++-- net/dsa/port.c | 22 ++++++++++++---------- net/dsa/slave.c | 6 ++++-- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/include/net/dsa.h b/include/net/dsa.h index e4b641b20713..d5b2aef52d93 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -822,6 +822,7 @@ static inline bool dsa_port_tree_same(const struct dsa_port *a, } #define DSA_FDB_FLAG_LOCKED (1 << 0) +#define DSA_FDB_FLAG_BLACKHOLE (1 << 1) typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, bool is_static, void *data); diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index c943e8934063..611833f162d1 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -251,9 +251,9 @@ int dsa_port_standalone_host_fdb_add(struct dsa_port *dp, int dsa_port_standalone_host_fdb_del(struct dsa_port *dp, const unsigned char *addr, u16 vid); int dsa_port_bridge_host_fdb_add(struct dsa_port *dp, const unsigned char *addr, - u16 vid); + u16 vid, u16 fdb_flags); int dsa_port_bridge_host_fdb_del(struct dsa_port *dp, const unsigned char *addr, - u16 vid); + u16 vid, u16 fdb_flags); int dsa_port_lag_fdb_add(struct dsa_port *dp, const unsigned char *addr, u16 vid); int dsa_port_lag_fdb_del(struct dsa_port *dp, const unsigned char *addr, diff --git a/net/dsa/port.c b/net/dsa/port.c index ff4f66f14d39..7e77c5d6090a 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -1001,12 +1001,13 @@ int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr, static int dsa_port_host_fdb_add(struct dsa_port *dp, const unsigned char *addr, u16 vid, - struct dsa_db db) + u16 fdb_flags, struct dsa_db db) { struct dsa_notifier_fdb_info info = { .dp = dp, .addr = addr, .vid = vid, + .fdb_flags = fdb_flags, .db = db, }; @@ -1024,11 +1025,11 @@ int dsa_port_standalone_host_fdb_add(struct dsa_port *dp, .dp = dp, }; - return dsa_port_host_fdb_add(dp, addr, vid, db); + return dsa_port_host_fdb_add(dp, addr, vid, 0, db); } -int dsa_port_bridge_host_fdb_add(struct dsa_port *dp, - const unsigned char *addr, u16 vid) +int dsa_port_bridge_host_fdb_add(struct dsa_port *dp, const unsigned char *addr, + u16 vid, u16 fdb_flags) { struct net_device *master = dsa_port_to_master(dp); struct dsa_db db = { @@ -1047,17 +1048,18 @@ int dsa_port_bridge_host_fdb_add(struct dsa_port *dp, return err; } - return dsa_port_host_fdb_add(dp, addr, vid, db); + return dsa_port_host_fdb_add(dp, addr, vid, fdb_flags, db); } static int dsa_port_host_fdb_del(struct dsa_port *dp, const unsigned char *addr, u16 vid, - struct dsa_db db) + u16 fdb_flags, struct dsa_db db) { struct dsa_notifier_fdb_info info = { .dp = dp, .addr = addr, .vid = vid, + .fdb_flags = fdb_flags, .db = db, }; @@ -1075,11 +1077,11 @@ int dsa_port_standalone_host_fdb_del(struct dsa_port *dp, .dp = dp, }; - return dsa_port_host_fdb_del(dp, addr, vid, db); + return dsa_port_host_fdb_del(dp, addr, vid, 0, db); } -int dsa_port_bridge_host_fdb_del(struct dsa_port *dp, - const unsigned char *addr, u16 vid) +int dsa_port_bridge_host_fdb_del(struct dsa_port *dp, const unsigned char *addr, + u16 vid, u16 fdb_flags) { struct net_device *master = dsa_port_to_master(dp); struct dsa_db db = { @@ -1094,7 +1096,7 @@ int dsa_port_bridge_host_fdb_del(struct dsa_port *dp, return err; } - return dsa_port_host_fdb_del(dp, addr, vid, db); + return dsa_port_host_fdb_del(dp, addr, vid, fdb_flags, db); } int dsa_port_lag_fdb_add(struct dsa_port *dp, const unsigned char *addr, diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 65f0c578ef44..4e22014ec469 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -3258,7 +3258,7 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work) switch (switchdev_work->event) { case SWITCHDEV_FDB_ADD_TO_DEVICE: if (switchdev_work->host_addr) - err = dsa_port_bridge_host_fdb_add(dp, addr, vid); + err = dsa_port_bridge_host_fdb_add(dp, addr, vid, fdb_flags); else if (dp->lag) err = dsa_port_lag_fdb_add(dp, addr, vid); else @@ -3274,7 +3274,7 @@ static void dsa_slave_switchdev_event_work(struct work_struct *work) case SWITCHDEV_FDB_DEL_TO_DEVICE: if (switchdev_work->host_addr) - err = dsa_port_bridge_host_fdb_del(dp, addr, vid); + err = dsa_port_bridge_host_fdb_del(dp, addr, vid, fdb_flags); else if (dp->lag) err = dsa_port_lag_fdb_del(dp, addr, vid); else @@ -3365,6 +3365,8 @@ static int dsa_slave_fdb_event(struct net_device *dev, if (fdb_info->locked) fdb_flags |= DSA_FDB_FLAG_LOCKED; + if (fdb_info->blackhole) + fdb_flags |= DSA_FDB_FLAG_BLACKHOLE; INIT_WORK(&switchdev_work->work, dsa_slave_switchdev_event_work); switchdev_work->event = event;