From patchwork Tue Oct 22 14:50:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13845776 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2080.outbound.protection.outlook.com [40.107.236.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 978807DA7C for ; Tue, 22 Oct 2024 14:51:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608690; cv=fail; b=SnRorplLkxczJqI1CDukzKmiqRZ6mf01ETh2ex4kipAYyF3A2/iHlXF76plOXyTbX8CAFDF1rBnQ1lSHHL3n5BHRniTWnHiFKOsK29aYck5lcE+PUCLwArJ6TIchJbdv1wV29lNU332jitnlsggtAGY03Kc74tmxA/WurOIrWdM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608690; c=relaxed/simple; bh=Dlrg+iYoc3moCw8DxpDWvhJqMUBd4eWPwzeZpX5XyCk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nltTlmmpQ1Ojh8h4SmIir/alvSTIuKhqHCucjevBLiecsvHcgCjuKKkUu8RXMniq1nT27w0Bh+Y/KsiAlz16oqieyVYBwWMeCgLlUeShu7/aG/y5qJSgDXBhiiWvzGE+Rx8OMrnqVZ3BX8493lVZcSuNIPQC6+HOl19NFUKW49c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=js6AWYLK; arc=fail smtp.client-ip=40.107.236.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="js6AWYLK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rHUvKmkFCcY25OSbshkRwEtt9yrY5hqDYTrb+kBd+gD7MfUFXAQl0emBa22W6pSsYTCNQgU3ui4UHuDSVzX5S6FSxB29UmG6jADexjr2Vj45HL7Whvqu7fqhd+vLPn6Me8LACFXAHwh7hqJFAofyJipCloyo8o1TF8rmE/f1dUJWuAua5Tfpsrni/XZev8owV7nQAxwuQYzpdN/GpoDcyOCxosJs0JCGcOh3T69ZdeMRgcH3vs3XmZPFg6CdBYQsNs8LHvxNZpMDSgIFYRnyK666FtwTLbmjYw6MwuiQ+fS8V9SYWkBvGJb7llH+a07QEiMTkkfh+Sh2+iTaOfjB8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=hIO3xvGTf22aCNfqHakyJgIhITzblk8urTZlYt9npWM=; b=bMhofnhNSbMbJW1WMxqApTeLSzSykXvzTTpBhXW/8eE+6ouHgBKDHTMQZKGbL9QjJqdPm0Il8DwplRqOlueTx5DzW5vtr8XDTlxCRPfDt34XWxWqVBaXxiqFcySQVlPrj9fm+Omz7slAxn5ie7moghDdeIZZTp5OlONKpAtRBT/f9yqX813e0y3XHfxGRCeD5mL5xK9vlZHPkVc25iAXqFnZazxB7HuBQeLw96V5LLVNOjZyz2kpq/zV16jt3giWdDu7EkGfS95A9U3TID6r1TupVtqe57FfxwSZhTtAZYSqDuepH0HWjgQNFk+M9v9jX8RWQpGHh9cWMm+rI/smCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=hIO3xvGTf22aCNfqHakyJgIhITzblk8urTZlYt9npWM=; b=js6AWYLKWynmLBMQzFuvH5/tLPmKtRpYj1FtArZ/ikET9k4CIbCq5xzuElogIT2DHfshyKK/CiD/IJ2KtrT17ZRmxrCQlglz29GzTnJAf6LVY3dt1XlnEOupnjC8aeTqTXRpOwp8+EkdU3D5Hu0/mcbd6RWcDBSQlKWptWVZfHketGmheu0K4TWNwrEWaQv3PbLhZ4/64rO2oaLKijQ3QSfwDpjd4OiMolw0lBI8ZFAT4S8SKgeWwjoiTbxVuyDxuSehMqmGfjkCb9ph64YhW28YB7GDEQFH/ddMJkDUy+GLgM4rGDH2DFADdXbQrzFVCOgtBXU3kHr0J/+M0Rf0Ew== Received: from MW2PR16CA0030.namprd16.prod.outlook.com (2603:10b6:907::43) by MW4PR12MB6949.namprd12.prod.outlook.com (2603:10b6:303:208::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Tue, 22 Oct 2024 14:51:21 +0000 Received: from SJ1PEPF000023D7.namprd21.prod.outlook.com (2603:10b6:907:0:cafe::11) by MW2PR16CA0030.outlook.office365.com (2603:10b6:907::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Tue, 22 Oct 2024 14:51:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ1PEPF000023D7.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.2 via Frontend Transport; Tue, 22 Oct 2024 14:51:21 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:05 -0700 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:50:57 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , , Przemek Kitszel , , , "Manish Chopra" , , "Kuniyuki Iwashima" , Andrew Lunn Subject: [PATCH net-next 1/8] net: rtnetlink: Publish rtnl_fdb_notify() Date: Tue, 22 Oct 2024 16:50:12 +0200 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D7:EE_|MW4PR12MB6949:EE_ X-MS-Office365-Filtering-Correlation-Id: 3421eb05-c072-461c-c1bc-08dcf2a8fe28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: jmktBR8+dxzAbccA17xsQCKOAo0gblcnHw2/N9REPym3gBd7oetg+25Me7t2s6liY1M2wAN7nepYH2ur/pUy7NGWnoNXCVqm+dguvM1+0JlP0+ERIMM3jnU2A6r0bCah3H+uAPqk34eGtQjdAVI6oNuHS6CVsBMZKz16oqSDorR+E/3wkHr1HCk1EJU1LQIGDlq/uNfh4E0BhOy/jbuAd3QAs5J79Zls8Ukebq0jXQkEBmI9a01KIwUgZTSTpO54eg6GIfJXq+jz++UhGCvNcCdCgCS9dFiQS1hjt+IpZuz6WRX9LbB4oRIacIukjpgn7O1y0bg7riWZPBbX3UNjRrlOtjZivHugtFXFJx/wMnmLGj6XZH866H6O/uUSyf7LrjbSdRzqgZm/xiaQVEGgCxVyzhE0WAIK372jbrvd1b8+mqHsIPwm3zflZbb+wf8tQsETxSExfzg3+0ImbhMS4inWhkzGDqLHWcOdzWVIVHKFmWBmP5mfgwoDhcXeXSc8uAEpo67GeKQ+goyRE2+hv6lZwxW1v81pxTnklKLmtWnJJT2FQBT2Yf4v2FaJ+54xl3/J2g/kkM8Tw75eFFRkfw0vUtOzMtUTTQW67rPckvCQQkaF4c/mAHaCpVCA5SpggJ7TbTrIGxPLx3GGP5sQNcpILMpB5R7Gj2h6w/1oIS2C01oyt7Wxb2LkwfKOr4QwZ0PcB1k7WIEx9kj8MQFmiJvbPSvQ3AWYxLcWc6KOiRgymKdfM/wpUgEadGrxmaES6bVbT0VCQ0rGwrefXAQMXAbZiSUTHl/l/xATiAE3UweKcAHbx3zocd79ZLI//Zs0AA91+P01Bv/2F1pqJ4DQmMssvvU+xA+siUMGdkki7UZKrQ3PPaD3LwLI9CCuZNsHeZNxVzh5XkfiDHCzaxXj2LjCjh9eA3esUNE3x4BrbHqHxeBStpgsS4fW3dcB9wxBippesbeWC3/jEzfORDpXApGdQHELj+tqXt6Fm9SNk0CJfTH5nRXgXAKcuKNCY3UboasNL098sjfzG8U53Y06X1kKrLEqPFjCdp+HxhqWB2EtPfq18NFMeu4yP3JyOCqsEMnR3Z0FmYNl+4lrr0fHjWyQTclRREJ8RIKpSStYI/pniTAlIeQXBCJTOcaKglBki2tD4uZXsA4JygM+AmMubRoFyiKJDmXyojcbSs48ZA4AdKOBrcD9RxXRQmtV8gGSdntZ2XlyYd8PyG7oNgCF+TGSDAySb+kA5DQ9MazXoluD5rcAtifdKrnM3P2AM/nMegiDSg6RUhJnAQ1t//47TD15BIHM3ZM3/Zkz+ZFkLO2BRlkY3OmmyVYWEJyoP97MnXzE66QaOExI9+ZVK80utCOBdCuh99vYkwz3puANEA0baV4yV45jYDUSRy2kaUlv8eRRFPhlj+LTMSUoWmq4sg== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 14:51:21.1029 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3421eb05-c072-461c-c1bc-08dcf2a8fe28 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D7.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6949 X-Patchwork-Delegate: kuba@kernel.org In the next patch, responsibility for sending notification is moved from the core to the driver that implement fdb_add (and fdb_del in the patch after that). In this patch, export a helper that the core currently uses for sending FDB notifications for the drivers to use as a fallback if there is nothing specific to report. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen --- CC: Przemek Kitszel CC: intel-wired-lan@lists.osuosl.org CC: UNGLinuxDriver@microchip.com CC: Manish Chopra CC: GR-Linux-NIC-Dev@marvell.com CC: Kuniyuki Iwashima CC: Andrew Lunn --- include/linux/rtnetlink.h | 2 ++ net/core/rtnetlink.c | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 8468a4ce8510..2e48b4ca7187 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -192,6 +192,8 @@ extern int ndo_dflt_fdb_add(struct ndmsg *ndm, const unsigned char *addr, u16 vid, u16 flags); +extern void rtnl_fdb_notify(struct net_device *dev, const u8 *addr, u16 vid, + int type, u16 ndm_state); extern int ndo_dflt_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 194a81e5f608..e5c6dd4c5cf5 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -4271,7 +4271,7 @@ void rtmsg_ifinfo_newnet(int type, struct net_device *dev, unsigned int change, static int nlmsg_populate_fdb_fill(struct sk_buff *skb, struct net_device *dev, - u8 *addr, u16 vid, u32 pid, u32 seq, + const u8 *addr, u16 vid, u32 pid, u32 seq, int type, unsigned int flags, int nlflags, u16 ndm_state) { @@ -4313,8 +4313,8 @@ static inline size_t rtnl_fdb_nlmsg_size(const struct net_device *dev) 0; } -static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, u16 vid, int type, - u16 ndm_state) +void rtnl_fdb_notify(struct net_device *dev, const u8 *addr, u16 vid, int type, + u16 ndm_state) { struct net *net = dev_net(dev); struct sk_buff *skb; @@ -4336,6 +4336,7 @@ static void rtnl_fdb_notify(struct net_device *dev, u8 *addr, u16 vid, int type, errout: rtnl_set_sk_err(net, RTNLGRP_NEIGH, err); } +EXPORT_SYMBOL_GPL(rtnl_fdb_notify); /* * ndo_dflt_fdb_add - default netdevice operation to add an FDB entry From patchwork Tue Oct 22 14:50:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13845777 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2082.outbound.protection.outlook.com [40.107.95.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 880367DA7C for ; Tue, 22 Oct 2024 14:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608697; cv=fail; b=b2JNCuJEDA5DDSUL4OsEaTccgcegWa4QvigFgJyldViFyJDXYaivk+GBF4xQu9wZGoxrsSwKOBCni9aIoKPUEqLYbVV5jfD1/DL2BGiKbW4VeqTivXIaHpNA2JNOFAwpdrrHNUC1Z7gyzEhJFLXOGt6lG0wDbXVt+qgeBUt0FeY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608697; c=relaxed/simple; bh=7ytEKFr6S2JYi8UZpG/2s6rGzLtH4SMMb9Q4FmX6DHA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=r7X+n/HnqLd9aqSS40umu1xmT+RDuJpq4wDRLIoi0R6gDGdSZXy4IeP0cp13ycMFJCtdn4FHlLj7NITnc8J3GyXjVOY6nr3Nqd48GCtkPTrIFFdEzbhfF95wJOQX78ks4Ff0XjbfgCho85jlw5285TFLvra1wA0UF1AOniv+rpw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=NM6bLSFW; arc=fail smtp.client-ip=40.107.95.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="NM6bLSFW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rPV6n06TRddDDSFNs6WcCC9zOAPKZjm7WQrUSq6MAak+dgojsx+0ATNQeONO4czwTp8d+Dql9oMwjEwHue5CT1cmLza/0pZUQJ5mrshKjYyf9RusYqtCU4ZiHNepHaWa5Slvj2x38MWNl+oU15nzGRYHVfdVBHbj8/sRHwiTgrn9Un5N2RRgeCCMnhW99Pa4Vg7/NnvgW8LniW3wyN2VvBRz4sxwwpAI1cR1r5ynrj8Q03uOg5R95VbSS7fwCRtDxuyKeXDxlEWHoQHhiC2ciZqdxLzZa/glq7e+RsIbbhNw5q08pjqFKWDLEADRh9lPcodIeRjnJnYeWT9BBL7TLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=b+ULd6/L4GurXkjQSYbxXr68gYbV008S1UfS7EvkWLo=; b=x2IUABcfL3Ajtyc80QPSP1OyEr0t0LmNecXsXB8s8+FDNaV2iJ6aiU9bsheUzaa66kP7VKb9muNK97uTsd9afHArSTyIVQIiRnWOHgV8optgysQzx/TDBo9mjTPLeFdRs+FcXdiHmz2/GW8ssdgVaOavKPDulAH2iWl6aQYYQzNdzTqzde0mCPQ2r+rFgfyjPyBE1rYG7vKPxBHXeqI7r76j/WFb8531U8t2RHtUv7qL7x5W8WXUUSWxiPE8R6ypPrGku/tywpZw/svRrAOmPEOzM+40FRnD632J8HCwb98eIGkHqHSbaTii4V4KFtVzdWBBME2sricJezt85G6plA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=b+ULd6/L4GurXkjQSYbxXr68gYbV008S1UfS7EvkWLo=; b=NM6bLSFWvd+d4C5Dw/dSiZk2tcyLUmFl5m7xMK6+2j2Nc4YxL9DO5uz0R66t7jNby+V8dyzsKv5P6USLbgWlMSxO34GeS72dHJ6t+LFDx0FMtG4QuIefFdR5ebeIuhmtlUQ1+QaltkOMdgd26dQsKURGPn8QNsg8STvsGj954XP37DV5fHG6xEDbip/0INffmrDwzzbLkpjBmJKQzFRmKKACr7MhtaebdhHCl0dONNID4V0ods/7Pb6dMSyCKBnzME8S7ZbcHCiezxtjF79+DrhAm8JZkQ30d1BjIiJjIP1UZX8M94/Ecoe2GkK88QsGUCiqwQSxFoBSF8bWFoUt8w== Received: from MW4PR04CA0076.namprd04.prod.outlook.com (2603:10b6:303:6b::21) by PH7PR12MB6657.namprd12.prod.outlook.com (2603:10b6:510:1fe::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 14:51:31 +0000 Received: from SJ1PEPF000023D9.namprd21.prod.outlook.com (2603:10b6:303:6b:cafe::e9) by MW4PR04CA0076.outlook.office365.com (2603:10b6:303:6b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17 via Frontend Transport; Tue, 22 Oct 2024 14:51:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ1PEPF000023D9.mail.protection.outlook.com (10.167.244.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.2 via Frontend Transport; Tue, 22 Oct 2024 14:51:30 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:13 -0700 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:05 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , , Przemek Kitszel , , , "Manish Chopra" , , "Kuniyuki Iwashima" , Andrew Lunn Subject: [PATCH net-next 2/8] ndo_fdb_add: Shift responsibility for notifying to drivers Date: Tue, 22 Oct 2024 16:50:13 +0200 Message-ID: <00caa74f6dea128400472b5dec77f61b16d0f9d4.1729607879.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D9:EE_|PH7PR12MB6657:EE_ X-MS-Office365-Filtering-Correlation-Id: 02a14d7c-f1a4-4804-338f-08dcf2a90397 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: sLGf+YL5Vy9mO2UqoErUAzdA2eLJBj40pcxg30lioI6rwAjliq3EQb/I3q0nIGgQ2Rnqd/bWqAgH5br+OxTpmMNhCozp47ZpxYH/74OGyOb95PTbItG/77yQ4tl8xJn1u8amKCIzagEJytP4JwYdh1EivzJV/3xIhku8NeXtvnEVXF1NNJo00hMxGW2I44TdHVeibbV6zgznTMWQml1/sqL0pzSi6UDWBDGwkQdnx0lzqZae7fyjWGxDztvFeXRseqzQfPb5TWI7i8QcF/blaWLxq3vsiCvyY+LbKlfIwi7E7AhIweNoLpqwJQDKNUofKbwQNhF9JGNLyhrNWN5aINfbSmAvk5TbWU4wfoVxN7PmMpp5HWz54RUzhrsY7Tw91QDzBBf3IX+eP2G3WdlEtO2T8LgcpWjvPkz4PAukUCMP7xDYojGav7Y1YqNzfQleCvbLJ3MzVxjKjSKrEAi8WTUaOgb+8Wba3dhvsaS+JRD02h3pGg4cwfJFaeflAAyY0xAtoMrO8JDZJ688VRv1kSfFjnnTBznCP8nMTK4qHy99NaqCjMhZ2LND8Br7j30fsCOny/YSQ0Px3Z/WyqoJ2WrNPp1Ec0Wq9i9hqflrJZYkOHfFQ6aRzSvQsT3v73OCABwxoXQBoIHg4PG0AKmOHQ0SmOYigEVntoO7V+W1SRhIkNg/2Zotk/OKWlUksb7zUKen0USl3RreLKRpYw1bpxHwE92najti+MnLl1+EoRpzyTRHZPK78RyLbUkgm1eZREMwuQfETEAwAUYoO/dvtTgAr5/DO0119e3SKfzsaejFN5ucRPyq8mIqKwTiK6MPP2HPJYpHQ674JYZQTEQgL3UfMMMebrfWfSLVyN7ZbirMnq3tjKzCPBYQ8S5nAFKuP9FyVCHVA3PYr3hbnfVsn2WQtFwaQGhBIPmVAAfuAJMv8Hi+ADlDagW1To9OViof/9yLQmEw9M824GMSW+k5CWay0N2kArmqObY2S2CcOSb6nhoCU9QONg/+u8jmqXKDH22dGgdk2G32R8FgvZRRtraCfU4DyKgDOCxGdkBWWsyyhY8dVo0AA66HpEIHNa4vVryMk7RfkmHRkZJ+6SsiSYCZDx4cQhouX/7D6bctGyIAZNibdWJfsg/wlfGiK3jCokQNnvzxM5RA3Us1L4nYF8s7oAkRzVnKN7IIVH6W9ja8aiaR95s2P71lseG9UKOgdfszT8YH3VLCp3ci3ZI1cClAxzEMkiehUbtuXpO7sx/PIxw3WGqwL1+zdul3akjaId1e8/CxCXTtTfSh8LrjgxleG6ne6jJImgg4jswv6JOuSTZ4I3HSUl+6pn9US+59NZdrsv9MaSpAA5PTDjjycVbD+Z2ANAO4ajlVXFfuDZXN4YcJO9eCo/qMTjvIvaQlcOVi6Fk8hWeYyAZHhJjw4A== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(7416014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 14:51:30.2153 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02a14d7c-f1a4-4804-338f-08dcf2a90397 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6657 X-Patchwork-Delegate: kuba@kernel.org Currently when FDB entries are added to or deleted from a VXLAN netdevice, the VXLAN driver emits one notification, including the VXLAN-specific attributes. The core however always sends a notification as well, a generic one. Thus two notifications are unnecessarily sent for these operations. A similar situation comes up with bridge driver, which also emits notifications on its own: # ip link add name vx type vxlan id 1000 dstport 4789 # bridge monitor fdb & [1] 1981693 # bridge fdb add de:ad:be:ef:13:37 dev vx self dst 192.0.2.1 de:ad:be:ef:13:37 dev vx dst 192.0.2.1 self permanent de:ad:be:ef:13:37 dev vx self permanent In order to prevent this duplicity, shift the responsibility to send the notification always to the drivers. Only where the default FDB add / del operations are used does the core emit notifications. If fdb_add and fdb_del are overridden, the driver should do that instead. Drivers can use rtnl_fdb_notify(), exported in the previous patch, to get the default notification behavior back. This function is made to notify on success, which means several drivers do not need to change at all. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen --- CC: Przemek Kitszel CC: intel-wired-lan@lists.osuosl.org CC: UNGLinuxDriver@microchip.com CC: Manish Chopra CC: GR-Linux-NIC-Dev@marvell.com CC: Kuniyuki Iwashima CC: Andrew Lunn --- drivers/net/ethernet/intel/i40e/i40e_main.c | 3 +++ drivers/net/ethernet/intel/ice/ice_main.c | 3 +++ drivers/net/ethernet/mscc/ocelot_net.c | 8 +++++++- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 6 +++++- drivers/net/macvlan.c | 3 +++ include/linux/netdevice.h | 3 +++ net/core/rtnetlink.c | 8 ++++---- 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 25295ae370b2..6a1ac0f4f8a6 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -13126,6 +13126,9 @@ static int i40e_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], if (err == -EEXIST && !(flags & NLM_F_EXCL)) err = 0; + if (!err) + rtnl_fdb_notify(dev, addr, vid, RTM_NEWNEIGH, ndm->ndm_state); + return err; } diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index a6f586f9bfd1..a3398814a1cb 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -6154,6 +6154,9 @@ ice_fdb_add(struct ndmsg *ndm, struct nlattr __always_unused *tb[], if (err == -EEXIST && !(flags & NLM_F_EXCL)) err = 0; + if (!err) + rtnl_fdb_notify(dev, addr, vid, RTM_NEWNEIGH, ndm->ndm_state); + return err; } diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 7c9540a71725..cf972444e254 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -737,8 +737,14 @@ static int ocelot_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct ocelot_port *ocelot_port = &priv->port; struct ocelot *ocelot = ocelot_port->ocelot; int port = priv->port.index; + int err; - return ocelot_fdb_add(ocelot, port, addr, vid, ocelot_port->bridge); + err = ocelot_fdb_add(ocelot, port, addr, vid, ocelot_port->bridge); + + if (!err) + rtnl_fdb_notify(dev, addr, vid, RTM_NEWNEIGH, ndm->ndm_state); + + return err; } static int ocelot_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index b3588a1ebc25..1de0290e15e0 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -409,7 +409,7 @@ static int qlcnic_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], } if (ether_addr_equal(addr, adapter->mac_addr)) - return err; + goto out; if (is_unicast_ether_addr(addr)) { if (netdev_uc_count(netdev) < adapter->ahw->max_uc_count) @@ -422,6 +422,10 @@ static int qlcnic_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], err = -EINVAL; } +out: + if (!err) + rtnl_fdb_notify(dev, addr, vid, RTM_NEWNEIGH, ndm->ndm_state); + return err; } diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index cf18e66de142..b1e828581ec4 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -1044,6 +1044,9 @@ static int macvlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], else if (is_multicast_ether_addr(addr)) err = dev_mc_add_excl(dev, addr); + if (!err) + rtnl_fdb_notify(dev, addr, vid, RTM_NEWNEIGH, ndm->ndm_state); + return err; } diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 8feaca12655e..9f7de8d0414a 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1247,6 +1247,9 @@ struct netdev_net_notifier { * const unsigned char *addr, u16 vid, u16 flags, * struct netlink_ext_ack *extack); * Adds an FDB entry to dev for addr. + * Callee is responsible for sending appropriate notification. The helper + * rtnl_fdb_notify() can be invoked to send a generic notification in case + * the driver does not need to customize the notification. * int (*ndo_fdb_del)(struct ndmsg *ndm, struct nlattr *tb[], * struct net_device *dev, * const unsigned char *addr, u16 vid) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index e5c6dd4c5cf5..a9f56a50fa57 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -4376,6 +4376,9 @@ int ndo_dflt_fdb_add(struct ndmsg *ndm, if (err == -EEXIST && !(flags & NLM_F_EXCL)) err = 0; + if (!err) + rtnl_fdb_notify(dev, addr, vid, RTM_NEWNEIGH, ndm->ndm_state); + return err; } EXPORT_SYMBOL(ndo_dflt_fdb_add); @@ -4473,11 +4476,8 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, err = ndo_dflt_fdb_add(ndm, tb, dev, addr, vid, nlh->nlmsg_flags); - if (!err) { - rtnl_fdb_notify(dev, addr, vid, RTM_NEWNEIGH, - ndm->ndm_state); + if (!err) ndm->ndm_flags &= ~NTF_SELF; - } } out: return err; From patchwork Tue Oct 22 14:50:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13845778 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2067.outbound.protection.outlook.com [40.107.223.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A47567DA7C for ; Tue, 22 Oct 2024 14:51:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608705; cv=fail; b=SkrH3TX5z/S1xDEpZUn9l/JyKZUA9aWXfcERRDddW2GMGUX8qYiZGLEwdWB8CAUc88EJStZ+gX6hF8nyjn3tG8Z5Tyz5Bi5fnSkBpngww8cylYEIZqA/OkecINyww3eEsymftD150MpmwzYeKBlzL7IYS1rUKKsSM65O/J2XLT8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608705; c=relaxed/simple; bh=5apdx0dcIvPQHs1nqNMkUe6FP8R7atP0/rX7a+qe9g8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XnKr5eThrrJtIdqRrNfnRCx9LrUahrFBxd/DdkM0O3JQdb+utdgCJt40w0imNq9iGLzz0MV6XKfWy7Nriy1yzyD36OU4es2kk8d/ZV3CGS0090eYgr+mCnHe66uLoMms7SFAFJWvs3hfYW1mc/N86Zm7bGQqUVfeItOwpTRJcWo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=IZHvuuFV; arc=fail smtp.client-ip=40.107.223.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="IZHvuuFV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lkVzAjcYGsaZcEoqyTUrlmeTFLclyV4Da165iUsWapYZ/hrwMjGVjHmVJdylGsLIQAIzKUvVZ5KRw4YyTdHHbmXfVvS/I2onieagF1OB6FR7eLnL0F0SIy2XHxdZ2Btfkte0c+pb6+0oMyHECOjAvDdwWwAZZh8UZDd85UVYPvzLkIkJP8yChvK4p7DJDrevRIpdMBhKAmBJEYngJj9r0AjJo2reffaAxs49eRS5nHnyjT8l9bE5C2D9HKJ9WYiH329asGQdoOHLK3DvoT9irZEJhZGMcvd+HjA3Pp72XUzBZnY3etz344ai3Qd6s670KhBUZqXKFq37SqpDsw7gsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ElBbeDLjGvvhhGtFi7QFhFFKumOUKQyBPgMhgBNvCcQ=; b=eJrgANxZ6kYhHUKdTNsATX2e5QvY/PlkkKtKLDYjCcdUJQQnYaxvm4TpHOypd+DqJarKCdo0BAUdj+QGE+X7lRQ+RGfZA/aUfcd7vTQnRwTOWJtv9eZtSzzAMk0HVYPJsI2vOzZF3R/fUxLFyzMzaP1zqu73gX3qQjb5CWbEsy9yYi3ZYU3RlCCPdXY9m1fk7vd2OQHVHVdYK44olDPEwN1ycakkizxd8GivL00w969dA6302dkaT7PKQTJ2XyeYwoKYQOUKLhoVKMSnrTgGqz1hH0mjqT8djZa7AeALketXttKu00Pwkg3b2cos7XDD9c5q4wkrxVIsbYwz8bbhQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=ElBbeDLjGvvhhGtFi7QFhFFKumOUKQyBPgMhgBNvCcQ=; b=IZHvuuFVzFa7QTS3/Bxbn+FwqxfIrmKMI26525nRyduV9ap+wiSwsB5uLYiuXgQMH0F82guxJ4phNVZ26dO4fGD4W/WtglF9hMo5kDhCRuCK5QhXzWvpvmbrFT8jv96QpG5o7nf7vuWTh7df5I4W1OSJJPeD6nHDZo/7z01/9mvNwvX3eJyajNfcEHtgrKa9kp24Wv4o7DOy61TwFepaguLpacc7yFkGG8bylsolTgQVYpWznJwMLWGqutjJ+TJtHZd7MK8DDeWXiDytbP+uRsOp6TFePm7hpc8zZlx5jrwxHCrURgEapE8ehbbPj1akN4iHx+lfe6+Ni8YCcFv61Q== Received: from SJ0PR13CA0061.namprd13.prod.outlook.com (2603:10b6:a03:2c4::6) by CH3PR12MB9145.namprd12.prod.outlook.com (2603:10b6:610:19b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Tue, 22 Oct 2024 14:51:36 +0000 Received: from SJ1PEPF000023D6.namprd21.prod.outlook.com (2603:10b6:a03:2c4:cafe::f4) by SJ0PR13CA0061.outlook.office365.com (2603:10b6:a03:2c4::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17 via Frontend Transport; Tue, 22 Oct 2024 14:51:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ1PEPF000023D6.mail.protection.outlook.com (10.167.244.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.2 via Frontend Transport; Tue, 22 Oct 2024 14:51:35 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:20 -0700 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:13 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , , Przemek Kitszel , , , "Manish Chopra" , , "Kuniyuki Iwashima" , Andrew Lunn Subject: [PATCH net-next 3/8] ndo_fdb_del: Shift responsibility for notifying to drivers Date: Tue, 22 Oct 2024 16:50:14 +0200 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D6:EE_|CH3PR12MB9145:EE_ X-MS-Office365-Filtering-Correlation-Id: 039fb121-1ec3-447e-68d0-08dcf2a906ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: EH2IIalf/FoJytTyt0sQvtGrSbJkCObMmh+Lh7U2Yh7xJuq5V6Lr1NO5vnBGLfi9JxMhzNVBrpDdGwtO+RyWRow+yis1HW/84kYC/NEZ2dRymvMOVKOg2xcjnhPAxbh4mNvTht1T8OaAOLqAyMVozXvIUxiY8o/0HV4cu9yILih5RAEqbRKTx+wqm0BIgliCdrxnh7/R+vgDoLacpp+6NwpgSTI22I79b8xvFW9X3JBKtU8toNkeeM9HIIrd4+Xo3EXKnEfuSmtNXxFkoMnAbmpj0/KJGWrltFZf2NdRq3fAekxdFDIWF3J+ui1e8RRaL4fBz9raQTUVDPArXzV/2Yh08HXrbGpUX2Aszj4UpQbV9DS14u5B4irbrMfFgsFugFpPZs0ihziUMmYbogfOgHNm0J5qde54gqdleLUvmh4nD+ePDGEKhrAXaDoNXnXYmNJx61669qwUpq83QQmOu/4nwP73tWP8pNH2RhcsCzboF/4wMCPETujVLdPhtZ3HaTbtwfbgbM28W4LxXkCDoKzwHsZvKB5knQkTsr7KRa1yZtdlYfXJK3HqOCrqLDp3tgSQm6/dAEkWYowikwKkkip4PFlbI8/8fa2NLY80rGvVljFNnC6WyFJuXNicXjMUICMwSPm620e305lCocFVEBZ/1Om8OZYTzKAZ9ngBsiOpVKvJSBr6h6FqIKAJA8cwXlQC85NMSTEplVE6IWCLSEV7BuHdT/ZOm3rfUBh3oo0/Hw3WA31DAD1BWwnh9tflfVq3/qUZOOReqTsRyu2OZu470jtBvvZe30PrTIhcZIHWU5Qgz/LGG9QW3OThB1eza0lO5nLWA9/bMg+nI963asOOiZteC+CzHKhd482mOi/1W8VGexsBtEIeo+sSlP83I4atpcDah4/uLhj+32+tUCCHOi9QWNWBS38rsNFi1bXX9RPnajkiHXoEIavSn1XpBB8lGBAiEDqu/F1EMa42WQTducqrvISDyBmRPC0KvzSfRn6ag+EmpUHe/s7o0jAK3InMmwZUH0ff19OQh28ikWmpxgI1hDxk8zBF4HhC8k3KnGE0n57krBHj+pFmuoGI9x5JKzzEyK0H5bHbAF82Z1FSrrHPCUYvH7gy3xfQRApyt1Tq93v3Soehlolr8HN+19o0tGy/1XE9M5SBn+c3J/sllcq0TNore6hAWjPqmogB/XRjUfdJXNEm+mFCApc0dxUlqtZj8bOtfdZO1lDPLndOVB5kJ7eR7JRBSehnC2N6D3sMKHgxQv/l9abTJ0Ew/OTipUCH9wV5btbIBKoed8ms7m7qwU93H+C6TDatyfRpWNo0zo6FRViK4au5xcA5rtKNN6Whwu/jrk51DmaFu8t9rPg79B9DZFGfuSXIGkTroGEXzXbl73VUgk+PSkKfB4eohm+8mUA55vkZQhNGjA== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(7416014)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 14:51:35.9315 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 039fb121-1ec3-447e-68d0-08dcf2a906ff X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D6.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9145 X-Patchwork-Delegate: kuba@kernel.org As described in the previous patch, the drivers that provide their own fdb_add and fdb_del callbacks should from now on be responsible for sending the notification themselves. In this patch, implement the fdb_del leg of the change. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen --- CC: Przemek Kitszel CC: intel-wired-lan@lists.osuosl.org CC: UNGLinuxDriver@microchip.com CC: Manish Chopra CC: GR-Linux-NIC-Dev@marvell.com CC: Kuniyuki Iwashima CC: Andrew Lunn --- drivers/net/ethernet/intel/ice/ice_main.c | 3 +++ drivers/net/ethernet/mscc/ocelot_net.c | 8 +++++++- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 4 ++++ drivers/net/macvlan.c | 3 +++ include/linux/netdevice.h | 2 ++ net/core/rtnetlink.c | 9 ++++----- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index a3398814a1cb..65f9dcf4745b 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -6188,6 +6188,9 @@ ice_fdb_del(struct ndmsg *ndm, __always_unused struct nlattr *tb[], else err = -EINVAL; + if (!err) + rtnl_fdb_notify(dev, addr, vid, RTM_DELNEIGH, ndm->ndm_state); + return err; } diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index cf972444e254..12958d985fd7 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -756,8 +756,14 @@ static int ocelot_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct ocelot_port *ocelot_port = &priv->port; struct ocelot *ocelot = ocelot_port->ocelot; int port = priv->port.index; + int err; - return ocelot_fdb_del(ocelot, port, addr, vid, ocelot_port->bridge); + err = ocelot_fdb_del(ocelot, port, addr, vid, ocelot_port->bridge); + + if (!err) + rtnl_fdb_notify(dev, addr, vid, RTM_DELNEIGH, ndm->ndm_state); + + return err; } static int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid, diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 1de0290e15e0..db847aed5222 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -388,6 +388,10 @@ static int qlcnic_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], err = -EINVAL; } } + + if (!err) + rtnl_fdb_notify(dev, addr, vid, RTM_DELNEIGH, ndm->ndm_state); + return err; } diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index b1e828581ec4..2c61b7b83875 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -1069,6 +1069,9 @@ static int macvlan_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], else if (is_multicast_ether_addr(addr)) err = dev_mc_del(dev, addr); + if (!err) + rtnl_fdb_notify(dev, addr, vid, RTM_DELNEIGH, ndm->ndm_state); + return err; } diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 9f7de8d0414a..9e1ffb21de18 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1254,6 +1254,8 @@ struct netdev_net_notifier { * struct net_device *dev, * const unsigned char *addr, u16 vid) * Deletes the FDB entry from dev corresponding to addr. + * Callee is responsible for sending appropriate notification, as with + * ndo_fdb_add(). * int (*ndo_fdb_del_bulk)(struct nlmsghdr *nlh, struct net_device *dev, * struct netlink_ext_ack *extack); * int (*ndo_fdb_dump)(struct sk_buff *skb, struct netlink_callback *cb, diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index a9f56a50fa57..4788bfc58aa2 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -4506,6 +4506,9 @@ int ndo_dflt_fdb_del(struct ndmsg *ndm, else if (is_multicast_ether_addr(addr)) err = dev_mc_del(dev, addr); + if (!err) + rtnl_fdb_notify(dev, addr, vid, RTM_DELNEIGH, ndm->ndm_state); + return err; } EXPORT_SYMBOL(ndo_dflt_fdb_del); @@ -4604,12 +4607,8 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, err = ops->ndo_fdb_del_bulk(nlh, dev, extack); } - if (!err) { - if (!del_bulk) - rtnl_fdb_notify(dev, addr, vid, RTM_DELNEIGH, - ndm->ndm_state); + if (!err) ndm->ndm_flags &= ~NTF_SELF; - } } out: return err; From patchwork Tue Oct 22 14:50:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13845779 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2055.outbound.protection.outlook.com [40.107.237.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C15B31A257D; Tue, 22 Oct 2024 14:51:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608707; cv=fail; b=qb1QY5iOjDYbNwSKVgxlPsKzkkOmcDBu4Fyr6wKE2BV7HcGywbUyNRIwQLMcxelsR01UAO/QwOH05pv8RHF/IT6d6rntfp9/+RVndXqDhOBDS930VugXFRWIaKqE1RvDiQISAQZTuTV7pIxPSipLUsp1TJm++n2Wxm25yFBCwiM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608707; c=relaxed/simple; bh=rgxDZOEsXWWOkGKIzm90NApYTnvFBiFzFItqLgea9n0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Kkn0lMMC8q0VYGrW1zRB/AiUdLitRCzQPgiSN7Hpi4Yr089tIQd9voak9aDbGBplJ/bHH3KmJ5whlDVLLSwXjCPMw0Aul4HJya9xKBwuYe9pzykNPhHQ30rPJKcwl5E/jSfMNmfCPWFWAZPuf+1zau9JW0zOTInHsZ5HdSJX6ys= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=q7pgm604; arc=fail smtp.client-ip=40.107.237.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="q7pgm604" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ITaGo2fZbcWH96tDUWwCcxHtu6KOlgQK0f7i2WwRTwiqNuVXrwK5btyvwAywC9Cvg0+LtQodOoqOb1d1L2zQXc0jWJLldKaIdEmVwmZDX70WYY1YMLB0ZQ7y2UuJA745uagveDd+79oXnogZPwgEaC5V72IGtFc530stvdbhIewArek7M6Y4rLskNzKntkE7r06GCVe6g3GPdbIf6osl9KEnxqLRsjESmUyL/KHyJBMpThKUJaSzjArYgXelByLxTcsU7iq4UurB0GRHuQ7mwkxKKTfYYJBFQ4CKiy0yTGDHwWBkmUy249F2nx5BMlB8NRUgCeBwD6V/thmNKmuzdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=GdO3rPdlb8EFNfFy+do5y+79s97PNpR/Z4h8OJIgKOY=; b=U8px+dpZ1vNIBNIeKcZH3f8jqRc9BAvJpXfTyqlaCNPGo834eXd762GuS9knvCh0mPM/YVQl9SrFW+QMi/FCwHm09ZPMlZLqL7231rrwPLtmLXt4JZX4dL6U+Zhqp6kSh7xg0vRAmiRNKWjnWRO4kvODBe4JfmB6Ue+S2vvq66U03B3peONrYkMydIIKawiS0qJotDD8Nqnvcm9V5lMMCkm1Ke+2m1m0B/FUrCSzYBEoM3KNFhlg5EzdafIIAIXe849Y4cHq75S1cRK9Gc7ggQCwfTKIXD7pXmH7QaHbKXrOryaAa1TWv2fFOI+HhaGgOwW0bPoRkTqxi6lGB2cEOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=GdO3rPdlb8EFNfFy+do5y+79s97PNpR/Z4h8OJIgKOY=; b=q7pgm604JEHrOGRZ0yw8J+AbPXLrD4/wBG6+zgm1UNnQBYpFvIyW43r3nCpYR2WObVoQ0vTV1BRblwjpIVtsOWnywc1GJkZIEfZlgE4LMrSMvs855c1DwUm20JJlsS/0HjYYEFRo1Av99Ne979WL4c2M5lNRaL71xrwzOLmHt92pp4Jsdq8lSJFp4MUN62RC8Yo+xmIB/rTEf7KFtrxTuyEV1gmGnSbJSQMDWZlRWY3L/ZfUXIB7Gru430TZGqmIap/td7lGq/ZcHNvGjbcKHvSXU1NuYxL2ROYFUC98oHRsUoMDwlcEBUPjW5Wtal+gnH3auTQRFeuxg6yM8cPh7g== Received: from SJ0PR13CA0064.namprd13.prod.outlook.com (2603:10b6:a03:2c4::9) by PH7PR12MB9254.namprd12.prod.outlook.com (2603:10b6:510:308::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.16; Tue, 22 Oct 2024 14:51:42 +0000 Received: from SJ1PEPF000023D6.namprd21.prod.outlook.com (2603:10b6:a03:2c4:cafe::d4) by SJ0PR13CA0064.outlook.office365.com (2603:10b6:a03:2c4::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Tue, 22 Oct 2024 14:51:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ1PEPF000023D6.mail.protection.outlook.com (10.167.244.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.2 via Frontend Transport; Tue, 22 Oct 2024 14:51:41 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:26 -0700 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:20 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next 4/8] selftests: net: lib: Move logging from forwarding/lib.sh here Date: Tue, 22 Oct 2024 16:50:15 +0200 Message-ID: <4421094dd36be3714eeea70d577ff761454de3b3.1729607879.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D6:EE_|PH7PR12MB9254:EE_ X-MS-Office365-Filtering-Correlation-Id: 79916a8d-d432-4916-7d05-08dcf2a90a9c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: XLWG1+5bM1Kbv/JczZRKV1FnE5x6FlbBUuq+aUDXVIRk3tBU/YqhjjaixGawW+k4M26/+IIQMhAWFEHgTIHm2gzVNkHMwbkiVUv3MjQaP4nzMszf+watxHMc5gXDCjh+LV7eDiAW4XEU68M8ZWRvX9AUKvlljXcPOglEBYTNgtm9Pus1S933iSGN+B7oX0bz8YTR3zt1mkgpJhoeXLWLP3vDwpV2oWjL1kHxdeK2RZI1+pZXE0dC6GKyV1tNvcxQhkrnBYsqh7rRcDtW40V9pVrGJpY0UR3Idqid/AtSjeX1KfFh5pHspeWyt0MIwP+AH4mJDv7yg3Lke8zqOwUJgcHxRxfKu1qNsg9WEcuvUjy/GfOXjkhySEQRqcS5BBKCux3Ds33dhHdZo9iWNI1dgmApf1i5v7SPma/gQJy2+JD9ApjVFncMV8EDsEqdWSlBTUeCe5QQMq3s6XTromu9OjvcpUdMsPXL3mvGV4qaWcd8gahx5TqVEGmaIhTP+s+mXjpUA48ckvf9b9PmkngJ9T835NDeGbKgNMcojqZZK0z56/YS0I1q/BOUV2tCzcpwB+CzGojkjmTDbMKB7HsXGspIDfREtrCtpgxgncagkc3+mRX4fIN9bANK1N4XE9lcdEyPxneLmcvKJW7YcK3MYDZIxGxLDJKHNwyn/0uklygRC1nipgFqPh5ITxSlBjCl9XxyIcrHe3x+mPayXUntGqxdMBNituKIeOQ5UohL2Buch0gN3Pps/8HwXVby9U7J/I/iXFhvrLtKujkXyZJTBtolgQLEqK8/rDlqNOdgrJgMHwP1osxe9c9BSA//yphqw2jDHk4zz64EThfgMi5ewE2jindQ5iukn20sjJzvCXFwDJHv9piTE7zu1QUM+6pgkvVPv2mmpmel78jAgftng/VsMxGyQXsMUuYXM5hNoT36FGc84pzBUgASpfTWZsb33T6kEZmcujcjgf+aKF+MCEQIMNd5KSoL7OWUQxGrEy+V7cjBvZbthnhSWzCLIqUZGpKei+thE7Tp473d49ZfZDiLT/Em1UkaFWX4ZT7hy22YfT83CwAqlb25qieWPn2fdANvnvui5qojz/aScDa0YgaXtlSR3mdhRNQ6Pq8oXVnvBJE9VSRWKGcCdMiE9+lGgSS2r2yDLU5IOl/Ci/NZeNRR/6VVmQF1GIz3LLn+AgBGMr69jGjlLZDzR7PB0kVjYj3wVcfK6xO/wBhxgJw19NCW+G3n8KmbbvpMPfTRkTzEfX36me/JDR/SsnRcU+0E8pk9Cmc1pcFSKMoBuiUG7YRGwNDhMhnqR7V/q3kStIHGAFCOBepMPgYsOgjA7kTWUzR64lH0sYNVOMmGtqR3bLuTPC6/UrS84BV1IVc0jAglywOLFR1fJk37Y90DPll7vUlF7Bs5uWVpkEK6DInUmw== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(7416014)(36860700013)(376014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 14:51:41.9940 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 79916a8d-d432-4916-7d05-08dcf2a90a9c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D6.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9254 X-Patchwork-Delegate: kuba@kernel.org Many net selftests invent their own logging helpers. These really should be in a library sourced by these tests. Currently forwarding/lib.sh has a suite of perfectly fine logging helpers, but sourcing a forwarding/ library from a higher-level directory smells of layering violation. In this patch, move the logging helpers to net/lib.sh so that every net test can use them. Together with the logging helpers, it's also necessary to move pause_on_fail(), and EXIT_STATUS and RET. Existing lib.sh users might be using these same names for their functions or variables. However lib.sh is always sourced near the top of the file (checked), and whatever new definitions will simply override the ones provided by lib.sh. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen Acked-by: Shuah Khan --- CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: linux-kselftest@vger.kernel.org CC: Jiri Pirko --- tools/testing/selftests/net/forwarding/lib.sh | 113 ----------------- tools/testing/selftests/net/lib.sh | 115 ++++++++++++++++++ 2 files changed, 115 insertions(+), 113 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 89c25f72b10c..41dd14c42c48 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -48,7 +48,6 @@ declare -A NETIFS=( : "${WAIT_TIME:=5}" # Whether to pause on, respectively, after a failure and before cleanup. -: "${PAUSE_ON_FAIL:=no}" : "${PAUSE_ON_CLEANUP:=no}" # Whether to create virtual interfaces, and what netdevice type they should be. @@ -446,22 +445,6 @@ done ############################################################################## # Helpers -# Exit status to return at the end. Set in case one of the tests fails. -EXIT_STATUS=0 -# Per-test return value. Clear at the beginning of each test. -RET=0 - -ret_set_ksft_status() -{ - local ksft_status=$1; shift - local msg=$1; shift - - RET=$(ksft_status_merge $RET $ksft_status) - if (( $? )); then - retmsg=$msg - fi -} - # Whether FAILs should be interpreted as XFAILs. Internal. FAIL_TO_XFAIL= @@ -535,102 +518,6 @@ xfail_on_veth() fi } -log_test_result() -{ - local test_name=$1; shift - local opt_str=$1; shift - local result=$1; shift - local retmsg=$1; shift - - printf "TEST: %-60s [%s]\n" "$test_name $opt_str" "$result" - if [[ $retmsg ]]; then - printf "\t%s\n" "$retmsg" - fi -} - -pause_on_fail() -{ - if [[ $PAUSE_ON_FAIL == yes ]]; then - echo "Hit enter to continue, 'q' to quit" - read a - [[ $a == q ]] && exit 1 - fi -} - -handle_test_result_pass() -{ - local test_name=$1; shift - local opt_str=$1; shift - - log_test_result "$test_name" "$opt_str" " OK " -} - -handle_test_result_fail() -{ - local test_name=$1; shift - local opt_str=$1; shift - - log_test_result "$test_name" "$opt_str" FAIL "$retmsg" - pause_on_fail -} - -handle_test_result_xfail() -{ - local test_name=$1; shift - local opt_str=$1; shift - - log_test_result "$test_name" "$opt_str" XFAIL "$retmsg" - pause_on_fail -} - -handle_test_result_skip() -{ - local test_name=$1; shift - local opt_str=$1; shift - - log_test_result "$test_name" "$opt_str" SKIP "$retmsg" -} - -log_test() -{ - local test_name=$1 - local opt_str=$2 - - if [[ $# -eq 2 ]]; then - opt_str="($opt_str)" - fi - - if ((RET == ksft_pass)); then - handle_test_result_pass "$test_name" "$opt_str" - elif ((RET == ksft_xfail)); then - handle_test_result_xfail "$test_name" "$opt_str" - elif ((RET == ksft_skip)); then - handle_test_result_skip "$test_name" "$opt_str" - else - handle_test_result_fail "$test_name" "$opt_str" - fi - - EXIT_STATUS=$(ksft_exit_status_merge $EXIT_STATUS $RET) - return $RET -} - -log_test_skip() -{ - RET=$ksft_skip retmsg= log_test "$@" -} - -log_test_xfail() -{ - RET=$ksft_xfail retmsg= log_test "$@" -} - -log_info() -{ - local msg=$1 - - echo "INFO: $msg" -} - not() { "$@" diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index c8991cc6bf28..691318b1ec55 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -9,6 +9,9 @@ source "$net_dir/lib/sh/defer.sh" : "${WAIT_TIMEOUT:=20}" +# Whether to pause on after a failure. +: "${PAUSE_ON_FAIL:=no}" + BUSYWAIT_TIMEOUT=$((WAIT_TIMEOUT * 1000)) # ms # Kselftest framework constants. @@ -20,6 +23,11 @@ ksft_skip=4 # namespace list created by setup_ns NS_LIST=() +# Exit status to return at the end. Set in case one of the tests fails. +EXIT_STATUS=0 +# Per-test return value. Clear at the beginning of each test. +RET=0 + ############################################################################## # Helpers @@ -236,3 +244,110 @@ tc_rule_handle_stats_get() | jq ".[] | select(.options.handle == $handle) | \ .options.actions[0].stats$selector" } + +ret_set_ksft_status() +{ + local ksft_status=$1; shift + local msg=$1; shift + + RET=$(ksft_status_merge $RET $ksft_status) + if (( $? )); then + retmsg=$msg + fi +} + +log_test_result() +{ + local test_name=$1; shift + local opt_str=$1; shift + local result=$1; shift + local retmsg=$1; shift + + printf "TEST: %-60s [%s]\n" "$test_name $opt_str" "$result" + if [[ $retmsg ]]; then + printf "\t%s\n" "$retmsg" + fi +} + +pause_on_fail() +{ + if [[ $PAUSE_ON_FAIL == yes ]]; then + echo "Hit enter to continue, 'q' to quit" + read a + [[ $a == q ]] && exit 1 + fi +} + +handle_test_result_pass() +{ + local test_name=$1; shift + local opt_str=$1; shift + + log_test_result "$test_name" "$opt_str" " OK " +} + +handle_test_result_fail() +{ + local test_name=$1; shift + local opt_str=$1; shift + + log_test_result "$test_name" "$opt_str" FAIL "$retmsg" + pause_on_fail +} + +handle_test_result_xfail() +{ + local test_name=$1; shift + local opt_str=$1; shift + + log_test_result "$test_name" "$opt_str" XFAIL "$retmsg" + pause_on_fail +} + +handle_test_result_skip() +{ + local test_name=$1; shift + local opt_str=$1; shift + + log_test_result "$test_name" "$opt_str" SKIP "$retmsg" +} + +log_test() +{ + local test_name=$1 + local opt_str=$2 + + if [[ $# -eq 2 ]]; then + opt_str="($opt_str)" + fi + + if ((RET == ksft_pass)); then + handle_test_result_pass "$test_name" "$opt_str" + elif ((RET == ksft_xfail)); then + handle_test_result_xfail "$test_name" "$opt_str" + elif ((RET == ksft_skip)); then + handle_test_result_skip "$test_name" "$opt_str" + else + handle_test_result_fail "$test_name" "$opt_str" + fi + + EXIT_STATUS=$(ksft_exit_status_merge $EXIT_STATUS $RET) + return $RET +} + +log_test_skip() +{ + RET=$ksft_skip retmsg= log_test "$@" +} + +log_test_xfail() +{ + RET=$ksft_xfail retmsg= log_test "$@" +} + +log_info() +{ + local msg=$1 + + echo "INFO: $msg" +} From patchwork Tue Oct 22 14:50:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13845780 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2050.outbound.protection.outlook.com [40.107.93.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F06B1A073F; Tue, 22 Oct 2024 14:51:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608715; cv=fail; b=HD2pTdUiuReaRHUwDR5+kVNkNDpwMvWtDq2OCI2uvd0nX+lIEmN1MVpWQWw01zXnbhoDmTU+uLaojD+VeotBOBUEU256acnCRs5aejZucJ/YapkQv4A/HRu6wHmTaImI1eyNzRsQZC+koMJb+Yx8AOneCdiDdRhl0UxIFjISY0M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608715; c=relaxed/simple; bh=J6pK3Sb0SVXqEZLC42T2wglyQJehaTywZH1sRUV3PZo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tAhvm+VRI8nTA/FxM/XgyZE+pndNX9RR9RAL3nOFa5QIhO/9ICnBqjhx8K9m0gMgCATnEOQDPmZzcnrsu9r3yIyuad+NoEgv2fY+rJ9VWSBwj5s/VNd/gTXL+s3wEeOMn6iuapuZVb4Tlf/SriWTAwK+NoQA6Y8Ej+G34I/MDHg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=FdF9GQ65; arc=fail smtp.client-ip=40.107.93.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="FdF9GQ65" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=rvuyuCYSbkNa3OEJzATJZ57raemCeQ/XfRvSWcc5vP50yFtQ9ireJts139tiv+jBCZHWLUylxY1RhvztIr6Nl45tPxj6LuupiF3nhATowxF6Lwo3x5vmSFXmvNI4XBwaIyMdDJbDU37AUOHrr4ND3If6G25rSq3b04ja5CX+BAtwoEAnScyc3vix7/lxsmlzW+zyzbSO5ksnT2n6UMzg3zPoMbvD6pzgteLVe9WOepOODJfT5yzrX5k82K8XqqxYUuexHWChwDxwCiThx7Dj6nZ7meud0YAuhH5WVBr1Pg9/lT67tyB7DjHif4dHciYUmqpAzyo33yVvPO6eVu2wYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=gNEu9x7CzHjUNmeuDiF9oLnqg8UZqvMjFIJzIzwDFlM=; b=UyZhJpUKKiZMEFSdHRPK9Fv+kJV2gXn7yMas/VVeBphgGksuzPIJbX6Gfb0ORP3fql0leGBwRrJ9gjjsGB67+F/n1VQufxN2rZtBZ1u/7wL5VqMM/0TqZaYU0bpQoIFzXSXo+xfCbK76OxofP8y/YzLMPCvVMKO4HdUKBBjrjj4rcFyD/FHv9SZyVynJ2m5kXOGJJbbrOZ1PULgupLtx3zjrvhC9FUekAEJYYuMmVByKuohZFd9EGwHvzeEgsz8QVYAfNELu6QAd9+l89lROcGZJ4+gz51TNdm7hRSU7HNhXZTSZ5pyWK6Rl2MEtkXB/KVWHcAfEIhF8pVn/Joag8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=gNEu9x7CzHjUNmeuDiF9oLnqg8UZqvMjFIJzIzwDFlM=; b=FdF9GQ65cLpOvcm/WjOImkztdZxTWjVR2RSgfVbA2y5zPXj4PBSAFxHvlYoBgCJhNY6treb3TOTtH7ySbfB1j1/RKV85p6R4ADX1EVdnJTTD/Q/FSEiMCVEMOTNx8UpfuuKdcS/CVHKQRRX5yqz9bl4GalCa2jBv09VymL5j/+/xho6S9FyZy4VXLNJJ38QzjvrEWRnAn5mKCu1H0Omsbd1yOItx05nLTFLx4BHMEieEJ0+wRxijnQ0knly2QgEoyYRibOTB5WFmJuFeOHSHEwk+LiZ0BgIK0knFOffg9Cy+pmyZ7aPNGR5pJbv1qV/KpuJt7JUixIMWZxhXZyW0Og== Received: from SJ0PR13CA0069.namprd13.prod.outlook.com (2603:10b6:a03:2c4::14) by PH7PR12MB5973.namprd12.prod.outlook.com (2603:10b6:510:1d8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.26; Tue, 22 Oct 2024 14:51:47 +0000 Received: from SJ1PEPF000023D6.namprd21.prod.outlook.com (2603:10b6:a03:2c4:cafe::ca) by SJ0PR13CA0069.outlook.office365.com (2603:10b6:a03:2c4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17 via Frontend Transport; Tue, 22 Oct 2024 14:51:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ1PEPF000023D6.mail.protection.outlook.com (10.167.244.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.2 via Frontend Transport; Tue, 22 Oct 2024 14:51:47 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:32 -0700 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:26 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next 5/8] selftests: net: lib: Move tests_run from forwarding/lib.sh here Date: Tue, 22 Oct 2024 16:50:16 +0200 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D6:EE_|PH7PR12MB5973:EE_ X-MS-Office365-Filtering-Correlation-Id: 8cc9e793-5bf9-4455-e5c4-08dcf2a90dac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: 9w7QsbTsD3UxeksQl7ZlhbPfICbeIX6jazGLkLyTCT8kQBKhFvr5rIOEoim8mmbWmGOI1glaVTqdsFTHUpXIynPcsihpADIoM8zz6a258frKeMR/llKJ6LuR5Q85WVhslQuuSUy9SPhkinFEqBmlywX9Clos/2tPwIlamzhClru8LGZWUQuhc+fJTZTxB5ZH1SqwJD19J9o/+Nmngt7J+sYbbJRKuwi7i9PWahlm2IszayBAl1+0M8b7OLCwL6vNPltXFHdCTOpX8CMg5AiKhHyw/lrN48xWgHiAGihhWohmUf9z1kUzD28OeSytMET96bI3t5DNJWQMwaoumuShB1RWLUvgRiJci/nsPItWny/Old8pevY53DtPjXVQ8lLYGJ56ldJzLe7Plr+CoebgTW0ikbmEMxZ2Gx+B6Hpn7nqngdFTS4TUXCqgguuxQGp17YfTuI/UHfH77NVQO4RyWMpQv8rECd5KR2iQCeKytybQEAuy9mZDvWqLfTfry7F9xm51H+u/9FmvuI2STbZ3ZuHLzDlYw4+6WaCuEBqTt6rqoJm2zz0XTJbXQEKc5y0nXWRHH72UMWTdUochj1pSQx6HoCIWM/BimdyJ42ROQwlTmkYvyyzQOk9Kl6XQ6uZpEnsDd3PCCzvJCfNDWawgrpzEoHvvcoxijQCl3/9sK4MyBd46KEvZ7Z/Re6JR+XRt/6ITUn7uo2st0z6mpE3ytVHL44VAMfPtD0sWb8b0LHRtw1A1NoxlpfLED8VAXxWhmlJi+1KAk9FscDcOJ742KVYcUxRec9gV3DjjY0rlSOV63rWPDcsfOAnqJcPMUgfdoZk4HGdKpFMDY466o+++/xoe+c6KtZEf91TlRSJlo3k5yOG3I94d1gSvBeSbGdI4oDtikkAxrgKbr2XLX29HWpS4Zra3zbYYftDIkzQcgueXnG/k5ietD9WL+kcrDr3XIfRJud1fBWah9XQylqord902ubsAF+iXbeCDnUvA97xo/nBR0C65D291w0S5EiKSOrfcphABTagwqz/lCIlObX29pato72N3C1BEmhLmWhhWzqzNS7/xZwYuGXnpF7pltl3JBYqxE+6qBhxIp52r8umt3IdRPkgvfQACnKTB8PYjE8hwE3VaAGhys02qbfM3ATN4OD2E553u/Jt9pSqxqvmgxNC+H+xATL3lplRQ/Vy1TDnKabLwtshghkRcu/jInPFoMiGFXdgXBIuiuJhEUDntAb1XlY5/bqA+laS9d1/abNpEkkZmvS0xI6vBMOy+7fLFDZl4sW5t4kWlFpM3mMsfr4Ocju6axlT0Aa1r6Jn6oQJEUtHOCkk2+dCnIZCvtrOlwvE5q7MpiVckqJpmLlfchMMaKbarccaMRI+x0jo6znK/LUy6aU2oR4qJTcqbEvtu7deYV9LT5mOSmta98g== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(36860700013)(376014)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 14:51:47.1191 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8cc9e793-5bf9-4455-e5c4-08dcf2a90dac X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D6.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5973 X-Patchwork-Delegate: kuba@kernel.org It would be good to use the same mechanism for scheduling and dispatching general net tests as the many forwarding tests already use. To that end, move the logging helpers to net/lib.sh so that every net test can use them. Existing lib.sh users might be using the name themselves. However lib.sh is always sourced near the top of the file (checked), and whatever new definition will simply override the one provided by lib.sh. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen --- CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: linux-kselftest@vger.kernel.org CC: Jiri Pirko --- tools/testing/selftests/net/forwarding/lib.sh | 10 ---------- tools/testing/selftests/net/lib.sh | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 41dd14c42c48..d28dbf27c1f0 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -1285,16 +1285,6 @@ matchall_sink_create() action drop } -tests_run() -{ - local current_test - - for current_test in ${TESTS:-$ALL_TESTS}; do - in_defer_scope \ - $current_test - done -} - cleanup() { pre_cleanup diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 691318b1ec55..4f52b8e48a3a 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -351,3 +351,13 @@ log_info() echo "INFO: $msg" } + +tests_run() +{ + local current_test + + for current_test in ${TESTS:-$ALL_TESTS}; do + in_defer_scope \ + $current_test + done +} From patchwork Tue Oct 22 14:50:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13845783 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2070.outbound.protection.outlook.com [40.107.236.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45F2F19EED4; Tue, 22 Oct 2024 14:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608740; cv=fail; b=OeBa+Zs9aUinK0Hp5wVS1o62fkUYO/xRagq/+5XU2/RQrYuSgqjE0VkFGhon1m4LKzqpCbOibxA6E8LUtLOFXEVf70LAHd4XXcxhz9FiLZO+hnxu+SLkiFY7v2p6xJwlydKyXtdKXIqep1rr4p5+QK37hBZ2ciT0CjFVU6TWeJA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608740; c=relaxed/simple; bh=UJmnmlTfL7DKpX0epTT+DWDmctUFH/S0+XoPbo1yvgI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sYEEK3d4K/BGs0hxpj8n2TT0vCGuoRa/CqKqXuFUpeYcoB2B9suH1Xt2liuSWSTIDRAEFrxGZixyciwAXJywF4fI26108TKdnzTC4bMKFTPVy1HKTc+gynr3N1Zb76PKAMvY68ftyH56YXa/lvlOssIIsWslB20s20SGxERcTuA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=Cbyu1Q0w; arc=fail smtp.client-ip=40.107.236.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Cbyu1Q0w" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XUliAKWwWB+Ewv5+Ld/PyhyJ2qxAGOliH3vgGKt2NXk/AqDv+25zc7OII1Xty9Fc1mHnEeA7hpxHPOPSfMXoMWyB7h66kGY4dvBgnKpSy0AAQwA+WPJlsYgaBTfaZeLN8+DDf7p3eh/gOMa40M6SiG+tnJfzDEE2geHnASMAA1Hqu74OJrumN3MrSsohZ8qRj/7xJgG7FZSo5n5bOrDz9zQPJx+Apg/BiIyUnyt/9HxpY0BRKuLNTDff/6elGrtaDXXSBYSacgRSgR7ZEXi+ikk/S00CnUNEYm74s/aUcitfkY+X4mms3Sh89yUXDnZSXU+7Pjiqx/UE8o7SHxbUPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=r6xOfbvduhWp3r2ZbJXG/bT3O79FynaTkLVDmv++o1M=; b=rtqyWAGJCjZRZvvolxn649cqsUc9TfwcW/QJHl8buanID2zu5Z1665oBe+ZXA19t549AogMSd/fgrLKmP6piWoYIIrMlGhegyEw+ZmHlWCt9pkf9yc8u/rWhKgmK+bQ7Sdj7KBxlOKA/UsyUDXAghJH0OgIl09s4BXHqwMSq1A3VR+5hTtrd4n05Yk6QdKktKgkzaG02HOLv0op97fWDfu8wGOAVN69XYGE4qgTJx+7bt0lIcwSAyEaqAe8qhSMopsXH1zjV/pwCeEWJTkmbQDSlrU/3vIBxsLKIedcaMjtz8QtW0HFT5yRJQDB7X4I5+MOPANXHnVP3uhNsPu39JQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=r6xOfbvduhWp3r2ZbJXG/bT3O79FynaTkLVDmv++o1M=; b=Cbyu1Q0wDdqC2ex7svnLpEno7ExPUKU8WtCKuucqNqTH8HAskUOAJ/4HO2cZdxe0BNx4Y5q8FmPkrhw4VB64rNAzz00f3CFlzS7TNvjxolSGtLjhnTBhh4ldclx/NeqrhIQW5OsEhFlY5ySJTc8MgkeKaHsfiZGls65QhrC/S9smYNZ4hMtYxdVbYG0fwpCk696RbDsP+jd8eo6s7ts/YxnOnhp32A31XUh0jkpBzT5/tga4EKqLdxsvMXLyix9FCs4zfe0tAluonSG73K5SHLIJLgoa9AsGJbQ7rnZpRcum7yIusRtUhjXYPuuFjw5bPLrVVxJJWMpNFND45cC+LQ== Received: from CH0PR03CA0351.namprd03.prod.outlook.com (2603:10b6:610:11a::13) by SJ0PR12MB6688.namprd12.prod.outlook.com (2603:10b6:a03:47d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 14:51:59 +0000 Received: from DS3PEPF0000C381.namprd04.prod.outlook.com (2603:10b6:610:11a:cafe::27) by CH0PR03CA0351.outlook.office365.com (2603:10b6:610:11a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16 via Frontend Transport; Tue, 22 Oct 2024 14:51:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS3PEPF0000C381.mail.protection.outlook.com (10.167.23.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 14:51:58 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:39 -0700 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:33 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next 6/8] selftests: net: lib: Move checks from forwarding/lib.sh here Date: Tue, 22 Oct 2024 16:50:17 +0200 Message-ID: <6e337cad958bf489d0dba5446cc01e90d2d9ac02.1729607879.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF0000C381:EE_|SJ0PR12MB6688:EE_ X-MS-Office365-Filtering-Correlation-Id: bb211a50-7efb-4dcb-8300-08dcf2a914a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|7416014|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: syduBq444RUWzg/IHfaiiy5ukLEKEQG0Lz0+MpwnB2lLcGi7JyIOEh/MN+4PX/sv4AQPbYBVycIBx6nn4BmQ4YstOKZVV+79Ie0zSYlJgNiPiI2iISPMgLAIeviINTqsJN1WmzAVohCkHOlWMySBGBebsVaHOxc6KvbpeyjX4OWzNhbAFILjZWxgIcFWhSQFb6UJNJzRxWHDVd9r5+5kUR9ALqjHOgkW2jALVK1B1Jok7vscO9i6LcBQZUVRCAoWUc1z54KeoVD6hKDRA/K2il4zFeiV07qRn/ZPzehPbAa9a3rnCzsneE3cSSUksFhZE4rbeenqoz1ov7b/h9whHuS0Ez8/x2Hm/2NoFD5gpMWi0uarP0EH/9ricezNusEMrzcu245/e1EemvAhfE4rthU2DHwO6GX1baK/gP1Jn+XZ+QrLviZtQex11wRJFNtIbwIpQDAw5b9CfmGqttGxXiY/iVL+J/zIJSUQRGHuK3gJChBgnIa1ZbZI5hv9hECDqyVdkHbMIjtG+3hCxgyIi2WXq0XRB+0vpHc2G++lYKU1FI5xDHFZjzrJqyc0GfFJ3WWFfvDsiF/3m/tDhw+C2OP7jmFBWPrgUzjJWLi0zZpkdnGud2Gy2jmMU3jw6gAAj3vD9D98/S1vptMDRH7oz3vw7ER/r4OFE6mznu6jcQkNwr4Rp30VpYb0DjgsPCPd3LNejjd1PPYhYGw6B24zQ78PjShooKC5pqkKX5EFz/VGYdi3BEwfJabfc78rTJrCVPW6NlurlCw3D1vJkSOt6PaCwXVufeK3gQpCS3wmO5S5CrHq+6bvSsrSoIrUGASAyBzADPTTbxG4Q1hZZMxKbc/Zu/TJ+XlPmctxrwBzOFoood2gy6lEFofBV2xb38lUvgIqQiJxH0WVzhaDQTF0t6XC24Y0eWc/vQZUuOwgjDL7SMVp8p/1pgAf/X41a+m7GvIw4sD6n+pKeoHDW1uB3Ue7UnF7JuIjkX26y3q95USEKt5jMMSdfzEzoWa83BtJhd7SOjXl6DOo8dlFb6Vg0mhflfyG23OobFKUsZQk7xfu+kejbCAxsW8CgnoMZRK2ogQaNzG0ISktIv74TEtstohEbRFO7km2isHyUBbaKgSR6LF9DQWXokOxKJsYliliY977Z6AuoTAKTQXRnH3AWyfVuDLUXZhntPKSnATCe2RNxv20ijhyqmaclB7HAJbcd/HfCckj4cYq8bxmcOEK0q7SDtjqFOAHXX3xJ9eSfo9ZqFC77MfEb0b2L2DSKGSKpS1EeVSN3FLIXdUFqhr2KbEv4Cl2UJFYifAw8nHbd6FctgwR2Q6ZldSQOPAwZRh8k861n01HalAVXCX4jkJIPX8GDhAcUOI0taKSMTVlypjXqnN7V8VDnPzi/M0v9VQYKC4P6cOAsdkOYl9h6oaRfw== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(376014)(7416014)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 14:51:58.8188 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb211a50-7efb-4dcb-8300-08dcf2a914a8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF0000C381.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6688 X-Patchwork-Delegate: kuba@kernel.org For logging to be useful, something has to set RET and retmsg by calling ret_set_ksft_status(). There is a suite of functions to that end in forwarding/lib: check_err, check_fail et.al. Move them to net/lib.sh so that every net test can use them. Existing lib.sh users might be using these same names for their functions. However lib.sh is always sourced near the top of the file (checked), and whatever new definitions will simply override the ones provided by lib.sh. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen --- CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: linux-kselftest@vger.kernel.org CC: Jiri Pirko --- tools/testing/selftests/net/forwarding/lib.sh | 73 ------------------- tools/testing/selftests/net/lib.sh | 73 +++++++++++++++++++ 2 files changed, 73 insertions(+), 73 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index d28dbf27c1f0..8625e3c99f55 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -445,79 +445,6 @@ done ############################################################################## # Helpers -# Whether FAILs should be interpreted as XFAILs. Internal. -FAIL_TO_XFAIL= - -check_err() -{ - local err=$1 - local msg=$2 - - if ((err)); then - if [[ $FAIL_TO_XFAIL = yes ]]; then - ret_set_ksft_status $ksft_xfail "$msg" - else - ret_set_ksft_status $ksft_fail "$msg" - fi - fi -} - -check_fail() -{ - local err=$1 - local msg=$2 - - check_err $((!err)) "$msg" -} - -check_err_fail() -{ - local should_fail=$1; shift - local err=$1; shift - local what=$1; shift - - if ((should_fail)); then - check_fail $err "$what succeeded, but should have failed" - else - check_err $err "$what failed" - fi -} - -xfail() -{ - FAIL_TO_XFAIL=yes "$@" -} - -xfail_on_slow() -{ - if [[ $KSFT_MACHINE_SLOW = yes ]]; then - FAIL_TO_XFAIL=yes "$@" - else - "$@" - fi -} - -omit_on_slow() -{ - if [[ $KSFT_MACHINE_SLOW != yes ]]; then - "$@" - fi -} - -xfail_on_veth() -{ - local dev=$1; shift - local kind - - kind=$(ip -j -d link show dev $dev | - jq -r '.[].linkinfo.info_kind') - if [[ $kind = veth ]]; then - FAIL_TO_XFAIL=yes "$@" - else - "$@" - fi -} - not() { "$@" diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 4f52b8e48a3a..6bcf5d13879d 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -361,3 +361,76 @@ tests_run() $current_test done } + +# Whether FAILs should be interpreted as XFAILs. Internal. +FAIL_TO_XFAIL= + +check_err() +{ + local err=$1 + local msg=$2 + + if ((err)); then + if [[ $FAIL_TO_XFAIL = yes ]]; then + ret_set_ksft_status $ksft_xfail "$msg" + else + ret_set_ksft_status $ksft_fail "$msg" + fi + fi +} + +check_fail() +{ + local err=$1 + local msg=$2 + + check_err $((!err)) "$msg" +} + +check_err_fail() +{ + local should_fail=$1; shift + local err=$1; shift + local what=$1; shift + + if ((should_fail)); then + check_fail $err "$what succeeded, but should have failed" + else + check_err $err "$what failed" + fi +} + +xfail() +{ + FAIL_TO_XFAIL=yes "$@" +} + +xfail_on_slow() +{ + if [[ $KSFT_MACHINE_SLOW = yes ]]; then + FAIL_TO_XFAIL=yes "$@" + else + "$@" + fi +} + +omit_on_slow() +{ + if [[ $KSFT_MACHINE_SLOW != yes ]]; then + "$@" + fi +} + +xfail_on_veth() +{ + local dev=$1; shift + local kind + + kind=$(ip -j -d link show dev $dev | + jq -r '.[].linkinfo.info_kind') + if [[ $kind = veth ]]; then + FAIL_TO_XFAIL=yes "$@" + else + "$@" + fi +} From patchwork Tue Oct 22 14:50:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13845781 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2085.outbound.protection.outlook.com [40.107.92.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36D871A0BE0; Tue, 22 Oct 2024 14:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608727; cv=fail; b=K/lF5FSr4uernpvplyxpJ/gyWLThO95SfGqDFzR4Z2igKDlc9h4Ve0C2cIAJSxmtnt4fI8BWgpeRy88CvQTVEd/uVPWGo0/u2vp6SVFhXYHwkhPef2RPORLuz+Tfynjzs/wyMvAbe11bj/JjW6cbAdP7CM6nyH4Y2UvEYZuCVgE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608727; c=relaxed/simple; bh=w6vLrNc06EtXLU0weol+DYdC4k1JkQaPnfFHKrgNuj0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jDoYaiHNuOIVAdENCJAsyFJUATng3oVAHQtFASVy6wORD2C8xoia16AaCfHmUwzsIJfuoCdrWdVWceL75t9P3Fe9Kf/5NtbHQfYg7Es9JPytQIVjIEeqW6Ph7hAw6CiESQigudyfs0GtMW7wiAQYYhb15ThNynLbi5cgaITf5ww= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=rZta4UsD; arc=fail smtp.client-ip=40.107.92.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="rZta4UsD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zKjtbDN/qlKt7reKNei9Yi1LCnXy3yy/in3+3B76jCDKu+MVYT+mHyPWHmZ8jHfVrS7fVIOUbMKqugZInFsmbE8S8dv9/lOn6ZPNsBbHU1Dgl++Ofih4gsDhA6iiCzfhuyod/RaZThsOfn3epfD8dwejnLjU6I4jEexefH4nWOzeMfZpkN3upkVdTE5PI6A2XVcuLzOXjJIzE8Gx267mBI3S0RswOGgY9nUafoA++8Uz1f5CguBDEOc5dJA8lQzd4hkyQiIntR2xBDENo/BycSmAr3m3eKieNAxerJETRadknFlCpCn2gDsoSwClMLitcERJwpt58IM8ADGXMY7qbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=9yO46m1wrD3vR22LA5vKZnXRrx/Xfxf/OgkDidzy+B4=; b=mQCCx8dV2TNpqEh/47bbYJqvVmM+RqM0EW8gD1O0olnH5ly41P3uN2Ax+QY+XIFQj8Ieq+IgH0dcWkO3HzCzwXwPLEUGFCsYFlVew5OKNy+5R5jhT/JPOa+Jr3wFFABzvm11W1o9lvFoJ9GL0Vi5L1GQVXze1NSEUKAzH3Wn33iLAL/QY/fYLnYYlU8rKMgL1sf3dzQjQmn52CBeV5aY5HWe5+AgqXKhrEMXP3iqm8cZZy6N5oXaPFJmvpiul8WsRujNco8OTgFdPipHIjNEveCWcnW59soQxABDz8zbNyUZqC5l+M/uaj7aHjZfrTrJt3V2XW+/hOBAogg64KYv/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=9yO46m1wrD3vR22LA5vKZnXRrx/Xfxf/OgkDidzy+B4=; b=rZta4UsDtqzkcEsGAWMq6WXBGD8R1uKcFW2bEhQG1KMJJIkgKeuB/+38ZFpbixjI5LJvpQIagx77/T9fCEhGUmzBQz0Sf1aZ0hqlijycqQqU10XQScPMCxQOLALnWPOGsUGi8+GtSTSX0zldqDytxPJFttClAvSy4K9Ij1tzpKIuC6C1WrtluQlX2d8yVg2ER2fXQAP3S5J93Fwc4fvA/0mkhIYpLfFybuh52FmOHjPzx+KATLGr1LvLd9CCZ9GPUNBfS4dPb9hX0SukncL1YYCfCI3XKvI1REMdkQr/HiHhlSYQEE7Hr+MojryYklzSjo9eHJrgncsyjtj4og/8VA== Received: from BYAPR08CA0063.namprd08.prod.outlook.com (2603:10b6:a03:117::40) by SA1PR12MB8698.namprd12.prod.outlook.com (2603:10b6:806:38b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 14:52:00 +0000 Received: from SJ1PEPF000023D8.namprd21.prod.outlook.com (2603:10b6:a03:117:cafe::7e) by BYAPR08CA0063.outlook.office365.com (2603:10b6:a03:117::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 14:52:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SJ1PEPF000023D8.mail.protection.outlook.com (10.167.244.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.2 via Frontend Transport; Tue, 22 Oct 2024 14:51:59 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:46 -0700 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:39 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko , Andrew Lunn Subject: [PATCH net-next 7/8] selftests: net: lib: Add kill_process Date: Tue, 22 Oct 2024 16:50:18 +0200 Message-ID: <53b69a578d52e69c5cecb897140523560a72a514.1729607879.git.petrm@nvidia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000023D8:EE_|SA1PR12MB8698:EE_ X-MS-Office365-Filtering-Correlation-Id: d2660e60-f5ba-4afb-a9d3-08dcf2a91541 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: 2HCEf/NhrCSR4TUR8+/BipjGO9s0LI5EuZihLnp8gFpMEGkmklYyK3rFIjoGs/QEwLU3yw5iySsIsav8XQSrIev15R0ICMQpPnTl9DnAihzampUDhJcH2ShZNHr6c6FTGePkRv+WMdLiE8OF6NECOOeNOGOHhMPScM747OxcDTJGMe0Xk44v3ngYhzW3Q1QdNHkiZuEl44ZRNQ9/Dk6Xq/3RAqM6mSa90JKOL3HZSyE89PNDeuL/4Z4CYC1eGZ7ESPRYzv1ChE4A4ZUT8JomxC3TPEGiefX0mb3DsoU1ceEGBpgobhr93BRs9Unq6tPebHQq9ToFKgFNdplLgv1bd/ff2RhoUDQEGAUMZQN0nDopoayNS41ICCVljPNZNuiHng5v155Q2M5KIFvKBQB6rXh/ISV71MFuCh1Y6I82IEcjG2Z8x6P16prqcZQEGn/R1ETfo0qER/i1gTxRNvnWotOiH/H9VrS0hFUqWnW6fKG8INQpltXBcIgZps/6pkd7kwfJflEclz0PjKHnspjiVUsXGlxyTNPyr5q7rgmpJ2FnmnxW4vigIbKI3WXkhI34ADrddCeZW34n/ty1pfgn1+owaygpYO3fEC7UgYc7MLBveP1MtMS8sLDnc/K79pOStVxInyWbGfmf2P+h1s27wS0SgOnoxtidph0ma4j8D3RY4TRg8VwJ4It5z4tnqZhjjLhEye6+HHS+MgGZnXvx6Kcfv9HNwEU8OBGB2Dbo6NZEM+i433YPw8LWwV4VBLEpwbz6TCYCUA6akdqgZ7eur/CQeP+PhA71P60724PJdRdJT3us5bt7P/sy57CuMSjSgJE0cf6Mj1dOtO8ulGcU+wuIFG1R4xvuwIpJGwD98M/Rv+ptR8RZhPYK1SFn0CBx15B3pILmh9CVkuTTVoPlpB+mRp7s0YR6Ykuxcu+Q/DTjb9XnUbySziYUWIJ9n8QY4ZCsvdLWe1aAxIDUfB07yCqSAVAGMEmYrt7/Bup9SCIOZSo6mR6hVB9OdKy8tbhMClcfwtEWY5E4NS6QcIT7zUgm4qgtDAoNLbXqwC0Gq/LPYSV26AKjMhGSQNEH6VvAAFpSwQnUliSMHrZmi/26bMCiwF2e05pKWyr8Ema5jBKpKL19Cix1y86YTt7L7HtS1QE/qeXjxU63mGTJ5PTB/NeHUI1NhbdZoTjGzhTpAJxTfweZcOYwuJlQDItBls00MVIXjIZh7qGOlCgqHFwbEDLYYpyfiCicTOdEFmCRJOLpzE2LiCKQ8ZQRH54JHme+JGG6ZdtGqtqPHWr3mEylQ/c00f3/KiJikChsAZS8Ligk0sb0g0VIK0RT3MLikh01sl9kX73IqAbhWh3GbNB9GYDYhdCrbPqwwebKYQX2cVrVGJM+Qd72VlUbTnIY2381WIZGZJef6S9DFNPVQWlhcA== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 14:51:59.8381 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2660e60-f5ba-4afb-a9d3-08dcf2a91541 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SJ1PEPF000023D8.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8698 X-Patchwork-Delegate: kuba@kernel.org A number of selftests run processes in the background and need to kill them afterwards. Instead for everyone to open-code the kill / wait / redirect mantra, add a helper in net/lib.sh. Convert existing open-code sites. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen --- CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: linux-kselftest@vger.kernel.org CC: Jiri Pirko CC: Andrew Lunn --- .../selftests/drivers/net/mlxsw/devlink_trap.sh | 2 +- .../drivers/net/mlxsw/devlink_trap_l3_drops.sh | 4 ++-- .../drivers/net/mlxsw/devlink_trap_l3_exceptions.sh | 12 ++++++------ .../drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh | 4 ++-- .../drivers/net/mlxsw/devlink_trap_tunnel_ipip6.sh | 4 ++-- .../drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh | 4 ++-- .../net/mlxsw/devlink_trap_tunnel_vxlan_ipv6.sh | 4 ++-- .../testing/selftests/drivers/net/mlxsw/tc_sample.sh | 4 ++-- .../drivers/net/netdevsim/fib_notifications.sh | 6 +++--- tools/testing/selftests/net/drop_monitor_tests.sh | 2 +- tools/testing/selftests/net/fib_tests.sh | 8 ++++---- .../testing/selftests/net/forwarding/devlink_lib.sh | 2 +- tools/testing/selftests/net/forwarding/lib.sh | 3 +-- tools/testing/selftests/net/forwarding/tc_police.sh | 8 ++++---- tools/testing/selftests/net/lib.sh | 8 ++++++++ 15 files changed, 41 insertions(+), 34 deletions(-) diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap.sh index 89b55e946eed..36055279ba92 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap.sh @@ -116,7 +116,7 @@ dev_del_test() log_test "Device delete" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid } trap cleanup EXIT diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh index 160891dcb4bc..db5806d189bb 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_drops.sh @@ -595,7 +595,7 @@ irif_disabled_test() log_test "Ingress RIF disabled" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid ip link set dev $rp1 nomaster __addr_add_del $rp1 add 192.0.2.2/24 2001:db8:1::2/64 ip link del dev br0 type bridge @@ -645,7 +645,7 @@ erif_disabled_test() log_test "Egress RIF disabled" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid __addr_add_del $rp1 add 192.0.2.2/24 2001:db8:1::2/64 ip link del dev br0 type bridge devlink_trap_action_set $trap_name "drop" diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_exceptions.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_exceptions.sh index 190c1b6b5365..5d6d88b600f0 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_exceptions.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_l3_exceptions.sh @@ -202,7 +202,7 @@ mtu_value_is_too_small_test() mtu_restore $rp2 - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $h1 ingress protocol ip pref 1 handle 101 flower } @@ -235,7 +235,7 @@ __ttl_value_is_too_small_test() log_test "TTL value is too small: TTL=$ttl_val" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $h1 ingress protocol ip pref 1 handle 101 flower } @@ -299,7 +299,7 @@ __mc_reverse_path_forwarding_test() log_test "Multicast reverse path forwarding: $desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $rp2 egress protocol $proto pref 1 handle 101 flower } @@ -347,7 +347,7 @@ __reject_route_test() log_test "Reject route: $desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid ip route del unreachable $unreachable tc filter del dev $h1 ingress protocol $proto pref 1 handle 101 flower } @@ -542,7 +542,7 @@ ipv4_lpm_miss_test() log_test "LPM miss: IPv4" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid vrf_without_routes_destroy } @@ -569,7 +569,7 @@ ipv6_lpm_miss_test() log_test "LPM miss: IPv6" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid vrf_without_routes_destroy } diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh index e9a82cae8c9a..4ac1dae92d0f 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip.sh @@ -176,7 +176,7 @@ ecn_decap_test() log_test "$desc: Inner ECN is not ECT and outer is $ecn_desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower } @@ -207,7 +207,7 @@ no_matching_tunnel_test() log_test "$desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower } diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip6.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip6.sh index 878125041fc3..fce885184404 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip6.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_ipip6.sh @@ -176,7 +176,7 @@ ecn_decap_test() log_test "$desc: Inner ECN is not ECT and outer is $ecn_desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ipv6 pref 1 handle 101 flower } @@ -207,7 +207,7 @@ no_matching_tunnel_test() log_test "$desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ipv6 pref 1 handle 101 flower } diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh index 5f6eb965cfd1..7aca8e5922cf 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan.sh @@ -183,7 +183,7 @@ ecn_decap_test() log_test "$desc: Inner ECN is not ECT and outer is $ecn_desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower } @@ -253,7 +253,7 @@ corrupted_packet_test() log_test "$desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ip pref 1 handle 101 flower } diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan_ipv6.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan_ipv6.sh index f6c16cbb6cf7..4599c331240b 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan_ipv6.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_trap_tunnel_vxlan_ipv6.sh @@ -188,7 +188,7 @@ ecn_decap_test() log_test "$desc: Inner ECN is not ECT and outer is $ecn_desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ipv6 pref 1 handle 101 flower } @@ -262,7 +262,7 @@ corrupted_packet_test() log_test "$desc" - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $swp1 egress protocol ipv6 pref 1 handle 101 flower } diff --git a/tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh b/tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh index 83a0210e7544..bc7ea2df49fb 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/tc_sample.sh @@ -218,7 +218,7 @@ psample_capture_start() psample_capture_stop() { - { kill %% && wait %%; } 2>/dev/null + kill_process %% } __tc_sample_rate_test() @@ -499,7 +499,7 @@ tc_sample_md_out_tc_occ_test() backlog=$(tc -j -p -s qdisc show dev $rp2 | jq '.[0]["backlog"]') # Kill mausezahn. - { kill %% && wait %%; } 2>/dev/null + kill_process %% psample_capture_stop diff --git a/tools/testing/selftests/drivers/net/netdevsim/fib_notifications.sh b/tools/testing/selftests/drivers/net/netdevsim/fib_notifications.sh index 8d91191a098c..9896580c3d85 100755 --- a/tools/testing/selftests/drivers/net/netdevsim/fib_notifications.sh +++ b/tools/testing/selftests/drivers/net/netdevsim/fib_notifications.sh @@ -94,7 +94,7 @@ route_addition_check() sleep 1 $IP route add $route dev dummy1 sleep 1 - kill %% && wait %% &> /dev/null + kill_process %% route_notify_check $outfile $expected_num_notifications $offload_failed rm -f $outfile @@ -148,7 +148,7 @@ route_deletion_check() sleep 1 $IP route del $route dev dummy1 sleep 1 - kill %% && wait %% &> /dev/null + kill_process %% route_notify_check $outfile $expected_num_notifications rm -f $outfile @@ -191,7 +191,7 @@ route_replacement_check() sleep 1 $IP route replace $route dev dummy2 sleep 1 - kill %% && wait %% &> /dev/null + kill_process %% route_notify_check $outfile $expected_num_notifications rm -f $outfile diff --git a/tools/testing/selftests/net/drop_monitor_tests.sh b/tools/testing/selftests/net/drop_monitor_tests.sh index 7c4818c971fc..507d0a82f5f0 100755 --- a/tools/testing/selftests/net/drop_monitor_tests.sh +++ b/tools/testing/selftests/net/drop_monitor_tests.sh @@ -77,7 +77,7 @@ sw_drops_test() rm ${dir}/packets.pcap - { kill %% && wait %%; } 2>/dev/null + kill_process %% timeout 5 dwdump -o sw -w ${dir}/packets.pcap (( $(tshark -r ${dir}/packets.pcap \ -Y 'ip.dst == 192.0.2.10' 2> /dev/null | wc -l) == 0)) diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh index 5f3c28fc8624..3ea6f886a210 100755 --- a/tools/testing/selftests/net/fib_tests.sh +++ b/tools/testing/selftests/net/fib_tests.sh @@ -689,7 +689,7 @@ fib6_notify_test() log_test $ret 0 "ipv6 route add notify" - { kill %% && wait %%; } 2>/dev/null + kill_process %% #rm errors.txt @@ -736,7 +736,7 @@ fib_notify_test() log_test $ret 0 "ipv4 route add notify" - { kill %% && wait %%; } 2>/dev/null + kill_process %% rm errors.txt @@ -2328,7 +2328,7 @@ ipv4_mangle_test() $IP route del table 123 172.16.101.0/24 dev veth1 $IP rule del pref 100 - { kill %% && wait %%; } 2>/dev/null + kill_process %% rm $tmp_file route_cleanup @@ -2386,7 +2386,7 @@ ipv6_mangle_test() $IP -6 route del table 123 2001:db8:101::/64 dev veth1 $IP -6 rule del pref 100 - { kill %% && wait %%; } 2>/dev/null + kill_process %% rm $tmp_file route_cleanup diff --git a/tools/testing/selftests/net/forwarding/devlink_lib.sh b/tools/testing/selftests/net/forwarding/devlink_lib.sh index 62a05bca1e82..18afa89ebbcc 100644 --- a/tools/testing/selftests/net/forwarding/devlink_lib.sh +++ b/tools/testing/selftests/net/forwarding/devlink_lib.sh @@ -501,7 +501,7 @@ devlink_trap_drop_cleanup() local pref=$1; shift local handle=$1; shift - kill $mz_pid && wait $mz_pid &> /dev/null + kill_process $mz_pid tc filter del dev $dev egress protocol $proto pref $pref handle $handle flower } diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 8625e3c99f55..7337f398f9cc 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -1574,8 +1574,7 @@ stop_traffic() { local pid=${1-%%}; shift - # Suppress noise from killing mausezahn. - { kill $pid && wait $pid; } 2>/dev/null + kill_process "$pid" } declare -A cappid diff --git a/tools/testing/selftests/net/forwarding/tc_police.sh b/tools/testing/selftests/net/forwarding/tc_police.sh index 5103f64a71d6..509fdedfcfa1 100755 --- a/tools/testing/selftests/net/forwarding/tc_police.sh +++ b/tools/testing/selftests/net/forwarding/tc_police.sh @@ -148,7 +148,7 @@ police_common_test() log_test "$test_name" - { kill %% && wait %%; } 2>/dev/null + kill_process %% tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower } @@ -198,7 +198,7 @@ police_shared_common_test() log_test "$test_name" - { kill %% && wait %%; } 2>/dev/null + kill_process %% } police_shared_test() @@ -278,7 +278,7 @@ police_mirror_common_test() log_test "$test_name" - { kill %% && wait %%; } 2>/dev/null + kill_process %% tc filter del dev $pol_if $dir protocol ip pref 1 handle 101 flower tc filter del dev $h3 ingress protocol ip pref 1 handle 101 flower tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower @@ -320,7 +320,7 @@ police_pps_common_test() log_test "$test_name" - { kill %% && wait %%; } 2>/dev/null + kill_process %% tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower } diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 6bcf5d13879d..24f63e45735d 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -434,3 +434,11 @@ xfail_on_veth() "$@" fi } + +kill_process() +{ + local pid=$1; shift + + # Suppress noise from killing the process. + { kill $pid && wait $pid; } 2>/dev/null +} From patchwork Tue Oct 22 14:50:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13845782 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2085.outbound.protection.outlook.com [40.107.243.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1D6E1A0BE0; Tue, 22 Oct 2024 14:52:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608738; cv=fail; b=AopMYLwR+vdrEozMw/yDtBZ3R/hGb79g+XkbC04pacYCwslcwFijqCXxlwfQTrGKJHXTlWpbY5hFWR8EoWVfjNnmBrdQBplFPOmSB0nRiSmw4uat0uK3tEowPuszagToWkn/YAepzODODY9yVPbB7iCpJhttS9CJGa3E1BksYZI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729608738; c=relaxed/simple; bh=lZQvmwDNeH5pMg0XXLgJCG73AbB+ZHDBicthcAv/nLM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eP5FlLJNIdEeibaKD3JfM5MoEsugeWOL9FaL0EWtS7TvC2Z6pOffYIrj7FiWk7XILoVJ2KVPv1WlWZy6K5XBgpruMGbPQjYreSaxpmYrJ1Tp4PZmoQXYvdJAqh0d1/hd/JcyqERNDGO/GrqC6/9Zv1ZTzy1HRzxS2XNNoq5PUR4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=dp8ddWAp; arc=fail smtp.client-ip=40.107.243.85 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="dp8ddWAp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dCddP0QOnh3B96x7/ORX/BY6D70YdKX/AXP4l6nhSsOIFhg+NMx/Ye+vLVZ4DGzxZ7ZtVtdxBx9CB8+wrY0DwJbB+s6+joX6sv9TC4luv3suwrIIeOW9Gzm8jrpzyEV71zAlJkYUzvhEPReO517ZJ+m46RgLZdfkJnfJJxFCOsoOJXU6XwZyHBmNwXH4sVrZQ4I9dj17aIpJpQUoYuJa/D5IP//mvsEqBlDbmARFNV2xGXPIQyoAZ7JR3YTRMEyViMzH2ZNxuA4Ks3KsBA6rwuoK6eeFP7tSZFjP5czWom/QpMx645RNf/SJ9w1qfoGfSu93fQwB022JPUQTGBERGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=RdTsgNe6H3Wuwwt715kdN/GAzD2TfTrGDPddrZWV6a0=; b=NRYy7h8swxBbgs+oLWi1ERJ4Tlu7zXwJmeT1PaQha8SSwiX+W/OBghf0c93ihiigSLaGGOeEsreQbt9A10WbRCLJOHTOvFCNQ0DtY4B7vgPsx8wCc4C4e/1+bZxFYU/ytFf6Po80VzgYpf+GtHPSCQ+omNg+9DNYaAVxyXNk4yxHwOoSVzdIYU+JNFPl0xCzt16uEl33gW1Fie0uvDQhBPDL5Y0eUvd/c4NI0cjGSHwAlwkkBrJDuTbgtyoScYgIXGfx+V5KZZCqP1xkOqlKS7xTb/UX6we0TGrTJ4EJBv85L0SCvl7f9pOrr1u8jQInohjAEBF4FIY0Ra0UrCA4Gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) 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=RdTsgNe6H3Wuwwt715kdN/GAzD2TfTrGDPddrZWV6a0=; b=dp8ddWApkfz+eCzh8Baxb+i877jdcGMT/OHRcKnz4Kyi4WhmQdXS9fwzExM/S0Wxn4R7aSPqFek0N3xjA9mibKL7wzinwFub52/hDPSRazuSSkU3MzXut+34XnSiB6XVdKbiLe4438SqEXrN9P6LvBhPbCLUa1sYfdngbWajVmx8/Lu0cZkXE02rU46EjsuU+eZZLAwZNZEZ85YYDWbFQuHn0mcV8WOmzenrqx7+rSSljk2cSdNBSkux4RxmLBRG9/e7/9JVv6aHXLqR3XMnpteEx74SBI2AwzRME26vtOYrFwNypq9Ts66uGzuG2d54YuvhiRQXnvkuBkFC8yDPrw== Received: from DS7PR06CA0034.namprd06.prod.outlook.com (2603:10b6:8:54::18) by SA1PR12MB8700.namprd12.prod.outlook.com (2603:10b6:806:388::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.28; Tue, 22 Oct 2024 14:52:09 +0000 Received: from DS3PEPF0000C37A.namprd04.prod.outlook.com (2603:10b6:8:54:cafe::1c) by DS7PR06CA0034.outlook.office365.com (2603:10b6:8:54::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Tue, 22 Oct 2024 14:52:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS3PEPF0000C37A.mail.protection.outlook.com (10.167.23.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Tue, 22 Oct 2024 14:52:08 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:52 -0700 Received: from fedora.mtl.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 22 Oct 2024 07:51:46 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next 8/8] selftests: net: fdb_notify: Add a test for FDB notifications Date: Tue, 22 Oct 2024 16:50:19 +0200 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF0000C37A:EE_|SA1PR12MB8700:EE_ X-MS-Office365-Filtering-Correlation-Id: c0381f4f-74d2-46a4-3000-08dcf2a91ab3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|82310400026|7416014|1800799024; X-Microsoft-Antispam-Message-Info: gCgSwJaya0RMkAWaKE8ddIHQM93CjQ3pHcSN4Fe7y1ACz+D7/e8+kXSNvqILKweFRaQa07Q0dNyV3q6zHA69qlAwwNc1dfU8NQqLtyHg7k1PVBy9QlP5USjjk3hSKFTcYv3/iyd/8Ly/fyfosA4Tlh1BMTgDnQDMm9J07CHLx5Plxb2rHR3Tnfn5kS4d0hA8ZJOoeznSau0Sp2uriV4dPfw/WeFdEv8LSgGVXkggQkm/f2BkrbTypZtPonduE8fvwiZRAPyFKwSh87BnZ41ZA7cpsN2ZJ89ByBDSb5Zz42hJdCichU2d8TeFqDuTB7sERk8x3WQY3sZaP+W+l2KJX5OiHQOfB2r79jrI4bp4txkDeNKIqFJC2YjRy/gI5jTBcta3XJsxtPodFktf4lQidkdOl36QzYHmAHOL0CFY2Y+/GSXlAdX6oKgAuV+ymxNrp5caaoPcy3itKeGAy/DlNIUfBxgOho7YnEfhwiW9R+EvIHA2QF+NDwj2yLJPQZZ7m5VEMmtAnnIVpPW1igT/tNKX3mZ7ysvAbhmzYKR0o5Og1G38/Q7yabrIFnew17cwuv5dkSTxecrjbRb6lVQsXGVIVi36znjIB6oDg4iyluTHpemI6D+p6weUTd9uZW+5s60ypIYPvtvQZqEh+/tXTlJlj8JubhJi2PPspN22pFEa0F02xy5Dbo377gCv5LRTQHXkunIig6MnXmtoaw3ymJ50mu4fib+uJFB/kGWBudMxeL5qv8o8FH2lPF6JJ/e//mvho2LsWxrtH3IILLuN7XHOEobYpl2/Qs7DqvkZAJwrUZmPSxDyNU88l//Mhf15iNdohU0uqh0RFI+nDug4PS9EmLg/Bq06PSp0sZG2oVKQbLCalc7cmYcTCRQocFOnPQxRgDf6HRLpyo1gB5STgk0z2C0sHgYMS9WuOJV0hwE2H8P/C4s1gA5RhjOutEMaaDgn3x07DdkcxVSjj8Sf9cL4wNB56mRne0DYWwwgmAFzf2DapmWBWU7/3ovp8bUGkn081+y8IsBjeyOxFKsdtESYVU05VwFz9C+iIvzBtUAf2eKtEozQDUmYoIZqhv+iHp7aT4uzM61idBaXPz/LR/ifzXgQGVYLqKnIeAEgKquEkD5ugO5aJA2SSmtS9TuL5Qct2sTpnmjKIERQdbetqcd/6DIwLSwP0GpnnfHegN8xfKjf2slYhwLgYUL3TLHsVcDzYl4a9D+hsUCe20+rJXd8OBqP7yetLc/v5qycwCF3dt+3vI4q/M3qEWqKfFmylYPveQfCTVsZ1UXOAyZq9McL+Np46dNtWJWrWkoQs0wwLJds5texhKlt1BklWdHSYpYXYFyVhFRdAbvSDbO0haIw+oiDGm0IPparIDeUe0edS8KwTxGB18pGI02/BYdn68rp6JZ/DeU6apwz9yqsow== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(36860700013)(82310400026)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2024 14:52:08.9550 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0381f4f-74d2-46a4-3000-08dcf2a91ab3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF0000C37A.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8700 X-Patchwork-Delegate: kuba@kernel.org Check that only one notification is produced for various FDB edit operations. Regarding the ip_link_add() and ip_link_master() helpers. This pattern of action plus corresponding defer is bound to come up often, and a dedicated vocabulary to capture it will be handy. tunnel_create() and vlan_create() from forwarding/lib.sh are somewhat opaque and perhaps too kitchen-sinky, so I tried to go in the opposite direction with these ones, and wrapped only the bare minimum to schedule a corresponding cleanup. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen --- CC: Shuah Khan CC: Benjamin Poirier CC: Hangbin Liu CC: linux-kselftest@vger.kernel.org CC: Jiri Pirko --- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/fdb_notify.sh | 95 +++++++++++++++++++++++ tools/testing/selftests/net/lib.sh | 17 ++++ 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/net/fdb_notify.sh diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 26a4883a65c9..ab0e8f30bfe7 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -92,7 +92,7 @@ TEST_PROGS += test_vxlan_mdb.sh TEST_PROGS += test_bridge_neigh_suppress.sh TEST_PROGS += test_vxlan_nolocalbypass.sh TEST_PROGS += test_bridge_backup_port.sh -TEST_PROGS += fdb_flush.sh +TEST_PROGS += fdb_flush.sh fdb_notify.sh TEST_PROGS += fq_band_pktlimit.sh TEST_PROGS += vlan_hw_filter.sh TEST_PROGS += bpf_offload.py diff --git a/tools/testing/selftests/net/fdb_notify.sh b/tools/testing/selftests/net/fdb_notify.sh new file mode 100755 index 000000000000..a98047361988 --- /dev/null +++ b/tools/testing/selftests/net/fdb_notify.sh @@ -0,0 +1,95 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +source lib.sh + +ALL_TESTS=" + test_dup_bridge + test_dup_vxlan_self + test_dup_vxlan_master + test_dup_macvlan_self + test_dup_macvlan_master +" + +do_test_dup() +{ + local op=$1; shift + local what=$1; shift + local tmpf + + RET=0 + + tmpf=$(mktemp) + defer rm "$tmpf" + + defer_scope_push + bridge monitor fdb &> "$tmpf" & + defer kill_process $! + + bridge fdb "$op" 00:11:22:33:44:55 vlan 1 "$@" + sleep 0.2 + defer_scope_pop + + local count=$(grep -c -e 00:11:22:33:44:55 $tmpf) + ((count == 1)) + check_err $? "Got $count notifications, expected 1" + + log_test "$what $op: Duplicate notifications" +} + +test_dup_bridge() +{ + ip_link_add br up type bridge vlan_filtering 1 + do_test_dup add "bridge" dev br self + do_test_dup del "bridge" dev br self +} + +test_dup_vxlan_self() +{ + ip_link_add br up type bridge vlan_filtering 1 + ip_link_add vx up type vxlan id 2000 dstport 4789 + ip_link_master vx br + + do_test_dup add "vxlan" dev vx self dst 192.0.2.1 + do_test_dup del "vxlan" dev vx self dst 192.0.2.1 +} + +test_dup_vxlan_master() +{ + ip_link_add br up type bridge vlan_filtering 1 + ip_link_add vx up type vxlan id 2000 dstport 4789 + ip_link_master vx br + + do_test_dup add "vxlan master" dev vx master + do_test_dup del "vxlan master" dev vx master +} + +test_dup_macvlan_self() +{ + ip_link_add dd up type dummy + ip_link_add mv up link dd type macvlan mode passthru + + do_test_dup add "macvlan self" dev mv self + do_test_dup del "macvlan self" dev mv self +} + +test_dup_macvlan_master() +{ + ip_link_add br up type bridge vlan_filtering 1 + ip_link_add dd up type dummy + ip_link_add mv up link dd type macvlan mode passthru + ip_link_master mv br + + do_test_dup add "macvlan master" dev mv self + do_test_dup del "macvlan master" dev mv self +} + +cleanup() +{ + defer_scopes_cleanup +} + +trap cleanup EXIT +tests_run + +exit $EXIT_STATUS diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 24f63e45735d..8994fec1c38f 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -442,3 +442,20 @@ kill_process() # Suppress noise from killing the process. { kill $pid && wait $pid; } 2>/dev/null } + +ip_link_add() +{ + local name=$1; shift + + ip link add name "$name" "$@" + defer ip link del dev "$name" +} + +ip_link_master() +{ + local member=$1; shift + local master=$1; shift + + ip link set dev "$member" master "$master" + defer ip link set dev "$member" nomaster +}