Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6561017ybx; Mon, 11 Nov 2019 10:59:22 -0800 (PST) X-Google-Smtp-Source: APXvYqwfEcpOuXwneeCk1WkDr/Kjj3R2VVlneBNtK58x7RxeamQF8qzGkfmpknVODAT0/vT37mTL X-Received: by 2002:a50:becf:: with SMTP id e15mr27985755edk.135.1573498762852; Mon, 11 Nov 2019 10:59:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498762; cv=none; d=google.com; s=arc-20160816; b=SSyHErOu43Ytvqy7rO/FDlPdQjio670j0gTB480zMYGZZffgQF9vCHGnnIQk21YDNb Mwh1Xp6jwA5EYDaoobDTEz+RMiCDjGmKaRqhMDKnsDFvqepCNCEh+16LGrbDCiRobDJd Y2Bb5gIUUFzkexzlu6j0AhHetvW5hPUUEbGvsT4jzb2toGj0HCrJEaTlDt3+wCjWAutd RiaRD6Smo6vyuprp2ZbEk0d/XS6JSkrKqyzRY79SFCvCAoYQQdKMBj9AK3qG+zxZ7Hv7 gGXWeWqrmtUx2rhCJIvCzo/QBQAtwpuar+DMg6v418uJgpIgSBl+vJVLzY+kGLvR73Vv IwzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=05qvSJinCMd8+BPnjnsStxCoa3ppTNwXQHwgVh5e1Ps=; b=qCcYGPKtfDdKTTkxwAGDLF3JSgdPjEGZajFhOGLtw3rnQ+jDjy5pUddwjYOJ236iAe cTQHcGXIm8vJOO8FsCUL1zY0163KXAzGi1NXpImVefK78mszqjeuMY+Zo9lCCwByTyQL 8+7OmOHQ8Tp0NH94wxsmmaEDMU6+bY/4bFLWp/U6anmX/lHhiIqxxfc5T9d5SAv0OZDQ FOm4JgVpbgGonqpv7kkUM2NC/WrAy484prjCRo+uP1R7aoS7t0Z7vWsgkbjIlATRLQoQ dJez70I4bqh5N38OXWgQp1IIIitj5amjyazibfqxTMLsV4ob3X5+e7Zyb+PxmR/HzRXT pOVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sG8IYItI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f10si9935946ejq.289.2019.11.11.10.58.58; Mon, 11 Nov 2019 10:59:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sG8IYItI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730236AbfKKS4W (ORCPT + 99 others); Mon, 11 Nov 2019 13:56:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:54502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730701AbfKKS4T (ORCPT ); Mon, 11 Nov 2019 13:56:19 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 379E32173B; Mon, 11 Nov 2019 18:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573498578; bh=6GKlE5c1X7Fx/I6EQaAYcQY55nqx95iZiiBVJ7+o18o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sG8IYItIOp6ji3ILSwvtBVuArFHUAcHZb6vN7KWpyKpWlCcFHLNFn9olFDwz48991 BMDdWnOSNTACCaSKv+4voJub03T//D0zbvdTlfD2IO9jzDV8LCXS/h/0RCk7Q/9hOC N9/WdGChTUsh4BkhoPlHO0QiKshsnWVoHRFYqiCw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Antoine Tenart , Alexandre Belloni , Vladimir Oltean , Florian Fainelli , "David S. Miller" , Sasha Levin Subject: [PATCH 5.3 161/193] net: mscc: ocelot: refuse to overwrite the ports native vlan Date: Mon, 11 Nov 2019 19:29:03 +0100 Message-Id: <20191111181513.003301670@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181459.850623879@linuxfoundation.org> References: <20191111181459.850623879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean [ Upstream commit b9cd75e6689560140dadaed98eb4b41aad75d55d ] The switch driver keeps a "vid" variable per port, which signifies _the_ VLAN ID that is stripped on that port's egress (aka the native VLAN on a trunk port). That is the way the hardware is designed (mostly). The port->vid is programmed into REW:PORT:PORT_VLAN_CFG:PORT_VID and the rewriter is told to send all traffic as tagged except the one having port->vid. There exists a possibility of finer-grained egress untagging decisions: using the VCAP IS1 engine, one rule can be added to match every VLAN-tagged frame whose VLAN should be untagged, and set POP_CNT=1 as action. However, the IS1 can hold at most 512 entries, and the VLANs are in the order of 6 * 4096. So the code is fine for now. But this sequence of commands: $ bridge vlan add dev swp0 vid 1 pvid untagged $ bridge vlan add dev swp0 vid 2 untagged makes untagged and pvid-tagged traffic be sent out of swp0 as tagged with VID 1, despite user's request. Prevent that from happening. The user should temporarily remove the existing untagged VLAN (1 in this case), add it back as tagged, and then add the new untagged VLAN (2 in this case). Cc: Antoine Tenart Cc: Alexandre Belloni Fixes: 7142529f1688 ("net: mscc: ocelot: add VLAN filtering") Signed-off-by: Vladimir Oltean Reviewed-by: Florian Fainelli Acked-by: Alexandre Belloni Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/mscc/ocelot.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index 07ca3e0cdf92b..7ffe5959a7e73 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -260,8 +260,15 @@ static int ocelot_vlan_vid_add(struct net_device *dev, u16 vid, bool pvid, port->pvid = vid; /* Untagged egress vlan clasification */ - if (untagged) + if (untagged && port->vid != vid) { + if (port->vid) { + dev_err(ocelot->dev, + "Port already has a native VLAN: %d\n", + port->vid); + return -EBUSY; + } port->vid = vid; + } ocelot_vlan_port_apply(ocelot, port); -- 2.20.1