From patchwork Tue Dec 6 07:29:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 703051 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3tXts82cbmz9t0H for ; Tue, 6 Dec 2016 18:43:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="djOqF+H0"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751977AbcLFHnE (ORCPT ); Tue, 6 Dec 2016 02:43:04 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33540 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751689AbcLFHnD (ORCPT ); Tue, 6 Dec 2016 02:43:03 -0500 Received: by mail-pf0-f195.google.com with SMTP id 144so18289667pfv.0 for ; Mon, 05 Dec 2016 23:42:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=SVelL3tf2fjblzppRnQ28n660LDC3GCm4XSYz0XhxAg=; b=djOqF+H0jYt9LWiI2Tk0jENE9E/6rWybfAJCJbky0KztIv/0ptyyJ4yeXtbU02sthO Uvsr5D+s6FdMbA6DFu4qZaX9iGvxhvSykB/w00qXv9v8P8S60qqbCwjq3M6Lu7LcOI1r lRjTOcqdPpB9ZdvSvqMbtM0D7Ba6Upcdus+XKlqyB5RGoUDYKWiWUGPyOPqLZG7SICSC 40VV9inJcwXQ7M2BtLIsC+/mp9G2vM6iB/Ez/6fgDmbmJmxoehCKxBarxDt7hSEI7cbU SSRaJdU2GLh1o+dkmMz2o+M4uhW3j2V0gYdym2/duQAJjVvrFpbK4yDkBrSb6O7UCXbW OGPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=SVelL3tf2fjblzppRnQ28n660LDC3GCm4XSYz0XhxAg=; b=Evu6icU/2GuqFvLYGb0j3ruB243m3DJTGe6D7jbYE46e1cGNuXYeorewhkMv4rb8Pa DVGHdkVDrSw9Ig0NYVpJJ4UjZ4wuH+j2D1o4VMi0E4HDZjjJBK3641EveGAmuNswAOiq gbcad02N8t6rW0zmRz9YOcgaDzqj5uXcMrx9iTdYQIngKCCi7Dj3ZlbI+jhhAPiVa8Ec scwq5grpYyViAtsu6U8+JG4GzP5C+uOJJ6SDBZwoha1f2DCRHVlwbGRZZJhl3IeVKQnz 2TwNuzVe2SG2G7taeekydLUvwbBiCivG7zYxlfY6f+pxfRdjEDOaFVAbfhexY6n7MQJO IwBg== X-Gm-Message-State: AKaTC02maWKFf6WD/OoSMfkirBGSNGhHPZxcroI6gLnz668kef/hp9654KUewEnuPrukpg== X-Received: by 10.84.175.234 with SMTP id t97mr133632787plb.145.1481009355168; Mon, 05 Dec 2016 23:29:15 -0800 (PST) Received: from localhost (138.128.208.20.16clouds.com. [138.128.208.20]) by smtp.gmail.com with ESMTPSA id a11sm32112206pfe.96.2016.12.05.23.29.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Dec 2016 23:29:14 -0800 (PST) From: Xin Long To: network dev Cc: davem@davemloft.net, Marcelo Ricardo Leitner , Jiri Pirko Subject: [PATCHv2 net] team: team_port_add should check link_up before enable port Date: Tue, 6 Dec 2016 15:29:08 +0800 Message-Id: <62f7aa9c00b68beed68a907c51dde22e7847d6c9.1481009348.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Now when users add a nic to team dev, the option 'enable' of the port is true by default, as team_port_enable enables it after dev_open in team_port_add. But even if the port_dev has no carrier, like it's cable was unpluged, the port is still enabled. It leads to that team dev couldn't work well if this port was chosen to connect, and has no chance to change to use other ports if link_watch is ethtool. This patch is to enable the port only when the port_dev has carrier in team_port_add. v1 -> v2: use netif_carrier_ok() instead of !!netif_carrier_ok(), as it returns bool now. Signed-off-by: Xin Long --- drivers/net/team/team.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index a380649..4bc0103 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -1140,6 +1140,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev) struct net_device *dev = team->dev; struct team_port *port; char *portname = port_dev->name; + bool linkup; int err; if (port_dev->flags & IFF_LOOPBACK) { @@ -1249,9 +1250,12 @@ static int team_port_add(struct team *team, struct net_device *port_dev) port->index = -1; list_add_tail_rcu(&port->list, &team->port_list); - team_port_enable(team, port); + linkup = netif_carrier_ok(port_dev); + if (linkup) + team_port_enable(team, port); + __team_compute_features(team); - __team_port_change_port_added(port, !!netif_carrier_ok(port_dev)); + __team_port_change_port_added(port, linkup); __team_options_change_check(team); netdev_info(dev, "Port device %s added\n", portname);