From patchwork Wed Apr 29 16:19:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 220308 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 77B0CC83004 for ; Wed, 29 Apr 2020 16:20:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5889420787 for ; Wed, 29 Apr 2020 16:20:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DcoEu8Tw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726864AbgD2QUB (ORCPT ); Wed, 29 Apr 2020 12:20:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726423AbgD2QT7 (ORCPT ); Wed, 29 Apr 2020 12:19:59 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75236C03C1AD for ; Wed, 29 Apr 2020 09:19:59 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id v8so5329678wma.0 for ; Wed, 29 Apr 2020 09:19:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sslderKR2VnBe3vbWtKjxt2i8MRgj916M4Mgvk8OZR0=; b=DcoEu8TwsirMmJY1ujDyd/YDbLX3E35lTqumTv3D1wU5xQRTGw54MEIDx6xwud7JGr f/vbErxiE/8r2Rmbj/K9x6tZp9p2EUWR6eT/Avis6iFNQXfgT9T0oQHKG7de7jxQT9Kj KoW/0333jIvdmDYCy5RPfvPwlzsGD+9EVKhu9XAKJpe1W/RWmeajAXaO9c3wX5K+PPsx YZnAG92ErIWWgt+yrncTkvV92OFQ8Wmm9xuIiAnrtAqqDw/imj9lQTSWnH9SoTpVGiTZ WfBayjCQ3xvXoft8U8B5p+4NZOcVHCqQIso7flwUIy9q32o+7FiJ9GPjt8bPSdbXmXd3 b/WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sslderKR2VnBe3vbWtKjxt2i8MRgj916M4Mgvk8OZR0=; b=j3GBvJHizNK7msyo7H/Kuyxbbziz1eqla1c6vwrjsonvxp8zMqaxzWo8OHnu9uVNBF JVbI5Geh8MPSnfcskUzNCsBSNHem5KC57De5My4cw783cxNemr7OYWfbd89xslbXvdui nDqr+T5CynpGlTZdmW0tekJ4zbMXPJYn8XB8YkQ/ORZBtx93ueTx4gcc84yopd84xAWx S0QlKBFy1mPwEwEOzamqCoK2LzmNS7Oht8Sb7qVNxDRULaOZQTHJjN/xI4g8KtkhZJjn HQII1SvX6WvQHiwE6oxzZ2HR+Ef0sr2RgozqYDLNvWB++BPrMCpWR8dSfyv++VgObzWr sWMg== X-Gm-Message-State: AGi0PuY2HX5yRUTE4vUPlUFCNosh8cJbfdjBaIDJYIC5JAyXw4LfTFB0 4C7ku3owJ93yJmqhWqWsEx4= X-Google-Smtp-Source: APiQypJJuUY/UEoG2j7KslBLNLCUWab8feTEw73uVtckG+jifWULQYVDGuH1I5gXP5qH19gDW6Vu9g== X-Received: by 2002:a1c:c302:: with SMTP id t2mr4225330wmf.85.1588177198160; Wed, 29 Apr 2020 09:19:58 -0700 (PDT) Received: from localhost.localdomain ([86.121.118.29]) by smtp.gmail.com with ESMTPSA id r18sm28132609wrj.70.2020.04.29.09.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 09:19:57 -0700 (PDT) From: Vladimir Oltean To: andrew@lunn.ch, f.fainelli@gmail.com, vivien.didelot@gmail.com, davem@davemloft.net Cc: jiri@resnulli.us, idosch@idosch.org, kuba@kernel.org, netdev@vger.kernel.org, leoyang.li@nxp.com, nikolay@cumulusnetworks.com Subject: [PATCH net-next 1/4] bridge: Allow enslaving DSA master network devices Date: Wed, 29 Apr 2020 19:19:49 +0300 Message-Id: <20200429161952.17769-2-olteanv@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200429161952.17769-1-olteanv@gmail.com> References: <20200429161952.17769-1-olteanv@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Florian Fainelli Commit 8db0a2ee2c63 ("net: bridge: reject DSA-enabled master netdevices as bridge members") added a special check in br_if.c in order to check for a DSA master network device with a tagging protocol configured. This was done because back then, such devices, once enslaved in a bridge would become inoperative and would not pass DSA tagged traffic anymore due to br_handle_frame returning RX_HANDLER_CONSUMED. But right now we have valid use cases which do require bridging of DSA masters. One such example is when the DSA master ports are DSA switch ports themselves (in a disjoint tree setup). This should be completely equivalent, functionally speaking, from having multiple DSA switches hanging off of the ports of a switchdev driver. So we should allow the enslaving of DSA tagged master network devices. Make br_handle_frame() return RX_HANDLER_PASS in order to call into the DSA specific tagging protocol handlers, and lift the restriction from br_add_if. Signed-off-by: Florian Fainelli Signed-off-by: Vladimir Oltean --- net/bridge/br_if.c | 4 +--- net/bridge/br_input.c | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index ca685c0cdf95..e0fbdb855664 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -571,8 +570,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev, */ if ((dev->flags & IFF_LOOPBACK) || dev->type != ARPHRD_ETHER || dev->addr_len != ETH_ALEN || - !is_valid_ether_addr(dev->dev_addr) || - netdev_uses_dsa(dev)) + !is_valid_ether_addr(dev->dev_addr)) return -EINVAL; /* No bridging of bridges */ diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index d5c34f36f0f4..396bc0c18cb5 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c @@ -17,6 +17,7 @@ #endif #include #include +#include #include #include #include "br_private.h" @@ -263,7 +264,8 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb) struct sk_buff *skb = *pskb; const unsigned char *dest = eth_hdr(skb)->h_dest; - if (unlikely(skb->pkt_type == PACKET_LOOPBACK)) + if (unlikely(skb->pkt_type == PACKET_LOOPBACK) || + netdev_uses_dsa(skb->dev)) return RX_HANDLER_PASS; if (!is_valid_ether_addr(eth_hdr(skb)->h_source)) From patchwork Wed Apr 29 16:19:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 220307 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 61BACC83004 for ; Wed, 29 Apr 2020 16:20:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AFD7206F0 for ; Wed, 29 Apr 2020 16:20:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XHexUZNE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726741AbgD2QUE (ORCPT ); Wed, 29 Apr 2020 12:20:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726871AbgD2QUC (ORCPT ); Wed, 29 Apr 2020 12:20:02 -0400 Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E88D4C03C1AE for ; Wed, 29 Apr 2020 09:20:01 -0700 (PDT) Received: by mail-wr1-x444.google.com with SMTP id x18so3280441wrq.2 for ; Wed, 29 Apr 2020 09:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zSQUFcTA5EZEGaPUB16rfmy3e7ibN/rhh32ryX4vK0A=; b=XHexUZNEEoPLgiKSW3tiPQbAg+klMt2VeEbN69JwmzWCJG75SktlhyIrXnnKMcrWFb faPL6lRlvCoROh4BQDqXo4Fur++S1Aw0eMONGRp1z6cBtWKZygoOp8RZSMKdebTs9mFz bj777HQcJFKwiY61tb0pqDFa4QfAQUcn0bmPfZdpBejIcR7XZR2u5Unz2zxhH6Ru9I2O z6Vb6wCcl2rMWzyjdsT3RsuIUThGYnRsdIFXHhSlCQXc4ZxGAL63IzL+gHCvfUxGK1CU ASXC8FoDYmAjwIPj1x5vLiSZaNDhuv8IPHxONseP+/VS2w2jRvmQHtampEaK4fFqXcyx 47sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zSQUFcTA5EZEGaPUB16rfmy3e7ibN/rhh32ryX4vK0A=; b=kNxJdYrn2W3+FsiLRPAMLUr6IAt1U52Av3eztO5oybu69p0FhYWFoSAkT/XCaSovxz vmXT78wmWiz/pjXG40DPB5bb7VxkaQVymJS7e1jJhOcw8JiSbSKKvjX8arGnSQ/9armJ fU9YeWiaNntmDuk2g+wMiz6EmcKTII/Y6WdxaOFNsu7kWOONuJUkqg56bTqwhZA8qpMp FREwyiZI0LpbAL+LcNMx4lJzFqJDBvuyTmFxqyrnq4My5HDbv5IwcESLJ3yvKOtDOSq3 7zUOEy8JERVs1+CCGh185Z92bHCSkWyXJFd7EVULm7Mc8fykNmOzUbQ9kiz12kXGD/dK ABpQ== X-Gm-Message-State: AGi0PuYztSDMZlGNX4x+atWxBVoMZ7WClNxqM3XHqUKCE+Q/ngyZbCCp K8KmO+U54Uh0vkxphnttP00= X-Google-Smtp-Source: APiQypLnRMNWj+gSL1nJEaYPI0cQv/guQjjTgnbCwZ0+y9mH8/h91MOFUuEH32wYsuPb23Cxzhzccw== X-Received: by 2002:a5d:4042:: with SMTP id w2mr37340690wrp.195.1588177200611; Wed, 29 Apr 2020 09:20:00 -0700 (PDT) Received: from localhost.localdomain ([86.121.118.29]) by smtp.gmail.com with ESMTPSA id r18sm28132609wrj.70.2020.04.29.09.19.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2020 09:20:00 -0700 (PDT) From: Vladimir Oltean To: andrew@lunn.ch, f.fainelli@gmail.com, vivien.didelot@gmail.com, davem@davemloft.net Cc: jiri@resnulli.us, idosch@idosch.org, kuba@kernel.org, netdev@vger.kernel.org, leoyang.li@nxp.com, nikolay@cumulusnetworks.com Subject: [PATCH net-next 3/4] net: dsa: introduce a dsa_switch_find function Date: Wed, 29 Apr 2020 19:19:51 +0300 Message-Id: <20200429161952.17769-4-olteanv@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200429161952.17769-1-olteanv@gmail.com> References: <20200429161952.17769-1-olteanv@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Vladimir Oltean Somewhat similar to dsa_tree_find, dsa_switch_find returns a dsa_switch structure pointer by searching for its tree index and switch index (the parameters from dsa,member). To be used, for example, by drivers who implement .crosschip_bridge_join and need a reference to the other switch indicated to by the tree_index and sw_index arguments. Signed-off-by: Vladimir Oltean --- include/net/dsa.h | 1 + net/dsa/dsa2.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index b2111924c7ef..8a337387565a 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -671,6 +671,7 @@ static inline bool dsa_can_decode(const struct sk_buff *skb, void dsa_unregister_switch(struct dsa_switch *ds); int dsa_register_switch(struct dsa_switch *ds); +struct dsa_switch *dsa_switch_find(int tree_index, int sw_index); #ifdef CONFIG_PM_SLEEP int dsa_switch_suspend(struct dsa_switch *ds); int dsa_switch_resume(struct dsa_switch *ds); diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index 9a271a58a41d..07e01b195975 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -24,6 +24,27 @@ LIST_HEAD(dsa_tree_list); static const struct devlink_ops dsa_devlink_ops = { }; +struct dsa_switch *dsa_switch_find(int tree_index, int sw_index) +{ + struct dsa_switch_tree *dst; + struct dsa_port *dp; + + list_for_each_entry(dst, &dsa_tree_list, list) { + if (dst->index != tree_index) + continue; + + list_for_each_entry(dp, &dst->ports, list) { + if (dp->ds->index != sw_index) + continue; + + return dp->ds; + } + } + + return NULL; +} +EXPORT_SYMBOL_GPL(dsa_switch_find); + static struct dsa_switch_tree *dsa_tree_find(int index) { struct dsa_switch_tree *dst;