Received: by 10.223.185.116 with SMTP id b49csp5445558wrg; Wed, 7 Mar 2018 11:54:03 -0800 (PST) X-Google-Smtp-Source: AG47ELuxEDWImcYEWPSwCXDDFkWAZaJgAFukTRJZ412Mi7t7IiNWWUSJ1jUP1i/zFT6mIDtDpGtD X-Received: by 10.98.71.210 with SMTP id p79mr21609793pfi.47.1520452443317; Wed, 07 Mar 2018 11:54:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520452443; cv=none; d=google.com; s=arc-20160816; b=r4oDnNLO5VvVKEJX36dAEBLAqeu9CrrAeLIt2cfuUjj0M9bv5a2GFkzEWDqBBndEEN 8T2aOgrFgenzxwAgGxgmmLvade/Vj18+zLYQ5zMWqWXSHJC/MxctFLY8TPaEaOLpoCWG 6rV9KcQguGY4jbPF2FhJgETaDcZNWdXBFr5G5srUgRJp3MpoMwJXeMPDn1Jrjq8ok8Az TesqihQ0KXVMgEethgXJh54CAHugwlJG9wI3uB4XDFWQNPmcKrKmo1LaNSCItv//2BOZ qUBUm+ArPiNGuYRMy1TnuC9Ou1k00/l59DG3DaDEQ0TEqxohs2aJGypAsycdMOanI++q qD/A== 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=+AgaDkjmyYYnyOLNYe5qRi/wpXOprUcijGKvORvjeG4=; b=QRG7U4MYZbVH/UtscMyR+0OAyatu4mFb1pfFAd2Y06w6HqTEzwiQgvqTPmbXTuVVc2 7XECENTkMhDsoEvmfwuS8YW3d/4nMLAzxMSpP3g7Fo1t22NjWkGgNswaxVtWnJFxdsfo hUw+D/e/auEdRsqszeXTizT+VbhY4uZZbHSnwfot4jzU+vbyKx+m57ZjEx/2WFEoKs6R haG3Mg+4mCgixxXFtdLi4zy8rqKZoboaC2m3bDIlpBHs0Bo9e91JFuo5eXeihGHULWRK HmTySe9R/8LCa50nmRTulLDpVffb+CNmyMi48AvNETiHj3c7GCwt6NEm9KOpkm/qZfL8 Z4Iw== 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 z8si11852652pgr.57.2018.03.07.11.53.49; Wed, 07 Mar 2018 11:54:03 -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 S965829AbeCGTrv (ORCPT + 99 others); Wed, 7 Mar 2018 14:47:51 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:45150 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965758AbeCGTrs (ORCPT ); Wed, 7 Mar 2018 14:47:48 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3C8E310DE; Wed, 7 Mar 2018 19:47:48 +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.14 049/110] mlxsw: spectrum_switchdev: Check success of FDB add operation Date: Wed, 7 Mar 2018 11:38:32 -0800 Message-Id: <20180307191045.991894527@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180307191039.748351103@linuxfoundation.org> References: <20180307191039.748351103@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.14-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 @@ -1098,6 +1098,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); @@ -1107,9 +1108,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; } @@ -1134,6 +1142,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); @@ -1144,9 +1153,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; } @@ -1191,6 +1207,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); @@ -1200,7 +1217,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; }