From patchwork Fri Sep 2 01:45:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 12963514 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 64FE7ECAAD2 for ; Fri, 2 Sep 2022 01:46:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234850AbiIBBqJ (ORCPT ); Thu, 1 Sep 2022 21:46:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232014AbiIBBqE (ORCPT ); Thu, 1 Sep 2022 21:46:04 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2048.outbound.protection.outlook.com [40.107.223.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF5364D247; Thu, 1 Sep 2022 18:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QroIEvzqCy400IQtXc48znF9AtfVaV2DJkyHLCECrh0+XfPL/ibZh/91KJqvrtKj1yLsOuR0aD6ia+IA6fwgP4E9Xcni7pTjhxJCKRNGcxlMncan65xF/Shc3Iiob/Cdpu4wo1KF1oW8HPoUIQQhzaalohgLxGaaOByBKwmIoeaMi5UeEZfrcquF/L8xgQtWyauJ4ttBbUUhSvH2eRR+xs+cFMH7Hr4PkT5ZKx2XF9t6LU07hwM5mJyT9b6xPPmbTDvCeS6+5/MkAWiz14yx3LJecUy/QOR+nSLnfD6+fVZ39SXQCbq7PQTSwRDpbzcL+JKlEcwC93r6nezvv2XF4A== 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=iKl593y8Uf2hPkl6dPNKIROWiO5BgmCd4qFHFDQns/U=; b=ZKvTA925SLBm47/Kze1+tGJE9wZt7ntk7C/cyN2QjulmRzdZnBuyuWVEszm3dDg5s6hBNtxhW8gu9JsaCBxTZzdiVlw1rXRGGPGHBBNPK8eBWIodZ0sWoBjDD4ozL3peap4EJxnsZVs/s0v7KggA/o8MaLJXgrUP3OH3lU//DoGSJD0n+Ar7/0cUHE0en1OudsWJ7mbYl9055teCK7IdPQfjx1Eb503b/f1PPh79W/O05jFcKnhYhTZyTGG8Rko/x2ATk25iKjwZI/yC06E4WEv7BON3C/xfZz5vXdGx4/xRSrosWxWVILzuuyVj4BzV0eB/kJ2Y/i3v7pdfmmWLjg== 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=iKl593y8Uf2hPkl6dPNKIROWiO5BgmCd4qFHFDQns/U=; b=tzfSCcLqrhgiBKClaTT5+SVgMNObmxB+2j8PbwUPsJE+qmFS081xk58w7AbPhSyhqKRuh1I5yeU1U+fPEj61P//xMqArgnmNoc4ZAl9JRuyCjwNO/vZSS9XxiGUhBVHPsWBzGjVkt/eMpivDLJ6j+yxOpu8Qu7b1vI+lHZ8NF+/+xIRhjGIDFkfdn2D9apS7gcCrPwoeQxZrA4khKFwX5lUxdw+DK2qN8rzrbd7TCNhjAHvGw+hbyV9swd2EuhKK9BEW4CDgQ8kSvJrU/P7Biw9k9SQFKbJXeAR1gQdYCqdqBfsnh0wJy1IwQTypC8rAz2i+P/lXKSvrmL+/+13bGQ== 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 SA1PR12MB6728.namprd12.prod.outlook.com (2603:10b6:806:257::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.11; Fri, 2 Sep 2022 01:46:01 +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.010; Fri, 2 Sep 2022 01:46:01 +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 v2 1/3] net: bonding: Unsync device addresses on ndo_stop Date: Fri, 2 Sep 2022 10:45:14 +0900 Message-Id: <20220902014516.184930-2-bpoirier@nvidia.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220902014516.184930-1-bpoirier@nvidia.com> References: <20220902014516.184930-1-bpoirier@nvidia.com> X-ClientProxiedBy: TYAPR01CA0079.jpnprd01.prod.outlook.com (2603:1096:404:2c::19) 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: f3e53ded-8cb6-448d-dad0-08da8c84e3bb X-MS-TrafficTypeDiagnostic: SA1PR12MB6728:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X7XxsD7YRHqJtahugAWnRCa/b0eHyVa2tmYwIb0rAr7vnZ5ioB9xCrcqKsFgx/g2cU6fJFyKamYD2SFm2qwXx2Bo+R7wpdrqim/QZmE1csKrDv31VXyzLLPftHmJrgC71Vtiz47hjWnfGJOhHhKL+U5SANbOX94WOzSh9B67ZVuSdFIB8rscdGdEiZv5+8iKbtMPcd0uVs+n+Q6beZ+yNjSmjMlTeNfa0H83/P3ZgsqW6JDUgS28q4mdCeiYtf875ROs9yoJ9qzWZFujYbp+CsbCQzmrXde41l95EEYNbNzjeeOnyIVbCYSoMG7uEDqW91CS0ewxAEFdXr2sTvtr2W7zrt+5G8kkug9doINRAUiTvpYxh95N29e1JufFbc7MkUPu46PYA0FtMTqNV9/WyOVXkwbW1jaIItKBlzdClnVG4CvsVnZV+tkP2hCey2t5HS8/+eAzBh+C5bYABP3ivkMgY4ftriwgWXf/Jc6JkPlbwGauOiQ91D2HrviYrrbjWp+RpxVEdVoxiguknY79iRnXxvVSrKLpBfEszjfFsonQcPPhko79bhk8yFDcsByigICYrtlWx7zBzjhH4lLk2NeamSyVSYN/8vbBW28zO/ZBKKEjF5p6/9QeGnGLlJ48HWNAl1zuj+cijGFgpfkgflx/hS0OEHApBVZ4WQb6nDB+GKv9KdOGaIOS6bFzoHvsVti/dk6Hqbtbf+3NXR2r9w== 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)(366004)(346002)(39860400002)(396003)(376002)(136003)(8936002)(5660300002)(6916009)(66946007)(66556008)(66476007)(8676002)(2906002)(36756003)(4326008)(316002)(54906003)(478600001)(7416002)(6486002)(41300700001)(83380400001)(26005)(6512007)(86362001)(6506007)(2616005)(186003)(6666004)(1076003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ffHN/gPNewfG9nJAcMHzZbVpsLPXB2heNJE9OUQd6Let1IW6bDFCIUKpClFZB4QrkhN6xTeL/GhwqXyCiqTD8kP8l4bTfplOnXZgGtQ/mxl5qz5GiUCIpmmWxVdvHphtd5yaH6mAz4xaenzJdTNh2RX+P8zZAEu4BDvYx6F6+TDp1YeCptf/tiVb6+czUmb3CVv9olv2TeaPz/kgJ1rCjMtnsq9DSWwNHOF4gJYfEj/VpktqZc70pULLvs+J32o1y4OQdw08wMKpSgB5kD0lFDDV5aIJcl6HbDj8aU2j4H6vju0nAqg/Tz806wvuUrpYYOacZQnyWI4xlE53znCyzJOLWQpfb+hceqseCkXhoJVLlUu4TkPrULhveZcXLmEcLdybTJKdjHrgg2GBiaNVs76qX5yeP5c/JgJ6skqLnCugeN3n8KEmj/oXhV+VjC+uZw1BnKqfsX2ZN0wHnP3dqFF4fs1bO/QwljcfGzHSuIWpiy91wxx4MLgozSRv13ieKoClWn6LsfnHwpbCdXGpy32YQILUKX3CFrWHOHkMZ2DoKaKS9vf3xE21nd2haQ6+jQhiuIFTG0yVvBdvyW7z2qbljTKlYmtvtCE36To78oyPFKQ1G8gW5DHeF3nIb/W6y12LnVvmGTOPlPOY2pHLd0mO5qSQrDZ3Lh1cQFaJ/iCpGijrxy5Bkv2NJMOq8BaMGGEkWg2J+cvukz05B+z8xtWtqI8oDX+sqz7btZVXkcAoRCZHotSm50+SvaHOTHXETSSPf6JUaHH0Az2tWqpgen5/okphTjgx+6zIlwFV7cOLUeBXm0X+tmPQ/rzLJr/JBAxftqfb+i2uP/RqLsh2rIMI/xQQh2lpl3U2yagIsQxfNcST9ua3HK2MbwgjbuCd6qumRycfsmvXKrArfguUuBpJg3n4TtrOojFbDfgkI/o7uWzjCfiPl8YnlQZzAaAcFuQWX3VEwvV4Tah2/u6ovO6AVHC0jb8FFyQnFNETAwpccgjJr6yrW8x89ph++Fmb1KeSRmQ/lElUpjKfA6KEMBc8Ewz03id7CWsTfQDWpd/ricsIsk9Jq/qPBoZJgXixit3XV7PdpipFIZMJ7JM5fpyvHnIHfmnqzYlJAXxm34/XIIqlF7hFNdFYfkWb2/CvFbGQCzJEE2aFDsxdPgn3j1OB8b77rPbCdmy/ybnTOh/2aX5igr5a0TkUlMXr6XKC6UjYELmk+fUAeb0MCeRx4RaZScqGdxcnCu4W3PiABC7wRDnxaq2DHu2JM1NCOXIBLz1somFHfcN1lrb3wbK2CGmlvctVJ0YVg4eiBz8QEjQ0QGI1JhLyfMYCvLj7uxBUGOGJ1SNQj36EkCP8H04PzzCNew/cdftE5C5WAsvGy/Etu3UOufjGZEN7+uRR/Z6oJSN/WCGMhy5AsY28GNuthZqOJs1SYcZkKuaI5OtJhrDH/2u6SSDCv5n9BHbA40J5KYcRx2917E0WXpUhqhFgRper1PdQndjc+g8FapfUs54fOP1SFr62nKqSGwP5IM6qGV5f9lEPtsMgXdu11KAXkdgV8W+xslhRfbusJ64tdsyx/LTDm+3DeIxlTIFAwIX1 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3e53ded-8cb6-448d-dad0-08da8c84e3bb X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2022 01:46:01.2688 (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: lrrhCPSvDXUHzdFUyc8f0RYW8QWCjKdFn3d/lp9CO/7b3njd/BX6MKXxy3z/yZQrFOlgUI/wb2BjARYznXH7iA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6728 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.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. The existing call __bond_release_one->bond_hw_addr_flush is left in place because there are other call chains that lead to __bond_release_one(), not just ndo_uninit. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Benjamin Poirier --- drivers/net/bonding/bond_main.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 2f4da2c13c0a..5784fbe03552 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -254,6 +254,8 @@ static const struct flow_dissector_key flow_keys_bonding_keys[] = { static struct flow_dissector flow_keys_bonding __read_mostly; +static const u8 lacpdu_multicast[] = MULTICAST_LACPDU_ADDR; + /*-------------------------- Forward declarations ---------------------------*/ static int bond_init(struct net_device *bond_dev); @@ -865,12 +867,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; - + if (BOND_MODE(bond) == BOND_MODE_8023AD) dev_mc_del(slave_dev, lacpdu_multicast); - } } /*--------------------------- Active slave change ---------------------------*/ @@ -2171,12 +2169,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; - + if (BOND_MODE(bond) == BOND_MODE_8023AD) dev_mc_add(slave_dev, lacpdu_multicast); - } } bond->slave_cnt++; @@ -4211,6 +4205,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_multicast); } if (bond_mode_can_use_xmit_hash(bond)) @@ -4222,6 +4219,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; @@ -4229,6 +4227,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 Fri Sep 2 01:45:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 12963515 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 9BB70ECAAD3 for ; Fri, 2 Sep 2022 01:46:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235121AbiIBBqP (ORCPT ); Thu, 1 Sep 2022 21:46:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232014AbiIBBqL (ORCPT ); Thu, 1 Sep 2022 21:46:11 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2080.outbound.protection.outlook.com [40.107.223.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 313FB4F69A; Thu, 1 Sep 2022 18:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hqJ82GLr185dKLick4ViNxBHY9VxG/JN5mbiAkjBCEeLf5al2z0webhJdI9iN1iUV95vn+y5QiCBJdZ33RZOWeq2l5GZR8Itr5PHdRB6ULksdZb4KpCnR8N1/Dm84WrMlAbNBy6C7pDrzXKRIMFsjBiGkgiRW2P2s/P6/dX/qcMw//Bj3ba1QbJmhjhAohhCh8HigQFNv2CKb14sfdzqJf9/fpQ8dG8hKYoVgmNN6812QLTStlCYL4kWxGDOiHcGmT9KOicZ6hXVWs4EwhrMNYTRLYAwqBg4OXi44/tipYzCKxciIHvrVIza+06UT3Niih8IxAjhGkcudpe9V6PD+g== 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=1L6OZgg9hBioGlEQ7oWb0UtEQdnxDWuOUqgrbjvQM9g=; b=nDo4/bi9/7XIfd1+7LplEOn60Bk3kAY2zE6/6iltKJmKB/RvBimnicdVluhvIcCXQhJcCmKzPoAgQht9JYDUeKASgVA6F83OtXNJrT3GfDwVBVqFM3HLmfmtGzrwwi+5Ghp/DkH0o0rqBcP1+vGQd1knNx0EykbueQAYBxEoEJAn0mr/EsJp1QEr5LjuOIyJzeDR9ClyNiulJaSMTpqnTYLmUwvBTZo70SE+D7QMq5x8ecPPohpKKKjGMbDgWujyYaFttj4APzwZ8GMYe+/VYZ9+pnLO/Gt65sTNM4s3ZqlAKAJupkiitQKJuRvtxWn7KxK7F6GpGQeDkX9HByfThA== 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=1L6OZgg9hBioGlEQ7oWb0UtEQdnxDWuOUqgrbjvQM9g=; b=LEWNvAziuMijeNK32qxrHaXH8kci2ZT4GcgmwlJCOZk7BxqYP2p+NRX0g+l7moLhagUfHrNMxvMuDrq2lYgU9mcqF9p/25gRvpwrKvvg7gAb30eWkZXCar7Ou+YPD3GhMSF6u8vXwRqDaX3ueQ6vfJCs2NXa7+xUAIWv52KCdOP87uyPWC59/R2atjKvVdT8ovSizchA57U9RBjmmu1pwuP+ik3Mhai4doqMDo0dl8E7ILjks3zjvIaJ1jhS7GBuwjwMyCKpcAGXBfXpBiuzOXek6B/TZokHmtqegu9jxNF7lmAhNBBAnNsFDZMGOntv2UlOF3La92dW8IUXF4p8xQ== 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 SA1PR12MB6728.namprd12.prod.outlook.com (2603:10b6:806:257::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.11; Fri, 2 Sep 2022 01:46:06 +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.010; Fri, 2 Sep 2022 01:46:06 +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 v2 2/3] net: team: Unsync device addresses on ndo_stop Date: Fri, 2 Sep 2022 10:45:15 +0900 Message-Id: <20220902014516.184930-3-bpoirier@nvidia.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220902014516.184930-1-bpoirier@nvidia.com> References: <20220902014516.184930-1-bpoirier@nvidia.com> X-ClientProxiedBy: TYBP286CA0002.JPNP286.PROD.OUTLOOK.COM (2603:1096:404:ce::14) 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: 1d7a5ff2-164f-4e89-328b-08da8c84e71b X-MS-TrafficTypeDiagnostic: SA1PR12MB6728:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hjrYuHoEJo9i/DWvMbnrHs1kqcRjl0QapCR0UNluqRzCJLDBlVwTp9oUhVgQM4HGrASgRqItdF9jMRoFzhDOAa7cHM+nBVXtnZj/Az8TI6UyYW/fkTzio6kEEcEmSTji8puQzGFV5dZ01tt6vjldMgm69/1bRjq6+JmD2cMSCwf9RqCcaH1/gcFIXZRwwyugrOeFuxLWY/I186epZN9lXzcBOR+N5uEPA6JR4P3MNj992MwUjhso+LiFft9a56NdASjm3gy55mpTdNiujwhRn4KVAciT0YrWqu9RWPPMnwxQgrLF2ka3fTNPX3hZmSFkl7/qSUBhg3iiqBAB/nZ0CfU3ssS2kVWAtM0DVjwn6c5IGFiynCCLjXdNRnM4xFU4VH+VuIea6uMuFJghRss7vIhzblniMuiNAO0OfTdzQH0MaW+mgq4/SKlqZPP/BXOV+PdQIsuVvHpbToQ7J89+st/oBSmJfhnqQGptNplpnxE4yNaukpw6bTMzXofgnL+L9XT7wh8cXZpylUHDCFJbHmw4v6OVcBjDZDl4ezM49suh1qY66PWj214KvzXCFP59t8O9cGFNwIX3/T1aWhU5cusc+7DoSqmjBlNeEEgF2GgGZq0nNqeRvl2OSs6PsEM9HuOw0xpSoHDCLHG6xFL6zmrOxAAr2N9U7JDDECxn9QpFBjmDPFAZPcr9gUFIor3w50jvhR7pJPRsrdZoCspW1g== 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)(366004)(346002)(39860400002)(396003)(376002)(136003)(8936002)(5660300002)(6916009)(66946007)(66556008)(66476007)(8676002)(2906002)(36756003)(4326008)(316002)(54906003)(478600001)(7416002)(6486002)(41300700001)(83380400001)(26005)(6512007)(86362001)(6506007)(2616005)(186003)(6666004)(1076003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WKMoC2wgo2xx3A+/VMmXSBpvOSS+CJRePD1Hw04N5ER98g75FbqKptbfq7toB8oPmKqLw8dYFF7EW30xNDd+flDp0QKDvYE2VmABj9TDr7gzFVnXr6Pmqfv2Ck7NRemAupMyxv+gYqNyJrtSu9sCB0aDhl9PBU4tkQdO6+w7X68fMa1FZVwZr0+kD1Qfv0B7WPlkRe1wB6PRiq9L1uQp39wYMMvmsXwK+LUwx0ioyIH2yoOXUXWHyVMp8uaacBFs7/q5wrgEEUhpEYHpZ7NavNfKKL4VhKgxcrooRq87GGbaq1UVwatfgia6BouTdUbI6jMXGUuPjfNaKDwxEiOg94FtdaY/2/lp9g4PeNjohVAvalfrrKsiyO4JAAD7t9M7Y/zUawXb/gJhABl8nGOwSSpxk0E50lSrM/TrpDmSwcEhl29dQCS8VfoOhx72y7CloY72ChmXQyiGHFIrkKY7N9bX0bAfttbZ7HN+DGB4Utyclw1zn8NeH6tfKjLw+6nUyXxFl3hBlQpWxVBm2iJ8wsrvh1L7cktDU7qx0lSakhK1CBckyHqXDXs9mEASvQ/r2jTHDx1dQz3urnk/mABXCzbs/x94hJ6pGBDc/UUrGZVhNKckS0SK1pg6Uq2KcVDXylqiMc2tMeSy8BAKR0rILqb1lkjJUb615SSMftigQk2yKn/+n0HfER2mLhM1vjQDzsc42LFUAVpB0Zw167FijP9JM5meYG26DDOcUc5pYycaQFs8v7LK5AxMQiFAMIDQ6yDO0FziBiyxMm+eanI8j7UNu7iwy+2EvWOGLZNEPdOBKOQRztJOKcC0qLIIVnHQFmJfhY+3aiDndsTj8miIHf8G7M64w/WGm9E4TGpKFZpNTv86jEMQpFr3beA0ulRaLXzyo6HSB7OJh6vfMkk/jsfpZBQspx6xtpoFTrHbHdadzKiJazNR0OXckSkURV7GUQJqm8PDA1a0zd/WyWAhx8mzaoOyWoTsSgUOW3PrXqV5t32yMWeB6DEtGR8h8NlQWbkkFzt/avyCTMrLQKhO7wGSH4NJEdJUTeq4e+1zMRdDDiflgu14sDNTQQDw9uY+N09RR/NxK5nqKyypJfxUnyXkkynZDD40CpCR/Xf7maRvREnwZ+eQo3V+AMaGnJp+qN13fEQwnu6+qsn/lOPGQrxlkKHwqIhE867o1ldDTTo73alHqnwaHk2LYmbw3MZ4aCPEhGif7FYNjSXwYmwBFGqc0leCS2D0SdU3Txs1Y2Mg19ev9AkxYVfdnQFodqthd3rfTbx6ejubwdGct/mtesgTTgIsYOr5lPm8JeXEs+jSr5AfyVRWJ5KlZOM1UhB4IubJvaOl0f3aapiInqMSZbrXVn2kkBMzvR2u58Rxd0EEHkPAKcyQNonF3F/sDS7yE1XDs3LefQYKmD+Em1UOxn9K6W/QLqNUp2oVRfzHqktYXCjlbuGMq1o1za4jDjFKq35LpRvReYDtJnGPbmLAWob70+4I9+A7LZVO2nADIiOVIIae7h1AAilFiIg84UR8M7K5Xp/W+Jxofx+N8Epm8yI8uMo8XXlXPXUX+FJWyP/rw1BOC30Yo9HNEXlZaEsZ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1d7a5ff2-164f-4e89-328b-08da8c84e71b X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2022 01:46:06.8812 (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: IiArVPZ/bnmdlnGN/3vjNAvFIQbmdKAwuj45QhoeYgtze318tdieMMd2829s8yst7qUPlVEQfRrZFZa8h/6XSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6728 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.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(). The existing unsync calls in team_port_del() are left in place because there are other call chains that lead to team_port_del(), not just ndo_uninit. Fixes: 3d249d4ca7d0 ("net: introduce ethernet teaming device") Signed-off-by: Benjamin Poirier --- drivers/net/team/team.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index aac133a1e27a..07e7187d46bc 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -1700,6 +1700,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 Fri Sep 2 01:45:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Poirier X-Patchwork-Id: 12963516 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 635ECECAAD2 for ; Fri, 2 Sep 2022 01:46:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232014AbiIBBqS (ORCPT ); Thu, 1 Sep 2022 21:46:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234977AbiIBBqR (ORCPT ); Thu, 1 Sep 2022 21:46:17 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2074.outbound.protection.outlook.com [40.107.223.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26F5E52836; Thu, 1 Sep 2022 18:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GjM2xa9SZZASavsNUIdMDTKoV6TJFFxsXMRwnERDyq+c1oMjbMhQs2dB79m/hQN96FabDnTVuWje3m2bEN36yOW7/MlvT5GF7Jp7gsM0scJUCe4YuJTsZd8eJINC5gExUM+/kAWlpLkQKpNIqITtoQl61e9B705/rzkoHGbj5dE40GmYvBLbHcFbxqBKQcpr/NUzYLGNeFt0QhHFumhbryuAxQz/mi7EXWXW81UNx8brdzZLoU9NontGhH6dSg7BGXuRAAuPwRkzBmmatqCNa5D33sg9CGFvSH2TGo+8GEZ7jEan/kthbcrhL2lcL16qfjVbrxRf37KYkxQiEB1trA== 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=XTqQ9IldZBmOjxAWJDSVhg7YAZi0DO0DgbP3ZO5o9es=; b=Y9oRo0VD+gX/Dnv+IDbZXXlbkjXTfCcEmZ69nxQ98UKV/QPTiDne+XO39Px7XKg49OuioJD8cS90fvnX4Gsc1LwCRUbFuYotnRealtJI4EQHjeKWhOibFUzRLSer22gxU+JJL5cen17ZpyBioOkBRBXWqM35ESKOuA7rGS7DhU8ZnsgD9Iaw0FKUMJhSDz5v1dLosK+lBeOnOZFu+03s3ZRmzFbvmbrcZU8vQDKy1NsEbqv7dkOmsHE08vmlPQkncIk9YGFC4BS1wIhFCM3QH/qNyMaXMsDQF8+ll5oygwRRyBjisc0PNJ+n4xfHxEOx3xBJqy7op27buMcBYgFx+w== 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=XTqQ9IldZBmOjxAWJDSVhg7YAZi0DO0DgbP3ZO5o9es=; b=Bv9fQgvFd9PNvbuqDR5AipSCv9rCuxNgg7HIlzn/ZOWby/LR9jGkatEo8t92tlKSuRCX7r2EuLkHBJJykQM6EAikUBsMg5OAsBJyuw2WIYvlfH5OaxLupTQzkd7MVlMEOJaCjJMPqPPmPsP4WZK4L64jCh0vauy5Xr1aDCp7wuPPWQDJ/nYG9fyQmbdkGZJPSJKpTD84tNSlw6LIKkQ9UpCE8ln+dIG++m4pITfzTZs3uTMAYnOIN7/vywVfbtRDMLgQXbLbxurKWZ5f4ur1zIkQwsqY2DkXyWQERRtWw064jMQ8BiL9MTwRb21YSdEweJtUjcmWV+huw//E+HC2jA== 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 SA1PR12MB6728.namprd12.prod.outlook.com (2603:10b6:806:257::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.11; Fri, 2 Sep 2022 01:46:12 +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.010; Fri, 2 Sep 2022 01:46:12 +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 v2 3/3] net: Add tests for bonding and team address list management Date: Fri, 2 Sep 2022 10:45:16 +0900 Message-Id: <20220902014516.184930-4-bpoirier@nvidia.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220902014516.184930-1-bpoirier@nvidia.com> References: <20220902014516.184930-1-bpoirier@nvidia.com> X-ClientProxiedBy: TYAPR01CA0225.jpnprd01.prod.outlook.com (2603:1096:404:11e::21) 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: 29ba24d6-97ac-4de3-9c87-08da8c84ea66 X-MS-TrafficTypeDiagnostic: SA1PR12MB6728:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GaCpj0qPVzdfB5QqXqm397HD5d6pYcPOGXLgowQOftUkQSp3AbxmobYHg8JtfoRbuJClPXYzZKew9QJxBNRPpYteobsjjnaIdCH2q0GuszXOtXRiONvSxPaOULp0Q0n+tV3/viSaOkODpX26qllkeajk3b8Qu2JFBFvtouq1X9c63YaGvleq4xT40JIruY8Zjr/MM+n/3DnzdUmd2NYw5gC8xLFsuSevh6dmZDQCl5dj9pI5TYmh7dbnONshHikrK/jlE0AjEeK1kfdoLBCgHt/yfqTq2A3o1u+1iCUoFQKCWQBrApi9bwDfZY0J7F9EUh7K2nupEnaZohMqOCJOxfuTYVwUJ+m/BUpfmwH3BXmASfPqndAGkUVStF0hHN3nXLajl79n5YXaIDljV1KW3pjU3FXQrjaRSfvMFDTDnRmGm/yY+MjvoUruY1TekYSXsLgwXYzROd/+PprQiwXfRkEI0simI/OjjZ1HNr8hRN5zGjOKRyaswj7oFSNjWX6RJ+fRTwU65DCe4SFAV2Uau9X4Jyla3Lhl9LUoQcNnNHDHEbMO12elQCpZDvzBSC38fOjNKah1MbSSTAi9w8xv7Uwm7uM7iG3/oO9q6+SKEJ0/cCoKXSKkHQWgxI8ZdpVBf4RZXKwn3S5j2O5h9bWNV/SkKv+fwVLbWkkCMlEN1/+ZIAo4+LEFf6Nkjf6ci/iv1IXINHi6EWxL3azUItJWkQ== 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)(366004)(346002)(39860400002)(396003)(376002)(136003)(8936002)(5660300002)(6916009)(66946007)(66556008)(66476007)(8676002)(2906002)(36756003)(4326008)(316002)(54906003)(478600001)(7416002)(6486002)(41300700001)(83380400001)(26005)(6512007)(86362001)(6506007)(2616005)(186003)(1076003)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jVEOEN3aqRZQywfalVwE0Q8/TVmMqM3MS07eSm2CjC6S/dzZnoIK4LS+apo8vxHGSiNMTZs9fSDoE516kW0jR37CPpGqS4VGZf/Yor84twjzDUeA7yoYKMgnqraNP4E+Pxhyy40SnXwwAd56h+ZcQGxmIpfJ77jEZBs62dCretb8ewMsi2UqJ0kpdCZRvMuj7SNN2wMrt+v2H4KsL4j+rrxetLsxhr6MY5Ib/F5ITHt+xToP5f+LEmj0ZEzRIetJVP8ApR24nykIu0Q9O16IasMqm61Qp3M3GqvvBNo2eyBvSakGTVfmUvngosWvBNbOZb0n2vTkowDAi3L+pC+FaQNI/gWID/iNy3yYUS3SwAyvD51eTE37Pz7RSllUuxKxMrVQwHBgh7loCP3kpKoFR/XEk3YoEb+jrD1N29VJ4djw1wMSWziSzAyE86CjfcKGk1P9mGRuwEOBvT3c+fKf0azOpulp9pAaUca6n8Psf8zIE7EpyYw+1AJJz+64fe/STWGhmPEGVqHDI//lxN1+MEg6EEf33b10cB/HZfUVks2C3CA9KCjdo3ezhzAzBFdnPIaQ5BEJH5INEL/zVBzVVAU2oCkkOKekrQKPnd83cTaXzo84xnab8uF1HoyqhhHh//vfZPMUFSv3jtChcegKVjOml4J8C8V7FAqZtTX8ECeAhXq3kIDjPvPNVht+6I4sjDPJU7jA/EL+51wQAYk2vNYmw7M00f1+uXMGsbkMlrNIx2/N4uFBoIFJMN8uIuNnV4ZGYSeu7ox9zVLsm+Gn0pf9NGIvXJJ3URaiRGLaBquGsHVqODiELdDOTTI4qEapcyTvN5lWys1IbmJpVRx3GoPR9L/8+NLznJmb6gdUiwpMvPXD+llc7JsoCyKZ96w1j8svqftmrKg/7zKXlFODnyulsup7P6s5NcHCLmsjmCg+WX//ccaJ/akCGYuZwDMubsiccQofPpkNXBFfv7AKOTU/CiFhr7aye1yxkag/RXtKHAijPFh3l6nnRUjPT4PMfyRZcOzaaadLr4a3K3r23fsx+vYCu0gywTY/SJNr9ZV3qG7HbkMwtlYwKVlc4IQh8WUSMVOTkRDya7HQW7loKhZv0GcRtrzEaVinSR/OWxzH9Atz9TvpTSce4cBpbjBnKJU3rtQvKXbSRTBll47WSyQdQZx41aU28N5MNpAN6ahEkHi4l/Ly68kO5g9p0w8CJ3cWZz5xuiom7/VqJufTU0z4Y82yvzWtdXWRcDzsLBIH34EUJ9fFSx1jNUNk8ynmYI0Fm1fAv5DxYL2TtqXbpLoGsefGW2zGGGzDGFyEezTARPUXQ0up9oZY/QJcjRn1X276HTszHxE2wgZGd9eaQ2CwdF0cI9JjZUfH/c1xKy1no54UVwG2CGqSqZ2WVCvkkhEAmd9Dj2TMTZ6y5Wcj4TfzNFSgHWq3uYjbZpdMVtvGuRBfMy9syayMAaL7JkYzU5N+diFvzQT9957GKEHUQcmuFYLYckkY9HCZem3/awDsRR19DN6SOyuujZ4TRdQFxo8lNUQ3rTXaZd2q+p/5/58mXHcppSwfodnv2pRPBZS8MP+TV1Rosujcpryxm4su X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29ba24d6-97ac-4de3-9c87-08da8c84ea66 X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB4373.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Sep 2022 01:46:12.5479 (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: bUjQBuY7Rwr+FvLDqXEtaMWSs9VTv+AHTDouvw42xojUlbAjJL5OEzgqBiXohy63JY6fHDbslvuzUCe1DPvTwg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6728 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.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 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 | 89 +++++++++++++++++++ .../selftests/drivers/net/bonding/lag_lib.sh | 63 +++++++++++++ .../selftests/drivers/net/team/Makefile | 6 ++ .../testing/selftests/drivers/net/team/config | 3 + .../drivers/net/team/dev_addr_lists.sh | 51 +++++++++++ 9 files changed, 219 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..47ad6f22c15b --- /dev/null +++ b/tools/testing/selftests/drivers/net/bonding/dev_addr_lists.sh @@ -0,0 +1,89 @@ +#!/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 +" + +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() +{ + RET=0 + + local lacpdu_mc="01:80:c2:00:00:02" + + ip link add dummy1 type dummy + ip link add bond1 up type bond mode 802.3ad + ip link set dev dummy1 master bond1 + ip link set dev dummy1 up + + 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 "Bond adds LACPDU multicast address to slave" +} + + +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..51458f1da035 --- /dev/null +++ b/tools/testing/selftests/drivers/net/bonding/lag_lib.sh @@ -0,0 +1,63 @@ +#!/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 + + ip link set dev dummy1 up + ip link set dev dummy2 up + # 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"