Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6550197ybx; Mon, 11 Nov 2019 10:47:48 -0800 (PST) X-Google-Smtp-Source: APXvYqw57iHTr82ExrCB9q8gXqaKKtK/knjDW5cY7+ToDO9FGevfT6ZZY/3gJU0Kj7ESoWa8J+JF X-Received: by 2002:a17:906:948a:: with SMTP id t10mr24265389ejx.110.1573498068297; Mon, 11 Nov 2019 10:47:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498068; cv=none; d=google.com; s=arc-20160816; b=ZgaWlvfmHxZOzSWkILZLUhkIAnMe6KtCO8KEf3eqDlzJAu1hBDBgpXwLMRGblUVAip B4jtFU2t6wKDN7ZxKqZapc7/qOrB8IzapnS2vg+VUXxur1Lt1h6WvwjE22dxIQz/AeJi vYwBRAxRaPB7NJdXB76sjmw0H8VMVJEitrFKhjzEEanRGqQ5Fsqsv+X1gX1JPbBqoYo/ kquCAHZK4165zDPURfUlBmUkkJB6SoNuCk2kxdEYtLbjVVf8s3LWtPeLoWnCeDK/NMNY MiQ+4xg5jk0rBQacZDEkmLwmpcLX3KzYVg28PiMn8q1yySmBaRmTEfNn1Ljd/Nz9AnmT 2MeQ== 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=8T0qeO6CK4Ykxd7Ae5g2U9E1G4Bw4T6nCXEyncdVDGQ=; b=ZdOgN9RR3OcshQO8B1divaYtAJHiOvv7H515aiVHc4oEdPkic91JtAMN+WS9UaakR8 J4ipZJR4Rb76qcvPjVekZfSyU2T/7+iE4FIl8JjQoGsiaChCV04jRcBvDhdWN3jiAIXE nkHdCmhs7fbKna66stmi0zOgsoZWPu+qmWopr5CyOtADNf7oV4hrpE6HTDu2ZyaHaKFb 0KuTg2T1FrUOlokB6sFCcwHBrcHbTryQ4+gSAjQ9UmjkYMqo1VfQLxM86WCY/fSceKYy lX8iWrBafvUeo/za9DTTWyqwv/ez/fa58dDUj0en/c+3iECHv4NfuKzsNL+kk3tc92Lq 2C+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="ZLQU/Ot9"; 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 j5si11781727edc.195.2019.11.11.10.47.24; Mon, 11 Nov 2019 10:47:48 -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="ZLQU/Ot9"; 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 S1729958AbfKKSqI (ORCPT + 99 others); Mon, 11 Nov 2019 13:46:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:38400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727813AbfKKSqE (ORCPT ); Mon, 11 Nov 2019 13:46:04 -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 E93DB204FD; Mon, 11 Nov 2019 18:46:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573497963; bh=Qm4CgikDf/ByDHWDdREon3KcTscBsvq7y+65VqmgNiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZLQU/Ot9PZhrjl0petjwXk8o2yE6kJVU69op0d9cxs1zDW7xoOAvBcsNl5Sxph80p dNPfDHTH0Nycnbhqaf0BXg7dkNs+07apcpqteyyN8RJMQb1BuawjCeG5NULS6COzaC Vy9+FhcINHrMHh8sVevf/y43ZwTqgKmPP1h8Aw1Y= 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 4.19 108/125] net: mscc: ocelot: refuse to overwrite the ports native vlan Date: Mon, 11 Nov 2019 19:29:07 +0100 Message-Id: <20191111181454.341251788@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191111181438.945353076@linuxfoundation.org> References: <20191111181438.945353076@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 965f13944c76b..a29a6a618110e 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -253,8 +253,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