From patchwork Tue Oct 1 14:28:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 174870 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp8628779ill; Tue, 1 Oct 2019 07:28:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9ZZ2VIJJKD6xv0xIFDvyfu8Olh+NIKxbWRRcivYREZc6vtC1p+CgvErzIWOlxf4Y1QFhT X-Received: by 2002:a50:9e26:: with SMTP id z35mr25766801ede.265.1569940136738; Tue, 01 Oct 2019 07:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569940136; cv=none; d=google.com; s=arc-20160816; b=Cthlep4hM1Bbx6TNJTbZ51e7eOI8KAl/+DDw5YDtjWdjcu7H6YOZe6ia3XIBdS9PEW yjcjiSnR/y2zRnQFMRmr42yMacRxKiiY140X4L/AoU2Xochy4Am/R0U+Kx1vwrLb0VDJ lAyofGNzVwvGxLO39qXlVjBhCIxFkYqz3JzCJKUQVuq9MaauiuzcOmB4oXJAieNf6GZt XOVlD27htucPsyr8bCNeevX5K6cnTnMLsMRAJ77Oq3dhEBAMLVURXk5mJz70cPNEvvZ1 kHcrnqkvxz8v9O2wdlPKncDqnc+SM8QHa5cS0LxBwSptt5A921euxgs0iUIs1rN1VA6a ns2Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=dOnQRHuZg3+A43ZWR1Sh4+B1CBZaubbsu4Cf1B78l2s=; b=YgBzRZy3Je2v5uDsTXHuL245w/FBmEo5xZXo2i/nhwAU7sC+CNbpL5dhv3bgIqIw/Z WYMnq2Jd432lNWgsc66+k+8SgYostCWCpP9Mh55v7IhUAX4IitIPGSVUNR7I2PgTJGFT DYCKvns+k8+RpXNO0KqKOWwd21+VC46a802OyD6lB4Qr4rLPQXCHmZgzkQmWANa2z2/j ki8LGew2ItbfzPsh+OWCPPWCceof/T5r/wO/6B+P+zBMUwzywh4mmEWnJCIDenhDyxnb KnSYrSkwzJKAVyzk4h7c7UURi3GcvWFr2aKxlokCJ19TLd1wLon9OFX2OU6BMwMwRhg1 IUbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GCSBgWUh; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2si9633084edq.264.2019.10.01.07.28.56; Tue, 01 Oct 2019 07:28:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-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=@linaro.org header.s=google header.b=GCSBgWUh; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388205AbfJAO2w (ORCPT + 8 others); Tue, 1 Oct 2019 10:28:52 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:40983 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727051AbfJAO2w (ORCPT ); Tue, 1 Oct 2019 10:28:52 -0400 Received: by mail-lf1-f67.google.com with SMTP id r2so10027630lfn.8 for ; Tue, 01 Oct 2019 07:28:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dOnQRHuZg3+A43ZWR1Sh4+B1CBZaubbsu4Cf1B78l2s=; b=GCSBgWUhLC1/hacn9w65hkfjd2QAXs7sPy2jFeYGMt8o+ZvKe2D79/hX5I0kPWrpbF IciZFYCy/UAURk66OdagJhJjqZqq4BG3vFtdn3PDXS161c9jmnXxh2rW04eRrzdQYxqA Wo3C5ureV12bWq5i2QysA1LLjNlxhkq8/sY5SEMlP3xhFMccFifeJ4hd9Kw2XktDplBO IUoPvPkpXjmTpnSNxDtQQA9eO+3VhEQHq4KN3NzBS1pEt0xCUlSAiVThMVrMGxbLvBVh vFnsWWWosYxENhBoXiJYeoo/H8izmrKnVv/BUGMRhCcv4huvgyevhRACwefz26pmrWUz 1rVA== 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:mime-version :content-transfer-encoding; bh=dOnQRHuZg3+A43ZWR1Sh4+B1CBZaubbsu4Cf1B78l2s=; b=KQV9VIHyuiYhJCGFUQ6MbQdnqv5Ea18LbeLcOnbA97AIQntnt9ZgNFxmLSK837o40p 4hLrtUl3h6JAs9GBJcPa73KHTlLLBGHFd9u/b0Xgrc++0SNQKd01C3MM8yYxNgicwhRP 6TR2Nk9fTYtBWoz9AQPFPua/PoWGI8V49oFNylW2GM5TfR9Wab86MscUQ0IsmL6mmJcw 5rSHnjKDOxaSr+cDphhwixFBFAbBSuWB+JGJE452Ty1oB7U9zksOIZKyhFpnDYJBc9oV Zuh6YIFYh1D3ROejOpQwrgnU+dNYwMv46Jig7LaoRjEK4Tb2WhumgWOqRlsXWCZPOwDT Apgw== X-Gm-Message-State: APjAAAVaXl6tiAYKD+r1XmS+gS63osZGsG9pNUVoIBl7vQ12EMC6KONa dKynhnBG7JSLR/6FEyczd6Xyuw== X-Received: by 2002:ac2:5966:: with SMTP id h6mr15787019lfp.78.1569940130552; Tue, 01 Oct 2019 07:28:50 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-79c8225c.014-348-6c756e10.bbcust.telenor.se. [92.34.200.121]) by smtp.gmail.com with ESMTPSA id w17sm3921054lfl.43.2019.10.01.07.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 07:28:49 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli Cc: netdev@vger.kernel.org, Linus Walleij Subject: [PATCH] net: dsa: rtl8366: Check VLAN ID and not ports Date: Tue, 1 Oct 2019 16:28:43 +0200 Message-Id: <20191001142843.10746-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There has been some confusion between the port number and the VLAN ID in this driver. What we need to check for validity is the VLAN ID, nothing else. The current confusion came from assigning a few default VLANs for default routing and we need to rewrite that properly. Instead of checking if the port number is a valid VLAN ID, check the actual VLAN IDs passed in to the callback one by one as expected. Fixes: d8652956cf37 ("net: dsa: realtek-smi: Add Realtek SMI driver") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Fix the iterator to actually check the VLAN ID. - Use "vid" as variable name. --- drivers/net/dsa/rtl8366.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- 2.21.0 diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index ca3d17e43ed8..ac88caca5ad4 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -339,10 +339,12 @@ int rtl8366_vlan_prepare(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan) { struct realtek_smi *smi = ds->priv; + u16 vid; int ret; - if (!smi->ops->is_vlan_valid(smi, port)) - return -EINVAL; + for (vid = vlan->vid_begin; vid < vlan->vid_end; vid++) + if (!smi->ops->is_vlan_valid(smi, vid)) + return -EINVAL; dev_info(smi->dev, "prepare VLANs %04x..%04x\n", vlan->vid_begin, vlan->vid_end); @@ -370,8 +372,9 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port, u16 vid; int ret; - if (!smi->ops->is_vlan_valid(smi, port)) - return; + for (vid = vlan->vid_begin; vid < vlan->vid_end; vid++) + if (!smi->ops->is_vlan_valid(smi, vid)) + return; dev_info(smi->dev, "add VLAN on port %d, %s, %s\n", port,