Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2668041pxj; Mon, 31 May 2021 07:50:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqtXbeQrEuBL0nkgbRbGaet6wP/dTfVDr0vdI9lKFIWERAWD03w3DY2kMOyL/jhEn6CxY0 X-Received: by 2002:a92:c268:: with SMTP id h8mr16905818ild.299.1622472622556; Mon, 31 May 2021 07:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622472622; cv=none; d=google.com; s=arc-20160816; b=t9fXpqtneEmr5hmQpiKq+KLeVmG76K+E9PVfykuprjJ8HqHGIz94HOm10RzEosZxFS FE/mduBqFTG0Ei9+aPkrBs9+DJ4622CLpNsIbnErCYPUoRU5kauHxgPA2L3/RJH0mZIs Vxnu9sQ7zaDoVpKCKyKlFTswUIyh5akVROcD2bXxCvwTYnD8QZF2rGDXw0+sN3oCZE6R fq/IdeWLYWeOZ9wYfTZ4VD+zylxd+Bh+AkRYNwheN4o1oX3O8HcYX0fqftbIdWCjpX/D KoJcZOTMRw0Nj8lWESDpt2xi+U0681Zr2gtEfpLe8rfwQFgijAj8hQs3FR1z28e65kcP i8iw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WFM1chhtlJM2AFJIgTTd7yrT13AmCBDmxntP3LkrCv0=; b=wJCO+chdIYqpIoehbwbzaReT0kF4knh2/jop8wxVX6HE8Oe5gLQSHau8xDo+cI/4N0 G2YYCoO7pxBHZ8NqnZvlO1LFBfjA5S+75r+w10TGyNwi/2Vq1Dkx0uiCiD91LlLnLoXw cmAP4wg+TFqTgg0geIxJJXsE7LLqhtVpMukg0rXEN2/jXnHWxzaTBJgzPeBL3K1Ex8Uv gjz/PUcxHmFwHVrfPWf6QIkhLi34rQq28qK5bpbznZMhF0s3yuIqgUvwC06znIwaRMWp dXeWnIpAO6HK7ff5egFTaD4NbSXEZX8vF7RZ1THIHZfXolyZs6Rd3D6fcH9FI4ng8CE9 jnYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="LR+HTBc/"; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w31si13907423jal.77.2021.05.31.07.50.09; Mon, 31 May 2021 07:50:22 -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=@linuxfoundation.org header.s=korg header.b="LR+HTBc/"; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234042AbhEaOtU (ORCPT + 99 others); Mon, 31 May 2021 10:49:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:36896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232043AbhEaOBY (ORCPT ); Mon, 31 May 2021 10:01:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6EE1E61403; Mon, 31 May 2021 13:36:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468211; bh=aAVtE617rl5nQDpqiNCoWaWMLuSU+g+6+Vz1RfPlFH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LR+HTBc/rlWeb2lo7RCUYvmPXODof7tzi3kZSaAZ5KfJjwTNS5FGBRF0xvVricEIq j2QYTK62OXyBtTctc6JvziSbMBlaU2T+wblS6sJBXUSPTTNehObeOFxMRORvf8qXpF 8LEeWIAgsSKlIx7Jae9F3SHsKwVyw1DhSJJ1xQ1M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , "David S. Miller" Subject: [PATCH 5.10 114/252] net: dsa: sja1105: update existing VLANs from the bridge VLAN list Date: Mon, 31 May 2021 15:12:59 +0200 Message-Id: <20210531130701.847779032@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean commit b38e659de966a122fe2cb178c1e39c9bea06bc62 upstream. When running this sequence of operations: ip link add br0 type bridge vlan_filtering 1 ip link set swp4 master br0 bridge vlan add dev swp4 vid 1 We observe the traffic sent on swp4 is still untagged, even though the bridge has overwritten the existing VLAN entry: port vlan ids swp4 1 PVID br0 1 PVID Egress Untagged This happens because we didn't consider that the 'bridge vlan add' command just overwrites VLANs like it's nothing. We treat the 'vid 1 pvid untagged' and the 'vid 1' as two separate VLANs, and the first still has precedence when calling sja1105_build_vlan_table. Obviously there is a disagreement regarding semantics, and we end up doing something unexpected from the PoV of the bridge. Let's actually consider an "existing VLAN" to be one which is on the same port, and has the same VLAN ID, as one we already have, and update it if it has different flags than we do. The first blamed commit is the one introducing the bug, the second one is the latest on top of which the bugfix still applies. Fixes: ec5ae61076d0 ("net: dsa: sja1105: save/restore VLANs using a delta commit method") Fixes: 5899ee367ab3 ("net: dsa: tag_8021q: add a context structure") Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/sja1105/sja1105_main.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -2756,11 +2756,22 @@ static int sja1105_vlan_add_one(struct d bool pvid = flags & BRIDGE_VLAN_INFO_PVID; struct sja1105_bridge_vlan *v; - list_for_each_entry(v, vlan_list, list) - if (v->port == port && v->vid == vid && - v->untagged == untagged && v->pvid == pvid) + list_for_each_entry(v, vlan_list, list) { + if (v->port == port && v->vid == vid) { /* Already added */ - return 0; + if (v->untagged == untagged && v->pvid == pvid) + /* Nothing changed */ + return 0; + + /* It's the same VLAN, but some of the flags changed + * and the user did not bother to delete it first. + * Update it and trigger sja1105_build_vlan_table. + */ + v->untagged = untagged; + v->pvid = pvid; + return 1; + } + } v = kzalloc(sizeof(*v), GFP_KERNEL); if (!v) {