Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1368154rwi; Wed, 19 Oct 2022 09:44:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4byxw1hzFVchiOjNJeF2VkAHp/xUvPo/k2Zv09YdiITwGidEKH/b6EPnMd3ImHj6x+zxnb X-Received: by 2002:a05:6402:440f:b0:45d:297b:c70a with SMTP id y15-20020a056402440f00b0045d297bc70amr8460075eda.187.1666197866962; Wed, 19 Oct 2022 09:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666197866; cv=none; d=google.com; s=arc-20160816; b=koXPZGltmnVtoc9hFppf+9qO8UWElpc1HnUhMx1Qz4Sjg9uGJavNGkNMNEdfPR6eey oMXyhhfhDkiRxZyGsPGf/IQW1MUfPhGWD5pQl8FXqFZ5ByTYrm07u5WlqWaOwTLKsf8Y uvg5482FkkWeQcqBl9O3LZFu3g1H+2M4tRpxOoAfSXqlpiaG0Djleu6Ua501LXHWA2hT yght2tVhRhp67J9k47e4s2YHUDQTOSYJimMAhDaD0MMDGipgTzW53tK3G7vfKBS0r/cp HZFscUMTqhsCZ2y0as5N7xyAnYZxOIL1oxfZ/stLoStKtPaHcSFuX36IFcrhff76pJz4 WPfA== 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=Z6A//gbFPwQQyslu5B/bjprqc73lpBnyMlSOQLuVKFc=; b=TG7EctBi7MJOqF5Veyc94RQh7BsWaKUJeLPPE4a5TxVjmTM66wfxkwx6J7AITdM1aJ sxpxFfHZ/1zYFxEYmimtmylDCHJeV+kGDClJlElyFyrtO0c83fFQ04aeWP6OHWl0jLof AQLMBYM7IIZWx+HfbjZ18wk6ngF/p2vyhmrJTzdGJ9iuPlQOewb8QmnO8/zTkmt2/LEa fMeFbnSVqS47yqZiGv9Za/FM572Yz1ZNvlsTF6+gAyQd2Rb3sA2tGP0kzza2Kw0Vc8EH 2rV7rwS2+7B1bqe6q3l/z2kkakfO9vUNqN7xDRR07Wzz9AuoIN8+fUnuse2sDv3xOP/T ZL+A== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz12-20020a1709077d8c00b0073d72e1633bsi16626070ejc.908.2022.10.19.09.44.00; Wed, 19 Oct 2022 09:44:26 -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 S231272AbiJSPcT (ORCPT + 99 others); Wed, 19 Oct 2022 11:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231795AbiJSPbt (ORCPT ); Wed, 19 Oct 2022 11:31:49 -0400 Received: from mailout-taastrup.gigahost.dk (mailout-taastrup.gigahost.dk [46.183.139.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 301A016F778; Wed, 19 Oct 2022 08:25:01 -0700 (PDT) Received: from mailout.gigahost.dk (mailout.gigahost.dk [89.186.169.112]) by mailout-taastrup.gigahost.dk (Postfix) with ESMTP id B2BF41884AE2; 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 5B3C32500721; Wed, 19 Oct 2022 15:12:49 +0000 (UTC) Received: by smtp.gigahost.dk (Postfix, from userid 0) id 21AD89EC000A; Wed, 19 Oct 2022 15:12:49 +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 D26009120FED; Tue, 18 Oct 2022 16:56:57 +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 06/12] net: bridge: enable bridge to send and receive blackhole FDB entries Date: Tue, 18 Oct 2022 18:56:13 +0200 Message-Id: <20221018165619.134535-7-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 Content-Transfer-Encoding: 8bit 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 Enable the bridge to receive blackhole FDB entries from drivers with SWITCHDEV_FDB_ADD_TO_BRIDGE notifications and send them to drivers with RTM_NEWNEIGH notifications. Signed-off-by: Hans J. Schultz --- include/net/switchdev.h | 1 + net/bridge/br.c | 3 ++- net/bridge/br_fdb.c | 19 ++++++++++++++++--- net/bridge/br_private.h | 3 ++- net/bridge/br_switchdev.c | 1 + 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/net/switchdev.h b/include/net/switchdev.h index ca0312b78294..39727902354e 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -249,6 +249,7 @@ struct switchdev_notifier_fdb_info { u8 added_by_user:1, is_local:1, locked:1, + blackhole:1, offloaded:1; }; diff --git a/net/bridge/br.c b/net/bridge/br.c index e0e2df2fa278..85fc529b6a9f 100644 --- a/net/bridge/br.c +++ b/net/bridge/br.c @@ -166,7 +166,8 @@ static int br_switchdev_event(struct notifier_block *unused, case SWITCHDEV_FDB_ADD_TO_BRIDGE: fdb_info = ptr; err = br_fdb_external_learn_add(br, p, fdb_info->addr, fdb_info->vid, - fdb_info->locked, false); + fdb_info->locked, fdb_info->is_local, + fdb_info->blackhole, false); if (err) { err = notifier_from_errno(err); break; diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index 8d207b1416f7..ef973d21d7bd 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -1145,7 +1145,7 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br, "FDB entry towards bridge must be permanent"); return -EINVAL; } - err = br_fdb_external_learn_add(br, p, addr, vid, false, true); + err = br_fdb_external_learn_add(br, p, addr, vid, false, false, false, true); } else { spin_lock_bh(&br->hash_lock); err = fdb_add_entry(br, p, addr, ndm, nlh_flags, vid, ext_flags, nfea_tb); @@ -1401,7 +1401,7 @@ void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p) int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p, const unsigned char *addr, u16 vid, bool locked, - bool swdev_notify) + bool local, bool blackhole, bool swdev_notify) { struct net_bridge_fdb_entry *fdb; bool modified = false; @@ -1418,12 +1418,15 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p, if (swdev_notify) flags |= BIT(BR_FDB_ADDED_BY_USER); - if (!p) + if (!p || local) flags |= BIT(BR_FDB_LOCAL); if (locked) flags |= BIT(BR_FDB_LOCKED); + if (blackhole) + flags |= BIT(BR_FDB_BLACKHOLE); + fdb = fdb_create(br, p, addr, vid, flags); if (!fdb) { err = -ENOMEM; @@ -1447,11 +1450,21 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p, modified = true; } + if (local != test_bit(BR_FDB_LOCAL, &fdb->flags)) { + change_bit(BR_FDB_LOCAL, &fdb->flags); + modified = true; + } + if (locked != test_bit(BR_FDB_LOCKED, &fdb->flags)) { change_bit(BR_FDB_LOCKED, &fdb->flags); modified = true; } + if (blackhole != test_bit(BR_FDB_BLACKHOLE, &fdb->flags)) { + change_bit(BR_FDB_BLACKHOLE, &fdb->flags); + modified = true; + } + if (swdev_notify) set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags); diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 3e9f4d1fbd60..4202c80e465e 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -812,7 +812,8 @@ int br_fdb_sync_static(struct net_bridge *br, struct net_bridge_port *p); void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p); int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p, const unsigned char *addr, u16 vid, - bool locked, bool swdev_notify); + bool locked, bool local, bool blackhole, + bool swdev_notify); int br_fdb_external_learn_del(struct net_bridge *br, struct net_bridge_port *p, const unsigned char *addr, u16 vid, bool swdev_notify); diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c index ccf1b4cffdd0..ce7b80c782ec 100644 --- a/net/bridge/br_switchdev.c +++ b/net/bridge/br_switchdev.c @@ -137,6 +137,7 @@ static void br_switchdev_fdb_populate(struct net_bridge *br, item->offloaded = test_bit(BR_FDB_OFFLOADED, &fdb->flags); item->is_local = test_bit(BR_FDB_LOCAL, &fdb->flags); item->locked = test_bit(BR_FDB_LOCKED, &fdb->flags); + item->blackhole = test_bit(BR_FDB_BLACKHOLE, &fdb->flags); item->info.dev = (!p || item->is_local) ? br->dev : p->dev; item->info.ctx = ctx; } -- 2.34.1