From patchwork Fri Sep 27 16:39:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 174633 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3754392ill; Fri, 27 Sep 2019 09:39:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqym8rkWFvZ6Do4YUWLdF7EvCduTORgIm6j2YqbRh/KgXDg7UBQzvhGithyCxZTekJO2UCzm X-Received: by 2002:a05:6402:1688:: with SMTP id a8mr5446754edv.225.1569602385418; Fri, 27 Sep 2019 09:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569602385; cv=none; d=google.com; s=arc-20160816; b=F/5o//FkCYsSK1I2npI7ecw5uDlOGyJT/ve4AQPLnk0xLm+dzKMLAx9sMIrtAXyCya hO5P2NhqYBBW9r+UGeE1Q06MxlFwXEwfZhPJoY84LhPrhAgHK4Ku5qyNDEkQ64tDAJLf X3P4thQ/6nXkVN4bPT1KxBH3cDaEoORRhHhL77Zn//135Nr+kbfYEzW3DF+qoUXX2jqh FZ6mntHeaPwrQMy/uNnQ9rBwr3pRT1YrczOT1JPXGvf9wUR/a6fb6OXpe9eXQuzBKlgP A7LT+3Tw8Pss++ftMqSXrGIr3Q+Dz/XNetJc0xbc+nuMTLLrX03vhh8j89NzDPKVcqql G/3A== 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=xCf1P0jSPhZkBtwHTc7vUPr69Q1RyQk/RlFM9BYZbYY=; b=q+ooG+Cf99hjkBTGP7W74dQlAPlc1hC2xAJLiM4DwodEUHZkhvzeqcaQRL2XMFcpIM Aju1hkHtpZnlru8BUEXHcIzjR4yX/GQm+NQlzskpwW4MPJuAdzhbuFLQLJwT72YkfPwn B/OfYB0pXEVgrVcvox37v/nrk4Vlp00BI2vTFmy3HG176v46SmixsklUOUiXQ/3sQAuV x3iyal508GCYM8AqWzEDW39atlDgwFY5BRIEW67X3Tu0gb88LNlNcfNDL9tJ/6ZlZ2Ej sqijh5XXGBOVzbaQvvSHqh0ZBW3M4eJ5JUdJrou8IZZ3p2ZJRFyfooCEYJYH6KOQbJ2O vRRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pUMk2g4D; 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 qx24si3056231ejb.138.2019.09.27.09.39.45; Fri, 27 Sep 2019 09:39:45 -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=pUMk2g4D; 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 S1727784AbfI0Qjo (ORCPT + 8 others); Fri, 27 Sep 2019 12:39:44 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:45580 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726251AbfI0Qjo (ORCPT ); Fri, 27 Sep 2019 12:39:44 -0400 Received: by mail-lf1-f65.google.com with SMTP id r134so2372556lff.12 for ; Fri, 27 Sep 2019 09:39:41 -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=xCf1P0jSPhZkBtwHTc7vUPr69Q1RyQk/RlFM9BYZbYY=; b=pUMk2g4DCkoXn0/vLtWnyJN2nfxb6zSsltCNso/CF29YsYoY4ZzcMfR+i527Etw+B/ wvzXS2pkVoaX1e6m0pIG9rACkLHK7UnK9N2Azf87jcZQnJP2mLxIicNxgJ/KHnEuApVp +TVAnSM8UgKQjsgSannSJ1wBpa2cxSFwM3Xg3nFTSq3C01oM4VPiqmkohUja1Pq/gpw2 8OIZviqmGaEolvyP2wNgTQgKPXs0L/htJU+6e2wT4lsbpHQpkxJWkkKJcWYbDzMe6mDl kQeov3qVsIZ+yaqIIVRPF8pWmeu+3hlMaOHtuy7blvehh+i7NSOO7n2o1Bh+SoZtFGgK ERog== 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=xCf1P0jSPhZkBtwHTc7vUPr69Q1RyQk/RlFM9BYZbYY=; b=N/tHB7TEw5PJ+5Mn64Bg/e04A6QQi56Fl9tElahNh2XhETcRwneQscpmVUDx+CAQ7g gkZxzx7YPGOUDUpTsl5jE4K1gzBRcJFgoW4jZnqgOefOgWHqtkPQgKmmTlKc4Y/J6ddK 4t2MTD/fVmI5NO8FBKBaYC+SR2NjD4GTAWI3R+8KjOrBZx7TItyY0zbMWZ5IIUsQNDzJ BLWYwSmOmE9y+dwiOhXWj4Qdk4LgzypuX9FUHSbnVtePBvVt+RWJ9b3Iq+/3N3gbv2P6 YCqRy0U/gF1zJtZP7wPOC5e06yHtNdMVyZCTgS6isRyrnsouaNVIiFQa37GkMDmvLIpp ZvwA== X-Gm-Message-State: APjAAAUpr5R/w38gZAPCwkPR4v/6fEWS/sCbROYBASzYCbehlF3njiWT vwW8Qe6y1TnsIi3HHncsKwwfsg== X-Received: by 2002:ac2:46d2:: with SMTP id p18mr3480582lfo.140.1569602380474; Fri, 27 Sep 2019 09:39:40 -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 j84sm564846ljb.91.2019.09.27.09.39.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 09:39:38 -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: Fri, 27 Sep 2019 18:39:11 +0200 Message-Id: <20190927163911.11179-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 --- drivers/net/dsa/rtl8366.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.21.0 diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index ca3d17e43ed8..e2c91b75e843 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -340,9 +340,11 @@ int rtl8366_vlan_prepare(struct dsa_switch *ds, int port, { struct realtek_smi *smi = ds->priv; int ret; + int i; - if (!smi->ops->is_vlan_valid(smi, port)) - return -EINVAL; + for (i = vlan->vid_begin; i < vlan->vid_end; i++) + if (!smi->ops->is_vlan_valid(smi, port)) + return -EINVAL; dev_info(smi->dev, "prepare VLANs %04x..%04x\n", vlan->vid_begin, vlan->vid_end); @@ -369,9 +371,11 @@ void rtl8366_vlan_add(struct dsa_switch *ds, int port, u32 untag = 0; u16 vid; int ret; + int i; - if (!smi->ops->is_vlan_valid(smi, port)) - return; + for (i = vlan->vid_begin; i < vlan->vid_end; i++) + if (!smi->ops->is_vlan_valid(smi, port)) + return; dev_info(smi->dev, "add VLAN on port %d, %s, %s\n", port,