Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp106535pxt; Thu, 5 Aug 2021 19:40:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUFC0jlnzKtuWxRdKIdaNq/lJVmgYis5PV6mnYJIli0pQsuDZKrWXm2YTfBhQjbarQX/Iz X-Received: by 2002:a17:907:c12:: with SMTP id ga18mr6068231ejc.107.1628217609623; Thu, 05 Aug 2021 19:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628217609; cv=none; d=google.com; s=arc-20160816; b=w3jZzYIcITLIrFpQCt3oeuU5RYlVUkVAM50HmQ7eENty1WSNXgK9040MmyBfyU5N/T v2CZXfriKksQ+jUhP7J0VobLHHbMBO1meTDn7K3nJT9CFBbAd4JS4dfKr6lkcKEIzN8L toC8CXH8nMKDjHSdh+HxJDadMBJA1ZQ4btCRgJ7G3YpF8gIf5mcREu/mRmJsC/xiJ2Ne /aLATrK6GMV+Fr69enwWvtJRHIX9rtHHhQp3i7NKxxXZOTDhA3aT04V/DDyGjznVUM6k q7rt6Ua5dA1APlQ7tTrbY/ZA8NeIyHir7awmPhY+KF3hLHSeXVPYrS66HilyCyChTlPE /zwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Zw/0qEnKJrmNekra6VcoVeV33INMsYbzX2fsWAAHgGc=; b=ENML+HM8cNYBBtRfT/drlxD+KvUjlRZVWVxY4JEUxFf2uVGu4tZP+iB7WHsfmf6suu 7To1isBe1SckE1dRFjtVfNR0euEpC+tWoLNOrB75etzdTfE/ghz0t4m6BimcxZZUzE/I OFjwx9yN11thibF5Sfhe3Bl2FNkxRWVqjzsAnf6oXXe79arlePb/kimFRhq3o8V3RN0x R6t6l7Z9tyN9kqqrz+1f91NwX4cxWY6RtvhH9Cv18fTeqholX0/HBXckoStWBHdAsibI B2d7OQZY9Ix9S5im4iYeCNym0SBG9iaflw6Bp6cch6ljpyl6hNHrvxF3UgV6lhKKVtU3 rKOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KlKFIEbL; 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 lh3si7037808ejb.149.2021.08.05.19.39.46; Thu, 05 Aug 2021 19:40:09 -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=KlKFIEbL; 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 S242952AbhHFASI (ORCPT + 99 others); Thu, 5 Aug 2021 20:18:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242860AbhHFAR7 (ORCPT ); Thu, 5 Aug 2021 20:17:59 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAE6AC061799; Thu, 5 Aug 2021 17:17:43 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id cf5so10829233edb.2; Thu, 05 Aug 2021 17:17:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Zw/0qEnKJrmNekra6VcoVeV33INMsYbzX2fsWAAHgGc=; b=KlKFIEbLFH7X8P9jgl3li1QFlvN3OTz+loXJhEfDS6OcXaR/faZOvCa7SdV2lWai5s jhWXxY2rv0HYfDUihsP+IzOJ6DYjelhcZ8wB2gK3lJBRU4noIp8VHDD2O6BlB+G9s3v4 qxTBT98CzPXXtf4if/wI+bG4n18DPDbnvPjgdA04H/M6HXsxiyeKKu5kmg4S7vxwfe4p XByfaD3VeBu1Wss2TShZv/A43XPnDtToTLtZM+PW7JJXJGFk3d2dyFSheLzYZhRbeFSY wZJEN1Tl0t9b3+1ujBUWCMNtlCYpeCFBwzeRQRW2TqLW6vn+OIH0MqhumcggjaYukjHi a8+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Zw/0qEnKJrmNekra6VcoVeV33INMsYbzX2fsWAAHgGc=; b=eJfqFb7iNQTdED6KUacCyHv857QIyGVssx7cFX2oYHm39sN5UuJzBn81det6ZyFYqi 30jBOm7PELo46iVjDAIAdwCMgcRFqcHvjYbmjDh4vHIdsGBvVAwdl2I9V2IJA70lkL8r SjgKL67c4OFW84e8LhitcW7zhUhBEIGq2X8vixlrqQ+XfZ8J2s6bAXw5OBoe2TMqh0Gp gqLYM78fBPZ2Xts9msnr8hrQtqdiDD4ByM7gN3Q7PboHH4D63bJ2bd+P9Zihoq+Fvrq+ 8LOstjf9bghCBJkto5VpfXTYrLK6OgnI7EbdaR5JqtLDONpypjUfauO/Tzy1vm5/61bl eRdA== X-Gm-Message-State: AOAM530RpdHnglBR34it2LzEd5sg1QBLPkoKgS3M2eBcOLFKmQ+pS3Wu LBPj7h7BukwvF/KABoNuZv4= X-Received: by 2002:aa7:d899:: with SMTP id u25mr9821469edq.151.1628209062424; Thu, 05 Aug 2021 17:17:42 -0700 (PDT) Received: from skbuf ([188.25.144.60]) by smtp.gmail.com with ESMTPSA id o25sm2186250ejh.109.2021.08.05.17.17.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Aug 2021 17:17:41 -0700 (PDT) Date: Fri, 6 Aug 2021 03:17:40 +0300 From: Vladimir Oltean To: DENG Qingfang Cc: Sean Wang , Landen Chao , Andrew Lunn , Vivien Didelot , Florian Fainelli , "David S. Miller" , Jakub Kicinski , Matthias Brugger , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] net: dsa: mt7530: drop untagged frames on VLAN-aware ports without PVID Message-ID: <20210806001740.cayorz3vlfrvk75l@skbuf> References: <20210805172315.362165-1-dqfext@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210805172315.362165-1-dqfext@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 06, 2021 at 01:23:14AM +0800, DENG Qingfang wrote: > @@ -1624,11 +1631,26 @@ mt7530_port_vlan_add(struct dsa_switch *ds, int port, > if (pvid) { > priv->ports[port].pvid = vlan->vid; > > + /* Accept all frames if PVID is set */ > + mt7530_rmw(priv, MT7530_PVC_P(port), ACC_FRM_MASK, > + MT7530_VLAN_ACC_ALL); > + > /* Only configure PVID if VLAN filtering is enabled */ > if (dsa_port_is_vlan_filtering(dsa_to_port(ds, port))) > mt7530_rmw(priv, MT7530_PPBV1_P(port), > G0_PORT_VID_MASK, > G0_PORT_VID(vlan->vid)); > + } else if (priv->ports[port].pvid == vlan->vid) { > + /* This VLAN is overwritten without PVID, so unset it */ > + priv->ports[port].pvid = G0_PORT_VID_DEF; > + > + /* Only accept tagged frames if the port is VLAN-aware */ > + if (dsa_port_is_vlan_filtering(dsa_to_port(ds, port))) > + mt7530_rmw(priv, MT7530_PVC_P(port), ACC_FRM_MASK, > + MT7530_VLAN_ACC_TAGGED); > + > + mt7530_rmw(priv, MT7530_PPBV1_P(port), G0_PORT_VID_MASK, > + G0_PORT_VID_DEF); > } > > mutex_unlock(&priv->reg_mutex); Good catch with this condition, sja1105 and ocelot are buggy in this regard, it seems, probably others too. Need to fix them. Although honestly I would probably rather spend the time patching the bridge already to not accept duplicate VLAN entries from user space, just with different flags, it's just too complex to handle the overwrites everywhere... Plus, bridge accepting duplicate VLANs means we cannot refcount them on DSA and CPU ports at the cross-chip level, which in turn means we can never delete them from those ports. Anyhow, enough rambling. Reviewed-by: Vladimir Oltean