Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp798773rwb; Mon, 26 Sep 2022 06:06:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5g6GkHn0BfO0PZ5ZzQYQCgsWWVGjFpp5EyH/B8Gqri2KX9fOhDHDN/vU9VXCx0WLxeS9EP X-Received: by 2002:a62:7989:0:b0:541:e66c:c19a with SMTP id u131-20020a627989000000b00541e66cc19amr23574814pfc.24.1664197592017; Mon, 26 Sep 2022 06:06:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664197592; cv=none; d=google.com; s=arc-20160816; b=jRW6wPPyy2v8M5LMWuajVV/7P6Yy/PEEWMlZ2GltaDRUOVQPllyf3RQBNW0pY2GRj/ 61mpxi+t28LKZpEuqlKXpxRmEY+zY5iVWgFMbmqB9+22LfW55d6Tl1ba5i/9CGGmAWiV wkoSFoSc1wVLf8Wj6FJ7tx1cSdu6OpywV0HFuWgHg1rZeUKNJol8rC0RnXhPvvLcZ54e IY6YfbGSClhZupEfg2Z61NVKxKdRazyu9ulJZqfkrJoU3oUbDITrlvn09JiK0IoRheTT 1WTC13LmMJk05MFgHalAnF+3JtbSoCx7aztUmqNVyNT68ZY+G0U5ZH06m6fX9a02Ehad Wmrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QIn7V9uLEawDp9QHi/yYEFdIXy0Tj6JGkITWSubGEHo=; b=g+z1YuJKJVMTPcvTc+HeY9uZ3yY44v6QtXX38eraaZDdg5mDLdnbI5K08/5L7BH3XD 52Y/SOGqpf17MZF4wCw6f/hB/SZVHYj33/l5Ewhu/AKvCtTp2g04bdba84HIde9lf6Mm WW9zJsBEDQLafbD/IJM3bBTpa/F8iSV1koEx616cUSUS3RCPLUwTBoLmdCx9pV2dwnCx 7T0s6zzuPfXbbCN5LgOrzBA3cZzwpiBM+7+LnQlB2g5Aj+JruyRRIBEt/wWERNEne8ZU WI1VEgpUbi7nuCAup7NrDZczaJ3o8PFrYe6VRPACDa1RKxxLSYUbczObTcznIPMKhWa9 17aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vrOa5QDa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e14-20020a63544e000000b0043447486c84si17283289pgm.875.2022.09.26.06.06.18; Mon, 26 Sep 2022 06:06:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vrOa5QDa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235757AbiIZKaf (ORCPT + 99 others); Mon, 26 Sep 2022 06:30:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235641AbiIZK2o (ORCPT ); Mon, 26 Sep 2022 06:28:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 158964E623; Mon, 26 Sep 2022 03:19:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B16B0B80926; Mon, 26 Sep 2022 10:19:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AA02C433D6; Mon, 26 Sep 2022 10:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664187540; bh=7GK2AKFlWUrcqmq7eNKe1bJ+5y4F9zZSwGlM48csltU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vrOa5QDabZLoOg7GKsVTA5q6mfXI6PlPbWHKEomfVj1GmNYvu2px2MSvDzyiD0LHH UDgFm6emeXn+3B9OseIepAOjqL8Gc2wx7En8yTLkDvOfKyTv4CT6ZaTGrPzsc5b5g+ 5IrzieCYHF+IfUAxdEUI3/PBXThAXQ3sZcv34Q48= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Benjamin Poirier , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 40/58] net: team: Unsync device addresses on ndo_stop Date: Mon, 26 Sep 2022 12:11:59 +0200 Message-Id: <20220926100742.930754398@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100741.430882406@linuxfoundation.org> References: <20220926100741.430882406@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Benjamin Poirier [ Upstream commit bd60234222b2fd5573526da7bcd422801f271f5f ] Netdev drivers are expected to call dev_{uc,mc}_sync() in their ndo_set_rx_mode method and dev_{uc,mc}_unsync() in their ndo_stop method. This is mentioned in the kerneldoc for those dev_* functions. The team driver calls dev_{uc,mc}_unsync() during ndo_uninit instead of ndo_stop. This is ineffective because address lists (dev->{uc,mc}) have already been emptied in unregister_netdevice_many() before ndo_uninit is called. This mistake can result in addresses being leftover on former team ports after a team device has been deleted; see test_LAG_cleanup() in the last patch in this series. Add unsync calls at their expected location, team_close(). v3: * When adding or deleting a port, only sync/unsync addresses if the team device is up. In other cases, it is taken care of at the right time by ndo_open/ndo_set_rx_mode/ndo_stop. Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device") Signed-off-by: Benjamin Poirier Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/team/team.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 8a1e9dba1249..2410f08e2bb5 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -1280,10 +1280,12 @@ static int team_port_add(struct team *team, struct net_device *port_dev, } } - netif_addr_lock_bh(dev); - dev_uc_sync_multiple(port_dev, dev); - dev_mc_sync_multiple(port_dev, dev); - netif_addr_unlock_bh(dev); + if (dev->flags & IFF_UP) { + netif_addr_lock_bh(dev); + dev_uc_sync_multiple(port_dev, dev); + dev_mc_sync_multiple(port_dev, dev); + netif_addr_unlock_bh(dev); + } port->index = -1; list_add_tail_rcu(&port->list, &team->port_list); @@ -1354,8 +1356,10 @@ static int team_port_del(struct team *team, struct net_device *port_dev) netdev_rx_handler_unregister(port_dev); team_port_disable_netpoll(port); vlan_vids_del_by_dev(port_dev, dev); - dev_uc_unsync(port_dev, dev); - dev_mc_unsync(port_dev, dev); + if (dev->flags & IFF_UP) { + dev_uc_unsync(port_dev, dev); + dev_mc_unsync(port_dev, dev); + } dev_close(port_dev); team_port_leave(team, port); @@ -1703,6 +1707,14 @@ static int team_open(struct net_device *dev) static int team_close(struct net_device *dev) { + struct team *team = netdev_priv(dev); + struct team_port *port; + + list_for_each_entry(port, &team->port_list, list) { + dev_uc_unsync(port->dev, dev); + dev_mc_unsync(port->dev, dev); + } + return 0; } -- 2.35.1