From patchwork Fri Oct 2 02:42:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 267133 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=-12.8 required=3.0 tests=BAYES_00,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,USER_AGENT_GIT autolearn=unavailable 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 CD7E4C47423 for ; Fri, 2 Oct 2020 02:42:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8DC8D20796 for ; Fri, 2 Oct 2020 02:42:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uAqnAgxk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387585AbgJBCmf (ORCPT ); Thu, 1 Oct 2020 22:42:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387485AbgJBCme (ORCPT ); Thu, 1 Oct 2020 22:42:34 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45E76C0613D0; Thu, 1 Oct 2020 19:42:33 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id k13so230270pfg.1; Thu, 01 Oct 2020 19:42:33 -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 :mime-version:content-transfer-encoding; bh=odFd5HP3SrWjbzeDvFMjd47wiKSJOjEU0D88/qTJTVI=; b=uAqnAgxkUY/UrVdDabt8vA0fjYMREHfTZfbYcFAGDMqUIPNiwNVyv0yPHQvkJ69K4B TkxEUb3bBF3ZK6K7PpIlKIVkfBBDzklz2VZP0aG9K7tFjMlpw9Wvnd3mRcVlxLXfBeas +2k8n3ruZrdTHEclfdVh1pQaiTw+4T4TsLnYzEYFTr88mztbC8g1KFnRTJVXT4Px6oFy 3vZQIrN3/etersVmBGV0MUE9KKWW9wV9swyrTPk3FP36QkVkKL1lMJdfYrC/Ceq07cR0 DqrOyEGXHbeAJXfnr65qkiqm3Vvn8qZj7z7aH/Prwn4fY9A5ofWSG7Ow71fgRbNoiGIZ A5cA== 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:mime-version:content-transfer-encoding; bh=odFd5HP3SrWjbzeDvFMjd47wiKSJOjEU0D88/qTJTVI=; b=mc+uO7bkmOQeunYo/YufqOn9TNSaVpv/j5ZkAJKFN1al8grqGXDCI7RCIijVNIO6hM IeoeHThfaMYpNrU5EEhm3H1prBcgECNcjqKT25QoeFugUAhb7u//EqLH1cOGxE8aTKrn 6tKdDABciz1meq31YTcAGvFXs7SNt0UHLLjk8B/UaZAxOD8TxOQm42Td7D17I62pWNnk h+9bC8xTudM7vm4+pDAY2EZcj7A6qanijLsF+WD3Y/3o0ACT7VVWIClwDD5WrH32B7zO dNkHw6N/eauYeTF827Cja8bNNnMdm3b/8BIysGGmpYC3DEr6GAHcugqcOdk2jem8Ut/y vgOg== X-Gm-Message-State: AOAM53059o/FBDDSso49xoRN48w+6u6x/Lsc5CSG1xdyN64jSljuGstv t0kTg8xhj6le3eYOtnGqFR5cgL8A50Uj4g== X-Google-Smtp-Source: ABdhPJx+BKNzjXZOlCBR2SmJyxmtWkplyGOTBO/0nS47RliLDmvuMMBoJ+NXZVHqjTpngBm1YDf7mA== X-Received: by 2002:a65:6487:: with SMTP id e7mr8486945pgv.409.1601606552344; Thu, 01 Oct 2020 19:42:32 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id gt11sm150185pjb.48.2020.10.01.19.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 19:42:31 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , "David S. Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org (open list), vladimir.oltean@nxp.com, olteanv@gmail.com Subject: [PATCH net-next 1/4] net: dsa: Call dsa_untag_bridge_pvid() from dsa_switch_rcv() Date: Thu, 1 Oct 2020 19:42:12 -0700 Message-Id: <20201002024215.660240-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201002024215.660240-1-f.fainelli@gmail.com> References: <20201002024215.660240-1-f.fainelli@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When a DSA switch driver needs to call dsa_untag_bridge_pvid(), it can set dsa_switch::untag_brige_pvid to indicate this is necessary. This is a pre-requisite to making sure that we are always calling dsa_untag_bridge_pvid() after eth_type_trans() has been called. Signed-off-by: Florian Fainelli Reviewed-by: Vladimir Oltean --- include/net/dsa.h | 8 ++++++++ net/dsa/dsa.c | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index b502a63d196e..8b0696e08cac 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -308,6 +308,14 @@ struct dsa_switch { */ bool configure_vlan_while_not_filtering; + /* If the switch driver always programs the CPU port as egress tagged + * despite the VLAN configuration indicating otherwise, then setting + * @untag_bridge_pvid will force the DSA receive path to pop the bridge's + * default_pvid VLAN tagged frames to offer a consistent behavior + * between a vlan_filtering=0 and vlan_filtering=1 bridge device. + */ + bool untag_bridge_pvid; + /* In case vlan_filtering_is_global is set, the VLAN awareness state * should be retrieved from here and not from the per-port settings. */ diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 5c18c0214aac..dec4ab59b7c4 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -225,6 +225,15 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev, skb->pkt_type = PACKET_HOST; skb->protocol = eth_type_trans(skb, skb->dev); + if (unlikely(cpu_dp->ds->untag_bridge_pvid)) { + nskb = dsa_untag_bridge_pvid(skb); + if (!nskb) { + kfree_skb(skb); + return 0; + } + skb = nskb; + } + s = this_cpu_ptr(p->stats64); u64_stats_update_begin(&s->syncp); s->rx_packets++; From patchwork Fri Oct 2 02:42:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 267736 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=-12.8 required=3.0 tests=BAYES_00,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,USER_AGENT_GIT autolearn=unavailable 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 82960C4741F for ; Fri, 2 Oct 2020 02:42:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4876F207DE for ; Fri, 2 Oct 2020 02:42:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QK0odRNw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387605AbgJBCmo (ORCPT ); Thu, 1 Oct 2020 22:42:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387485AbgJBCmi (ORCPT ); Thu, 1 Oct 2020 22:42:38 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2861FC0613D0; Thu, 1 Oct 2020 19:42:38 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id e18so518518pgd.4; Thu, 01 Oct 2020 19:42:38 -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 :mime-version:content-transfer-encoding; bh=PVE6dj7KElSm5JHuEzI9VdWXB5S7Zzgg0Ylks3nzGTA=; b=QK0odRNw1YbgwIN2z/O6EwmnuAh8zTAPtPAq291jHHuQOIFUnorxxfBeq4hzQDCRE2 42iJfjCOgnapQ5iZ+7UqEy8dSaK+1AHQACRJNvhO3NKp0xh9m52oHPb7qZ7RSzyhEujr WqKOzEeS2MPzVZX7LtPU1zs0GIqsXLOdQnKIApzfhiRHhybyGsxK5rxMH9RAQaVLUdRs 3stajDvV9shpg358X0Jd80VfQYuouVZ7hGseKiOXaPdrL7vdsg2/yIk2j0eLq/Vh/p15 I0Einu+IVvI7RYHxW6ZEO5Hi5lCCeQpfTXYrQ2P+LULnOw6J27nce2T1x9l5hTw2rahl Y1dg== 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:mime-version:content-transfer-encoding; bh=PVE6dj7KElSm5JHuEzI9VdWXB5S7Zzgg0Ylks3nzGTA=; b=EBa7w5EZTJmauZ2N6NngkQ6UujNv0Xlru4sxP2mbK4N1v0Hwb4QvC0njShnVKw6VRE hEswnAtLFfY6zHkNv6hrdz/J3C5WfTiWjrhVI+UT58PQf2hKhcALdInyZbW9YQH6obdP bTzt8jATDBLuT051VdBfJhh2ROKTGRhI5SQ9MusAnyU29ZB69n0oixvPizdX+lVNKb+1 aARwc2rQrTeJFDWYgQ4tYystO0sKh+Ho3FHwSOmEZn42DLP+TT80+6JjkFo9smkGABLa DFm8Gv06N0pvOViQuw4Ep5snMrusMA1MPPlbf1v1L2hrdbyidybd85ro+YM2ygLWA4Tb oTIw== X-Gm-Message-State: AOAM530FlKvnFVzb0WvGzYsmT07gMYy2sp9AZmV3oBx/c001K+WG327C ouuDaKAdLCibt6nqRWdtyRfShA7Rg782og== X-Google-Smtp-Source: ABdhPJyqetfkTbQRqPyc/nUNuil1jXA6b5y3h2eNa3/SPC9H8ZKGRx0e/1xQRczANyJGdbbAbrA/nw== X-Received: by 2002:a62:7a14:0:b029:13e:d13d:a0f5 with SMTP id v20-20020a627a140000b029013ed13da0f5mr175423pfc.17.1601606557193; Thu, 01 Oct 2020 19:42:37 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id gt11sm150185pjb.48.2020.10.01.19.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 19:42:36 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , "David S. Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org (open list), vladimir.oltean@nxp.com, olteanv@gmail.com Subject: [PATCH net-next 2/4] net: dsa: b53: Set untag_bridge_pvid Date: Thu, 1 Oct 2020 19:42:13 -0700 Message-Id: <20201002024215.660240-3-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201002024215.660240-1-f.fainelli@gmail.com> References: <20201002024215.660240-1-f.fainelli@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Indicate to the DSA receive path that we need to untage the bridge PVID, this allows us to remove the dsa_untag_bridge_pvid() calls from net/dsa/tag_brcm.c. Signed-off-by: Florian Fainelli Reviewed-by: Vladimir Oltean --- drivers/net/dsa/b53/b53_common.c | 1 + net/dsa/tag_brcm.c | 15 ++------------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 73507cff3bc4..ce18ba0b74eb 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -2603,6 +2603,7 @@ struct b53_device *b53_switch_alloc(struct device *base, dev->ops = ops; ds->ops = &b53_switch_ops; ds->configure_vlan_while_not_filtering = true; + ds->untag_bridge_pvid = true; dev->vlan_enabled = ds->configure_vlan_while_not_filtering; mutex_init(&dev->reg_mutex); mutex_init(&dev->stats_mutex); diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c index 69d6b8c597a9..ad72dff8d524 100644 --- a/net/dsa/tag_brcm.c +++ b/net/dsa/tag_brcm.c @@ -152,11 +152,6 @@ static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb, /* Remove Broadcom tag and update checksum */ skb_pull_rcsum(skb, BRCM_TAG_LEN); - /* Set the MAC header to where it should point for - * dsa_untag_bridge_pvid() to parse the correct VLAN header. - */ - skb_set_mac_header(skb, -ETH_HLEN); - skb->offload_fwd_mark = 1; return skb; @@ -187,7 +182,7 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev, nskb->data - ETH_HLEN - BRCM_TAG_LEN, 2 * ETH_ALEN); - return dsa_untag_bridge_pvid(nskb); + return nskb; } static const struct dsa_device_ops brcm_netdev_ops = { @@ -214,14 +209,8 @@ static struct sk_buff *brcm_tag_rcv_prepend(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt) { - struct sk_buff *nskb; - /* tag is prepended to the packet */ - nskb = brcm_tag_rcv_ll(skb, dev, pt, ETH_HLEN); - if (!nskb) - return nskb; - - return dsa_untag_bridge_pvid(nskb); + return brcm_tag_rcv_ll(skb, dev, pt, ETH_HLEN); } static const struct dsa_device_ops brcm_prepend_netdev_ops = { From patchwork Fri Oct 2 02:42:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 267132 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=-12.8 required=3.0 tests=BAYES_00,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,USER_AGENT_GIT autolearn=unavailable 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 8D148C4727E for ; Fri, 2 Oct 2020 02:42:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53248207DE for ; Fri, 2 Oct 2020 02:42:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="snQHdcK2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387627AbgJBCmu (ORCPT ); Thu, 1 Oct 2020 22:42:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387604AbgJBCmo (ORCPT ); Thu, 1 Oct 2020 22:42:44 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B74F6C0613D0; Thu, 1 Oct 2020 19:42:43 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id o25so536584pgm.0; Thu, 01 Oct 2020 19:42:43 -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 :mime-version:content-transfer-encoding; bh=vhJrTuKe7PDz10GtNZQbkYGDQuGZYuoM+kYSrehJVgg=; b=snQHdcK2Lj0GYmkGAMK+uTYrfZPPy/CkOc4CDSftneJIFxmF/+ZJC/pLeIPJk4N0wm jTtIYJ38X33KJLvA6yr/Vut3N2E8Qq5MdgK4qsyKSvGpY6jwAxh/3lXICP1Tjc0OgZUD yY0PdElkMYfdrBAZiGZNh6KL8h6NXZyIC6DI8vHKXDsdI5Hae7mzE5QvaesltPflNPmb vBT73gdfmh4xl1g9VfRapcGsUU7Ttytvb38iy53Y0yNvLQiwMBsillsyVoa/7JQIVvaF JidnH7q5TM+nJlLhuQL+eiXwxMt6R+D4P5lKc0pkgg9Jc9RmHJgCU+y12yJII+bEx879 yabQ== 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:mime-version:content-transfer-encoding; bh=vhJrTuKe7PDz10GtNZQbkYGDQuGZYuoM+kYSrehJVgg=; b=uQ6ulqffxTaJaA3hJ4n3to7SZyELjo4aUKOM1bUpSYqGuwnt72ZvrlZ1cRdlz1DUrS lq16AT0//BuUISUm2FCrUcDWvNFf71OK6h8CAUJn9igq53Y4MJ+4fgtCJ0Pp7ZUGDv6l W95H76oJDCSJHXxKMeQTW96+OoXO3ONX1uOJT0ruhfxyE+yGRTuZlJCVzzbwGwZfjP64 p+Wpgfi2tls7Ja0y3Yqt2N2JpUV9WQeemqdikkxwAR3yylcqGYV11DW9jAP60BtC0pqK tGIEtT+c72wWt2FEI47zraXnlQfKjrE299AtNb6Wv5osPzdlHs75kebqvVuLnRS6VLfe 39Bw== X-Gm-Message-State: AOAM5331xHI6CPSCBkBDnDxvP0jmuKMuhlCXuYSgbH8gHT+RuZ2dczZL bgLZC2khDkVsIHncapn8oJXV/gofULSUig== X-Google-Smtp-Source: ABdhPJwSVJkhy6QDj4UfhIyYeyf97BTCqf224vB3pU5Fu8758ZvLqreNoLtNHtqCh1L2ZUm2XKPqoA== X-Received: by 2002:a62:2985:0:b029:142:2501:3969 with SMTP id p127-20020a6229850000b029014225013969mr139245pfp.46.1601606562137; Thu, 01 Oct 2020 19:42:42 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id gt11sm150185pjb.48.2020.10.01.19.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 19:42:41 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , "David S. Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org (open list), vladimir.oltean@nxp.com, olteanv@gmail.com Subject: [PATCH net-next 3/4] net: dsa: Obtain VLAN protocol from skb->protocol Date: Thu, 1 Oct 2020 19:42:14 -0700 Message-Id: <20201002024215.660240-4-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201002024215.660240-1-f.fainelli@gmail.com> References: <20201002024215.660240-1-f.fainelli@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now that dsa_untag_bridge_pvid() is called after eth_type_trans() we are guaranteed that skb->protocol will be set to a correct value, thus allowing us to avoid calling vlan_eth_hdr(). Signed-off-by: Florian Fainelli Reviewed-by: Vladimir Oltean --- net/dsa/dsa_priv.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 0348dbab4131..d6ce8c2a2590 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -201,7 +201,6 @@ dsa_slave_to_master(const struct net_device *dev) static inline struct sk_buff *dsa_untag_bridge_pvid(struct sk_buff *skb) { struct dsa_port *dp = dsa_slave_to_port(skb->dev); - struct vlan_ethhdr *hdr = vlan_eth_hdr(skb); struct net_device *br = dp->bridge_dev; struct net_device *dev = skb->dev; struct net_device *upper_dev; @@ -217,7 +216,7 @@ static inline struct sk_buff *dsa_untag_bridge_pvid(struct sk_buff *skb) return skb; /* Move VLAN tag from data to hwaccel */ - if (!skb_vlan_tag_present(skb) && hdr->h_vlan_proto == htons(proto)) { + if (!skb_vlan_tag_present(skb) && skb->protocol == htons(proto)) { skb = skb_vlan_untag(skb); if (!skb) return NULL; From patchwork Fri Oct 2 02:42:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 267735 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=-12.8 required=3.0 tests=BAYES_00,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,USER_AGENT_GIT autolearn=unavailable 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 0068DC47420 for ; Fri, 2 Oct 2020 02:43:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF0C0207DE for ; Fri, 2 Oct 2020 02:42:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZIAxAI3L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387637AbgJBCm5 (ORCPT ); Thu, 1 Oct 2020 22:42:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387623AbgJBCmt (ORCPT ); Thu, 1 Oct 2020 22:42:49 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB6D6C0613D0; Thu, 1 Oct 2020 19:42:47 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id q4so173272pjh.5; Thu, 01 Oct 2020 19:42:47 -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 :mime-version:content-transfer-encoding; bh=pNIFCfbxn/994O6tOncE60q/cKfHn8CJSzrbaSDB3Bc=; b=ZIAxAI3LB542ee7hXFPsZjEdnq9/UH8jbb3Stpq8hN1b/FBaLPqG+SIsRK0wtRCS53 Tz56f9PKsbKDcZQokW3WzR8jm6PcdRT5LPMhSPf2IFYv7u0XmGP0Ms/b5tpgrKx4aSUZ ds7nRnT8Pk8zrErOCMbJ989MkywmIIVipUxVYqp6FJCkiKF0+QaEk1C/sxhR1v+Oysf7 7z6Uq444AzF71+PM/YbsopVzY4cjdNwi5dQcBSsVMDdTHy0ZLz97jhhP1K2RoG3AWrL0 Db3YpVJYMU2fvoGPCYaALZFIxr8gnXMAPGuUfPXuCOF5Wpm185jLl6X/FZEaXtHKVYEJ K/cA== 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:mime-version:content-transfer-encoding; bh=pNIFCfbxn/994O6tOncE60q/cKfHn8CJSzrbaSDB3Bc=; b=R3QLZI1AGlTuf0IraZGCtwJbnxlqORVKwTjoo5fG+vXiTC9QKvEHUW2vajB4/GD12U x3RkUeXaGnL+0gZ5GCqYuSVvEoV4perRK7w8mDlCEtC8bu2iUezGgG53id85pIZQ8ubq Fj4uxfVDsqFNLZJ/BjnRwlwgtfspogOXRE50lRLJvjc/heLIBDkcARVTmAa1unP5xC4Z hxmG4vrdpQECyzZzQclpQ/SmNrYDoCi6W7vL6O5Bm8V0HK4kmrAkgVUkQR2NRpQxc2br OJ1Fo1t1tmblpi7h/gRcls3dRCc+JKRE/eIoRjTk/swsUEhC+TVw2yMAoNqgGEGhfqRz 5m/w== X-Gm-Message-State: AOAM533RUgvCEILulpBx+QGn19lQrGve3DFqEHi0sAJx9O6DKd6yeShY 99jME0YrdqUFBFFC8YjN58IAtENXSY16nw== X-Google-Smtp-Source: ABdhPJzKhXnK0vZ8esfwylqznfrHKgFVR3MRH2VN/JYz+WcFROH/2z0GjS2o1YoyQl145HarX3XgMg== X-Received: by 2002:a17:90a:f486:: with SMTP id bx6mr344996pjb.130.1601606567011; Thu, 01 Oct 2020 19:42:47 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id gt11sm150185pjb.48.2020.10.01.19.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2020 19:42:46 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Andrew Lunn , Vivien Didelot , "David S. Miller" , Jakub Kicinski , linux-kernel@vger.kernel.org (open list), vladimir.oltean@nxp.com, olteanv@gmail.com Subject: [PATCH net-next 4/4] net: dsa: Utilize __vlan_find_dev_deep_rcu() Date: Thu, 1 Oct 2020 19:42:15 -0700 Message-Id: <20201002024215.660240-5-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201002024215.660240-1-f.fainelli@gmail.com> References: <20201002024215.660240-1-f.fainelli@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now that we are guaranteed that dsa_untag_bridge_pvid() is called after eth_type_trans() we can utilize __vlan_find_dev_deep_rcu() which will take care of finding an 802.1Q upper on top of a bridge master. A common use case, prior to 12a1526d067 ("net: dsa: untag the bridge pvid from rx skbs") was to configure a bridge 802.1Q upper like this: ip link add name br0 type bridge vlan_filtering 0 ip link add link br0 name br0.1 type vlan id 1 in order to pop the default_pvid VLAN tag. With this change we restore that behavior while still allowing the DSA receive path to automatically pop the VLAN tag. Signed-off-by: Florian Fainelli Reviewed-by: Vladimir Oltean --- net/dsa/dsa_priv.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index d6ce8c2a2590..12998bf04e55 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -204,7 +204,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; @@ -246,13 +245,9 @@ 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) + return skb; __vlan_hwaccel_clear_tag(skb);