From patchwork Wed Sep 7 07:56:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 12968570 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FE9DC38145 for ; Wed, 7 Sep 2022 08:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230190AbiIGIAx (ORCPT ); Wed, 7 Sep 2022 04:00:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230180AbiIGIAk (ORCPT ); Wed, 7 Sep 2022 04:00:40 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2063.outbound.protection.outlook.com [40.107.237.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAF0561D6D; Wed, 7 Sep 2022 01:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g0YSQy7P5VDyPXap+xwmp4WaAmN1PYBxeKdyd9PUr2BLAVZqjoOzxvjAB6kf4K13EPOqgOWWKNdrWDQWLVhDVZ+qNPli3lZUbWr0Px1VFouXyZvNDVORF9ub7J4Z14f9HgNabuQTvsGPaJ7W63nxOi3AbAxdssHZq5HQ5nmUo45LIosv4R4qP0sH8VN+mDDx5p+CnDWNAZ7MxKDycUZA313KHs7OtvrAXR+UpRz9+gQM+dpNzp2MFlA02F4WjWsdi5BQ+B4IFT+/yM5IuVkyHopeFg9TnpUY9oz/oR+dw6K3wPfys53au3badnfroBV/yBhyKS9Et1fYCUBj4I4r/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XH4ClpXLoh0Yfvp0GxMtnOS/ifat+xwjj8RzbBez1U4=; b=Y9MhuNOM8ymITCZ1/2Ut0upDspNes0ssqiuV/Cv9RMy/Mi7GXR+P2xhOdO5i1FyeJVPlJvZvocn6/vtqmZbyLLgnwTqskN+6eKkP32xOo7aLi8SG62MwD0aVgz8EhH/0Ut9sIGBu09sE4RH1AEt7X+Rr7QebCJAfOdkn+RXQjT9nhYG5x0hrNAC4kV65G7bqMsUsDR8DtWxF3KulIj3pxcKAlM91CMHeELUaWMwmixuSgciAf1Xqs7ydFqdUnnVQpxQ5y66K5QwFBfrXc6tkZaS3XIINfruD1wur0uznzQwmBGPEIVCPJgisD/BbkcOVw7Ht3CWf3lx+GRzl158MMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XH4ClpXLoh0Yfvp0GxMtnOS/ifat+xwjj8RzbBez1U4=; b=kNmdatgJ+1XCf1UamkTb6HWvfh9vyVISgjS+jT/rqY8jeCvzHW8+LZ4GI4WmvqDihYO2s/kSpBRtcGD7gbEvwl8cg6OPd4C7PWY4T8ADBnMrppLX/1e7m5zYSy9DhnmPu3880gR6O10WiQKWVIdQeYSvOlJKIyRxvqTGgWz54tWeYKk1jdMEieiqbNKHriiR6/ctDLqI+Izpn5wcTW1Ij+tlDi8GjkgVtGkMw8VvJNi6xL6UMlwn5lEFIav5T5EYYLcclkT+7qPSsKplvQI08XPhNrp2V+kThyWcdyKYk7OyvNB/cvtEpRryBnTFEJEb/nYaDC/yEcYGR3fD++HxCA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) by SA0PR12MB4495.namprd12.prod.outlook.com (2603:10b6:806:70::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.12; Wed, 7 Sep 2022 08:00:35 +0000 Received: from MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::51f3:15f4:a31a:7406]) by MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::51f3:15f4:a31a:7406%5]) with mapi id 15.20.5588.018; Wed, 7 Sep 2022 08:00:35 +0000 From: Benjamin Poirier To: netdev@vger.kernel.org Cc: Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Shuah Khan , Jonathan Toppins , linux-kselftest@vger.kernel.org Subject: [PATCH net v3 1/4] net: bonding: Share lacpdu_mcast_addr definition Date: Wed, 7 Sep 2022 16:56:39 +0900 Message-Id: <20220907075642.475236-2-bpoirier@nvidia.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220907075642.475236-1-bpoirier@nvidia.com> References: <20220907075642.475236-1-bpoirier@nvidia.com> X-ClientProxiedBy: TYWPR01CA0021.jpnprd01.prod.outlook.com (2603:1096:400:aa::8) To MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 082b7987-f0f7-4c54-46d5-08da90a70b8e X-MS-TrafficTypeDiagnostic: SA0PR12MB4495:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fdkMMRRuxpy7V38jiNaFoICAxBxQb6RIqE5aSOGWKKzbg3uNZA+n8SB+PA6YTpoqysp3yfDsgFy5g3xxt80A+o8YNJEr8G8a1ViqKP91O0mcksqICX9oD9mrpGOAr6KwPjCs1oaCERmMR8EV+TX3OLhdqGFpaaEQgqxjugKn7XuQvUQmsLuO2eIO8Mh4F3ppQIKD9NpJ9lmS3kSS9OdDU9pC+6EsP6m/si2IBPtjAF0iORv3IUFZRx9zCaXwdWxwYtK2jOeW2GGQBiAwfSn9HX0cgWCIFWIJ9OFtcI/PzWsXhXd1DaMAz0kvPDYnfdSKXcBYjCkK2at9mRayFQnT+iGSMmISw4rBQ2UrvsmX+duuCQj5JFVnQh4ogLTN3hlx25C+e0p/G9OjkmMGS5XX2fVNcOI4eDhVc9kJ1XxoZAhpimPB/autBjq+jfqQDlqgEoZHPAxI8swGTEgVLwNollJUtAin65Ta405+C/jyvQefz8+CPslXCqxiBjObRxzHqPSqyMvsd3lKIsDlzijRX+HrUNG4n0qEtkwDRjKQT5FabQCG+mY9EsPXSDt6pHwt790sf1vVPV/VUlTB9hiUlLkWPe9u2U5WA0/W/MJSGjEv6/kFE7LgN7ywuDdwHDw9zVhi9y53iffe6yRK+cCBTgIDAnppGgKCu9zqgHG/ETXAP7SnUf5hFdMilwmf+xWCQ0V3puFYdat9i8+EFV8ayA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4373.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(366004)(376002)(39860400002)(396003)(2906002)(5660300002)(7416002)(38100700002)(6486002)(8936002)(478600001)(6506007)(41300700001)(316002)(6916009)(54906003)(4326008)(66556008)(83380400001)(66946007)(66476007)(8676002)(1076003)(26005)(6512007)(186003)(2616005)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-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zWmEbAIrShS2zjSqeArfLfxqe2RaTWzaqbQH2ls0HGq9GBxitEVj+CWW6fsz57FGwqZAALiiEtGbqo7IwZQSuHKS8E4L2FslgHfCVytYKgIlbrtRzwCblmAk7kVz6sjv7LTf/tkGK3lYfxdyiLOG6eY6HBVW4AOf+x1iWbwtEtxu7f6YNaZERsA14hCRpTOFpoE6UUBEXALSWygzN7FV62COK8AqxOfDSm5Ozh2VB3dewRqe3X9TX00wMwymn6W0b6joh8/QT5MO8Zbfb7iLrc/rwAFLzChuO4vk/+9NAqAJ81x16HWCt1HyiDbXcZOizM7J1hrh5u1ICh0kxbmSmIsdECMmhHZfHBTUsIaHGn+ufxkZjicaz3RhXq3KUC5rACVu37YgQrRycGHPWL6SpPts+Taj+1p705emr9z3dsaTu3Meob+FcvNBDabpIqywtvo6YOxdOn4Y4qg8IJV76PeNAz9kwV6RydH64Yy0cERZ/ceiEPYk8hG61dCIgte4uuxpFb9DGN0cwdmytEnRXGjf9fJuoqJiFj5S4OSR X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 082b7987-f0f7-4c54-46d5-08da90a70b8e X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2022 08:00:35.4939 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3v4CuSjI0xZn1iOEQy1us9aVysaUkophwMoc3++f3cVJNIYam1XrU+8+DkB1AHzYRZvQCusSFy28fJU66zjyMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4495 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There are already a few definitions of arrays containing MULTICAST_LACPDU_ADDR and the next patch will add one more use. These all contain the same constant data so define one common instance for all bonding code. Signed-off-by: Benjamin Poirier --- drivers/net/bonding/bond_3ad.c | 5 +++-- drivers/net/bonding/bond_main.c | 16 ++++------------ include/net/bond_3ad.h | 2 -- include/net/bonding.h | 3 +++ 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 184608bd8999..e58a1e0cadd2 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c @@ -88,8 +88,9 @@ static const u8 null_mac_addr[ETH_ALEN + 2] __long_aligned = { static const u16 ad_ticks_per_sec = 1000 / AD_TIMER_INTERVAL; static const int ad_delta_in_ticks = (AD_TIMER_INTERVAL * HZ) / 1000; -static const u8 lacpdu_mcast_addr[ETH_ALEN + 2] __long_aligned = - MULTICAST_LACPDU_ADDR; +const u8 lacpdu_mcast_addr[ETH_ALEN + 2] __long_aligned = { + 0x01, 0x80, 0xC2, 0x00, 0x00, 0x02 +}; /* ================= main 802.3ad protocol functions ================== */ static int ad_lacpdu_send(struct port *port); diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 5c2febe94428..faced8ae4edd 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -865,12 +865,8 @@ static void bond_hw_addr_flush(struct net_device *bond_dev, dev_uc_unsync(slave_dev, bond_dev); dev_mc_unsync(slave_dev, bond_dev); - if (BOND_MODE(bond) == BOND_MODE_8023AD) { - /* del lacpdu mc addr from mc list */ - u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR; - - dev_mc_del(slave_dev, lacpdu_multicast); - } + if (BOND_MODE(bond) == BOND_MODE_8023AD) + dev_mc_del(slave_dev, lacpdu_mcast_addr); } /*--------------------------- Active slave change ---------------------------*/ @@ -2171,12 +2167,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, dev_uc_sync_multiple(slave_dev, bond_dev); netif_addr_unlock_bh(bond_dev); - if (BOND_MODE(bond) == BOND_MODE_8023AD) { - /* add lacpdu mc addr to mc list */ - u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR; - - dev_mc_add(slave_dev, lacpdu_multicast); - } + if (BOND_MODE(bond) == BOND_MODE_8023AD) + dev_mc_add(slave_dev, lacpdu_mcast_addr); } bond->slave_cnt++; diff --git a/include/net/bond_3ad.h b/include/net/bond_3ad.h index be2992e6de5d..a016f275cb01 100644 --- a/include/net/bond_3ad.h +++ b/include/net/bond_3ad.h @@ -15,8 +15,6 @@ #define PKT_TYPE_LACPDU cpu_to_be16(ETH_P_SLOW) #define AD_TIMER_INTERVAL 100 /*msec*/ -#define MULTICAST_LACPDU_ADDR {0x01, 0x80, 0xC2, 0x00, 0x00, 0x02} - #define AD_LACP_SLOW 0 #define AD_LACP_FAST 1 diff --git a/include/net/bonding.h b/include/net/bonding.h index afd606df149a..e999f851738b 100644 --- a/include/net/bonding.h +++ b/include/net/bonding.h @@ -786,6 +786,9 @@ extern struct rtnl_link_ops bond_link_ops; /* exported from bond_sysfs_slave.c */ extern const struct sysfs_ops slave_sysfs_ops; +/* exported from bond_3ad.c */ +extern const u8 lacpdu_mcast_addr[]; + static inline netdev_tx_t bond_tx_drop(struct net_device *dev, struct sk_buff *skb) { dev_core_stats_tx_dropped_inc(dev); From patchwork Wed Sep 7 07:56:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 12968572 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 148CAC6FA89 for ; Wed, 7 Sep 2022 08:00:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230201AbiIGIA4 (ORCPT ); Wed, 7 Sep 2022 04:00:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229958AbiIGIAn (ORCPT ); Wed, 7 Sep 2022 04:00:43 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2075.outbound.protection.outlook.com [40.107.237.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D87257F26F; Wed, 7 Sep 2022 01:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P2IRqjageziJ+h2f1199hAkb2ImX8hx9gxHyvS+R5kHkzHsagzpaPbBYxuscnF+m9yb1A9eOlNr3g4o4WS3q9zIt5Pq2X2FDbocYi9h0wD6uxhXT9Yp23DxLgCtG2zRz2haRP9R6gitx1tgxT191eLOrB9GS4V57H7URWDAdjD/+lv2LUw7tIEyrBe8BY+c/0+v55soq7+/tKWitDsLE1MtopxtGImNflVuLmXUUHeaDIcM+o63lHnpkanxddomH5gpCzYWxl7do2e3EA5orfHRN2LtkLHQ3ToLfiPjGeSYS+1PeHXN6Fi5v4AVdpM5atsHAqJA/1I5jHQc/b8gNQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7N2g3lNAUJyf6++63BNdZhHL+ljWXgh+vkLh2LfrlXQ=; b=nb372AmsxBhAzVGXP0WLDp7ax8q0PVRjkYKfRf0aCOknySy+jR+9eNzaVvvYTyddMnUqmp81D0CHnlQWJWHKSNzpNgoKHDDlkMmiQTjkzLGTDyBxQ4aWgV+PFtCEJBKvJhjnTVoajEGBavzGAififIIYnWa0t0IaRNkLGRfcxoTjLZD8qUa92vk/R9pRizA1g2CvMIhUkAjW+y7vXddZMMZP1Z4aAlbs/95vHeSf6AD5h/LUfBjFEa4Bas+Cs7vhy4+t+y3DRjzdSDck2w43NzA7wglttWVEaURpywDWq4fEeIrsi31G/6xYOMxv4F4T8aq8MhXKosDQbo0AEJGPgQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7N2g3lNAUJyf6++63BNdZhHL+ljWXgh+vkLh2LfrlXQ=; b=iZLUw9vaqTjejB67Yihmy+QaHlgDY54osww4I8wCSF9KGIjVkva7Dj/drBvc/9y9oTgxWpijT4d+lLabuHT4Yriy6ABwupsvadKMkEpCK4TWvJScyh5vEL1JlJ6kX1e1A9Q1ELnDdhIYjNUBVLETYuyKXDUozmObCciG0J4T64/q5CxV3fLOssdJtbbLhr/CoBmJskyM0OIUKFP4THbeDF9h+uE/z6i7/y+EgpJBIfIjIkxH2sEs503drHIP5wiFvnL7rGnPE9146QX0goSrbsRR4sqky5y5EEqNExGOnKxezz+8jsLXQ3iy8thPQthAJhAhjUBStieIoGWxSNmn2Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) by SA0PR12MB4495.namprd12.prod.outlook.com (2603:10b6:806:70::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.12; Wed, 7 Sep 2022 08:00:40 +0000 Received: from MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::51f3:15f4:a31a:7406]) by MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::51f3:15f4:a31a:7406%5]) with mapi id 15.20.5588.018; Wed, 7 Sep 2022 08:00:40 +0000 From: Benjamin Poirier To: netdev@vger.kernel.org Cc: Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Shuah Khan , Jonathan Toppins , linux-kselftest@vger.kernel.org Subject: [PATCH net v3 2/4] net: bonding: Unsync device addresses on ndo_stop Date: Wed, 7 Sep 2022 16:56:40 +0900 Message-Id: <20220907075642.475236-3-bpoirier@nvidia.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220907075642.475236-1-bpoirier@nvidia.com> References: <20220907075642.475236-1-bpoirier@nvidia.com> X-ClientProxiedBy: TYWPR01CA0015.jpnprd01.prod.outlook.com (2603:1096:400:a9::20) To MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5a001035-6ff9-4c03-234d-08da90a70e68 X-MS-TrafficTypeDiagnostic: SA0PR12MB4495:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pwbpQu6kbV9QoseFyhfStyLR5c+n35IJJ7EvmrNMpaK9yHGwV0AMd59tNXows4IQyXWP91RVmDe2IvFZSe6FpYiJcDiY5yTA7IvPByu1pzydEdt0+/qDua51AKdFwanzSjk5PpSQT6peNNq/Odhtz630IDBsAXNv1g/OkyCCS1pgKbjmi1XpGTTjVThurHKxvJ98szgcS5DukyrVsH28w3+WXu/4KJ5EraxbI6Lw+OZp7frJ1dR0jf2LwNLUoxGzG+gXuwqgKFe7iWmlmBOZzOKNhmIzoEfxY1D3DBsGNx8AW0FcrRonjbnPRBWRkIpmykgbmsBRyhrvJo/sCxVn+/cr+xHCQtogXIh4A7QTmiSwTi8oSHOZpWbPHnz6MNCc54SoGY+Wsa7WWSd22yu3ttVYNfMmlQlORp6KshFDPbQ+Ks73VpM3nIiGURN8najywYtUr1u5gkDCLoumo12QgQ/GAVVHhhKCgFbYOsuPSQIdGUvc23q5FycyXFuKghSoOuxsElnM9ETkI9t8PoSHPLKM0ywSDHIGi8cJRJr8jzHLif+Mq/huuYe6DsEQpSeDA1CW2yQOhBr9LUkFae2O/gUoAPqRQISC594vtPTipkRkq31e6yQE+ihXZv8752S5UIUKYKcw515C4f7RwDBGwk4tewCMxHH48o4LESpaM0CeE1gAToMKKUguyE2+XrOKCleRevA8q8Yq552UwLr8HA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4373.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(366004)(376002)(39860400002)(396003)(2906002)(5660300002)(7416002)(38100700002)(6486002)(8936002)(478600001)(6506007)(41300700001)(316002)(6916009)(54906003)(4326008)(66556008)(83380400001)(66946007)(66476007)(8676002)(1076003)(26005)(6512007)(186003)(2616005)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iQxCLrnGgGe+hgaMRmwjV2tD5iBxPdkXq7qjqCWU9uIYBXv2zRwFwF54/DCOfX0OFp38sIeuPNZdQnuKvQqfJJOhJWvSPufHgrl+vqVBixAn6EC7k+bTbWRcllnRGYpytHIkfaV/DUYbpQm4bW7FgTpWzjVeJzorV6zRA7VnhBPGJcAUqL4tPySZTpr8dorseLEZ/6uoDIj9dW+4CFVzD/FOhcq/YhhFDLLE0Nbh6sqlK2ZGSsy5h1+L70QJ7x16rUlyYylFidtBgAh8skq7H9acyV1pgTzk9UEP/PzaeI5DYE8zufYvt0ec4efy4UEMC25hL61N3Jt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NsqCOEx/Gfn+b/9R8gHG54XrOLf8d7gdihwcYeGiHJ+DZKpZ8rqphn8Vw81koi6NtL5giMVabuM1pK5FjkzrnP5Be/Py5gCbKikbgKKMkhDYlwElTT4gAwCNN50oUZkA9Hlv7KXgdbkg7oQB9JP5r0G7jVwc5GExnIxeo5mdmIAFeh29VptmUl3XjZgnqQ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a001035-6ff9-4c03-234d-08da90a70e68 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2022 08:00:40.2785 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xDmgB/autkY+XuByqfbBQOyI41+xyQd0e9NY5WMsy9cHleSZZrOthNkQQ2UiogL55U/js7/coWZZQk1DkCk8hA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4495 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 bonding 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 bond slaves after a bond has been deleted; see test_LAG_cleanup() in the last patch in this series. Add unsync calls, via bond_hw_addr_flush(), at their expected location, bond_close(). Add dev_mc_add() call to bond_open() to match the above change. v3: * When adding or deleting a slave, only sync/unsync, add/del addresses if the bond is up. In other cases, it is taken care of at the right time by ndo_open/ndo_set_rx_mode/ndo_stop. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Benjamin Poirier --- drivers/net/bonding/bond_main.c | 47 ++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index faced8ae4edd..bc6d8b0aa6fb 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -886,7 +886,8 @@ static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, if (bond->dev->flags & IFF_ALLMULTI) dev_set_allmulti(old_active->dev, -1); - bond_hw_addr_flush(bond->dev, old_active->dev); + if (bond->dev->flags & IFF_UP) + bond_hw_addr_flush(bond->dev, old_active->dev); } if (new_active) { @@ -897,10 +898,12 @@ static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, if (bond->dev->flags & IFF_ALLMULTI) dev_set_allmulti(new_active->dev, 1); - netif_addr_lock_bh(bond->dev); - dev_uc_sync(new_active->dev, bond->dev); - dev_mc_sync(new_active->dev, bond->dev); - netif_addr_unlock_bh(bond->dev); + if (bond->dev->flags & IFF_UP) { + netif_addr_lock_bh(bond->dev); + dev_uc_sync(new_active->dev, bond->dev); + dev_mc_sync(new_active->dev, bond->dev); + netif_addr_unlock_bh(bond->dev); + } } } @@ -2162,13 +2165,15 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, } } - netif_addr_lock_bh(bond_dev); - dev_mc_sync_multiple(slave_dev, bond_dev); - dev_uc_sync_multiple(slave_dev, bond_dev); - netif_addr_unlock_bh(bond_dev); + if (bond_dev->flags & IFF_UP) { + netif_addr_lock_bh(bond_dev); + dev_mc_sync_multiple(slave_dev, bond_dev); + dev_uc_sync_multiple(slave_dev, bond_dev); + netif_addr_unlock_bh(bond_dev); - if (BOND_MODE(bond) == BOND_MODE_8023AD) - dev_mc_add(slave_dev, lacpdu_mcast_addr); + if (BOND_MODE(bond) == BOND_MODE_8023AD) + dev_mc_add(slave_dev, lacpdu_mcast_addr); + } } bond->slave_cnt++; @@ -2439,7 +2444,8 @@ static int __bond_release_one(struct net_device *bond_dev, if (old_flags & IFF_ALLMULTI) dev_set_allmulti(slave_dev, -1); - bond_hw_addr_flush(bond_dev, slave_dev); + if (old_flags & IFF_UP) + bond_hw_addr_flush(bond_dev, slave_dev); } slave_disable_netpoll(slave); @@ -4213,6 +4219,9 @@ static int bond_open(struct net_device *bond_dev) /* register to receive LACPDUs */ bond->recv_probe = bond_3ad_lacpdu_recv; bond_3ad_initiate_agg_selection(bond, 1); + + bond_for_each_slave(bond, slave, iter) + dev_mc_add(slave->dev, lacpdu_mcast_addr); } if (bond_mode_can_use_xmit_hash(bond)) @@ -4224,6 +4233,7 @@ static int bond_open(struct net_device *bond_dev) static int bond_close(struct net_device *bond_dev) { struct bonding *bond = netdev_priv(bond_dev); + struct slave *slave; bond_work_cancel_all(bond); bond->send_peer_notif = 0; @@ -4231,6 +4241,19 @@ static int bond_close(struct net_device *bond_dev) bond_alb_deinitialize(bond); bond->recv_probe = NULL; + if (bond_uses_primary(bond)) { + rcu_read_lock(); + slave = rcu_dereference(bond->curr_active_slave); + if (slave) + bond_hw_addr_flush(bond_dev, slave->dev); + rcu_read_unlock(); + } else { + struct list_head *iter; + + bond_for_each_slave(bond, slave, iter) + bond_hw_addr_flush(bond_dev, slave->dev); + } + return 0; } From patchwork Wed Sep 7 07:56:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 12968573 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E572DECAAD3 for ; Wed, 7 Sep 2022 08:01:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230211AbiIGIA6 (ORCPT ); Wed, 7 Sep 2022 04:00:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230141AbiIGIAr (ORCPT ); Wed, 7 Sep 2022 04:00:47 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2077.outbound.protection.outlook.com [40.107.237.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A506B3ECF1; Wed, 7 Sep 2022 01:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OMELm0BPTyhOjJ3ZUiwNntwOaiUUUMCBSZDz5EgPSlAVmp4kJbF9Pwbdqv2oCWw33Vp6K4z4fRB7QiaIvCCziWeeITb2zcpGmjppCx/ZHyap8tsM1bs0s3V4iARbYTg48v5oUGe4FWL5jaTTZMjVnd+E6mBhJeLsKj1O37Cg9YGkx2i2jzbOXOgAmJzatmo1srLqospBvTolxwEITTKCMjDXxjgqYL+HOQR7IXwbC9ZJ70gsJCQoIe9bXQM/tT2rlL7MGUJg+hsVjvIXzHfIX0cwT3uQzDf5n/wiCu2y/P7JrVj7S+zQrV+2EWEfjI11XS309mfpLkR416GCB04R2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ne7JlujsLTX030weVXhC73h8Bb375qxQOqw5aWGT9c8=; b=Ld+bX1Yr80vltr2+tOzYhr/inDrAIsmDNQy1JiSCuaKpxrt20gg1GSno/+2mkw4wax+PXAUzsfHuYA9i328LlKKLTiVAakVjEBaMuffIKOnXNffjRSTrryMdFNvYK+fHkhuMluc2LZ41pu5Wni+0f+SLJm32Gv6/f3BlH6e/hOydF3uHr24uoRnj1s3k4kO9izOJfCmpNluDdRB8Ya1NqIKXNxq9qCWyRYa42ChFMHWSUoW6E16NGawvsqHTu1X85UVgPWVyavenaDTQViDI+CvJjyT0AYTOysFvBIRYWZbXzX6TUjrgTN4Yxwcqkx1pNlew6n2e0GFEnUVyHHfTuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ne7JlujsLTX030weVXhC73h8Bb375qxQOqw5aWGT9c8=; b=MAFmW/dUoPFFu6676vzW+OOXl+y1YapD+oH4QwDoC76DUzwuEfaluhGGKG6NB5cnuKbKgqIyn87jON+1Ia1gOJ+DUWdujWy79NCxHsF79R95hEzdEaNnN/7mMzgoI1/37kaZkbwJnP43XYbJgosPUl35dtmMqFQWvrHeD1tXD7qgZdppapx031xYjRio3FxK3syvAIvg3U4NEdJXh3mjfBw0AvU6Om7/eMnvsclKi5dkagQxoWP7Rrniub89bTZVs4ODSfbWXmdpZEDKWA7oeZU+bPmiftJ85KJZ+47Sqqmf+RsTBQ3nRCJLo8r6Duh5hYOJn2E513AUsI/BkYa/bA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) by SA0PR12MB4495.namprd12.prod.outlook.com (2603:10b6:806:70::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.12; Wed, 7 Sep 2022 08:00:45 +0000 Received: from MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::51f3:15f4:a31a:7406]) by MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::51f3:15f4:a31a:7406%5]) with mapi id 15.20.5588.018; Wed, 7 Sep 2022 08:00:45 +0000 From: Benjamin Poirier To: netdev@vger.kernel.org Cc: Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Shuah Khan , Jonathan Toppins , linux-kselftest@vger.kernel.org Subject: [PATCH net v3 3/4] net: team: Unsync device addresses on ndo_stop Date: Wed, 7 Sep 2022 16:56:41 +0900 Message-Id: <20220907075642.475236-4-bpoirier@nvidia.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220907075642.475236-1-bpoirier@nvidia.com> References: <20220907075642.475236-1-bpoirier@nvidia.com> X-ClientProxiedBy: TY2PR02CA0048.apcprd02.prod.outlook.com (2603:1096:404:a6::36) To MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ade152cc-e16f-4c42-937e-08da90a7114b X-MS-TrafficTypeDiagnostic: SA0PR12MB4495:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: w/M3m0WfcAZ27UmMjIC7jh773cmyIlUwzCScmx6oHXOBwOUCy/gi+pNzbIPl2+94EQBZBKJ/lW60fx+95w6oGp4VbJg6il+mxTYOMmW5JySHW6k+xFakZ6u/1+7fpgnRb3EXieHC6nnT3yWTjKMbl7JZf2iQRwi7+rVGIg2CjZyO6zqc6uJqOmYKeI7rJYFF7iqGd1eep4Sqdo3nBf2EWTws6xfwT53XZCeBMnoLqH6IV+MXxetxlcbDEC+8cV2LhmC21RVp6G4eZzj2ihMYaunBnTvYv6bPG2wwwcHKhf//uy19TGlNgOVlPUjzsXKjMunVDRfo01Zjhyib8S/nbc43ozQkfOhnjWRWebndRVvH78j5mzUsoOiqeR4t3Ab0/rBIsIxL4niewUjskuVYN7INox6QxXBHbNrG/RTzTf0bgx4Be7jAnPiPFEtKnd4uCvufsJD5v+fDdKzO1ITLOtVyGljQeTHYm5e6l/0gr73iFzlsAOFiuF5fDhenTiF86ikJ0rnUsP3SKc2lhujZF8tejRb3sWB+6m6aycvoSz+4lySW1fd0/XqeD6sD6uP45c0SgQDmsHresHngES3qrMxDWDqiUpsNGVM7kM9mJwbR4j/hykPaF6qEwPpJdgmEO1beQNvLO/ESyvi5l8wUe1a20F+LzrUvqoHy/2VNP6XH1DM3MMdYOdVb1s5afHuctnDsq99JphUEaUu41ksQPw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4373.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(366004)(376002)(39860400002)(396003)(2906002)(5660300002)(7416002)(38100700002)(6486002)(8936002)(478600001)(6506007)(6666004)(41300700001)(316002)(6916009)(54906003)(4326008)(66556008)(83380400001)(66946007)(66476007)(8676002)(1076003)(26005)(6512007)(186003)(2616005)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BwsKZyEJa/8D1LfNT36XWMnOsFFSdMGUNYkLqucKp52m6rgC9iLFaJF3TBcIow6qGopjxTb7HhxWLAD3CGmsVTEiavpYbPAIU+4afXeKmGX4a+872mBQX2LwVeVwSw+fAkPcwQfScmjKZAzMkDT0D9Goin4nKJ32KEE8SH8KyGjlF72pgx84GWl+Gg6BSNL+I0/ZlAoVaoKOfoEzQvgO19bUe2jphfgIBAHxPphc+BwWD3ICqHKmdNDDgtHMAwQ3EL2kavR9MV3q/UV34lkbkfdFYJYVfadgLPkSy0Aetqbhydbu8rQMSHb4lLJoxJx+FbQCyq/6+OQCZy5iVq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GYwG76hlhCKr5DtFZBIPZz41VShhYvoCOHsfUTDLbqcOv6Ps7Vt6eb65hd3sAd1rPN6uen+oCTp5QjsGKjeniHboN1c4u5otzvHyOqso4coXPNVj/NkGe5UAU7X1y7rahnNuEsnwqzNDFG+k29ICMh18aGPrNyml/oSj7jb8evzvx6jZSikccK/ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ade152cc-e16f-4c42-937e-08da90a7114b X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2022 08:00:45.1231 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HDS9fJ5OwSxzSgE/JHzUuyQ1K00i+dfdsRKWS0BMN9pMB7B+K3k4ubH1y6j/U+kWnZrA3UAyPhuXZ8xyRWNMAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4495 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 --- 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 aac133a1e27a..154a3c0a6dfd 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -1275,10 +1275,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); @@ -1349,8 +1351,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); @@ -1700,6 +1704,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; } From patchwork Wed Sep 7 07:56:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 12968574 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4558EC6FA83 for ; Wed, 7 Sep 2022 08:01:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230199AbiIGIBW (ORCPT ); Wed, 7 Sep 2022 04:01:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230207AbiIGIA4 (ORCPT ); Wed, 7 Sep 2022 04:00:56 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20602.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::602]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65A4C6265; Wed, 7 Sep 2022 01:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xy5lg5G8Dnb46XMH/QAZr6fgVGpL9/xsn782mfNs+pRIse5MNyrcINf+REIGVKZ6EqSRWMiFa9jAGiH/wsjET8w5rl1CIuI3rF/SSLV7XvXRYvmkuAHZMDD6RiKI/5PCvk/asg9INu26Fn3RptIEGh3SkHDwAiOXw/Cw1auhH2Mkj/xAhZlxqM7mYk5eEBIaYi/Vmk7sqCJwsbBlSFL8Pvjqd1uMRIewOMYo7Mg+EYbc1bfDVy3JDmR0jLX+czYPgi080/nMjRxupIOz76qJZAnAno2fuVOY8WBT4ldkzIwjL18jV5CgEHenYQuuJH923BQOfgtKHJmdg9Yusl/wQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=E1B6ud6q1XCCrN6bz9awYFuF47bAx3Jw5c5XtEjQSFo=; b=WBUEF0Tfha3eI6KtH4DccV/DnGaIyNUhcWfrIxUit6laHFjIVDSk9ye/z/kXjgyClnyYapb/FO4NoTspapJV5QZrdDZLin/eCV0d/hs4pCHSZiuTrruGxcv0VUIfb7VT0LAuXWxmlTro4qip6bShttq1gz7+/2RWee7KiV5Yg5m+YQ3v7LOq0t0ZKLB+ad9XT4OFMYNApIR1alqNxxZbVApzMRkGRia7Y5FjolQKVx6aHKKOa0BsuM3HpB2dEBd0kYMUMe0I3bPcCtBJbDobH0zvr7RAUv0O0hrAJiAkormPqmsOshHKL5i3kRVGkBXROIcOffTDijH6iCXNwy+ZNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E1B6ud6q1XCCrN6bz9awYFuF47bAx3Jw5c5XtEjQSFo=; b=Ug4HHtN1RsSwaO0al7cAoZDCJX86CowAaSaeJHU7aaJFEgBnGPkfKPpcQsiwf+hSDfVy+7NgwJoE5xbd13imMlEDX58Fmqv1YMf/FYEEGSiUQVFjrOjD/DSONIElPq+sV0CLa9jlGHsKSo9ValXwk21ZakicW/KQKtrkcTTgL4SNpm8fxw+DaLYDUA9nizgaJM+5jHRV4yRlZG+JOAYU2oWKaMsNWQp3zDJCnOc7J08Dos212tSI1ovhuWJfdikFkaiCdSzgoDVimyOQbON/an/9Xe1b+zHoKCrkwGVKG7kVyUBMSx8owyhIvFWM+bDcDyKI1LuXWWhvNhvRX7CAiA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) by SA0PR12MB4495.namprd12.prod.outlook.com (2603:10b6:806:70::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.12; Wed, 7 Sep 2022 08:00:50 +0000 Received: from MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::51f3:15f4:a31a:7406]) by MN2PR12MB4373.namprd12.prod.outlook.com ([fe80::51f3:15f4:a31a:7406%5]) with mapi id 15.20.5588.018; Wed, 7 Sep 2022 08:00:50 +0000 From: Benjamin Poirier To: netdev@vger.kernel.org Cc: Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Shuah Khan , Jonathan Toppins , linux-kselftest@vger.kernel.org Subject: [PATCH net v3 4/4] net: Add tests for bonding and team address list management Date: Wed, 7 Sep 2022 16:56:42 +0900 Message-Id: <20220907075642.475236-5-bpoirier@nvidia.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220907075642.475236-1-bpoirier@nvidia.com> References: <20220907075642.475236-1-bpoirier@nvidia.com> X-ClientProxiedBy: TY2PR04CA0011.apcprd04.prod.outlook.com (2603:1096:404:f6::23) To MN2PR12MB4373.namprd12.prod.outlook.com (2603:10b6:208:261::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b21960d4-2bd3-4207-3d1f-08da90a71480 X-MS-TrafficTypeDiagnostic: SA0PR12MB4495:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tUdnB+40/PSO2ngED+8B19IomqfbWpmxpNN4Ymd8hiUBEfS8ANwa00HAaLADmqPuiEWFTJXkvt4hYtgMhJBFQ+aHdBwNdQc2iMVD1LikCVZCknZyxS9N+JJS4sUhQH3ZFAf4cUx/Fn2g6+JIq1EFUcoeyLNyPCcBaf/OUA6X/x5VcgWWSIK22QlEXe7xgaFoY7pnw/VDHucIh6kRxYCw79ShCPOUPkaQQyaDhyEzWiLgMgzDsbdNNvykZaLJeJqb4pj8TXR1Mh5FlOGQSA4YDKRhhXIDcvcnsmZHTvxrw05EVOuXGE9ujqVqTy1JOqtItoifJmbf0BpTEUYxdUlf/hd00s2fq343fJ7E8O4sjgbwdny6mxLKIFRs6G/skDuE7Igvslvqf0yJr2K0p6mYt27VsNahk9ogxrifwf7c+1FZgZw41Psx6OMuiP6MPQHC5KkpmdPkP9QkmrPUBnQ8bM+UBL36UBBO7j3k+WoJx7vO6ghl9dJkCXDuSaYUBaWKyZBpzXQKyel1v/i+ikp7XucR+Cp1qIUHSDiz62hK5urn5jaNdblFs0x14mVJh4Fn4kHzOhwfHAp+mRnog3FH0FBZzlVnkittVPn3q0WEcPiLM+jsXdnX/B2eucYoyRw9ZgOuJuKRanyRjAiHCKEgGhx1qvi4YnM+txtSVwJMu6b1FqTDTUz784l4BI3TQm41pYb5tCIeNr5nqyUEHmq+tQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB4373.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(366004)(376002)(39860400002)(396003)(2906002)(5660300002)(7416002)(38100700002)(6486002)(8936002)(478600001)(6506007)(6666004)(41300700001)(316002)(6916009)(54906003)(4326008)(66556008)(83380400001)(66946007)(66476007)(8676002)(1076003)(26005)(6512007)(186003)(2616005)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Dj0yiack/GTax/dD/pndzc1a2RGXWeT2DHD6RA3RF810NFudCUH6hFe49UmsXevgylthOvR4JqA9ZN7JJZTftz414z3/ovhF4FkyHideC9gb+FjBAh0Gk8NRe88b0hEfnynl4U+TOhg/JZbL4WdT4hyn5ihsz4KA40IMUPj67fkMDes1JGyF0K2q8P+oYUGZlHtluF8YToypYCfY0d+Nm5DvLjjlyju3LvUPmdXOHPimEg0IcOeo6RL/97nXLGWJIy9w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rd58tXF5EpYph3dVh+uJa1ntKolQLDLTSQWijIQBJhtMFhA+YP5ytYH8CM3sbGBgVxbI1LxRPF4WUKRKtHZkOwh6O1lSvGdaR/Gz8KVE9VTvI1rrNTu9HZ0xiBc8CtTuMhJz07gcYjOQnOpccPMY+FLzBV4TT4nsSyczwIrCn+UjFoiGxTIYDNWyVLAqioec+JlGs/icbRQbBXDtt3RQKTeweFqQkmV0a5GJlO1KDBZg14fKB3vyDm6hoWPBpKmG6m94RgIs X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: b21960d4-2bd3-4207-3d1f-08da90a71480 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2022 08:00:50.6733 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0LFDCArG3cSZVC64oNbmHzqGUlVryoEF6K7YkzuFcUodnt1k9+hmOGImZYYZJD08dkN0pz28GBIJACw7PpDIEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4495 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Test that the bonding and team drivers clean up an underlying device's address lists (dev->uc, dev->mc) when the aggregated device is deleted. Test addition and removal of the LACPDU multicast address on underlying devices by the bonding driver. v2: * add lag_lib.sh to TEST_FILES v3: * extend bond_listen_lacpdu_multicast test to init_state up and down cases * remove some superfluous shell syntax and 'set dev ... up' commands Signed-off-by: Benjamin Poirier --- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + .../selftests/drivers/net/bonding/Makefile | 5 +- .../selftests/drivers/net/bonding/config | 1 + .../drivers/net/bonding/dev_addr_lists.sh | 109 ++++++++++++++++++ .../selftests/drivers/net/bonding/lag_lib.sh | 61 ++++++++++ .../selftests/drivers/net/team/Makefile | 6 + .../testing/selftests/drivers/net/team/config | 3 + .../drivers/net/team/dev_addr_lists.sh | 51 ++++++++ 9 files changed, 237 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh create mode 100644 tools/testing/selftests/drivers/net/bonding/lag_lib.sh create mode 100644 tools/testing/selftests/drivers/net/team/Makefile create mode 100644 tools/testing/selftests/drivers/net/team/config create mode 100755 tools/testing/selftests/drivers/net/team/dev_addr_lists.sh diff --git a/MAINTAINERS b/MAINTAINERS index 589517372408..4194f44e7bb9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -19937,6 +19937,7 @@ S: Supported F: drivers/net/team/ F: include/linux/if_team.h F: include/uapi/linux/if_team.h +F: tools/testing/selftests/net/team/ TECHNOLOGIC SYSTEMS TS-5500 PLATFORM SUPPORT M: "Savoir-faire Linux Inc." diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index c2064a35688b..1fc89b8ef433 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -13,6 +13,7 @@ TARGETS += damon TARGETS += drivers/dma-buf TARGETS += drivers/s390x/uvdevice TARGETS += drivers/net/bonding +TARGETS += drivers/net/team TARGETS += efivarfs TARGETS += exec TARGETS += filesystems diff --git a/tools/testing/selftests/drivers/net/bonding/Makefile b/tools/testing/selftests/drivers/net/bonding/Makefile index ab6c54b12098..0f9659407969 100644 --- a/tools/testing/selftests/drivers/net/bonding/Makefile +++ b/tools/testing/selftests/drivers/net/bonding/Makefile @@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for net selftests -TEST_PROGS := bond-break-lacpdu-tx.sh +TEST_PROGS := bond-break-lacpdu-tx.sh \ + dev_addr_lists.sh + +TEST_FILES := lag_lib.sh include ../../../lib.mk diff --git a/tools/testing/selftests/drivers/net/bonding/config b/tools/testing/selftests/drivers/net/bonding/config index dc1c22de3c92..70638fa50b2c 100644 --- a/tools/testing/selftests/drivers/net/bonding/config +++ b/tools/testing/selftests/drivers/net/bonding/config @@ -1 +1,2 @@ CONFIG_BONDING=y +CONFIG_MACVLAN=y diff --git a/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh b/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh new file mode 100755 index 000000000000..e6fa24eded5b --- /dev/null +++ b/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh @@ -0,0 +1,109 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Test bond device handling of addr lists (dev->uc, mc) +# + +ALL_TESTS=" + bond_cleanup_mode1 + bond_cleanup_mode4 + bond_listen_lacpdu_multicast_case_down + bond_listen_lacpdu_multicast_case_up +" + +REQUIRE_MZ=no +NUM_NETIFS=0 +lib_dir=$(dirname "$0") +source "$lib_dir"/../../../net/forwarding/lib.sh + +source "$lib_dir"/lag_lib.sh + + +destroy() +{ + local ifnames=(dummy1 dummy2 bond1 mv0) + local ifname + + for ifname in "${ifnames[@]}"; do + ip link del "$ifname" &>/dev/null + done +} + +cleanup() +{ + pre_cleanup + + destroy +} + + +# bond driver control paths vary between modes that have a primary slave +# (bond_uses_primary()) and others. Test both kinds of modes. + +bond_cleanup_mode1() +{ + RET=0 + + test_LAG_cleanup "bonding" "active-backup" +} + +bond_cleanup_mode4() { + RET=0 + + test_LAG_cleanup "bonding" "802.3ad" +} + +bond_listen_lacpdu_multicast() +{ + # Initial state of bond device, up | down + local init_state=$1 + local lacpdu_mc="01:80:c2:00:00:02" + + ip link add dummy1 type dummy + ip link add bond1 "$init_state" type bond mode 802.3ad + ip link set dev dummy1 master bond1 + if [ "$init_state" = "down" ]; then + ip link set dev bond1 up + fi + + grep_bridge_fdb "$lacpdu_mc" bridge fdb show brport dummy1 >/dev/null + check_err $? "LACPDU multicast address not present on slave (1)" + + ip link set dev bond1 down + + not grep_bridge_fdb "$lacpdu_mc" bridge fdb show brport dummy1 >/dev/null + check_err $? "LACPDU multicast address still present on slave" + + ip link set dev bond1 up + + grep_bridge_fdb "$lacpdu_mc" bridge fdb show brport dummy1 >/dev/null + check_err $? "LACPDU multicast address not present on slave (2)" + + cleanup + + log_test "bonding LACPDU multicast address to slave (from bond $init_state)" +} + +# The LACPDU mc addr is added by different paths depending on the initial state +# of the bond when enslaving a device. Test both cases. + +bond_listen_lacpdu_multicast_case_down() +{ + RET=0 + + bond_listen_lacpdu_multicast "down" +} + +bond_listen_lacpdu_multicast_case_up() +{ + RET=0 + + bond_listen_lacpdu_multicast "up" +} + + +trap cleanup EXIT + +tests_run + +exit "$EXIT_STATUS" diff --git a/tools/testing/selftests/drivers/net/bonding/lag_lib.sh b/tools/testing/selftests/drivers/net/bonding/lag_lib.sh new file mode 100644 index 000000000000..16c7fb858ac1 --- /dev/null +++ b/tools/testing/selftests/drivers/net/bonding/lag_lib.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# Test that a link aggregation device (bonding, team) removes the hardware +# addresses that it adds on its underlying devices. +test_LAG_cleanup() +{ + local driver=$1 + local mode=$2 + local ucaddr="02:00:00:12:34:56" + local addr6="fe80::78:9abc/64" + local mcaddr="33:33:ff:78:9a:bc" + local name + + ip link add dummy1 type dummy + ip link add dummy2 type dummy + if [ "$driver" = "bonding" ]; then + name="bond1" + ip link add "$name" up type bond mode "$mode" + ip link set dev dummy1 master "$name" + ip link set dev dummy2 master "$name" + elif [ "$driver" = "team" ]; then + name="team0" + teamd -d -c ' + { + "device": "'"$name"'", + "runner": { + "name": "'"$mode"'" + }, + "ports": { + "dummy1": + {}, + "dummy2": + {} + } + } + ' + ip link set dev "$name" up + else + check_err 1 + log_test test_LAG_cleanup ": unknown driver \"$driver\"" + return + fi + + # Used to test dev->uc handling + ip link add mv0 link "$name" up address "$ucaddr" type macvlan + # Used to test dev->mc handling + ip address add "$addr6" dev "$name" + ip link set dev "$name" down + ip link del "$name" + + not grep_bridge_fdb "$ucaddr" bridge fdb show >/dev/null + check_err $? "macvlan unicast address still present on a slave" + + not grep_bridge_fdb "$mcaddr" bridge fdb show >/dev/null + check_err $? "IPv6 solicited-node multicast mac address still present on a slave" + + cleanup + + log_test "$driver cleanup mode $mode" +} diff --git a/tools/testing/selftests/drivers/net/team/Makefile b/tools/testing/selftests/drivers/net/team/Makefile new file mode 100644 index 000000000000..642d8df1c137 --- /dev/null +++ b/tools/testing/selftests/drivers/net/team/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# Makefile for net selftests + +TEST_PROGS := dev_addr_lists.sh + +include ../../../lib.mk diff --git a/tools/testing/selftests/drivers/net/team/config b/tools/testing/selftests/drivers/net/team/config new file mode 100644 index 000000000000..265b6882cc21 --- /dev/null +++ b/tools/testing/selftests/drivers/net/team/config @@ -0,0 +1,3 @@ +CONFIG_NET_TEAM=y +CONFIG_NET_TEAM_MODE_LOADBALANCE=y +CONFIG_MACVLAN=y diff --git a/tools/testing/selftests/drivers/net/team/dev_addr_lists.sh b/tools/testing/selftests/drivers/net/team/dev_addr_lists.sh new file mode 100755 index 000000000000..debda7262956 --- /dev/null +++ b/tools/testing/selftests/drivers/net/team/dev_addr_lists.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Test team device handling of addr lists (dev->uc, mc) +# + +ALL_TESTS=" + team_cleanup +" + +REQUIRE_MZ=no +NUM_NETIFS=0 +lib_dir=$(dirname "$0") +source "$lib_dir"/../../../net/forwarding/lib.sh + +source "$lib_dir"/../bonding/lag_lib.sh + + +destroy() +{ + local ifnames=(dummy0 dummy1 team0 mv0) + local ifname + + for ifname in "${ifnames[@]}"; do + ip link del "$ifname" &>/dev/null + done +} + +cleanup() +{ + pre_cleanup + + destroy +} + + +team_cleanup() +{ + RET=0 + + test_LAG_cleanup "team" "lacp" +} + + +require_command teamd + +trap cleanup EXIT + +tests_run + +exit "$EXIT_STATUS"