Received: by 10.223.185.116 with SMTP id b49csp1111017wrg; Sat, 3 Mar 2018 15:54:08 -0800 (PST) X-Google-Smtp-Source: AG47ELtJreg58mWckjaQUg0ZGxcKjtXpKkdlROpDixCxKEm1+K5RxJDBlKBD8/6t+Uc7Q+Z1bsIy X-Received: by 2002:a17:902:e65:: with SMTP id 92-v6mr8987890plw.268.1520121248767; Sat, 03 Mar 2018 15:54:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520121248; cv=none; d=google.com; s=arc-20160816; b=JdY4/49624xK8ouAYJ9ZP9Btp7txzLaED9bzDddXkOPUx5W9icGnuiQpYUB1was1K4 3IXvUwBGH/RuMLKZN31DkgDn1DBnf9RaiRLoeTI52pms4rAs7hIKduZJeOHpAaSsuEva N4ULkQ9mi8SYL8knw4BKLHPh4rc+8g6SzcBqBEjLdTga+WLAZ2mlNDTgccBCS5fmoH14 vcFlE7HxDCTzQoZXZ0VKTmX+EjJ7slKYYGMj6I5Tr092N4oPaO25wefze1iPchMfwCv/ xY9CjZkHudzkxH1EWVWSfwXjC+diwW1HG0looIIfdi6brXfJNb/9Yo/NmdZV+U7Bcv7O pljg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Ge1fpX2Vposo/7ULmO57QNXz7UGE6lRom8nfvb53MwM=; b=m459cP8YQWqdvAIq1MZcCyVXEQ+qqY1aC2h0D0DzbEpvkB9DaSnbiI7dTWMZergFKx 2XJeXCFFIrJTML0WtSS8wHhD1g1xnekZHgztZeO2DAkGNHCjjwvMdA2iAf3WXuA8Hn99 8aTV/+dM9xY74EEa6RaqnmOLyubJ1EG/Nd1lfvUNKxlXpEM/unmFB3+7xUjEE1v0qs8i eQnJ0AqQBtLfppW1NLgPMV8ZjfSZ9FRbQL3FXUzBstXvWvfqMaRxlVnWbscetFRPHlqz suftupoNosVaopMaQEI5lHdhxQRhwJJTrN6H5Wi6GlEa0QdVEmxHQv9JIquwOmrrSC3K 2AEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=AIZmvqcX; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18si6145141pgo.680.2018.03.03.15.53.54; Sat, 03 Mar 2018 15:54:08 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=AIZmvqcX; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934006AbeCCXxB (ORCPT + 99 others); Sat, 3 Mar 2018 18:53:01 -0500 Received: from mail-by2nam01on0107.outbound.protection.outlook.com ([104.47.34.107]:45280 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933934AbeCCWdD (ORCPT ); Sat, 3 Mar 2018 17:33:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Ge1fpX2Vposo/7ULmO57QNXz7UGE6lRom8nfvb53MwM=; b=AIZmvqcXipndUN1yRbtcLGliU2tf3n8u7s0y3Dw1nHomnwjQb9ELm93vEaegcTBnGtyejPCp9Y/gd2vNpa972HTLFe5tO/knSxZrlSWlyDyjf4JIdCFkG3mhbCeRhe74zO5mBdmazzJ/ApmohDdyRaFI+GrzKp7NEdJfTJBCkmM= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB1097.namprd21.prod.outlook.com (52.132.149.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.2; Sat, 3 Mar 2018 22:33:00 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:33:00 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Mahesh Bandewar , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 076/219] bonding: make speed, duplex setting consistent with link state Thread-Topic: [PATCH AUTOSEL for 4.9 076/219] bonding: make speed, duplex setting consistent with link state Thread-Index: AQHTsz767QmECbfWiEOzOTuBML4yBg== Date: Sat, 3 Mar 2018 22:28:39 +0000 Message-ID: <20180303222716.26640-76-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB1097;6:N+U9rdMuRXEPcrpLF7gALg2G47YgNfHKAKm/9YVRH8oLlM/9QyvahjOAz3lnYewA6zsgIb1bSeh0ztOF5NHpLQ6a3y/3h2+TyYtvNsdpehEO/SAftuTdaQfZIYca1zlW2eg83UI0XhWboWtOdE/9kDoKStrlB/6aqu0v45D/av33Z5V55VoCu4KxsN8EVmvpTXU1fGcr5FViYvNm1JOVn7dyQZD+X4GDAQs+ljJnqtInCAMhuXeis5N4GYL0NNBynSiq9qDMy+55OfGc6bySmjd6z8JOKU98Kq842MpFf0NqWuTbm9meVCz6snWNJ9ocHwR4CGZyCj97uKwK8XPeSim7uOy/FrYX4T6ynsZQnyPNfMx0Z+Sq3p+XZM1p2Tc2;5:MVuVZl7m7vkOX5zv+nLTWcJSxLk8PMGIZDb/o+7druL6mFcN62ZEx/t8I6RMcyIb/uyN97mKkLuPBUwP7wv84AL/AlOretWWsjoz6tvHputmPta7iE7+x1D8u4YnpHOLgqMdnps0WwmTiev0q0jW7KHkgfRluTkxTog1Rf45bZE=;24:hpkKZlwb7DeK5fNyjh7usgQild0QeSDuSOEoRoG2FLbao48CUsOHks6BF0+dOmGrdfClHAHJR+Ne1+tATRclXpTWRqfoSO6/g8p7O0HrDZw=;7:b3QDyb81fQe45PWos8OVOUtRS3Ow+thl/InbSy1fNIyFwmCANNH0+TNF25ITiei97T7+eKPds52cxszRLrINXTWIMAzm8O+dBRaFk8tvnTZ8To/w6x6cZgDiIQI/1wbREGRyw4VKIPtxViQMALK5fRWILazPj8a0FRErrZTr6meSxYTFmsELpK3bXChYFbdWLlj5r3o4GC+rg0h0/gMc/IeuVDC0tRwKPgH9vPm2pmaJhE+xJ+PxIj+YejhBChOf x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 3163f6cf-ef51-463d-2dca-08d58156b84f x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2PR2101MB1097; x-ms-traffictypediagnostic: MW2PR2101MB1097: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(211936372134217)(153496737603132); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(5005006)(8121501046)(10201501046)(3002001)(3231220)(944501244)(52105095)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:MW2PR2101MB1097;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB1097; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(366004)(39380400002)(396003)(39860400002)(346002)(189003)(199004)(305945005)(105586002)(36756003)(3660700001)(86362001)(6666003)(66066001)(2900100001)(5660300001)(8676002)(10090500001)(81166006)(81156014)(8936002)(22452003)(10290500003)(2950100002)(4326008)(25786009)(5250100002)(2501003)(68736007)(7736002)(72206003)(14454004)(478600001)(186003)(110136005)(26005)(316002)(2906002)(97736004)(6512007)(99286004)(107886003)(54906003)(1076002)(6506007)(106356001)(53936002)(59450400001)(6116002)(3846002)(102836004)(6486002)(86612001)(3280700002)(6436002)(76176011)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB1097;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: bA3OtEqR7hMQpyD4Qz9q8nB9Sm1Hr+eC2eai5X1fiE2jw9vlQfsRBQuYPKSWpVGe1V4oVBAWBq+okWuqKxsj3JAFHIcfkAUhX7DKUYf68PQy1Q+8o41BmGiUpdemJXQXo8roLsMrbMqbvcUlV1YYY0MR4NWmEVyC8x1CEKAr0Yc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3163f6cf-ef51-463d-2dca-08d58156b84f X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:28:40.0100 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB1097 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/net/bonding/bond_main.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_mai= n.c index 63d61c084815..6b4b43319ffa 100644 --- 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 =3D slave->dev; struct ethtool_link_ksettings ecmd; @@ -383,24 +384,27 @@ static void bond_update_speed_duplex(struct slave *sl= ave) slave->duplex =3D DUPLEX_UNKNOWN; =20 res =3D __ethtool_get_link_ksettings(slave_dev, &ecmd); - if (res < 0) - return; - - if (ecmd.base.speed =3D=3D 0 || ecmd.base.speed =3D=3D ((__u32)-1)) - return; - + if (res < 0) { + slave->link =3D BOND_LINK_DOWN; + return 1; + } + if (ecmd.base.speed =3D=3D 0 || ecmd.base.speed =3D=3D ((__u32)-1)) { + slave->link =3D BOND_LINK_DOWN; + return 1; + } switch (ecmd.base.duplex) { case DUPLEX_FULL: case DUPLEX_HALF: break; default: - return; + slave->link =3D BOND_LINK_DOWN; + return 1; } =20 slave->speed =3D ecmd.base.speed; slave->duplex =3D ecmd.base.duplex; =20 - return; + return 0; } =20 const char *bond_slave_link_status(s8 link) --=20 2.14.1