Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2509645pxj; Mon, 10 May 2021 04:51:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4hmEP7BwuhkSVaN5/I3tj2Uj4v+Bf7wlameGFYF+kLoC2lPfShaVvn4TOLwbynvbUlxWR X-Received: by 2002:a05:6e02:148:: with SMTP id j8mr10346526ilr.196.1620647483752; Mon, 10 May 2021 04:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620647483; cv=none; d=google.com; s=arc-20160816; b=0HVQ6HRctr9EEIY4JpLErsWazXWLXy2vqtWlOABMYUKNvtwRM1PGWcMmO1A8bTZ2nz vZ8uyDumfBsSI76CmsE/WDYhCfUtJo221sgaKXMkW7TlVgLHcpB2mr+SylJFfKY+T9u/ acl3SDzuTEf7OG693b/HRJkphX8tqiFnYk2jo1Qj/k95i91JsfbNWAwsIko8P0pVpqNv rJm5Jo6keoCoyL6T2AYGaot0bv+3ZMpnJ//6Zf44OL/mIKV76h1Aml7TNPtcQMOBHxfc ijgYCVSJ78A5Mqwz9LRdOEPhT3GAXrdX+N9Bi8Jt0LsqxTacoRZghCixP2X6JRVBL/e1 FUHQ== 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=0nSfW5lgmojOOzsEzRtboE/L8HkEQA9+sxEDLrkmYV0=; b=bxXXv/mTb+MuIrhJaB25DxLZEPKaIQzK/HJ/vEU5k2iPw4wc2TZMsTesQTJJuGm0gJ lTyOOS+S9MpYWQeQs1HY6KfS5ZsJYHDYEGdon5fwy+esI1Y75QHf5B1ktWO5KXvnLgDv pOcwP3/bQX9qimzMRVOTNAcVyMXn+RtrHBvr8wp8IVF8PD5A+gwO1PpiJNiMWihurWak 3vzAs2JX4ksMF44/+GQyFWpVbUoMcbfhNHZQYBM+cl5hZ/c9ESX4d7OdV19dxMePxhXT 4k3xH/xrfM4zb0+IaDHBB8L3T7fEtb+JLEqQ59/cwRidk+cQd2b+pojTKQhF6gF0d0SR 54CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="J1kyQaC/"; 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 h8si15037643jas.102.2021.05.10.04.51.11; Mon, 10 May 2021 04:51:23 -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="J1kyQaC/"; 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 S233266AbhEJLsm (ORCPT + 99 others); Mon, 10 May 2021 07:48:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:36658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233732AbhEJLBt (ORCPT ); Mon, 10 May 2021 07:01:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 957A46101A; Mon, 10 May 2021 10:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620644033; bh=5fuRqTcKIiPzxbE9ZPKDhNPvkmZlbtvNlweGkPwV8cQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J1kyQaC/LTJ9Sqy7+N0+/f8LmvGf9FHhpRJWmU3H+nqIQR47QdgvhZGA0i7zk9CLz d2TTeQLlgUkcpLyJBkNmXSVCI7JwtT5sNRcTmL84mQnUFzB3lJjnqOmbep+dR5gp4Y 0cQlX3iFbrAxh955V1/M+G/0P1ByqRWUouBip3CU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ido Schimmel , Petr Machata , Jakub Kicinski Subject: [PATCH 5.11 261/342] mlxsw: spectrum_mr: Update egress RIF list before routes action Date: Mon, 10 May 2021 12:20:51 +0200 Message-Id: <20210510102018.719559548@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102010.096403571@linuxfoundation.org> References: <20210510102010.096403571@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: Ido Schimmel commit cbaf3f6af9c268caf558c8e7ec52bcb35c5455dd upstream. Each multicast route that is forwarding packets (as opposed to trapping them) points to a list of egress router interfaces (RIFs) through which packets are replicated. A route's action can transition from trap to forward when a RIF is created for one of the route's egress virtual interfaces (eVIF). When this happens, the route's action is first updated and only later the list of egress RIFs is committed to the device. This results in the route pointing to an invalid list. In case the list pointer is out of range (due to uninitialized memory), the device will complain: mlxsw_spectrum2 0000:06:00.0: EMAD reg access failed (tid=5733bf490000905c,reg_id=300f(pefa),type=write,status=7(bad parameter)) Fix this by first committing the list of egress RIFs to the device and only later update the route's action. Note that a fix is not needed in the reverse function (i.e., mlxsw_sp_mr_route_evif_unresolve()), as there the route's action is first updated and only later the RIF is removed from the list. Cc: stable@vger.kernel.org Fixes: c011ec1bbfd6 ("mlxsw: spectrum: Add the multicast routing offloading logic") Signed-off-by: Ido Schimmel Reviewed-by: Petr Machata Link: https://lore.kernel.org/r/20210506072308.3834303-1-idosch@idosch.org Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c @@ -535,6 +535,16 @@ mlxsw_sp_mr_route_evif_resolve(struct ml u16 erif_index = 0; int err; + /* Add the eRIF */ + if (mlxsw_sp_mr_vif_valid(rve->mr_vif)) { + erif_index = mlxsw_sp_rif_index(rve->mr_vif->rif); + err = mr->mr_ops->route_erif_add(mlxsw_sp, + rve->mr_route->route_priv, + erif_index); + if (err) + return err; + } + /* Update the route action, as the new eVIF can be a tunnel or a pimreg * device which will require updating the action. */ @@ -544,17 +554,7 @@ mlxsw_sp_mr_route_evif_resolve(struct ml rve->mr_route->route_priv, route_action); if (err) - return err; - } - - /* Add the eRIF */ - if (mlxsw_sp_mr_vif_valid(rve->mr_vif)) { - erif_index = mlxsw_sp_rif_index(rve->mr_vif->rif); - err = mr->mr_ops->route_erif_add(mlxsw_sp, - rve->mr_route->route_priv, - erif_index); - if (err) - goto err_route_erif_add; + goto err_route_action_update; } /* Update the minimum MTU */ @@ -572,14 +572,14 @@ mlxsw_sp_mr_route_evif_resolve(struct ml return 0; err_route_min_mtu_update: - if (mlxsw_sp_mr_vif_valid(rve->mr_vif)) - mr->mr_ops->route_erif_del(mlxsw_sp, rve->mr_route->route_priv, - erif_index); -err_route_erif_add: if (route_action != rve->mr_route->route_action) mr->mr_ops->route_action_update(mlxsw_sp, rve->mr_route->route_priv, rve->mr_route->route_action); +err_route_action_update: + if (mlxsw_sp_mr_vif_valid(rve->mr_vif)) + mr->mr_ops->route_erif_del(mlxsw_sp, rve->mr_route->route_priv, + erif_index); return err; }