Received: by 10.223.185.111 with SMTP id b44csp908544wrg; Fri, 9 Mar 2018 16:35:06 -0800 (PST) X-Google-Smtp-Source: AG47ELsZjCZOVqBFJ+s8DSVaa6p/92X6WPWhkjpvHRzKJFb/cxhcocRlZpJV61quy1be/+QORXM7 X-Received: by 10.99.122.71 with SMTP id j7mr286914pgn.151.1520642106747; Fri, 09 Mar 2018 16:35:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520642106; cv=none; d=google.com; s=arc-20160816; b=qkcTYrSMh1R8pkuxr7pfyEGFts+uHIK3aI5L92FTzDkr8w9C+4TCXKbBBoh4Qe/bbh YQWjJLIHEmU+4aQbsgOdp5GcUT3wgHNCsLpNQaEWEXQ1GXBBTz1em38J+p3x+UeZoQYc aFtbQnnHDM3enHACYaFOq3W47H1jl1WvwMNWkixLaBsHKpN3JGg85jgql2NmmYLvZAmY NzrYzA2iNwtbi9c9sedIJDw1ntOZSV1pveehkf5DiRnhBWCpJjd5pTUqd6gJS2a9NsgZ ACTK+8Gx3dXvtuItjnB8BAz2a3PDqF3AtUXOxl6Ep+BqQFUjCroVcJyhIHl9jTjIRuwN /vaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=QsdH0osN6P3her8eBFZpnEPbBSRydW+1Bc93d/1n+XE=; b=Fd6NQtSeWV+sTPP9fMAkgLfpJjR5IF+dy7BID2H/TXoKyzCtpslV445Zn8tWeyIwrT wtySCGujvR9RiYfsT2iPAe0paUT22JKJyhYOGFA/LyaigQjIcnplN2PIMR+rjnCSOEAF JNkPIRS7esE02GCcBn4Kb0DeDydr9yuruvSkS3R8unImlrOYLrUWZb6bZBQzJ1w+MTit he+y/IGlG4e0oYVbibrgEJjH0sJA7ww3xdwuMQ9OA+X9I6JakJuTIip5WYMnepIBcEpb LNO8Y0ZGdurnWCUUHOY/SuHzGD96lJX93iTs6dkEf6E1jWXg/u+Y/jpsyjpbcRhTofPC 8g0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y125si1502204pgb.120.2018.03.09.16.34.51; Fri, 09 Mar 2018 16:35:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751741AbeCJAWO (ORCPT + 99 others); Fri, 9 Mar 2018 19:22:14 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39904 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933839AbeCJAWL (ORCPT ); Fri, 9 Mar 2018 19:22:11 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EDBF61176; Sat, 10 Mar 2018 00:22:10 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ido Schimmel , Shalom Toledo , Jiri Pirko , "David S. Miller" Subject: [PATCH 4.9 43/65] mlxsw: spectrum_switchdev: Check success of FDB add operation Date: Fri, 9 Mar 2018 16:18:43 -0800 Message-Id: <20180310001828.431646614@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001824.927996722@linuxfoundation.org> References: <20180310001824.927996722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shalom Toledo [ Upstream commit 0a8a1bf17e3af34f1f8d2368916a6327f8b3bfd5 ] Until now, we assumed that in case of error when adding FDB entries, the write operation will fail, but this is not the case. Instead, we need to check that the number of entries reported in the response is equal to the number of entries specified in the request. Fixes: 56ade8fe3fe1 ("mlxsw: spectrum: Add initial support for Spectrum ASIC") Reported-by: Ido Schimmel Signed-off-by: Shalom Toledo Reviewed-by: Ido Schimmel Signed-off-by: Jiri Pirko Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 29 +++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c @@ -809,6 +809,7 @@ static int __mlxsw_sp_port_fdb_uc_op(str bool dynamic) { char *sfd_pl; + u8 num_rec; int err; sfd_pl = kmalloc(MLXSW_REG_SFD_LEN, GFP_KERNEL); @@ -818,9 +819,16 @@ static int __mlxsw_sp_port_fdb_uc_op(str mlxsw_reg_sfd_pack(sfd_pl, mlxsw_sp_sfd_op(adding), 0); mlxsw_reg_sfd_uc_pack(sfd_pl, 0, mlxsw_sp_sfd_rec_policy(dynamic), mac, fid, action, local_port); + num_rec = mlxsw_reg_sfd_num_rec_get(sfd_pl); err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sfd), sfd_pl); - kfree(sfd_pl); + if (err) + goto out; + + if (num_rec != mlxsw_reg_sfd_num_rec_get(sfd_pl)) + err = -EBUSY; +out: + kfree(sfd_pl); return err; } @@ -845,6 +853,7 @@ static int mlxsw_sp_port_fdb_uc_lag_op(s bool adding, bool dynamic) { char *sfd_pl; + u8 num_rec; int err; sfd_pl = kmalloc(MLXSW_REG_SFD_LEN, GFP_KERNEL); @@ -855,9 +864,16 @@ static int mlxsw_sp_port_fdb_uc_lag_op(s mlxsw_reg_sfd_uc_lag_pack(sfd_pl, 0, mlxsw_sp_sfd_rec_policy(dynamic), mac, fid, MLXSW_REG_SFD_REC_ACTION_NOP, lag_vid, lag_id); + num_rec = mlxsw_reg_sfd_num_rec_get(sfd_pl); err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sfd), sfd_pl); - kfree(sfd_pl); + if (err) + goto out; + if (num_rec != mlxsw_reg_sfd_num_rec_get(sfd_pl)) + err = -EBUSY; + +out: + kfree(sfd_pl); return err; } @@ -891,6 +907,7 @@ static int mlxsw_sp_port_mdb_op(struct m u16 fid, u16 mid, bool adding) { char *sfd_pl; + u8 num_rec; int err; sfd_pl = kmalloc(MLXSW_REG_SFD_LEN, GFP_KERNEL); @@ -900,7 +917,15 @@ static int mlxsw_sp_port_mdb_op(struct m mlxsw_reg_sfd_pack(sfd_pl, mlxsw_sp_sfd_op(adding), 0); mlxsw_reg_sfd_mc_pack(sfd_pl, 0, addr, fid, MLXSW_REG_SFD_REC_ACTION_NOP, mid); + num_rec = mlxsw_reg_sfd_num_rec_get(sfd_pl); err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(sfd), sfd_pl); + if (err) + goto out; + + if (num_rec != mlxsw_reg_sfd_num_rec_get(sfd_pl)) + err = -EBUSY; + +out: kfree(sfd_pl); return err; }