From patchwork Thu Oct 24 16:57:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13849426 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2040.outbound.protection.outlook.com [40.107.101.40]) (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 24F401F81B9 for ; Thu, 24 Oct 2024 16:58:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789110; cv=fail; b=gH2GmgFFtcWG6sm6WekTx/nOnYccOJZe4ypoS4elM3Hxd8fguDyZECyTVsJ+XX+WFInNVNEvGdgW1Lz6N2mkC3mKCT4lHVwQjO0I+fVyPNdDGs4VImpjd+YXCwqEMB7n2hq2b8D2ywDkhE3ngpClGsspjG40FDWQe4FxA+PGWto= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789110; c=relaxed/simple; bh=71PsBdfnKTDEV8mGSETLlyETmkofyhpK+a+Ba/Tuf+0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Mi8xMpFEMBBwAIU85FCH6AjSQcnSM1lcAtuTKtpKczQYp2jZfI7KrvB57lgxGNeiHT6FecTQn94G7AttzeQ/OOO1/LzTGe6RSnu1EmYRwoAS0SwjY9siKrtl0M+J7b9y/yH5cLrIxMeCycLape5T0xl/3Uk3W0vscHvdMoMkBDo= 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=pk8Zm5Ke; arc=fail smtp.client-ip=40.107.101.40 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="pk8Zm5Ke" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HkCjZ8SBdnElbvZDN9OQyx9DbotM3YkcB7OMABew7cfB7T+xX4W6jjGgdBnkHnN7BazSn/ek/X5KKPsnfaz9MLICgHb3xhp/I5TWuzfDBh4GpK2he4e1036PyTUz73Y5Qe18ptvObtnMcR5aU6CEZDrDI0RSzFRcs+Z7L4HiWhMDedcETYqxcaBZio8d6GKSlrbNM26Rhvn3O7hrONMo8OXOrcPacW6YGOFkrgEJc+RJimbmBkuU5H3Dzz4LJAKM7QSeOqVxAdyt2aJH5Vt0mMGiLXL/ADMV3bPLtiDT2/3ImjJiOFvFueTOX0mKJJ7dOr0OWGWZ12+KIUAc1pl0NA== 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=ji37eBUP6AOL/3De1mGYqKkdbcPdB752V6giI2c0vas=; b=oVIlIvP53qsPnbeMO6PSfDAzRRGcbEo5WK1b1Y0c20k0a1wHqD9OmyIDn9EgR6iIEwTG09PUY4rAcUB7lx4xlgvOyfZvzLID1km0IvaIeKxwyHoeg+7FhwWvGbBS6vLsAxq29qEjaAv3O7OE8zcsq0WYGqcc++7ebCIq6Gt0UFnk9TX/bIgqoG6vO8CU9KRnOngqQfu7rv9geKT3nQnN3exVBfOYre5CVASFfdJ/AXXhZWNR1QzpC1M6OA4TdvYw7uVkZHFpFbqrFR96/ql6BD6lmrkWTIqM+M3qslVqCl4j51ohR+zJvSuhe7KQGhha9Ud7gS/hZs5j7Lxdj7e6Zg== 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=ji37eBUP6AOL/3De1mGYqKkdbcPdB752V6giI2c0vas=; b=pk8Zm5Kerbr5e7A1aly870n6qn4PIdlPZFYUqFVKF9ztRjjH+ktOczDE+9CXbYe7b/1RJk+EP4sOmpxWINJ0Xd1bdadVzj5mjJrLDEH4pW+DZc49fu3qz9Ss097tPqzwnwlGffBm1NXTFUtMd/wWs6wFIlgJ0IwDeLsqjiquJVZpQsde+No5CkdURVwgKJyRPPtvYwbQcAB3Ke7s1S5M6fsL/R7HhOoYSc3RdTlDjQZLMJsbNLGTDXA/7XYo9VaJ94BJb0a6c7yR4Qtvqx4TFat49ScJ5b2lxp5LlFZSx/IkS8ZN6pAVVVzIAV8gr90CqcRtsWyEtlstB0yRQMTnkw== Received: from SJ0PR03CA0332.namprd03.prod.outlook.com (2603:10b6:a03:39c::7) by DS0PR12MB8813.namprd12.prod.outlook.com (2603:10b6:8:14e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Thu, 24 Oct 2024 16:58:20 +0000 Received: from SJ1PEPF00002322.namprd03.prod.outlook.com (2603:10b6:a03:39c:cafe::21) by SJ0PR03CA0332.outlook.office365.com (2603:10b6:a03:39c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20 via Frontend Transport; Thu, 24 Oct 2024 16:58:20 +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 SJ1PEPF00002322.mail.protection.outlook.com (10.167.242.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Thu, 24 Oct 2024 16:58:20 +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; Thu, 24 Oct 2024 09:58:06 -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; Thu, 24 Oct 2024 09:57:59 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , "Andy Roulin" , , Przemek Kitszel , , , Manish Chopra , , Kuniyuki Iwashima , "Andrew Lunn" Subject: [PATCH net-next v2 1/8] net: rtnetlink: Publish rtnl_fdb_notify() Date: Thu, 24 Oct 2024 18:57:36 +0200 Message-ID: <2e53a70cbfa8b04fe396ef13993d107da31c8c4e.1729786087.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: SJ1PEPF00002322:EE_|DS0PR12MB8813:EE_ X-MS-Office365-Filtering-Correlation-Id: 0615bfb1-adb9-423d-ac20-08dcf44d105f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|82310400026|7416014; X-Microsoft-Antispam-Message-Info: GffkoEqZbYqOeq90yFp1ZdO+V3r2uMJlBkTDOUBl+6UhWf3D2xh8oW9daYOhKNcyG331J/+fpkDCoCv3aD5F/sQMXEF8omB3qgbkbTJLxGNv07ZF3jdwjgjbx4+tTuwb7iYobQ2+DvvJQ99w/pMsfrRMrWP6MqRTjoB0UWUcW03xv9a/f0gXZexSOomCG80HLNwPUL8+qD0HXPqu1aEsc0HPxLut/IjIK8F2TEAEJLUEY0CxrABnL6rdciWiNcHFxJ6gs0RwrC1E0jejmrKA/ul76yAzPp+oDdS7yRyB2GooIpeOXEGNJLEssSqu6gpYgRe5T4D2UI42BhtWR/ShHBUnY0q73tGXValOPa4zXFQKB5QVvK2LhdAwJ9/BXVYM1kC/9idHHELuVx2QAFsG58yUlTTNVVrfKJHFujMjpp48Qg7kcEcfSaPfcHVaZijHnPz5+47q830uZ/m4e8jbb0ddTB2HSMoERxF7862pOrPIRMtqFY0fHf6bWgC/EH8XRab/LE5l7f+huPFdzrXkDXzNCWFWHbCCY/mFsovCDLEfQF1ay82tpCeLQxlrTwGRKx+AKg5b2m9SVmTzsm7nfTqZD8uyhy41G7SnIzS0Sb56NYrxTrc+XfNLT0xOkNN6p9XJVFzRw/MVfKrcv0W8wFFUASSNGBS2InAleGChlXGsTHeukcYK9yDuxFLyV1luMkrr96TC8vZoGuVT3qLYHQ5uXoknpCyo+EHOohBR1poo8Rie0sfphO04pKibWlXJgoG6NMQI4L7G3nifABJ6fwlqbj/XELVSV6gb+PtBQqM85wWALrPHdDk8kuZAY5u6DuCroCgM2CnjGyQWQkLRQMSP5wP5pHhnSB5ofevwM9iUNdYnipr3L383eMyVWmxEhZbDD8xNPjvK0oOV3a3kwKJPf4g1P41kiPRSq/ppcUuuR17CKEN+P+5uSyk6p2U826aH7DU3w1wrVa9kiaBXlU8M7gnDiMEuuQKwIaJJMMJCpqR8jj8S+qqFZItgMWeP9eUZISU3n0osbfDS+0b7YmZzmcN6wm5A3b7Oq1NXETZdk/jY8hhetUp8Hk8n4a3TKmSHhHlT7WcMiA/MX0I+55rDLetB6yeixUMG/W/JKhRvGl0F3eHrrF1azcTfg+zlDeBe0jwjnQhb2ZrU8SRLe8y+hpdR0SpJJiMbABzC97iIXL8rKbCh/Q50jxx9zToiyaOwpAz+8UFIKQJ7/rU62WYQdgqPIvgwqwuzXvrkrMHj1xVooOba48NcuCbdtEmRMxvs/QBP6n0bZcaATgoDcJg6uNlr8EZ/nk/B9edKaRoMZsdsOMtOM+iKY8iPaO2w5BcpSRe9PRi6PS/p5RGtiYeLevboTHIkQYqoDYqrPFRcjSbK3HJjFb7UeEd07TzFWrOALgZ2lp+6U1EZqqvB0g== 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)(1800799024)(82310400026)(7416014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2024 16:58:20.2882 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0615bfb1-adb9-423d-ac20-08dcf44d105f 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: SJ1PEPF00002322.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8813 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 --- Notes: 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 Thu Oct 24 16:57:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13849427 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2078.outbound.protection.outlook.com [40.107.237.78]) (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 EE67C16F910 for ; Thu, 24 Oct 2024 16:58:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789118; cv=fail; b=f+P+h99SG72oFI4fatGO6DKXNDr+UIRFfCUYWAdGkDRrL8TF8v+og4NIPfldFFQWBUtFQ4Jspp9TuhZFi3l7OAosu8zPLTy/+4x4VpVKeQDhxJdnCgfBbpMQ4JjZnCTxHdTTmu0w9nlK8Q227N3ION+LNyWHio5e+VqQV8LCdgQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789118; c=relaxed/simple; bh=q3ts4vUUQfYkL2Bbe1qkzu0i9GgOQqyjD0KcC0VzGq4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VLkpwTQDlOeGdUid5z77EDhuYBOrcUlKwRuQiHQ+S1uUHGPAaa+yPYtYdsKVK/l2gE7Al+drvSoI3VWvnT/Em0wcGqJwkYr7QV5yznFTjr+W8KMnvmtwicnr9VObsuO8tAJeMCg2jvGCdWwpgE4RL411nRzUwLHfkNCiWCJ+u4M= 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=DnVSCP94; arc=fail smtp.client-ip=40.107.237.78 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="DnVSCP94" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xi1spLHLkvekhz/0aDODb5owEkh8RavrpUBsFm3T4SlEGs1OD+FRQ6ZYTl/1Ru1YfoAS4cedxDv/d/rvh5tZwSlgE6XkECQZTw3OvALLiS21pQWNOtSzOnMyvoqYhN3SXUUu/icRNe36lqK4/9W1nGPGULYoXrPokdzCB8++8z/8dJGGYm7kEnV5Ahiy5zgHzJguI6Kj5mltZ++BTkDcYWyFep0UXn/Z0WwcezQBNLLGX/rNA5AG0v6pZNdcb3hVQ8FGVXa8+W92kNORewCadXtVoAhDq6Nt6z93wO9G0n7MQJO9tAJWzGmN98Qbl415MquBvr80yJBSBkVFEYktkA== 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=B6o8GVt3j2bzQyzwjo+CDrFwovQ0czdOAGsQR+DF4ko=; b=YSuuy91UsVhlQhpAhI0WftLK4PSFyRg2FHUdu7G5yQYfWf24wRmCTX+k3fck0r526llibsXdZLXPjm4RMB+9BENhv6R5H1D4DzG6vgXtYZrnvp6Z77ou08CfbUO5VhEsF7NBKyMweQoyW6KKcRn8gHqZ4lIKXinNh97M+HCGOA2UzRuvahN8vdwcctBF4UeBS2/eIW2Vu2WY7lGtq5Cv+1NwzSe0rku6179C4d/1+WhKF+IqR/sc6Igotjt6xp9CJUlX7MF2bpVpA3BkUeTkEvdCf0E1hp73kYhC/Q2+1vOs0+jGacF9sKMzswQpvkJJ3Vr/pJdcq+uUCzNW1sNbcg== 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=B6o8GVt3j2bzQyzwjo+CDrFwovQ0czdOAGsQR+DF4ko=; b=DnVSCP9495U27NgFvAxkJjZtSpBKJHrZoYFrtwhYyg83iwh42c03v1lRbaksyIl4rXNgtrBuw9EiNiQ9EGzxi7q6xCXUut7MhZvelIVrfQROyz2V7iwg74guRFq1Bft1UTksL7rdThkgNZND5C6xZQzhl9ThvAfVTkz8vZb2ddESJ+uE5/iT8fIqU8KZ/E9UxzCB6Kf9pz5UTfzwgWm3jEt4mmXYPf/5Omim0jlvB4Q2xiYCeUq2xpUnzv4MRCFebS7YznH8udHtatzEPeC65g2VcIBq1DEVMdwSUAA01JwF/mOoYo1vP7plc5dZnsHRx8c8m1LT5k1PloiJLTYvCQ== Received: from BY5PR17CA0044.namprd17.prod.outlook.com (2603:10b6:a03:167::21) by CH3PR12MB9021.namprd12.prod.outlook.com (2603:10b6:610:173::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.23; Thu, 24 Oct 2024 16:58:29 +0000 Received: from SJ1PEPF00002315.namprd03.prod.outlook.com (2603:10b6:a03:167:cafe::1a) by BY5PR17CA0044.outlook.office365.com (2603:10b6:a03:167::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29 via Frontend Transport; Thu, 24 Oct 2024 16:58:29 +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 SJ1PEPF00002315.mail.protection.outlook.com (10.167.242.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Thu, 24 Oct 2024 16:58:29 +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; Thu, 24 Oct 2024 09:58:14 -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; Thu, 24 Oct 2024 09:58:06 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , "Andy Roulin" , , Przemek Kitszel , , , Manish Chopra , , Kuniyuki Iwashima , "Andrew Lunn" Subject: [PATCH net-next v2 2/8] ndo_fdb_add: Shift responsibility for notifying to drivers Date: Thu, 24 Oct 2024 18:57:37 +0200 Message-ID: <5fb245d2d6a0ad78c42bba2a3d30dc1a42f9ea8f.1729786087.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: SJ1PEPF00002315:EE_|CH3PR12MB9021:EE_ X-MS-Office365-Filtering-Correlation-Id: f2832bd5-6da4-42f0-0a15-08dcf44d15da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|7416014|82310400026|1800799024|376014; X-Microsoft-Antispam-Message-Info: 7sxn4AHgASYCaE+pIV7bVoh32FS6tw9zndUToVucgXz5H4874uYcTBfco/F1gFloYnaTik75VBwTnk4sYXvTLFnutdO7zqSGS0pUDu9vTjQduBwfRXy8CGLgRmS1/XWDrfvkflI8KNJeL6pFp7CY0F6AJyKGHfz4qWPFyFWSrkvGA1pL4YklK2iEocmBV3T7J8P8yYNul9MfMFNKNsmBOaR8vP5+xEkuTCbxiDHb4+m2+0M3szdMaNBZXy7NpzSYPew7PJY9Yv/tSFwNAXvsI6XSTv423glFRPY2jYjdnGdbNjD/huwYpTSJ8aBzOM3GCaw6xMDm1Cd4j/BtA4nsh370TwDSAIzYc3U8x1Qs/0rA0EZytnd6q0bDFIL8QeFKcqJnrJx5XDM6Uh0+0Q3ULjLw+2tTv7SW7PK8tXBgbl36QA9L4rOH3fP90fog0LJjjrjyOhG3hbToJ76oW1CN2BU8s3YQBO75w1FIj5RPIXgidKqPovsu1Iy1/JZFWuZ6dje0NBgyRvePPDEjwtYy9Jn/EjmLui8BU9VY5cwweyWNwvm1SCjlSQfDs/uY4SLXV8fwaYW4KE2JfalaNHUG4n1iizH1QwsUzGyzjWRrkm/bapxtJjxErER65ftKvwx2/UjQ7LsCpskzztDSimu0HKuBIZmAf/10zbWUKYV4SaN3pc0llpm4y1YtkVgJU4V8YQm/uWwfJFgszMMCAmkfTiwg1jViaIDPsl00NUOfIrdzT6NNm7c/87xRjWA/NPkagOMRj6E8rZiubhFYIgbInOBmzF1gDmGVRwf7IBJHLngtLu6CP6a3WwnsFcIXKA9iGbESJtyrr24Y8qjuRKCgIcNGAdabfx21rOnxX1JgS346TVnGAlH/rgqfSY+Xlw+zUbWLiSRPwwMOkzFtXn/j64/FgadWY8tIaduKInPja/yFzOcQ+/VRJ3BJnV16xGw10Q3Nu06/FHe3sMJFxtpfAd8wm3K0B380gBRg3w6a53ARMhVnXfTtzEAoAQg9WMEfvmZZrkVCBmX2h8AqlESI6yfAP1u5c5aePVGRrUmW4clh4kfkgwbQ0LngDqiKj5J0z7zGUu7zGtH6NVxOT2YSLMwiCofIye73ELbX3LrGWbPi4sjHJT8NZrhwCRiU+0FtI/tNqF4BwLMdL4j4WHiAf2ni7OHHXsPi3OFfAz/3JzWrS0HPjTw45x/acmGKbaZ7GuaGffyNv/ILZJ984/V2JDdqbDdO2mCPBc3pCIJHXrTiDazWpWXE6WwrrOfExu3WwrMowLNhGE4S1NDsekUP6Jan/Qw1y+DfqN2ig/mWYm9A9W8CzrBxpofr3atwFRLTjOjc7ggbGH+nWXD7o777LrfwtBnvaA5heHyRt/TyIzZN+t85npKpKODpiv2vwZw+Yo2j9fpAPtfibuYLR6vl6g== 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)(36860700013)(7416014)(82310400026)(1800799024)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2024 16:58:29.5725 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2832bd5-6da4-42f0-0a15-08dcf44d15da 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: SJ1PEPF00002315.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9021 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 --- Notes: v2: - Fix qlcnic build --- 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 | 7 ++++++- drivers/net/macvlan.c | 3 +++ include/linux/netdevice.h | 3 +++ net/core/rtnetlink.c | 8 ++++---- 7 files changed, 29 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..584c85c10292 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,11 @@ static int qlcnic_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], err = -EINVAL; } +out: + if (!err) + rtnl_fdb_notify(netdev, 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 Thu Oct 24 16:57:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13849428 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2058.outbound.protection.outlook.com [40.107.94.58]) (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 BC7091F893B for ; Thu, 24 Oct 2024 16:58:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789121; cv=fail; b=ktFDbHs/WSLrSGviDx2at2V6c/SZ5ICuDjTEeLSHwtPFVq6eznoxMp6dfsOW0Z4W4A6VlNEocvdbgGWGvtLHLKyYy4T+wrUKMg9C6ReC90/b8IeF1dcaV/mrB354nMONmTqT8IK0TrrTJoO3qZ8oiVKhOn/t3XcSY+CwSv33XX0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789121; c=relaxed/simple; bh=4uLHOiU9vgMrQjIhgxzt0qMhZHd+5zG3MUJHyME+SxA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KXssbfxXkA4C8xKGnY3HRdT6m0XrVGEGoWSJ6Fmuh8exeMTEFdTtU/FEFCAmEt8m7WUpJRfqHiP71vpzsbc4ztXL7PaD0m2GsYl6sLvvUSmwt8D9sjJYkR37znXSawQB+1hQwiVQDh869gnETtGCWxDfqPSnItAx2BtEMkxKFBE= 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=idy3jsZD; arc=fail smtp.client-ip=40.107.94.58 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="idy3jsZD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aTN5DWJSC1np3DgItAhngRIbRTCKcFPKnfQmZlyfdKYfAoDwOMaQXQ/V9AODOuXPl8ydMkPEXKsz3oypOmQZOnxqBFV6E3hSzO8Re5hW0qaCjQv7x9oNg+IseHUKGOjn3ufBuVMPi1dcab5sTtt8F/E7OXkNHXi2ZUIrTIyOvUoosmjv77dZIVX7S9nzk6JNqL7VjP1DXKR94uL01ynUgf5xg48G2xv+VyCZaWiXzHvGwo/r3R57jYXDwrNAoSepXEfr0rCWn4S4DZwS4D3mM2AQGb0nbyWG76IDGMFU9YC1A9ewEDQTEHP0E7WHIa0k2i77MN1cZe+6ULkHoP8T4Q== 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=JBIFWuxjeftBm326+w2qINTjyCljOxo9XLDD0TN4p30=; b=ZybIpOfWzeTqRJidb1Gm1dReCPEi/WyxYU3E0/NFAlvZG173rbZ8ljIRC77fULeNNtEnVvjC85SsVX/8/kO8Yfa2U6fxHbMrXh67rX6God2kRbM0Cvt1QegpvAe6M67jJIA3ALAwUF/XsKGZ6JiSdaVMaFZrEZqFmhliUJG+Km3QSyzZEPGw7NHb9XgMOwndMRafz2VnhyfJp9ZiXAJOOTQZUEjOMoaXqd1X3aIDBuDBWsidvFHogdg9ZV1qdTiAbEjs66vhpR7gb3deL4yVQ6LHskBpaLvnYuJARQN0NtJH2QiVFeKw0wa/QK3pIU0Apl7F2EVFFT5T7uVJ7fGKHQ== 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=JBIFWuxjeftBm326+w2qINTjyCljOxo9XLDD0TN4p30=; b=idy3jsZDmRUe/0ez3acjesz6SC7Cm60+UFgbfmx267CM+4o+lO5GZdthawt0/ALDJqGFuVrpeCPKS5Snp+t2wyhrQuTNTD69WLnu6OoHbvkqzoyKmyVaed8wWZNasp8/5LqWNPCdvn6j4AEaOvGEamcR+feKOMtb5iTnmzLOEA6y+K2srOsDaUeWYKHT/wgfVAyJQNDzZGUkAOO1YuRyJ6Hr1pHewyERbvXRQmLmM5fbRTJtuJ64Vscl/6raI53OwMxyHXiP8jZ3ZAoYZgET48KnNSGsC90EYCJ0nWH0SSKGFQSW3OfqXzH4SCS25Y8jdDFzy/tn2lxSklz3jjJ0Pw== Received: from MW4PR04CA0142.namprd04.prod.outlook.com (2603:10b6:303:84::27) by CH3PR12MB8909.namprd12.prod.outlook.com (2603:10b6:610:179::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20; Thu, 24 Oct 2024 16:58:34 +0000 Received: from SJ1PEPF00002310.namprd03.prod.outlook.com (2603:10b6:303:84:cafe::27) by MW4PR04CA0142.outlook.office365.com (2603:10b6:303:84::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20 via Frontend Transport; Thu, 24 Oct 2024 16:58:34 +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 SJ1PEPF00002310.mail.protection.outlook.com (10.167.242.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Thu, 24 Oct 2024 16:58:34 +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; Thu, 24 Oct 2024 09:58:21 -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; Thu, 24 Oct 2024 09:58:14 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , "Andy Roulin" , , Przemek Kitszel , , , Manish Chopra , , Kuniyuki Iwashima , "Andrew Lunn" Subject: [PATCH net-next v2 3/8] ndo_fdb_del: Shift responsibility for notifying to drivers Date: Thu, 24 Oct 2024 18:57:38 +0200 Message-ID: <8a28bbbe632e48613887aa7371cdc93ada36b0e5.1729786087.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: SJ1PEPF00002310:EE_|CH3PR12MB8909:EE_ X-MS-Office365-Filtering-Correlation-Id: e3e3a6fe-87c5-42a2-fb97-08dcf44d18da 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: GRNeehSFTE6xm+hcZSmtIjwLKfg47+WbAyTD87yb7V1vNCoaEfNurHXAi8mzTc8g4oblZS58n+CZDmI0cGTnXoBQcTwOS+rXvssmjIsGZsoCt1bs2R0S1yovXjWx6rGO+snsIqrYyr9qapbzDcqLWxljzxZ6f1Q8yFnKVnLUXeD5Bc1JfTl9MWQ0zNdsbWvj6Q/KqGsb10/Xzxh4moD1AljnrSJFGPYt3DT3ZS3MD7RmwEH0S8The+1LC+Vu3b7UY18nyOiZGhZh7KBnNkg4McNzsXS9wLgIm6wbV9ZzLGkI+f6pjvCC2EvfbwK6C5bQGc9g6RyDuw8+YJAOrWUJCnQcYiGc0FM4RhufyMRcyv0YE9LsbBOfLwi7trVGTZea19NquJEzyjppFeEo7fP21Z2GsopEKhGa9i1a5/JIiiWNfE2N7JWvuZsQSzgvT0eqyOeqc9qMj63EIjJdIIcKNSC8Fpa6iDJrlwmMaq0btnqG4y0GZqRHjao7kCShZMRG17yALQJK1wmD4XXJLYks+aQYe8kJOAsr6ks/Dl+/yP2EZhEwbu+MzSlQTOPriUaIroK+NPW03banVXe3PYOwKMWSu+/mdWeaUH7UzcTzs+bcnlhAmHZ+PomjVB/8KQfWlfCsGAOytOFfsv+BxTviXjA9Mr7QUNeE7OGF0dCQFzOxSiJxfjXRICZYAt2UO6tSDdS+BRsDJUqO8T59CWtqvagMgYKEuuybxmuCXz71rOexu25c/HwaEP27cMVTZGu0I1gXn7mguB3lXCQ0RILUBR/uhZhG4SQCux+JHlSrOdqBaz/YoDundPqFZ43OJJPLx2wZO8Vrg2blwRh2uAb8Q/WkMtCbxrZH+BmKckfuab9zzjRrMT68ZQDuVCFkWlA75oN0QWkzfakKFgkBqqwEGnYkJOjHL6LHB5b1hLs+HptbemOrTX3lJbtMIhQ/1J+2YHV5jiPxwNM3B2fZ9Nxc6RmklqiT1kvj4oOsMOXmFAj7dSACdMP6Jba+xI2cDn6hbvVwLykN8XCvi70k8DfSS7T9BVNDcxphyNTwzJbs2ktbFtQbeJB+q4xfiLod1W6prpdIokuljdQisBLaPzj1NhgONLUekG8qR2QcEHpUU75xYXzmxqD8mUw5RcD67Hc3bdcf5Fo1ZE81agpc7ZAzKa1uo46/fTf5i1w8OGyGS9zFdzfcgCpURdm8nhczpVm428hDuxanULie25gEJ618OW6DWnfmCObKenm1xyeLal2Xys3l85qYbBxoq0Zz6laD93iBRoSh/fkXb1dnNVW12HodXpdAEa+aUR3Q/rYksDv1l1ckriJ8LDB+NdQFu8k4v7L1HBIkQiF2l9KAddrU/xSc9KLXSxuNsLgEPHahzPnqkDvxadZAXiFklJf7hSDHh/GmlJc/DSzYvjhnhrswDw== 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)(7416014)(36860700013)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2024 16:58:34.5962 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e3e3a6fe-87c5-42a2-fb97-08dcf44d18da 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: SJ1PEPF00002310.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8909 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 --- Notes: v2: - Fix qlcnic build --- 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 | 5 +++++ drivers/net/macvlan.c | 3 +++ include/linux/netdevice.h | 2 ++ net/core/rtnetlink.c | 9 ++++----- 6 files changed, 24 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 584c85c10292..88308c30f88e 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -388,6 +388,11 @@ static int qlcnic_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], err = -EINVAL; } } + + if (!err) + rtnl_fdb_notify(netdev, 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 Thu Oct 24 16:57:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13849429 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2068.outbound.protection.outlook.com [40.107.237.68]) (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 B39DC1F81AF; Thu, 24 Oct 2024 16:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789132; cv=fail; b=Z5b2Toyv4rJH3yRkgo3T+PKEtuczHovQ91y4E01LskMeKOTQqqv5TjEyBiWOhyiWnqnIZAmc7JJwgqwjXOiWHuDGqjoXgJDWRA0SMZZEqsfsvtqe1rRQ9LIaUpro/+v4ammGKGWNlCSBsfvB8WpWDY0DbRoHPILJpIL1XfINnOM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789132; c=relaxed/simple; bh=bB2VEd4YT6YHTgXj+C/TTYBPSR0awEE01De4Ib/o5PI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ty/Jhg3ux1a3UFRTNfhZVqBIoZttLyqqu4tVBUzHwAg6Z4kkuTirpPmAtPwPNmc9unT3N6rNB0UXx0u3/24MIF/lhM+DBulXOOKmqt4K+JGMFpld7TcaQ+6pJ0nONIxXXfGw41sYfSZQRSG1bEoi/g/S3bkMuqtt6EVWWHiaSEA= 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=ugK+WGIs; arc=fail smtp.client-ip=40.107.237.68 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="ugK+WGIs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MdW7jF/Rn2a5aWVPsVQ4e9fPq+5PXclS582p1skN9oTdW66g+wSM40s1A/+uiLDrsZV4fgfakJUsM9WzrUWh+W9NdxAGQX5D5HUJNwoUyIfMCoIVR+Mjr+YTBnQ7xaMmXeEXyZrFtb9jQ84ArJD2NFb/9FXQc9TmQ9ek3r/xKM/XgDkeXIkRCjXlrijgBjR3wo42XlpE1NCmjB+H5pL9FfqgW7CgP4OmSy2cpdtwaK1Z7YdNv9Tu9bhbMf9BYgPTK3aP0T0DA9IxzlJWRYjKV5vXCHIaF1SYEx5G7LkqJxwKaLmig4EK71gsi5B3HU0thb/2joLHbzTzWGRz89fStQ== 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=9VNNSF0NBgVWkmy9I4jKrbk6AagiRly6wf8AwsXICTQ=; b=pmXNVPxyDcw42iHdseMbWVNwt2VvyRZKvtwpouvRnMymmkYSt85ar/Xeekv1i9C5A73TcOwsmCDY1LiEQLDQRNaa8wyw3aSOY5lHZtdShUb24VAW4LTHMAx4kUUxuU6G1OJe2OBh6gPoU+FuKn8LluaIZy/4KkZe7tIgIeN5vmxWg2fA+rJFvqehDWDsK/yhWf0RB2kq7l1oAjdpO2DZHAB6y5xavRV2kEIcNTimvUcA499s0FbPqiA1lF2vrSVW0kf2ZDAQcrTrgy98L1ulmHBSJO6DxIAJN77IP0noyIKAF4kov0/iCTNf/M++/Ko8AZN2HyzVzLkPLvNSwY3HWA== 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=9VNNSF0NBgVWkmy9I4jKrbk6AagiRly6wf8AwsXICTQ=; b=ugK+WGIsz1TjqrAsbPPD32UOpcwNPDyDLmUy/gFDho78448yFBjQodnOgzVNMqBIRijhIv+virL8W+JfwyLUeL9giVt4T/TTt/iGHgpW7DDOpWfOQFDmhCL2JYG1FuWm90eci0+W7zQ4YT/jQ6OYRssipRXF4it5qHL1CeJWtV88v/fyVJr61Ca5NjkbTndZ0E9TafFUvrgKg5XqYuUpS9FiS+TSpwEDe2XaQAWaOX4LKwyPltbglBv3l0shVdt8aK5n+10W7KcsHqC4bj30HdarnhjJ617ewR3ltAJgV4yzsa3mTd7cd+2I9XV2Uc2jjwJb5+XdamdXQJVtud/cdg== Received: from BYAPR02CA0009.namprd02.prod.outlook.com (2603:10b6:a02:ee::22) by IA0PR12MB8375.namprd12.prod.outlook.com (2603:10b6:208:3dd::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.16; Thu, 24 Oct 2024 16:58:42 +0000 Received: from SJ1PEPF00002317.namprd03.prod.outlook.com (2603:10b6:a02:ee:cafe::2e) by BYAPR02CA0009.outlook.office365.com (2603:10b6:a02:ee::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17 via Frontend Transport; Thu, 24 Oct 2024 16:58:42 +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 SJ1PEPF00002317.mail.protection.outlook.com (10.167.242.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Thu, 24 Oct 2024 16:58:41 +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; Thu, 24 Oct 2024 09:58:28 -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; Thu, 24 Oct 2024 09:58:21 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , "Andy Roulin" , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next v2 4/8] selftests: net: lib: Move logging from forwarding/lib.sh here Date: Thu, 24 Oct 2024 18:57:39 +0200 Message-ID: <74af7d80d649ac931c0fa164a2a510a6600966bb.1729786087.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: SJ1PEPF00002317:EE_|IA0PR12MB8375:EE_ X-MS-Office365-Filtering-Correlation-Id: 1563387d-edb3-4903-f7bc-08dcf44d1d27 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: K2PpV30iDcwYk3W65WAcF1DMEK+17JjqxA5fv6tG25senQom9BC2Na1NvgMvtN1YBjDxkxtut8/olGjKzAda7T2cg0R5MNa0OJAH0JT6VamPvd9HHOBFqr0LFouAGe5yv/AoVyEJXfj7e1ZTpcxBEqKaExyqpdLWHTcihjskaeRyAqN6865FuHiI2qPnJ6zYkBzl6qnl1C/ep9HqCZtENDl1+ob8GM5Wn1eya2Hyz9oXBB85X/Gaz1HIBm/6eflVF62v+wecfw85JyI5FpVH0d7vdyjSzOJH5VptyDlLyev5sLMu/hMpumKbeG7wGKEO02EtYnKft4kZbR8X3w5VXVW9C+dqyyySno5RjWqxzS5PPngOtX/UhKrOjzUp1fk1G900ntKV/pCEHQN0vUm/B3Jy5p7o/0JfKhLdjna9Oe4nFLq2UJ75Xa2mQTBtrZONAM9/4SoUvokUhQXivkfqCN+qCA9sudGnP4Ipi22vZ5GV2cy45ovfTDf4tHDdd2+hD6WiNayveuuk7QWtEuvQau1Rcx+g3VDqM9jAE8yeAlhNj9Hl9IOHCT6SXRlE42lj0NzOJwrfse4YcM/yFmKHWq0hsK9ZohJuNhy8hQgDP7leJaVLzZ9WiHzo6ZveorSil2sfSJvRGorQpwx3k7U6Yx9OO1EMHscl90LJC03lcP8DjsU8dxgneQwue31l7Jyv1RCLEG2i9CcqQMiET352OVxMI1BlbhuYEwziM6w66ZY7Sr1fXZTbUoG9/s4fI4rPWWWCLsa4yRNsexeG0MbmGq15PS9oFeTn27sqB3acjVH/uSDFdV6yp2FNhjqSHfLB6OcJfh+OoiOlPd8cLdWZkD+oyiKchHwrM4sthYKLG91OQrK6Gi4rAUruUxDgWTvo2yi2m24B/iBMd1XYvNioYRQu8v71jtkQ78Q8ch4iC6Scu1nea6xW06y5bF9b8tn762mfJg32sbuiRA6J72mYiuHpdNE0qkQN5pBGIgCerdp7GjEhNhM+b+h7r2aBJawpAiMps6ZH1YrYr5tIKGvz3u3VhP4j+OiYwwAdIDAJVrOnqzhBhWkpPWKSknxolRqzOIAD4qwQZef5qO8YAomoN0/8+xqSHdCL/t8qezm3gqoHcoNI20CBa+HhDhnlWS2/fDoVthjprGv3rXIJm6nFwQ4EtiIdahbkw7d1YfD/TZcFq21MVHjYDuNTxGEoGIb/4NiOSvxQYZ2rAkQWye6tW2SpafZoqtlp70BYTtmZ6TqKXPaf12CaC6aZnggq2qHURR1LBPeNLBE31L9hSJTwGvcirLVHYGcp5+bm9LAZ41UqKOZ89fQCSwDYoEfPM49jekbqpfBIHu6CTaljSlEbWEQtSzwRj50+iPhQY6ShfdM6oUAzs6Eq8KKmahJ7L930E/MNnn80FwVV8WoUuqAZZQ== 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)(7416014)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2024 16:58:41.8273 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1563387d-edb3-4903-f7bc-08dcf44d1d27 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: SJ1PEPF00002317.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8375 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 --- Notes: 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 Thu Oct 24 16:57:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13849430 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2044.outbound.protection.outlook.com [40.107.92.44]) (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 0257D1F81AF; Thu, 24 Oct 2024 16:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789137; cv=fail; b=olsD9UUXzzMDTptmxrnxhcNrKxmJgKVRjv1m7hsbCq1m3TeADkxg5jinSAfGMCEB7d9PC5/cdtqGGy1ZmrL2lIk4b5PPr+ItuL68PGNkG/DR+8k3P+6OFiQAyNXDy32z2U+VFXXd160Prl7nbHbLeqeNaDxbj+zDoSYUyxHtJBw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789137; c=relaxed/simple; bh=Cx1KZ+eM+5wKNXtVq3x7VyerLK4E5Jp9hqU0zwPDRaM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WldwG3Pucfn/NHtvRRFZLvMS0wJ9hHoHxJX9EDGa6a+K3LBYhhqeuAhaL2+vDlyc7j2hERglObf//etVwzvGlneqpD5R35ONsSJdJT/cW1U0n5DAy2b9j6xnSOMCl0hxPq3OTblB6gmWusIsnzdqM8aKMyWDgPP+FDhyjWBkEw0= 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=JlqQ0neT; arc=fail smtp.client-ip=40.107.92.44 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="JlqQ0neT" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kMp3ejDsB3bB3d2CCZiCdKpdQ41lv5SJcIAnnN49o0Eck0e30Bh1w473Jr5Cuapb0UZYt3fsLYnLYft1A9tDJMq7mTWm0NS94DqjDTOpGYVZoHsxzHRPlEce3wH237QD93uBATigfFMLAmr7m4DNkMOc6RaWjOrURdTwg24hYmVHxQCOTVbK8lQlbnGKhQr88KzNPbWSkErbUofLNPGyzLhRl9TCdHPdlUBtBr/KVbck/ZQOVDDd2dSeqfXmybszmrM99mWPU6BtGUMM8H0eIBGQArF1emsj6IHCFVYp2TKn6cK8meyBjjdPNHG1b4WV2bg4oIlZDl9aw0sdZVRlGw== 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=h75OKqmbdspK33j1SNqmnzjhuVTM8evUshJkvY4u6Jo=; b=k2Cv3v+ZiUUH/ajgRTUurz8TwVHF8aF14Z1BmgYk8xvJjNNmhFvwev8N/5NM8o8ubUymfmtxIBJx8Xj96zXx/WFY5UR98E7Snug5A8d46/F9u485FxcQEfEgw2ubXcWL3f8koDwHr0FUmIgigIDXVoNdac4tqi9RRucrgJV+mgNrD3K3wX0fA/BaiJsgs4x7SuFtUyU2YYyi80l+zbVotUVros0HTGIXrNWfQQO5DXSjx1QNAJVt1TbULs5hTT8N8EIXqS9yIcXIxAlEPDVALpw9bmTGTfOIh/cSxNbENphzWLfvmesZzwUoEglNUKBPB6RqRCymzk6KzbDaIiIO7A== 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=h75OKqmbdspK33j1SNqmnzjhuVTM8evUshJkvY4u6Jo=; b=JlqQ0neTemiPxMX2uuV9tLL6AobXNBU87wMcy2yDfuszE5/oCftJRTMgqXyFnyw89LMmXvrzgMQ78vh6FuisgyG/82JkYxkAMdKJ0B7QP7+LIZ+QHF20lzBpMdlKTekciZYu/y+aVdtsukJxAgee9ayjG3KGWFwn1WuJVDbsQTjdMLf4SBzAUdFL1tjNm6v/ApgF57zuSYmXyoxHJfmg//TfzOr/EV7nCspmEKhWPjWoR8yjF3fNf4c15tTyqoDRGY+Ksm+tJ+sVApCXIXGJfq5PI5A30OUAj1JXuZXfb0dNbVuo5nlGYvysjdEaOKfgFuI+4a5zeGur2+te5SygkA== Received: from BYAPR03CA0006.namprd03.prod.outlook.com (2603:10b6:a02:a8::19) by BY1PR12MB8447.namprd12.prod.outlook.com (2603:10b6:a03:525::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8069.29; Thu, 24 Oct 2024 16:58:51 +0000 Received: from SJ1PEPF00002323.namprd03.prod.outlook.com (2603:10b6:a02:a8:cafe::c4) by BYAPR03CA0006.outlook.office365.com (2603:10b6:a02:a8::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17 via Frontend Transport; Thu, 24 Oct 2024 16:58:51 +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 SJ1PEPF00002323.mail.protection.outlook.com (10.167.242.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Thu, 24 Oct 2024 16:58:51 +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; Thu, 24 Oct 2024 09:58:36 -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; Thu, 24 Oct 2024 09:58:28 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , "Andy Roulin" , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next v2 5/8] selftests: net: lib: Move tests_run from forwarding/lib.sh here Date: Thu, 24 Oct 2024 18:57:40 +0200 Message-ID: <08d58ac71e0418883a1a3af190277f1cb3f2f6c3.1729786087.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: SJ1PEPF00002323:EE_|BY1PR12MB8447:EE_ X-MS-Office365-Filtering-Correlation-Id: 465aa389-babb-4357-e19c-08dcf44d22e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: 0R3CSRgbh7hH2vxZrbWRpBiY56e1qCbCfMyM0EkKIgW05spLV6ooVwPcI7NjwuVKUO/5fibFaUMcU1hVKx5kYJP/0czzFuDc6LWEJzNcIJzB2JfIsWFBW9hIWEXcCUgn6irSS9PvjSs9N2N6v0OApIQxt9P+oHjTehrVwWFeNm8pwtk1Hg39qkfrWG7hkhIadx1NrcrNBiG59uSpICFc2hrYv9EDRsNTkO5vMQWgTSBpjG6odiOvly/WTlTUl3sOcDdIXm5mmAvM+39nXRiMzMFvod/4M3fJYRIM/b4BcyB5bT62+vvZFTz7MLsvP4TZg6ePQxmSoqoHpOwQuuZ5DZV4JFoIEathWslG712333uy3Qc4zIV+/rBOrW6QgPCrGiigmWxepL46E7PJtkfcBHhjIF4wOzb+ox8Br/A6ZVfK7NDbvfTUNSX34UqaqyWqSnU0iwcuFXe+7x9JxyvR0O3OGCdSeDX1yGEyt9DRMmBlmu97fwOXRaePbl3czZcnf20In1uqq7I7y0vOXd+uuPZcWwB2EcnH2PrHCGsvYkYNrJkVjf7eWwn83U+fFnggbdJRX6bsEztVIKUvLQxQ7Ddekko4WR8UhxdTNh25rFoLSRlXJ7D7HLZnSOvTtkQ5HVVI9CzFBlP4OAaX8CtK5Ww4Vq+Evh96Ds7CbJjbwpZpJDWUeS86JoayPjoxarBYrh0cARVsFggfK33jCZTNzFA9HABmzF3G2HguxRHNdoIRGDaYt6DLBAqXfzaIAz+X2wL/OH6PKS+muRd6eP9jZTR4itQ1Kx7t3bfYCg4py+0HtfqAJ78nc8YzSGnY9GhJslbaUrx83elYu6ghByakkudjqJRF4gTQ4AhRgLudnlgyrg9+aTBeX4iSaaOPuljcffbHZxDr39bSBoLUNTEQ0kPv5HpxX/fTsR1rIgdOJa5/0NgSvuJKnn5WvBdlIfSe4g5zg2kr8Q72XsZMslpTNByMCsURImwIIaxsiP2k6GOPDvuqYhraf0eiZ+/41krDQa/xo+qlqoEmYXNnf0uv96qGfqUObgFv2vLwdbhz4L4o/qNyr1pWSGJ/18HQIleN7YZLjgR20KP3mFzFJ7gDufngLMPHEWECUQc2gbvZEE+3T5ILiSN5UEHaqkhJnQKXg6GwAQ8zG3m9A5lmoMRj+q3+W+I6zzwCPZxCDbhQAPujOyxK9vOiJ/FvT7mpEj2Q2oPzYNKNUySg6scl6v8I/TA94h9D01ENuDo+lCLvnHd2Rb09VCDkVZWsX7bCoeSXIPjVOtg5p/Z3Q2Bu6TjnZzV1X8QKJTiy+bjzG6+VietBdF0XpZF3KC5QKPrcATxILlrhwNOxvoX2ptrNQ1aFEU+YdGV7SyFdcOLMYUJZs/Y9r/RXNFocGSfs5J/WITUq+3/whbg6nY4OEP7fhEplFA== 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)(82310400026)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2024 16:58:51.3027 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 465aa389-babb-4357-e19c-08dcf44d22e0 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: SJ1PEPF00002323.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR12MB8447 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 Acked-by: Shuah Khan --- Notes: 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 Thu Oct 24 16:57:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13849431 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2083.outbound.protection.outlook.com [40.107.92.83]) (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 9CC401F81B8; Thu, 24 Oct 2024 16:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789148; cv=fail; b=sfHHwXxGPh0BCZz6xyer3lkKqybsZ5QlEc8G5bLv6Ycqwm+OC7GUmDrMvK4RtGHMpd4K2UCq86TBcwtsKABguy4DTLgqHgPI1zy+BxuSVVw8oI4P85PrPFmll+xh4qP0q1IkpNMFxJcefV4+E0PMP0x9xg4OrUzshPOcq1tEctU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789148; c=relaxed/simple; bh=xxAdYsW3HOEs0Cml+QCp5VwfBEkfmFKsghgwW8Ivsm0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Yrk8fqPNqHMA1d1q3z9ig4/ilhT054NJBGyYf+3LYyVZ+B2ZHIfNRjb2tFNcBJSbXCMzvllA7GHUFTeZFeurvMyJXWFPx2F3p0LOVqnigNMVbAxHrrXXjW0ecCLK40JWtceaPRSzcmoxRaDvUJLZyseYgE9op4CYian2K2HsJlY= 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=BTeoLZf+; arc=fail smtp.client-ip=40.107.92.83 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="BTeoLZf+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sr1Ur7l4snzup+ox1pgZIWNFK2gNK7kTMX9qNUl+OU8h2RLQSRvklZi9L48qmubVwO6My+cwPA1YNMv89kLvXAd6gKJEIdnWvSU23R+lJpu6drREdm56/aRtuYk3+peezlkSxVqQwi2hBwQ9b6aTurgbsJHG2ekeHiCqkWGEYbGyOEk0tcwjjyTCoOgCwLq9FtMXfnvSA6GM/GQZEAWBAAVBUVHF56dLnAgDqzQKs65KVI9CtczFlQqTA5rlCk3wkXkZriiuCXdNxNZhQH5GhBcuLDOdCyi7YcLROnG8MxjMW9XD+Xp0GWORFvxrqBjBbOo7OqmJnMSohwxRBcc5gw== 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=eNQzkEYujqRiG0Ljs6B48BRVlLwKrxXSiws9RhvFwEo=; b=cQzhdR07PM8hyccU+kGcAahFXNRRpI66d1XRLHg9jZx8pVh57dvs2kXjU4Kb9gDf98JUEUFf5sSDlV9cSM6AJQBq3LZrr8uLx1K6SeSrezbHAzdsQO1rmXC24f567cdQG3tq1P2NCxbXOOP7DcmfhrFclv800ug6a72+pbMZk93PypgkbJgcxl8tBWUExqPHnks4kXDK9EpC3vXPieBjyQenht9S8/CJpHOLa4kABsGmFiEp/ENYuS+JBq8SUKymluZUpMS+dqLxOnG2xAivVdd/lTEC207zsBdzxL4XCyq+mhvOoV39cnMX/IRO0ga4c7wDoND1avEDhftM542EDA== 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=eNQzkEYujqRiG0Ljs6B48BRVlLwKrxXSiws9RhvFwEo=; b=BTeoLZf+zsyh3kKr/saSrhKkx2VP/eh3oN6O106lEJM1FejUKPxgr8NDzi6BX85tYS9o7QeSTu2H79unXd8mxRJQT13tuZKkVh7nr7d1zXHTLU7c+vmk+lI6ED9LyWwd7+9KiGJ0FqBhRRlBKAMM4IT9eURHsn96nIWkSLm60hwoqXSrCaRsPjV76shGKmTamkPP7OY7uVVtRiITIHZVb7v+Pt0iM/tNAegPOHcwVs9OEZAkBHltulGLTGJlC9W6255vKZfIgtRuzf9nt7RLVUd70WTdSLrH2ytYA61G1E8Wyp7Kxnja19ffd5OlWRYs8knQ78Or60ON6vO/ygPXJw== Received: from MW4PR04CA0124.namprd04.prod.outlook.com (2603:10b6:303:84::9) by SA0PR12MB7076.namprd12.prod.outlook.com (2603:10b6:806:2d5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.18; Thu, 24 Oct 2024 16:58:59 +0000 Received: from SJ1PEPF00002310.namprd03.prod.outlook.com (2603:10b6:303:84:cafe::31) by MW4PR04CA0124.outlook.office365.com (2603:10b6:303:84::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17 via Frontend Transport; Thu, 24 Oct 2024 16:58:55 +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 SJ1PEPF00002310.mail.protection.outlook.com (10.167.242.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Thu, 24 Oct 2024 16:58:54 +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; Thu, 24 Oct 2024 09:58:43 -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; Thu, 24 Oct 2024 09:58:36 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , "Andy Roulin" , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next v2 6/8] selftests: net: lib: Move checks from forwarding/lib.sh here Date: Thu, 24 Oct 2024 18:57:41 +0200 Message-ID: <6a29cda5dfe01a29673c300d01725ff93a4bea6d.1729786087.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: SJ1PEPF00002310:EE_|SA0PR12MB7076:EE_ X-MS-Office365-Filtering-Correlation-Id: 50d09751-d41c-491e-9150-08dcf44d24fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|7416014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: xNWKjSxDueE2fob8Z83MMvTH1LAMrr6L6P6qJGsFiZAlkUD8ttQXHGZBvXuwnVBl8ssuD5youmIb/Hg+517HUrpv7KffRtu7cjPZ4mdPRIrpM/bJiN0lyVZ2hDYbmI9HFLrBlGvt0wYBa5VwzcfwWC34+SdFXPy7Ud1+TBvxndijgp/iPf/MEIkZJFaiDuOo0/6N9XM9oWaDrvi5SYoNQUIALjqEQ8UfQBMSUiYsKZn5N0HXtr1YxkDVOuf28rhm5m6iSYKsOoTHshw6eO/3tCvx3+SjJaUmHHMRd0ZfT3hgho6WEG3+XrbUvnpiA7W5X8k6ze8XWoexzB5fvCUSvGQkYGxTXvaeAZFQ/A8SiAcQU5GiBdwrAFovtuw5vE0lVmnERkrzPXj0y5lFJg3h0nX03x8pbhMTUq1aPdPMuKE+0ar+ktPMo8yBLumZy+phvXcOzAOwKW0dpLw3eWyzRfCT45hpj9b8cQv7kQ/J6L8GFuMKGfPAHVuRRe13CZS3BkHod+OrcGhBwll3elIq20/UCyUoTdgGFXUXDxlW6dAEofalWWxsMPfTU9/nSI3AvgGoMY0YSH4XMspiM+Tn6e5FNbU/1TptVDCfTUONFnGeRQb68fWTMU7fmfi83bTkdAspS26uJP+Oc9xpbO1q2WiTNsOR1uplHAuA27ULuAQ65/4c7QETfsi0oUmTKPpcnpmVpV0B856R32SgWptYehR9eMSlrlZBD6N1EmvrtBu0sv8wRNGF1VpcKTHM+5xzHJEuvHh7NN9+/80Spkf8qasWQNmmU7jnyrRjcilrRk5TEEyHYvVMqFUF94+STkKsLKBd+wdVlC9Un7DmIhZq4btcBqATlJoMJ60tnqb4NhalSSBXSXh6q8Ii6NXvTLbIlZfqaewAXQHzaBa8/2SCgt62otNfb8jGlGxJTw7e2xUrqb9BAkE4gpbEKpLWI/U3vOK3i5JnHBVFCl8iRAtAYCBKmSE5EKL81Br4Ruyfr9lxaU15Dmt0rIbGEEHIxxklEDBlSlSYPfGlFlaYzSf/JhlBQvxP1R19VCxWgm4ntsBjDYdSYXqNmZsrVjd6kE/el7sXBWV1KqhAHFzVrpmSd5S2iwT/ODA6SgkqLATMg9iHaNJnObvoezqTJbULFde0oHkIe8D4/cBHopGEWxqGRC1yNuQ2yN230u4Z1F3tMHJzhu5A8DjFb89FcyTqGWG4U0akQaFxEqk2JPXdM6DbU1TvFWBoN8j7dJGsMnR64IRA/PXj4n5oeMzHDsMBboY8ZMdC8P/3zOwNAGKYAhGG+hbmDAXQZlFe9JbnX4BNdqy1CAyTN3dhMdMTO+w7wqbW1jBmmNdzH64z2SqB3qUnXTRjKVzRS0TOoYefGpwEmnWbEQ6X+qWcknbihORzFufje2zOS2SFhqoxPdzCa0kTDw== 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)(36860700013)(376014)(7416014)(1800799024)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2024 16:58:54.9555 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 50d09751-d41c-491e-9150-08dcf44d24fd 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: SJ1PEPF00002310.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB7076 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 Acked-by: Shuah Khan --- Notes: 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 Thu Oct 24 16:57:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13849432 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2072.outbound.protection.outlook.com [40.107.101.72]) (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 A63DB1F9EB4; Thu, 24 Oct 2024 16:59:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.101.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789155; cv=fail; b=tuIPncnL6oijDP3O4fIDoconuQOC5a5fpE2ZTcWNrdVYJ4vRIsAbJQ3XnSpC59mWrcEC5b+JEQxcvxxJsmzpagyRTfIyu0qWrq0bO87DzFMJudQGU8LtvMSxLaDWC9tY88p0Jgdw2VdgLJUl9H0bJzOCncXGsL2yCbUjd/4opC0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789155; c=relaxed/simple; bh=Za/wZNUdZpKGdGfqsUXM/Us6k9nRkv9bLiBP//c+rYU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=STUQ1Z7S8BGUcwknCgIn25xGfMsDkZcJU807OSN5odqphV8GdMyQOlunGFtMhkzrlvktR1S/Sw9xaCMgMWPlET1+sretVxR6IRFTjffZAMcNbhrB47H0DlRbAkSTajKQqQnt/acqTCQs3he5kBPHKxu/nUcxc98rAxppoc5Apro= 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=iuD4m0q7; arc=fail smtp.client-ip=40.107.101.72 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="iuD4m0q7" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=no2kuGHg8EUX5dxFIE//SuLnx4p1gkkYMeoUGNsa+bPK8fsZHxiZZsc1uXeqi7NrLJuJXhbmkQtZMq35hVDwdFEc5IQ6Tpj6hf7mMlY23GY2NDn/PaUzquN6uMcFv/lhlCN4f+vEUvdXyCguwO36pEB58bSMvY7+7o4gnppgAvLp2UsIwWWoIvf320uVw0PmEPyOakMwBpPhU3JjlxVQjP3KtRjQBpm4ywMI8eolsNprnmCFiq5U7OYIQqzpHVVF+fji6/YPdCS1i1YQ+XSjk8erdGgQ4SYY2M6/rBbD0RjqNRSO7mgCaNXZi10Bhr8b46+bkydSuBhhj0beYQxiOQ== 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=Rq6vivG0V/8Xg5flvI8sdeUp8jHh7+IgZY+tHhZ3HeI=; b=NvO6/pGLkbENmMAWp771m4GUuEDPN8kgN7ii5NjcSc1KGr0Q7LpXdj+1gnN4dDYzKR4YGWvxjS1VbiMx2Q67+aJmBa7YA7Sfjqo4Xu9br014r83k4wiSMg58PSFInCleyQtyfp4cAjKRdD4UdQD90r3lNOslos+w7N/ig+I6JmOxtm8yx6pVs59YmQDrdFpJG4Wzc3cyff7HH4ucqXBfjiM/HSao9l0b9fnah2GV7Ci64pUnVh8TvK9dip69EKXhWu8uwvdVgnRa7FaM1KXTnemt33hUhh0N8/1hchTfC5wUDM7EK95nw92RFeaMmw9/ZRXieu46CTcNmNXcqqJsjQ== 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=Rq6vivG0V/8Xg5flvI8sdeUp8jHh7+IgZY+tHhZ3HeI=; b=iuD4m0q7YveBbRJOL1jUVAWVluaOZx54MPsX6PLcM7kP/6QYISO2/sm31d7Jnh5zGVIFqB7ekDyeNtD/wB3ruhC6m/OvoZOXwH6+0pQu6X3IaaBrNFRLrfsP2Tu42xqvKjjuuEWc12VPq+SaTZaydEPfyVr2zcUK2RAO1h53sth2EwDWI9y9UClYZKpWTlu0EiFUnSe645qS9pTbzpTtFQcotdxRgzAgBFsvBIgSR9Ybj1upb0VcZjNPVh4plzEB8kiQsA32coRVZq5/1Sl3B0yc0ZSriEFfXo/Li25fiFB2qBttJlugFslHwVD3It3lHBcZUU7C0eMX74O9Fu93nA== Received: from SJ0PR03CA0390.namprd03.prod.outlook.com (2603:10b6:a03:3a1::35) by LV2PR12MB5750.namprd12.prod.outlook.com (2603:10b6:408:17e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Thu, 24 Oct 2024 16:59:07 +0000 Received: from SJ1PEPF00002320.namprd03.prod.outlook.com (2603:10b6:a03:3a1:cafe::ba) by SJ0PR03CA0390.outlook.office365.com (2603:10b6:a03:3a1::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.20 via Frontend Transport; Thu, 24 Oct 2024 16:59:07 +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 SJ1PEPF00002320.mail.protection.outlook.com (10.167.242.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Thu, 24 Oct 2024 16:59:06 +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; Thu, 24 Oct 2024 09:58:51 -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; Thu, 24 Oct 2024 09:58:43 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , "Andy Roulin" , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko , Andrew Lunn Subject: [PATCH net-next v2 7/8] selftests: net: lib: Add kill_process Date: Thu, 24 Oct 2024 18:57:42 +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: SJ1PEPF00002320:EE_|LV2PR12MB5750:EE_ X-MS-Office365-Filtering-Correlation-Id: e4c5eeae-48a8-4f13-de0d-08dcf44d2c1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|7416014|82310400026|376014; X-Microsoft-Antispam-Message-Info: Ykhgk9PJOCSuaK1s9Rjzfl87dB6SvudTNQiPjP+egWU53Rilpuabli7Bb1xV+WHM7/8uYfchk2MIAlUANGv8tQhH3ClbjJChqqKpQJr0qo4TdmoWbYCyFh9epuFS0NaWQqJV8Lo56OkIFWq2ZXGP0PdNWDBVfEk8v/1guhwPIHX1JZ7ltZwYuO1pRUbBPCHN3mCVijRKxUQEPt4NiLGyJbXL8gjFjcIJPlouvTOSOQz78tltwYVjxvZdDH4WBtvJazS9+8+t4NXiKz62WoLJPboyhvQrnC4etC9WMITS0iXATStFukte+lpfUlSa5jN16wCeEiac4hQGewWPeA5++i9Y1hK2Ue/nASHyIGrPbkClis87egwfasJ9jsSVrn5rmZjnHK2brlgGbIowkdp2QHtj8+Uvp1cpk6yq54nij619mqsj3u5sf6i7yOQPmL+UIuKIBde1+SM37X2WB7NH5131/01b6iOKd5weB7XkZMnFl85h1ckGi/ed19M4l4GMIEEnV9csSl6L6kWe0DO6cVgSo3gNG/LEdsRFTpeNdgM3kGkQeYucc3WHxSyFA3bs6QHDFk0U8iG1UhDAcfKvO7f+dpzN1psFOx1uuE5/OAYat4rI3y8ifc+3J+NjFUiC06d9fuZ/FcBK/BVngBCuEey7jxNE0fns7I1JVetfHfahI6cH4MKE2pMK+62HHMEsmqc5PisZ77Su5cgfewxbfAjjpcWDVVhXgoPYxbjbyLyKU2STr9BZjisVfekK926QUBNEvgZi7leeWgFV8Ek5aTOevvK85fnVBwRLVHsMp+mklpTal0l6lLLNH3PRiAuuRDPHViGZ8FUU5G3AungAbfoWt/H2G+DsjwwLqJD2CSOgP092UYUAXSP/6Ufez7klY4zYKfGsZLMyWvjrhAZ6EDbEEV7glL+sz1Q8RBEeAqcKkbilzhtIHb+S0q8xAZs1kv2t08YszNcG3YiSuVUdG4fuLfmp+jbT07zzxfl66NUtruusDTXjm0LDwySZVO2rQbB3fnDzrvPq2gkeGn6u5SuTaynYytE17GbKhucyXQl7aWwa5FttUtqmxvUZzgSt/tGzWPkbJfxgzM8r6Xd0LlZlWQC866vZ9I8rqLVtSG5nQEKrjvtZpsIphV+PMeQcR68JP5dfVcCoYrtfQEh8n2law+nMmixSUIhgo53gOOhaPPTUo6gLzSafyubJPt4mSLuK6eF/ttHbY3+SMX0vMvqjcV++D7ItpuPEhj7v9Gdk9P9jBequIpqdkYCYyR+Ymt/+2XVdmBIADE29F/4zm7JsAbe8aM3Bv+qCuBhbEnQkX6QpG7aE/r9I57YP0VC3OqdW+UgaCMPcoHyoOJO7CjH1AdYlDDO/fB3TceVD+TajDMFKI+8QGNlGh5JfNRi1owncJHJprXH4fZTOuaUhHg== 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)(1800799024)(7416014)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2024 16:59:06.8800 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4c5eeae-48a8-4f13-de0d-08dcf44d2c1d 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: SJ1PEPF00002320.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5750 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 Acked-by: Shuah Khan --- Notes: 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 Thu Oct 24 16:57:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13849433 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2041.outbound.protection.outlook.com [40.107.237.41]) (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 1075E1FAF1F; Thu, 24 Oct 2024 16:59:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789157; cv=fail; b=ZPDyq4bzS5cc6oC6PYhD/djdhvFEohGivvvuZrDBfRFrKhUgGNGtISa7I3uzeeaSKo7CycPnSo/s3Yqiovsp/hN2jfRYjOd4PN0tyVKsm943f11q3bJLzH1Ykklcbspgm+MqdtCk+Nxg2CY00BzwPTSokLg0QXqBFSj0n4V9Cmw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729789157; c=relaxed/simple; bh=SqmKoOyxJbusXs1HirNMeqT8OSxn4yExkFS3AOQdfTI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ucqerTteI5GGcE0ILdaJ99D0B7mFeJGT5W4J+GJlH9FNtP96L8RObwfOunrgv11kSQkcyOgl3q8hf58/9P273lBnwn+SoOG8CHQnYBP05dKQuEOjsW1YrhLzhEnfwT387sIf1AuxebO47M01FraSA1XvjKF00n1bG7gJK368skM= 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=C0YEB8BV; arc=fail smtp.client-ip=40.107.237.41 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="C0YEB8BV" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eYZDf7fuYz0trcu86/mXHQZvljI3VY5P+++EACyFzA9R8Me0BJgci7RkSmy6UBVPo3rdpnQAcegDeDRgDWs0Ob6sSSF9q7o+qizl7UtvXPEMkqO3CsYyTuYWTM5YtB8lnoPoHwDirypXXpHYv6Cj9cvR4huO6I8BuMjZjEO4fKDWgsYAMHcOnfGubLcxy4Jfm8zSyDNjyqioUtsCAwATZXLnPz9PbdsaJ4vhfGzASSCSv/60iEJFg9j7NKu0qAmyd4ES2KzHZT7rf8WEP4qO7aRr6tEj4466oirVmQ2bFLn9C833wdQImQ3Vj4a4r/rwq5Uify5APrP0dMf391eUaA== 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=yzHXYOyqnaDXp8RSPJk72+eqZOrffk/t6kNw6CHFUIg=; b=OSbuXzzb7zBcMhdjUgtOm79JFzqFSGK0otAHZuoVTsABFDHLKPDKmf4RVuIGzw5F0w1+r0jMtjxfuW4oH2dRWfBDyTnsnuRVFWbPkTOEQRIiBJu8T1am2LzaenZ0Ms1JzhDVU/DrP8VvOE8vLj3jUb3Abary0iut6je3jKU7iXuwd/5rvuCjRcUU5EXQzBGx6teGd4OuF7coTFIMzTw0ok0jjtVD8zMT6ReVQ49KYhvFTTnBLBm4FNIohu+qWdiIlfYFrXR80AJOUCDa8vKzSsIClzmUzaxbBWJtuLX84D00qGgGsB/m+KwsCQ/dVGynbFuiBzr6UfJtAcbDcjSP9A== 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=yzHXYOyqnaDXp8RSPJk72+eqZOrffk/t6kNw6CHFUIg=; b=C0YEB8BVTHlbOHDfZjDfPsb6bmVWhid2XO4OLTauoicF5nE46rHzOz32jy4JuXErSKAgQlz2IWZ4cLr4FWeEULPuB+IqOpiVIOlfx4Y7N4GdiN1i74/15/cYQN5iKg8moOtuptFgkxHuvFxyTT6xXqVsRoBPAe2o3Kao2bpi+Udt+ZaBY92+56N2jwCprgNcQNaX0GFIrnkbX4nlYdF7b1Fdyg/X8UY3zCyvlLRutCjZEJrlZyW44lEp1/pUi/J8u2VoNKmvFjOzQMPSIje6dh5592Kl9qsvpJOZ8FcaeLCYGXcc/O9qBzXS6Nzovt+TYso6dQy6cxBQWlHXV9AjNg== Received: from MW4PR04CA0136.namprd04.prod.outlook.com (2603:10b6:303:84::21) by MW4PR12MB7311.namprd12.prod.outlook.com (2603:10b6:303:227::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.17; Thu, 24 Oct 2024 16:59:10 +0000 Received: from SJ1PEPF00002310.namprd03.prod.outlook.com (2603:10b6:303:84:cafe::ba) by MW4PR04CA0136.outlook.office365.com (2603:10b6:303:84::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; Thu, 24 Oct 2024 16:59:10 +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 SJ1PEPF00002310.mail.protection.outlook.com (10.167.242.164) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.14 via Frontend Transport; Thu, 24 Oct 2024 16:59:09 +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; Thu, 24 Oct 2024 09:58:57 -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; Thu, 24 Oct 2024 09:58:51 -0700 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Ido Schimmel , Petr Machata , "Amit Cohen" , Vladimir Oltean , "Andy Roulin" , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next v2 8/8] selftests: net: fdb_notify: Add a test for FDB notifications Date: Thu, 24 Oct 2024 18:57:43 +0200 Message-ID: <4920232d77e781b563cc477b56495c3cca2ea1d1.1729786087.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: SJ1PEPF00002310:EE_|MW4PR12MB7311:EE_ X-MS-Office365-Filtering-Correlation-Id: 293cd9e3-f5bb-4069-b065-08dcf44d2ddd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: KPQR2qjJy7X3AAFtvM34EbdG9EOQcUgABBCmghBAyRjC2UgiSPgCzNH8FHmhsHLBUvMLjTv7zBetWICkVfJMsDDHZSgw9Am2hNX2UUHIsPZcshI2m1mimkW74sa891kz1pkbGPpPchVOqVI+hQKCwb+3Q5Z41n2lFqTkvNG8eAeqAFauVeleNDS4TWlwZSdLn2jTtQNvkmSCodKDxYlACbBQNy3lwwfIj60LnkpWrUwL1Ugv6rIXOu7DNnmIU7rOGKzr0bJjdNufNKDeZIx+z4cO4aH37PnnDf4ybSQFV+xMGWLA7xjf8dDrjYnmmaTVEtmW27QEMesRQIPRshBmQDdYM0LQcZYWXwXIK6dEJvEA0c+yZQsjHpqzFqmWfz6i0WrbUKNlTPE83ahALHjgNzkUcmXGmRLjCV+WKQcMRJVxrD/dYTMC1H6gVYHV7iQb906aoI7P4PSThzZZamq+bctI3O7NrABGvyAXHd/yQ1c5wvA9DpTs/tR//Cn6ULWG8/N1nm6D6lWN6MSQmuDVj1a3HaoG4mPe4rLfT7EuiZLLY68f4ROCbrKVDD8JnzGuZoEltznhsVVkrQJyTDoxWFMMbeG+dA0uhR6AwPKL5DPYjH3djn7hcb6+p8b27TC7+1HXfJFg3Xm7H1RuXlEQoFhNEuxEXWVelEUXSkVoOR7o9gwZDrJFknmcWEEc1X+a798R8pVWqwDzJgQMFHZvLuyTNtZau3cTDgj19MhHieeDCxG29ZZa4HNfQAtJOUVj4Xt/nGU6YFVaV2/SAEAISg3NICDlMsWpvfnZhQTy4GKwY6OIOn027rC8qa3iW0R65D8bnVtiTSd7+I7oF6/GW3Pw9R3rlbAukY2hoyBCKTA5pssADp8hkhH3eFLCsWFKOqdyOtA8ntMsdEp+0MSfHBoFXHgXd7HDPWmHd27+V6qvY4kOQMb4WgpxZQEJCZnsU4vHgalhNdVY/MWsi1L8mN3ok7IFMw3jsON4cSPMSyxGZW3/NafPS2KuM/S6rMRIL2yvEnt4KNjKm9Tum9vH0oduTeqnPHjQ3lQGC8TRZDiWZs91cfUKSGwLVa/G737fpChRk2l6iA4nsJFZFu9eGTT7bh6FzgDbten9h8/N10eHwhW91W9UwY4AZgobtQglGFpSbfpx+V6C9oeM43ex90/LoOs4rkZDLbAwt8P6++VpaDEmgQk05fodaBm7+oOuihjvUBYArkZei2NXbUSIcV3StHDXxhw1wUSbtLQ/tDtyRvTBnqxn8YXuIlvcDplkT0eduhDwqU6snk0VjcNei3Pqx6mTEWg434vBWsyvZOZNxNnbUIHYBKalJAtTEak46w0DIHH0iKYy+PYozeJ+qVEAm4csI1BJLVxezNg+7IgN8LZ0lQTuMOdMFlAjFrfZ5UBS28pPSu8Hhuh9wA155A== 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)(7416014)(82310400026)(1800799024)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Oct 2024 16:59:09.8617 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 293cd9e3-f5bb-4069-b065-08dcf44d2ddd 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: SJ1PEPF00002310.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7311 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 Acked-by: Shuah Khan --- Notes: 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 +}