From patchwork Thu Aug 27 14:38:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murali Karicheri X-Patchwork-Id: 248451 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp249922ilg; Thu, 27 Aug 2020 07:39:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5ycjCB37aUfiILnO7KLCheHMo9iYnu5d9iJxjOSZgIM6XTI/vTpY4f/arOJ46qYHUPj2A X-Received: by 2002:a17:906:73d7:: with SMTP id n23mr12364118ejl.37.1598539143040; Thu, 27 Aug 2020 07:39:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598539143; cv=none; d=google.com; s=arc-20160816; b=SXZpJpx/kM0Alc9pxl3kfmEfR1Qlqf7igC9zahIXdbH3LpIZm2Lf59UhWLAvjLLuTq bD07+xl30x4fgCfRjz0oD1Z/+x9s7LRFQSBjUFDU3WSq4xnrxVw5uOKq9x0LWVpKEj9o 0Q0FHi7XBhjmt5L1ETuYOucRLCPkFjt32mB2xYcERixmUXZ8VbT/03EYjbkSh1GxrMWA qSEpDVTHaHURmdbnCVJvMQ/FInZl/Q2kblQbqU71R+aBmjlIUklfsGa9VPQSju4Xjyqs 8yzHNoACFdok57Gi6ubETyFR3lAx+YNOVORIP2PjvPOjmddet7bKd6+01V+HlLhyEznL bVlg== 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=CrPTzMA+DHBs/z0X+YPElCGG/nR1ypJXBFHwOxsCeR6BWVjJgpmCcZbl01RLZnbCMN bZLtAqtLBJAJOjsdQ9OESex7xbV52OwWSg9l7kidWXoQyVNz+xiUNwzzKMqHWOvxxu4W PuO29oIWW4qqWOHHksa5C/NjC1c+hTfY//PDlEgBRTWLqM5A3f8qseng3qeorjYYyzJ2 S0CFHwLb58Hr1pLd/SpT8UDIAETY7NmIbWzduLbFbmKxtlfLwRxjTIUssIdxrGdQ+QUg Ko6lOiGGUWkN0K7tpq7wKevu/Hh0cwMYoM+0DHNO8KwN/yn9mjCg+LCv0/9PzcAsWLl8 hrzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=bxrgwWZs; spf=pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-omap-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 u2si1605948edt.17.2020.08.27.07.39.02; Thu, 27 Aug 2020 07:39:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-omap-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=bxrgwWZs; spf=pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-omap-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 S1727937AbgH0Oi7 (ORCPT + 4 others); Thu, 27 Aug 2020 10:38:59 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:38928 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726093AbgH0Oiz (ORCPT ); Thu, 27 Aug 2020 10:38:55 -0400 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 07REcf84051246; Thu, 27 Aug 2020 09:38:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1598539121; bh=jcZmBfUXVLDbmP9+jachlmxqxGc7XxXtsRG81uIPyOc=; h=From:To:Subject:Date; b=bxrgwWZsT0eo3uU5wZi3d55LQmuKmlv71gcbgKBU8gYiWowUjA/XwRAIz+S/RLagB ZPt09NaVK4rFoKkm5aNTZyWjyNdYmY3FGpnvd10+9/Igj3p2dT2pMy1YaZ6BAGK3kV eKkRgWxDaPQs+4De/MzBtRSdV3LWyNHEfRKKcGCs= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 07REcfO7085833 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 27 Aug 2020 09:38:41 -0500 Received: from DLEE101.ent.ti.com (157.170.170.31) 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 09:38:41 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE101.ent.ti.com (157.170.170.31) 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 09:38:41 -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 07REcdw8129109; Thu, 27 Aug 2020 09:38:39 -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 10:38:39 -0400 Message-ID: <20200827143839.32327-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: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@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;