From patchwork Thu Aug 27 13:21:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 248452 Delivered-To: patch@linaro.org Received: by 2002:a17:906:6447:0:0:0:0 with SMTP id l7csp378761ejn; Thu, 27 Aug 2020 07:52:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9bDK6k/kSmovkcBpejv+M9uxSPXgLbS5SfTw966prySbxwY05tQ/iFSjlI/FkxyQ2Ylvs X-Received: by 2002:a17:906:ad9:: with SMTP id z25mr20847726ejf.484.1598539970037; Thu, 27 Aug 2020 07:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598539970; cv=none; d=google.com; s=arc-20160816; b=L0eH7LCksPhtbxVvsZagLqFAJr9KEg6ZGtFRtsAHeKZj+m5X0mkn9JjiHk0kCBVefS +YnjJ1kOEoELadvpRqZJMV/vRw9ibEVTfDx2U07vxIHZI2Tz4M//ZXMMRuYutXK1wmYd OzwHvN6lz+dXMvp5j88AW0nCEqgJwj1WDhpzKbuH80IVSho8RERG9oNij3tGPPw7uMya zcOv0Q3NxeXfEAqH6yne7tzbg9zN391J5wSKMwu0q6DqoGSy1qS6UiE3AO+FjYLu0NOu y1neg05hAXW3DaF/diCOikHCqiiv+bQ8gQTgFW4qKsNmlu2su8SOe70ySiPbiOX1z+Az R1uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:to :from:dkim-signature; bh=jcZmBfUXVLDbmP9+jachlmxqxGc7XxXtsRG81uIPyOc=; b=nOL/BGjiJnhlxmcQdboAIJe6FMwNEIeMYvyd2LUhM+sGRwMi4viTNgpq1E0xsya4Gc V8OQN/er2atEgMVjZEvhiwaGKwtZE3RBsvjtShr2UEP51a9iYKNtYmHz4IJZADQuNhZL WxAUWRJqlmFFNKn15Yr5V3zf+2wUWvD/rHo/RRKG/4rNhvIIfxJJ+C0C1WHvUmw/h4QE Uzv0WMS5BKi+VuoJi0c6g4y0EH2Oh/HGdhMprIkbCFWm30Qv8D3hvsf0icjrm3z7IBib PEzVrTMRCmyZ/p5I7jwJIQj55dY+Q6H5wexhYKhnV99wkjVw1WvN9Linpj0CtO08qlEB vsPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=SzqCyDHm; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q12si1483446ejs.273.2020.08.27.07.52.49; Thu, 27 Aug 2020 07:52:50 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-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=@ti.com header.s=ti-com-17Q1 header.b=SzqCyDHm; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728367AbgH0Owr (ORCPT + 9 others); Thu, 27 Aug 2020 10:52:47 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:55178 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbgH0NVm (ORCPT ); Thu, 27 Aug 2020 09:21:42 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 07RDLL32051660; Thu, 27 Aug 2020 08:21:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1598534481; bh=jcZmBfUXVLDbmP9+jachlmxqxGc7XxXtsRG81uIPyOc=; h=From:To:Subject:Date; b=SzqCyDHmBO2/C3U30I0112wCgCfaHCnbscxSsxiJFpWyQJ29kACluLvsyPdoZme/E T8VSmxq0RJanT7Ca8gDvE1QUO8BzfvGjzgMwlPgsTc2ls+jcKotzckur082i8pyF8z rPAIZ/jPIFyae6u3Hc+y5Hm3es6TFf6RwNqZFT0E= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 07RDLLHU025533; Thu, 27 Aug 2020 08:21:21 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Thu, 27 Aug 2020 08:21:20 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Thu, 27 Aug 2020 08:21:20 -0500 Received: from uda0868495.fios-router.home (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 07RDLJJo113730; Thu, 27 Aug 2020 08:21:19 -0500 From: Murali Karicheri To: , , , , , , Subject: [PATCH net v4] net: ethernet: ti: cpsw_new: fix error handling in cpsw_ndo_vlan_rx_kill_vid() Date: Thu, 27 Aug 2020 09:21:18 -0400 Message-ID: <20200827132118.31768-1-m-karicheri2@ti.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch fixes a bunch of issues in cpsw_ndo_vlan_rx_kill_vid() - pm_runtime_get_sync() returns non zero value. This results in non zero value return to caller which will be interpreted as error. So overwrite ret with zero. - If VID matches with port VLAN VID, then set error code. - Currently when VLAN interface is deleted, all of the VLAN mc addresses are removed from ALE table, however the return values from ale function calls are not checked. These functions can return error code -ENOENT. But that shouldn't happen in a normal case. So add error print to catch the situations so that these can be investigated and addressed. return zero in these cases as these are not real error case, but only serve to catch ALE table update related issues and help address the same in the driver. Fixes: ed3525eda4c4 ("net: ethernet: ti: introduce cpsw switchdev based driver part 1 - dual-emac") Signed-off-by: Murali Karicheri --- v4 - updated error message with name of the function failed. v3 - updated commit description to describe error check related to port vlan VID v2 - updated comments from Grygorii, also return error code if VID drivers/net/ethernet/ti/cpsw_new.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/cpsw_new.c b/drivers/net/ethernet/ti/cpsw_new.c index 8d0a2bc7128d..8ed78577cded 100644 --- a/drivers/net/ethernet/ti/cpsw_new.c +++ b/drivers/net/ethernet/ti/cpsw_new.c @@ -1032,19 +1032,34 @@ static int cpsw_ndo_vlan_rx_kill_vid(struct net_device *ndev, return ret; } + /* reset the return code as pm_runtime_get_sync() can return + * non zero values as well. + */ + ret = 0; for (i = 0; i < cpsw->data.slaves; i++) { if (cpsw->slaves[i].ndev && - vid == cpsw->slaves[i].port_vlan) + vid == cpsw->slaves[i].port_vlan) { + ret = -EINVAL; goto err; + } } dev_dbg(priv->dev, "removing vlanid %d from vlan filter\n", vid); - cpsw_ale_del_vlan(cpsw->ale, vid, 0); - cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, - HOST_PORT_NUM, ALE_VLAN, vid); - cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast, - 0, ALE_VLAN, vid); + ret = cpsw_ale_del_vlan(cpsw->ale, vid, 0); + if (ret) + dev_err(priv->dev, "cpsw_ale_del_vlan() failed: ret %d\n", ret); + ret = cpsw_ale_del_ucast(cpsw->ale, priv->mac_addr, + HOST_PORT_NUM, ALE_VLAN, vid); + if (ret) + dev_err(priv->dev, "cpsw_ale_del_ucast() failed: ret %d\n", + ret); + ret = cpsw_ale_del_mcast(cpsw->ale, priv->ndev->broadcast, + 0, ALE_VLAN, vid); + if (ret) + dev_err(priv->dev, "cpsw_ale_del_mcast failed. ret %d\n", + ret); cpsw_ale_flush_multicast(cpsw->ale, ALE_PORT_HOST, vid); + ret = 0; err: pm_runtime_put(cpsw->dev); return ret;