Received: by 10.213.65.68 with SMTP id h4csp38703imn; Mon, 19 Mar 2018 18:48:39 -0700 (PDT) X-Google-Smtp-Source: AG47ELsKKeQPAYpKc9zRLsZPkp2lbFyTidNMoe6PIxL4WxBoq2gvGJca0wY7ZFuwP0ofkksBxxg/ X-Received: by 10.98.152.207 with SMTP id d76mr11889844pfk.130.1521510519860; Mon, 19 Mar 2018 18:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510519; cv=none; d=google.com; s=arc-20160816; b=EyiljpU0V8g7krvKwPcMsfK9kx9OQ6hujDdHp/eqDJld2z/Sund4fTS6rhOfp4Ll06 lu/JAvyZfBVJ79nKffgLo5ip1/8CjsEVX2wEzdXuzlWpMoFqt2UGZj+c4squy0z9mV3c a+Unk5qgVJekXlrpRcFwEpHErxCoo0JmZchCztGLwi5wjW/LU21OzZ7MjwkETzASNJES 1qnonCXqt3doeAiuPLTYKeOwywv+V+q4k6KDIfhr4qVAyiEPuohJLCWELe/vSAU722Op Tm5mRhXb2Dr+SNuZiEuQZJxRNquzERWLDwYOMpwXGu6gPgcuWTrXde4wGakGbQeCzBNp gETg== 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=2OaC4KVkZchYwDzrumpGgf+28qg4gP2LmPwWW1z/HcU=; b=hPbeOkPLMitYZr1i66F71S2WtH2sjQvdAUde4PGW15r2FSfkSN7bVbAsB4ford5oEU HHEpPmB+MYmPLzKkjOYsRjxTaR0PPSo6W4uLEjOKHHeR9x9ryhRbCiTms8uKCMu0bGI+ geWKdlM8QnpNLjagHdAeqbpTYuWMZbRhojhLF+8JlPDRBusC34Nx1mV5lxTQVef4HIH+ ZpacnBjRgdD1SiZRQ8DIVRwaOr+OQJd867mVuT91M6sPf9rS/cmT2j2wc0iElvy9Zu7u EnGM0YU/ZD2okbHTBHm0jg8bICbbVKQj7u7Y2BGsWrqC76TkEWiNVj2LR46zj0NLZeAU l0nA== 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 n3si394089pgc.12.2018.03.19.18.48.26; Mon, 19 Mar 2018 18:48:39 -0700 (PDT) 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 S936187AbeCSToQ (ORCPT + 99 others); Mon, 19 Mar 2018 15:44:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47968 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031034AbeCSSVH (ORCPT ); Mon, 19 Mar 2018 14:21:07 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3A0E31206; Mon, 19 Mar 2018 18:21:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mahesh Bandewar , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 073/241] bonding: make speed, duplex setting consistent with link state Date: Mon, 19 Mar 2018 19:05:38 +0100 Message-Id: <20180319180754.226710212@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@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: Mahesh Bandewar [ Upstream commit c4adfc822bf5d8e97660b6114b5a8892530ce8cb ] bond_update_speed_duplex() retrieves speed and duplex settings. There is a possibility of failure in retrieving these values but caller has to assume it's always successful. This leads to having inconsistent slave link settings. If these (speed, duplex) values cannot be retrieved, then keeping the link UP causes problems. The updated bond_update_speed_duplex() returns 0 on success if it retrieves sane values for speed and duplex. On failure it returns 1 and marks the link down. Signed-off-by: Mahesh Bandewar Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/bonding/bond_main.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -371,9 +371,10 @@ down: /* Get link speed and duplex from the slave's base driver * using ethtool. If for some reason the call fails or the * values are invalid, set speed and duplex to -1, - * and return. + * and return. Return 1 if speed or duplex settings are + * UNKNOWN; 0 otherwise. */ -static void bond_update_speed_duplex(struct slave *slave) +static int bond_update_speed_duplex(struct slave *slave) { struct net_device *slave_dev = slave->dev; struct ethtool_link_ksettings ecmd; @@ -383,24 +384,27 @@ static void bond_update_speed_duplex(str slave->duplex = DUPLEX_UNKNOWN; res = __ethtool_get_link_ksettings(slave_dev, &ecmd); - if (res < 0) - return; - - if (ecmd.base.speed == 0 || ecmd.base.speed == ((__u32)-1)) - return; - + if (res < 0) { + slave->link = BOND_LINK_DOWN; + return 1; + } + if (ecmd.base.speed == 0 || ecmd.base.speed == ((__u32)-1)) { + slave->link = BOND_LINK_DOWN; + return 1; + } switch (ecmd.base.duplex) { case DUPLEX_FULL: case DUPLEX_HALF: break; default: - return; + slave->link = BOND_LINK_DOWN; + return 1; } slave->speed = ecmd.base.speed; slave->duplex = ecmd.base.duplex; - return; + return 0; } const char *bond_slave_link_status(s8 link)