Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp118536pxk; Wed, 30 Sep 2020 20:07:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3uhgh6IdyXzdmKFupTcPnAzMHXnxVIs9lbHNk84TxtUe2O8cdJSuZzJUztCwMQPX9oMgj X-Received: by 2002:a50:e68a:: with SMTP id z10mr6264428edm.100.1601521673398; Wed, 30 Sep 2020 20:07:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601521673; cv=none; d=google.com; s=arc-20160816; b=Zbi6qRBw4VgTUz7BdR6E0P4whMpYT/au/yeBKxDLyQcRYflz8WrE7JdprL5dYgTsyp MAdeLb5ExTR0Fx6upDEhhHd+zNF+idjm35O5f8YeHWyHPgRjBeTAopzisgM6MDqrnNIO WBdTYS7aAy0IKQEKl1hL+Msf3rC21Z+JojpA4r8gKz4Dh4r4T3zVtjfZL4/BkA+t/ni+ YZep1jz4GItyddcA6gGgEt3SxpmnxiSFzmas5r15USfBbkhyi3x40OarlmD+1XDJuuuy 7x4j7wStY1yOZWPJPsm8mxM8vKK/Z+3roGdbQprauuHrcsiVDi2Z3mbN6F92iRkY/RZz Nauw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=JpA4mEMdIMQkUgcqLmQKDXhuGQnqErnzJNy5+Hgc68M=; b=aRoNLLXBEoXgi3KF6bko5eMd2cfG5I+pCz+cb6DpznxxTpe4hvmGLnejGlEL1jCW4C aCkD1rBDdb6C23XVUk1uXRSSbqUfCdRoPSZfQBlgs2yyUl6K7PUSqoF9SIZzeZCfNlx2 g3HGG7wItfeOHDG1EYTN2jHD4iLj+GDu1Qw3ccMGz98kvOHq08vGsg2In3BZE92fDYPo oAF7UzaQPyzU5SDu9unZmiVyfk50pJdXWDhy0PbC9b2QjBDB7V4uFwpzKksmluH6oH/a nCdx6/21K/naDayf14M8YnPTcqKB/ZINCwVH/5rWP7+/YTjExij9x4+Z3nBe6jiWxaSE Fg4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EdzmHns5; 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 y15si2502951edv.532.2020.09.30.20.07.30; Wed, 30 Sep 2020 20:07:53 -0700 (PDT) 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=EdzmHns5; 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 S1730349AbgJADG3 (ORCPT + 99 others); Wed, 30 Sep 2020 23:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgJADG3 (ORCPT ); Wed, 30 Sep 2020 23:06:29 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21CC6C061755; Wed, 30 Sep 2020 20:06:29 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id v14so1078164pjd.4; Wed, 30 Sep 2020 20:06:29 -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:mime-version :content-transfer-encoding; bh=JpA4mEMdIMQkUgcqLmQKDXhuGQnqErnzJNy5+Hgc68M=; b=EdzmHns5Ys9SYSQBrQ4OCbXe5lPCgoPiDWjOAtayXKHCMASFFa23Q+IbQMhfLMLwrM N4URGoVlD/hIRgGYh21OQ3dyoin15IeNvlb78R2qsAk0ruDhf63vaEUrVBSpIrjH7wsw TWlY5pHNBMR1Vb9RTkdojCfNAvRR1hHAknxAAtbLLRIhSw7OHixlU006QxRgl+BKqtDO zrY/PunwpXSY69OhuK+3oXvYag/c6h1qMSLFMaxxk1XKmAuEA0s1NVYaD9ifqY2l5iBP GPmiQGcM5e3XjHrKHp3VO8MaCKUwgGeQaLQ49wjAU9TJDcj7AfukUDhsAITMqiO1tJSr DypQ== 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:mime-version :content-transfer-encoding; bh=JpA4mEMdIMQkUgcqLmQKDXhuGQnqErnzJNy5+Hgc68M=; b=Po80BE2SWxrchjhUXZC7iADLmkYUx41qo7/sHVTLM++gnPCGT+0utQNq3EVAAJQhxH ft1gSCbrpGgHLAXbecZtwfiok61PxDrYkWYS1MwpSH9pRfsS7R7QOi/OvqHCz6csZGPI ZrePhe+jn0jzkYXNdYwNroHqoNztFdzwX8fyS8H90UUy+AR/uWgEiEte5p5oXT8vrdDV eqFdEAW8gV7SZPLtD/HwtT4tglQnls466zgIeLjAm1ep2V+CvmEaT9ojz8jcdaTTE5eN TkfrikK5UenLObkiQhPSCmwGAkPuN3Rbja/me7D8gI5NKeTnfnLkocIUItKZJdrfes/t mI+Q== X-Gm-Message-State: AOAM530z4fSy18TtxTH+47w850j7dBpg1c8Id2uaBNkhG0c1sJ5pzu1D pXZROO48FHWDPFEWZFfM1bVwSe9zuBBLmQ== X-Received: by 2002:a17:90b:715:: with SMTP id s21mr4880625pjz.113.1601521588052; Wed, 30 Sep 2020 20:06:28 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id x4sm4056271pfm.86.2020.09.30.20.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2020 20:06:27 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , "David S. Miller" , Jakub Kicinski , Vladimir Oltean , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2] net: dsa: Support bridge 802.1Q while untagging Date: Wed, 30 Sep 2020 20:06:23 -0700 Message-Id: <20201001030623.343535-1-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The intent of 412a1526d067 ("net: dsa: untag the bridge pvid from rx skbs") is to transparently untag the bridge's default_pvid when the Ethernet switch can only support egress tagged of that default_pvid towards the CPU port. Prior to this commit, users would have to configure an 802.1Q upper on the bridge master device when the bridge is configured with vlan_filtering=0 in order to pop the VLAN tag: ip link add name br0 type bridge vlan_filtering 0 ip link add link br0 name br0.1 type vlan id 1 After this commit we added support for managing a switch port 802.1Q upper but those are not usually added as bridge members, and if they do, they do not actually require any special management, the data path would pop the desired VLAN tag accordingly. What we want to preserve is that use case and to manage when the user creates that 802.1Q upper for the bridge port. While we are it, call __vlan_find_dev_deep_rcu() which makes use the VLAN group array which is faster. As soon as we return the VLAN tagged SKB though it will be used by the following call path: netif_receive_skb_list_internal -> __netif_receive_skb_list_core -> __netif_receive_skb_core -> vlan_do_receive() which uses skb->vlan_proto, if we do not set it to the appropriate VLAN protocol, we will leave it set to what the DSA master has set (ETH_P_XDSA). Fixes: 412a1526d067 ("net: dsa: untag the bridge pvid from rx skbs") Signed-off-by: Florian Fainelli --- Changes in v2: - removed unused list_head iter argument net/dsa/dsa_priv.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 0348dbab4131..b4aafb2e90fa 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -205,7 +205,6 @@ static inline struct sk_buff *dsa_untag_bridge_pvid(struct sk_buff *skb) struct net_device *br = dp->bridge_dev; struct net_device *dev = skb->dev; struct net_device *upper_dev; - struct list_head *iter; u16 vid, pvid, proto; int err; @@ -247,12 +246,10 @@ static inline struct sk_buff *dsa_untag_bridge_pvid(struct sk_buff *skb) * supports because vlan_filtering is 0. In that case, we should * definitely keep the tag, to make sure it keeps working. */ - netdev_for_each_upper_dev_rcu(dev, upper_dev, iter) { - if (!is_vlan_dev(upper_dev)) - continue; - - if (vid == vlan_dev_vlan_id(upper_dev)) - return skb; + upper_dev = __vlan_find_dev_deep_rcu(br, htons(proto), vid); + if (upper_dev) { + skb->vlan_proto = vlan_dev_vlan_proto(upper_dev); + return skb; } __vlan_hwaccel_clear_tag(skb); -- 2.25.1