From patchwork Mon Nov 11 17:08:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13870995 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2071.outbound.protection.outlook.com [40.107.93.71]) (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 C26CA13C80D for ; Mon, 11 Nov 2024 17:11:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345114; cv=fail; b=mN5oUbF8O+S/B/ehRGVYDGNj2Zkq5z37dMfCFXobONiDn012Gq4mqvEb94hv0VbCiyw5y/+qve5FNB4Wdmz/m1E1UETr3vAWkhcH1qrR2jV1unSs2Af2CgO6FlK+s4IolgWWEIJI0v2dcEFKWxAJu1xvTz05VVJyu2Yk4zQokhk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345114; c=relaxed/simple; bh=v3DoheZQ6PB0aN8WGZLiPxfL3jPSFrnpmfjrqgSNjQI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=vEsinJ6DzQYgxhkDuhJEBA+LCZQFE2Ysim8QZLpy9pxCrel71wlZdImc7O7eyppHYSsI1SC5ixbXFSUIBng4ll+KIk7YWyEiNu7iJZACfcp0pqydk14/9VCgHetQ3a2GgQtFYb/N7zKgbY7cusEVR8Ct5dzw2BOXmJrDFOK2R8Q= 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=hvEsimWC; arc=fail smtp.client-ip=40.107.93.71 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="hvEsimWC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r6IzrAGDM6HwqfuIxqydJvwbp8J8tQgllJCq02VzOB+KIg097MQsH/CGG/zF3VwgGFKDVgcXOvKubfmu7hOcjsThOMGGVug09Zcxz4QWCsRFAXgVov4q/HfzTHqi7Av73lER+bXcI3nlRPqgA/zQvCskb5QtHK1T/6jq3CwgOxXNis3elFn+l/WZ1gquLIhK4NQa9Er1xwFHagCg4ayUqctBg10e+dxZNM4JwULPeajoLPguBcQERG4+yuLjQfxn2MVCAYnDwd4h7owD5B8cEOKfYysw4iUeXtwTUbknN16MtSFbPPqzD51uzolYi2hlJVCLHcEAaJzkk8fni3NF0w== 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=vLwS6yLLI7gKzPrJ0XQHtOYJ8byYIzeXvL8P3nLzWas=; b=JbmhP4cjKvqqtP9H02e3stcyU56vOyo1LjQQciewQuX3xIxSRzfcHpRUKcf/oxe32izjm4hU3wLjrry25uxtw9Z6LhxxstgDHuzNK0ERdTwJ1KH4SeQI2U15UdGMgbPPKx6hGgKW3l4EW2P8VSzXycMscLdILJF2Pkr7ELyRR/n+R8LT5AdLOgZNQnHDb5vywp3MSNzYymIj7r/Stfsv54yNBGv0i9UbdQZdsNWgl1ewEGGXQw+0R5adw/1ep9IoxqPLZjMt2i5T3gtWOJPtZa7GuQIbj1jjL7+dylVEPMC5Bm9T08OukSyWJ8HYUe3gCdYeP4LGZq+gqgoHfxoNMA== 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=vLwS6yLLI7gKzPrJ0XQHtOYJ8byYIzeXvL8P3nLzWas=; b=hvEsimWCzfWANTNQ40eHLUl7l/S9wQNuaRx/iAkE6jp4gnoKSod8Uc8txbmnSnAR88N+fanP0lcA8/vaUtN2sF36oJbAgcQeGLWFPBtdMvXD5lDdr7TZbtkAbzlVJd3BhNu1C5SUl+PFT+pMULVoo0rxMJ0lKpx61pqfvek8XzfVnIZiU+2P/vABKDfHpCUHPAPJm/Y8qvAM+Tschdojw0LQCwQbx99aUj8aLUV1Y+sMqWevQ3KukXE91ukNGC3RG/d0wZz4CZ8uT8S5X6A5W3eTwqeiRuaHgZQ/oetBfMDF1O73MmGGaUXeewu3z1db30hFY/YS0ffuOX1Of/XxnA== Received: from SJ0PR03CA0266.namprd03.prod.outlook.com (2603:10b6:a03:3a0::31) by CYYPR12MB8731.namprd12.prod.outlook.com (2603:10b6:930:ba::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27; Mon, 11 Nov 2024 17:11:47 +0000 Received: from CO1PEPF000075F2.namprd03.prod.outlook.com (2603:10b6:a03:3a0:cafe::de) by SJ0PR03CA0266.outlook.office365.com (2603:10b6:a03:3a0::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27 via Frontend Transport; Mon, 11 Nov 2024 17:11:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1PEPF000075F2.mail.protection.outlook.com (10.167.249.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 11 Nov 2024 17:11:46 +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; Mon, 11 Nov 2024 09:11:28 -0800 Received: from localhost.localdomain (10.126.230.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; Mon, 11 Nov 2024 09:11:20 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , Amit Cohen , Vladimir Oltean , Andy Roulin , , Przemek Kitszel , , , "Manish Chopra" , , "Kuniyuki Iwashima" , Andrew Lunn , "Nikolay Aleksandrov" , Subject: [PATCH net-next v3 1/7] ndo_fdb_add: Add a parameter to report whether notification was sent Date: Mon, 11 Nov 2024 18:08:55 +0100 Message-ID: <2afc1da2e9cd2dc348975b0fe250682e74990719.1731342342.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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075F2:EE_|CYYPR12MB8731:EE_ X-MS-Office365-Filtering-Correlation-Id: 684e5748-a2c9-4939-7ae1-08dd0273eca2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|36860700013|7416014|376014; X-Microsoft-Antispam-Message-Info: B2PTLvQxwly9kBvvdz5RALDwy+Ft+i3bp/GypsK8eceBaoXtCh+54pMLbh2MVK3zTNew82VBqqvslE8AHGHLxK4H2xOjSu2sL2BwM5i7BkbNIHPK/Dn8fMW/aIQaWKpDXvULKzmMXoFTLk7lwhBx0gAs8dAeJw3lLvRj0nVGzcKIZiEiE/Z7/YoKlSGTVp6ocqtY4C3lbcTUtEQsvLQhTCX30tbJJkcplTQuVZ1HZsDPbD1cy+8wWkEZVkNTzHNwHuYLm+I4An9H9keX+DiruCzT/Dj+IFHwOPYOzSwLv949nOFXdRS+vjcZkzsFeZKK74AuXthRxZPiXk+As5X6tLcsnnrKg+Fo5vrmcVE2VjYjO5WDb/ilNsWtjSG+IbrypmAiO54tzMEqmFNsGrWYtUM6XmqvTnUU0tBuzbr1qiJ85oMVwwctNi98sRDJREK5nNaNNxMbub/gPhDJm3dg7zWkow5O5KJLC2VS0CkNXtAXkFaimvfIMuLOSGM1kiv7nZr0guLQrJYzMjwqyL3SOIsAogWRrbeh925L2GzpILtNT+0klnAQ01/HuzR+bxqtebomh+V4kyisiCIhI+tlGr3Sf0aqy78W3Cw166tcG6n5N2LxbsqUjCAWLUIkN1l168YX59OvPH9kMAd7AUQ022HMWvLubZIkQqyU89jfJveOdnywzuAvoeBLXr6N3UZ4qdermxS0LtNc6ynZApI2cidBSwfKLbumnrUtxqmLrzVQSHK/qR6WcE4/e9EU/DusFzufr2CLOls1qclULcgAiru+nidOKs2elDvAvdIRL/0MkUboR/4xTc9tTNfUYW/0i89YBCm/GBDlHzYb7iOgRsMEIRAkWJasrD48B9lLipayyr3wo+PfsCBINY008Wbxj1enh1g5//GZRt+3EI+JTo8OCP3nAxZHilNb4ghknXp8O4BMzE95B/4IBZ6eW6kgP53WJM3nABDdV++aB6TH3FB7+eoRv3ojgjV/PwkIGymYHAIS3RS3dVqngltk2Gngwq15Fr0UJlPdoEnCv1ZJduPYoJ43XNkPE7qRvJFx4crdQNf3oV43q9Gh3c5X3ckt0NYXa55ozEc16YX6rMMt5b5g3JFX+1YwFZluHKPtSD1LiJQBQJMCZV4wmzqTi7WDsBb8VNPRzHDyKLJCiXOTMTyB3tsugPH4V7A1KrLqcjob5dwOyaIDt2tdAXOYzdTSqXcRayXjk02BQeW3vD+7OXIXGBidp9qBuft3iaNd7duqjBZSfPkCgN3lcCUZTLRmji4X6DsVhCwj3UxzOcqhrS1+fcQnkABRV6vywNL2PZrZp+RPE3hoURw9yiod9xF2N5L4IwRPsSfI2AOYlcxq/gszW+A80o02Gq00Ns+qAxZEyOH4kFSAuF+sPsl0Gp6W7WXx9DRXifqICst9+Z+8Nw== 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)(1800799024)(82310400026)(36860700013)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 17:11:46.9638 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 684e5748-a2c9-4939-7ae1-08dd0273eca2 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: CO1PEPF000075F2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8731 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, add a paremeter to ndo_fdb_add, bool *notified. The flag is primed to false, and if the callee sends a notification on its own, it sets it to true, thus informing the core that it should not generate another notification. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen Reviewed-by: Nikolay Aleksandrov --- Notes: CC: Simon Horman 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 CC: Nikolay Aleksandrov CC: bridge@lists.linux.dev drivers/net/ethernet/intel/i40e/i40e_main.c | 3 ++- drivers/net/ethernet/intel/ice/ice_main.c | 4 +++- drivers/net/ethernet/intel/igb/igb_main.c | 2 +- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 2 +- drivers/net/ethernet/mscc/ocelot_net.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 2 +- drivers/net/macvlan.c | 2 +- drivers/net/vxlan/vxlan_core.c | 5 ++++- include/linux/netdevice.h | 5 ++++- net/bridge/br_fdb.c | 12 +++++++----- net/bridge/br_private.h | 2 +- net/core/rtnetlink.c | 9 ++++++--- 12 files changed, 32 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 55fb362eb508..ab5febf83ec3 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -13095,12 +13095,13 @@ static int i40e_get_phys_port_id(struct net_device *netdev, * @addr: the MAC address entry being added * @vid: VLAN ID * @flags: instructions from stack about fdb operation + * @notified: whether notification was emitted * @extack: netlink extended ack, unused currently */ static int i40e_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, - u16 flags, + u16 flags, bool *notified, struct netlink_ext_ack *extack) { struct i40e_netdev_priv *np = netdev_priv(dev); diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index a6f586f9bfd1..c875036f654b 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -6125,12 +6125,14 @@ ice_set_tx_maxrate(struct net_device *netdev, int queue_index, u32 maxrate) * @addr: the MAC address entry being added * @vid: VLAN ID * @flags: instructions from stack about fdb operation + * @notified: whether notification was emitted * @extack: netlink extended ack */ static int ice_fdb_add(struct ndmsg *ndm, struct nlattr __always_unused *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, - u16 flags, struct netlink_ext_ack __always_unused *extack) + u16 flags, bool *notified, + struct netlink_ext_ack __always_unused *extack) { int err; diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index b83df5f94b1f..bb35f931f469 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -2486,7 +2486,7 @@ static int igb_set_features(struct net_device *netdev, static int igb_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, - u16 flags, + u16 flags, bool *notified, struct netlink_ext_ack *extack) { /* guarantee we can provide a unique filter for the unicast address */ diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 8b8404d8c946..adc9392463ce 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -9954,7 +9954,7 @@ static int ixgbe_set_features(struct net_device *netdev, static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, - u16 flags, + u16 flags, bool *notified, struct netlink_ext_ack *extack) { /* guarantee we can provide a unique filter for the unicast address */ diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 7c9540a71725..4f15ba2c5525 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -730,7 +730,7 @@ static void ocelot_get_stats64(struct net_device *dev, static int ocelot_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, - u16 vid, u16 flags, + u16 vid, u16 flags, bool *notified, struct netlink_ext_ack *extack) { struct ocelot_port_private *priv = netdev_priv(dev); diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index b3588a1ebc25..2484cebd97d4 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -394,7 +394,7 @@ static int qlcnic_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], static int qlcnic_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *netdev, const unsigned char *addr, u16 vid, u16 flags, - struct netlink_ext_ack *extack) + bool *notified, struct netlink_ext_ack *extack) { struct qlcnic_adapter *adapter = netdev_priv(netdev); int err = 0; diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index edbd5afcec41..dfb462e63248 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -1024,7 +1024,7 @@ static int macvlan_vlan_rx_kill_vid(struct net_device *dev, static int macvlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, - u16 flags, + u16 flags, bool *notified, struct netlink_ext_ack *extack) { struct macvlan_dev *vlan = netdev_priv(dev); diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 3ec77a67aad2..7b6baa63b6b1 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1244,7 +1244,7 @@ static int vxlan_fdb_parse(struct nlattr *tb[], struct vxlan_dev *vxlan, static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, u16 flags, - struct netlink_ext_ack *extack) + bool *notified, struct netlink_ext_ack *extack) { struct vxlan_dev *vxlan = netdev_priv(dev); /* struct net *net = dev_net(vxlan->dev); */ @@ -1280,6 +1280,9 @@ static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], nhid, true, extack); spin_unlock_bh(&vxlan->hash_lock[hash_index]); + if (!err) + *notified = true; + return err; } diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index df4483598628..cc5f5cca4ef1 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1246,8 +1246,10 @@ struct netdev_net_notifier { * int (*ndo_fdb_add)(struct ndmsg *ndm, struct nlattr *tb[], * struct net_device *dev, * const unsigned char *addr, u16 vid, u16 flags, - * struct netlink_ext_ack *extack); + * bool *notified, struct netlink_ext_ack *extack); * Adds an FDB entry to dev for addr. + * Callee shall set *notified to true if it sent any appropriate + * notification(s). Otherwise core will send a generic one. * int (*ndo_fdb_del)(struct ndmsg *ndm, struct nlattr *tb[], * struct net_device *dev, * const unsigned char *addr, u16 vid) @@ -1523,6 +1525,7 @@ struct net_device_ops { const unsigned char *addr, u16 vid, u16 flags, + bool *notified, struct netlink_ext_ack *extack); int (*ndo_fdb_del)(struct ndmsg *ndm, struct nlattr *tb[], diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index 77f110035df1..5f29958f3ddd 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -1152,7 +1152,7 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_port *source, static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br, struct net_bridge_port *p, const unsigned char *addr, u16 nlh_flags, u16 vid, struct nlattr *nfea_tb[], - struct netlink_ext_ack *extack) + bool *notified, struct netlink_ext_ack *extack) { int err = 0; @@ -1183,6 +1183,8 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br, spin_unlock_bh(&br->hash_lock); } + if (!err) + *notified = true; return err; } @@ -1195,7 +1197,7 @@ static const struct nla_policy br_nda_fdb_pol[NFEA_MAX + 1] = { int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, u16 nlh_flags, - struct netlink_ext_ack *extack) + bool *notified, struct netlink_ext_ack *extack) { struct nlattr *nfea_tb[NFEA_MAX + 1], *attr; struct net_bridge_vlan_group *vg; @@ -1258,10 +1260,10 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], /* VID was specified, so use it. */ err = __br_fdb_add(ndm, br, p, addr, nlh_flags, vid, nfea_tb, - extack); + notified, extack); } else { err = __br_fdb_add(ndm, br, p, addr, nlh_flags, 0, nfea_tb, - extack); + notified, extack); if (err || !vg || !vg->num_vlans) goto out; @@ -1273,7 +1275,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], if (!br_vlan_should_use(v)) continue; err = __br_fdb_add(ndm, br, p, addr, nlh_flags, v->vid, - nfea_tb, extack); + nfea_tb, notified, extack); if (err) goto out; } diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 041f6e571a20..ebfc59049ec1 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -858,7 +858,7 @@ int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev, struct netlink_ext_ack *extack); int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, u16 nlh_flags, - struct netlink_ext_ack *extack); + bool *notified, struct netlink_ext_ack *extack); int br_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb, struct net_device *dev, struct net_device *fdev, int *idx); int br_fdb_get(struct sk_buff *skb, struct nlattr *tb[], struct net_device *dev, diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 3b33810d92a8..09d5085d4f7f 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -4465,9 +4465,10 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, netif_is_bridge_port(dev)) { struct net_device *br_dev = netdev_master_upper_dev_get(dev); const struct net_device_ops *ops = br_dev->netdev_ops; + bool notified = false; err = ops->ndo_fdb_add(ndm, tb, dev, addr, vid, - nlh->nlmsg_flags, extack); + nlh->nlmsg_flags, ¬ified, extack); if (err) goto out; else @@ -4476,16 +4477,18 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, /* Embedded bridge, macvlan, and any other device support */ if ((ndm->ndm_flags & NTF_SELF)) { + bool notified = false; + if (dev->netdev_ops->ndo_fdb_add) err = dev->netdev_ops->ndo_fdb_add(ndm, tb, dev, addr, vid, nlh->nlmsg_flags, - extack); + ¬ified, extack); else err = ndo_dflt_fdb_add(ndm, tb, dev, addr, vid, nlh->nlmsg_flags); - if (!err) { + if (!err && !notified) { rtnl_fdb_notify(dev, addr, vid, RTM_NEWNEIGH, ndm->ndm_state); ndm->ndm_flags &= ~NTF_SELF; From patchwork Mon Nov 11 17:08:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13870996 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2050.outbound.protection.outlook.com [40.107.93.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 026031A08C2 for ; Mon, 11 Nov 2024 17:12:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345123; cv=fail; b=GeEJBsK9xSzU5EL5WzDVhlqa7QXnOYTKxuc+Y+ZVRPP9AKz5JKcn109filHU8HfpXlAV2p/QkSEuYURYwYI8dLzpkjKUgm4WpYcrJkeU5bAcrJD1oTwX1YwN8ddNFzQSqZ7V1SG3eN26nSgEZVxtYHThsGMjpY11xcToLXx76Us= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345123; c=relaxed/simple; bh=pgAnxQ27GUZ2HuqrVojxPQIAgqrxmy8TeUIoHoQtPCk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NvZhCEYKYIvgKCZx6JLX5mZ5hpVGBS6le1rj9OuFGuGgqrG4PrHUcCVb2W3b3FmfFFUGXLUf54QonYmR30TYVjAnI+NiqganGKkqEqQ4LSbJRXe+m4osiR4xTY+vhip4eKJ2XBT7gZ9cUDwFnSQMfByDftqFlP0bUy7Oux6Ilmk= 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=qEQ6075s; arc=fail smtp.client-ip=40.107.93.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="qEQ6075s" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T8olvKo0J/GFSgG4JBEUsIO1UdpiRv3e+cHNTwVgG5KfHgab5tbDJCsT70IMU2H43+4fMgNGeoCyPpKVSmjtRauBaY0x4ZjZEpYCNq92LcZdG4arD9EjQb4kLy1HqBentCGS51rp15lx+poOAb5Lp91hboVzSQReFGMjZRjZEvxQPD/oq2dM/XQatLFFbEbsQuyen4DEqRMVCTDad0HtUhzZrc1mzU86wW/4Ft8bBPnZJcd8WqtF+iEQnblZudCtQdHulCRrKWwWszt4EmGuP5AhjoCTJDI8n3I5q1Apj5dHTOfZKCLMoLMXXzsqRMV/5MAAaeacuST3DgD9kJrLGg== 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=vPe7E02qWfKJZW3JtVBbnaT6rMR+7yHXV4knLJBqCNk=; b=W2n0pnGkjjxDp++XAVnKoa8ADAOllik6Di0MypTbnNi4MFMFKpbbrjyGMylORNVeTq6olB4t7U9R6Oa8m7cGo9t+QqFMtXeut786nJQSVOs/8bashwwDFzPxf2pK4yQ9H4P8oK1ZxbwZFIDH/4t/31jC0X40g2Y6c/RH7flRtq86CsVB/m0A5gDpeEKMGGFEELZ2DA4eY+TxDHuT6VbzgK156DR+SHls/MAQKE5gLgOz/mgO2+HJeHbRfnQz6FpAB8Bki0OATktQiMVDiXWEUeC01PCjvtHvHnH7VgfH1puvDBfgsqgL8kdVkrjqpczFGh869Rlr/PjAR44ubLQhQw== 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=vPe7E02qWfKJZW3JtVBbnaT6rMR+7yHXV4knLJBqCNk=; b=qEQ6075s+LsbMXJ6CkHw2fOQdyZWEMLgs4RCKqNcJXXnfpdjO5pt9yIjyRKUENwUSrqINz1aamKVVhsYm4dB6pjB/GJaw8+mCkswsh3lq1KfX9xmlPj7sXWuOKyWUUNIjS5csmVOY4Voy6W9lVuY/UcY4ZDoABZDHJlBcBG+ANnGx9pahL/yEnuGphyxqlo/l7BkNNg57qQJ7zSrIB/RFXMlJclVm0TOLNx9mBfFKEoDZv5X6XFeCQXHm7/WMGw+CF0pF+YhXHvpGJe6dd1rQ7NNh5vwiZ3VD9X3qfIoxyOSJekV+YCyOgXZrwq/+ZDgL/JtXgtgMbytH52CfoplLg== Received: from MW4PR04CA0063.namprd04.prod.outlook.com (2603:10b6:303:6b::8) by SJ0PR12MB6926.namprd12.prod.outlook.com (2603:10b6:a03:485::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.26; Mon, 11 Nov 2024 17:11:55 +0000 Received: from CO1PEPF000075ED.namprd03.prod.outlook.com (2603:10b6:303:6b:cafe::b0) by MW4PR04CA0063.outlook.office365.com (2603:10b6:303:6b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.26 via Frontend Transport; Mon, 11 Nov 2024 17:11:55 +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 CO1PEPF000075ED.mail.protection.outlook.com (10.167.249.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 11 Nov 2024 17:11:55 +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; Mon, 11 Nov 2024 09:11:36 -0800 Received: from localhost.localdomain (10.126.230.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; Mon, 11 Nov 2024 09:11:28 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , Amit Cohen , Vladimir Oltean , Andy Roulin , , Przemek Kitszel , , , "Manish Chopra" , , "Kuniyuki Iwashima" , Andrew Lunn , "Nikolay Aleksandrov" , Subject: [PATCH net-next v3 2/7] ndo_fdb_del: Add a parameter to report whether notification was sent Date: Mon, 11 Nov 2024 18:08:56 +0100 Message-ID: <8153c15a3a5d341642e8c176cfb0d32e4be3efeb.1731342342.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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075ED:EE_|SJ0PR12MB6926:EE_ X-MS-Office365-Filtering-Correlation-Id: 623483f0-155f-408a-8319-08dd0273f182 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|82310400026|376014; X-Microsoft-Antispam-Message-Info: gm0IqOM1Mr+EvBC7jKiAZrWD6335rCCbfoZUX/TP3e9vgJcs3nyEaOB9D1ra61tBtXgtnBZ1EX3KHrYZa3gR2ZMW8DPCK2TQcIXNjNF/2hWPFyO+0/fElHMTuaF1Wqfk2/KlTCLF+CA/3mtZ4+WSlQBumDyJSjl/bDn5eJ17sREE/tE8AYm7t5giqn+obd41oJOtSrshm8gQ/vWGiBDzj0dirdixVx6FEcc9RzV/b2yIrg1IsAgs7xQlsbq1c3c5eYkCdPW3WNwmNX6aixKGphxlrAPQubZn5bNk9j5yMgSZ8SSji1FE3iw8MfWLZX37+6durcQogc+2E9/SABKa0XYGNwLAtys409WLRX5+njeU3KofBsi1i/DHabvK2CHDZCAm7aavRj+D+iedjza01PbYtl3GeKVYaj09mHpoBrGjGYfqJjcM/m6/nrGmiOCX7D38d2rfkAplhQEYY1brOlBv3hx7InK4AmLJxB2pzu0QbAnCI7yqeUFcMv6OX+k8RYJTJaBHFxeEzraJhVzWgvdzt4kfegUeAaK3TlJSdh0gNVntV7GdmlGj48/c98SagereakFFZpAP7NGGFlHRBMIVnxULnqFYMpx4zjVDcbkG9Gm3YQrxTbZxuvSxCARJ0Km8iY2anFsDhHOGnyPdet03aFm6gpcj9oTKo7SB8NVmWI/B8VLp+M7laBwa8gWpzYpCP8y2GbPJQpvh93tlCRpSMoYT1ZHUcNkrgvV9p4lrWBCGlK4G8H3ZmDEFK8Km8Rs84piCXoRCACeturq2tgt0uiKtG4oJGXr3dZmrb9braA/1yP1V047SKizccgDiSf0eKqvEABwOnUCBAMYMbahXA19XAH7OY07m69GQ1FG/Y8w68IShXozylc8ntojXyWPzjOQg38jTQh00HbZqhSt1vN+20wRHSIfMiYt4tIkXOlvI7kOPIaw4bHXbnIPigTCvgj0oQZqWt7skgaxdd/+g4dj1DT0cLuvnCmE1b2HzcZyKWEBJ5BUISj0y4YRghpgzz868BqEEGqTM/2yIPQ+uTGg6WGN5cimQWlg/8dQSdkYm2c+jLVUxP5qs2j59dao9OLAKMxL4DRM2MilTrh27KstcCiwSHgpMrVyT4i1gODW/XYRsaYya1P4vgwCiaK30Sb69LMB5DS2G/YB/qPt3Cedf7lwicyLk6HA18NxrgXiRv4C8bGpuxeaa5xX5QGbGNNXEbMST8yk/uOA2SD7XHQxzz50G5c9VqzheHA9ApuAUE9ajEBmQv8bpJOS4zu1hWs1KGVrdKYv2sRNc3ImFZwhyeZooM+ZZhGL//XdouUYXDUiPpuNZdB16hR9W/A4Rg9k9Nq2+JY8x/7QwOnrWnh2QRNvnrWh+iPMb0uB3eof3kX2NwQNXvl4Ug3FNkPCCZclEFFzYkTuOlDkfyg== 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)(1800799024)(36860700013)(7416014)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 17:11:55.1428 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 623483f0-155f-408a-8319-08dd0273f182 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: CO1PEPF000075ED.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6926 X-Patchwork-Delegate: kuba@kernel.org In a similar fashion to ndo_fdb_add, which was covered in the previous patch, add the bool *notified argument to ndo_fdb_del. Callees that send a notification on their own set the flag to true. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen Reviewed-by: Nikolay Aleksandrov --- 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 CC: Nikolay Aleksandrov CC: bridge@lists.linux.dev drivers/net/ethernet/intel/ice/ice_main.c | 4 +++- drivers/net/ethernet/mscc/ocelot_net.c | 2 +- drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | 2 +- drivers/net/macvlan.c | 2 +- drivers/net/vxlan/vxlan_core.c | 5 ++++- include/linux/netdevice.h | 9 +++++++-- net/bridge/br_fdb.c | 15 ++++++++------- net/bridge/br_private.h | 2 +- net/core/rtnetlink.c | 11 ++++++++--- 9 files changed, 34 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index c875036f654b..b79848fe2a9e 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -6166,12 +6166,14 @@ ice_fdb_add(struct ndmsg *ndm, struct nlattr __always_unused *tb[], * @dev: the net device pointer * @addr: the MAC address entry being added * @vid: VLAN ID + * @notified: whether notification was emitted * @extack: netlink extended ack */ static int ice_fdb_del(struct ndmsg *ndm, __always_unused struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, - __always_unused u16 vid, struct netlink_ext_ack *extack) + __always_unused u16 vid, bool *notified, + struct netlink_ext_ack *extack) { int err; diff --git a/drivers/net/ethernet/mscc/ocelot_net.c b/drivers/net/ethernet/mscc/ocelot_net.c index 4f15ba2c5525..558e03301aa8 100644 --- a/drivers/net/ethernet/mscc/ocelot_net.c +++ b/drivers/net/ethernet/mscc/ocelot_net.c @@ -744,7 +744,7 @@ static int ocelot_port_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], static int ocelot_port_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, - struct netlink_ext_ack *extack) + bool *notified, struct netlink_ext_ack *extack) { struct ocelot_port_private *priv = netdev_priv(dev); struct ocelot_port *ocelot_port = &priv->port; diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 2484cebd97d4..eb69121df726 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -367,7 +367,7 @@ static int qlcnic_set_mac(struct net_device *netdev, void *p) static int qlcnic_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *netdev, - const unsigned char *addr, u16 vid, + const unsigned char *addr, u16 vid, bool *notified, struct netlink_ext_ack *extack) { struct qlcnic_adapter *adapter = netdev_priv(netdev); diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index dfb462e63248..fed4fe2a4748 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -1049,7 +1049,7 @@ static int macvlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], static int macvlan_fdb_del(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, - const unsigned char *addr, u16 vid, + const unsigned char *addr, u16 vid, bool *notified, struct netlink_ext_ack *extack) { struct macvlan_dev *vlan = netdev_priv(dev); diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 7b6baa63b6b1..cdd36f76af55 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1322,7 +1322,7 @@ int __vxlan_fdb_delete(struct vxlan_dev *vxlan, /* Delete entry (via netlink) */ static int vxlan_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, - const unsigned char *addr, u16 vid, + const unsigned char *addr, u16 vid, bool *notified, struct netlink_ext_ack *extack) { struct vxlan_dev *vxlan = netdev_priv(dev); @@ -1344,6 +1344,9 @@ static int vxlan_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[], true); spin_unlock_bh(&vxlan->hash_lock[hash_index]); + if (!err) + *notified = true; + return err; } diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index cc5f5cca4ef1..d2b23df8cf6f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1252,8 +1252,11 @@ struct netdev_net_notifier { * notification(s). Otherwise core will send a generic one. * int (*ndo_fdb_del)(struct ndmsg *ndm, struct nlattr *tb[], * struct net_device *dev, - * const unsigned char *addr, u16 vid) + * const unsigned char *addr, u16 vid + * bool *notified, struct netlink_ext_ack *extack); * Deletes the FDB entry from dev corresponding to addr. + * Callee shall set *notified to true if it sent any appropriate + * notification(s). Otherwise core will send a generic one. * 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, @@ -1531,7 +1534,9 @@ struct net_device_ops { struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, - u16 vid, struct netlink_ext_ack *extack); + u16 vid, + bool *notified, + struct netlink_ext_ack *extack); int (*ndo_fdb_del_bulk)(struct nlmsghdr *nlh, struct net_device *dev, struct netlink_ext_ack *extack); diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index 5f29958f3ddd..82bac2426631 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -1287,7 +1287,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[], static int fdb_delete_by_addr_and_port(struct net_bridge *br, const struct net_bridge_port *p, - const u8 *addr, u16 vlan) + const u8 *addr, u16 vlan, bool *notified) { struct net_bridge_fdb_entry *fdb; @@ -1296,18 +1296,19 @@ static int fdb_delete_by_addr_and_port(struct net_bridge *br, return -ENOENT; fdb_delete(br, fdb, true); + *notified = true; return 0; } static int __br_fdb_delete(struct net_bridge *br, const struct net_bridge_port *p, - const unsigned char *addr, u16 vid) + const unsigned char *addr, u16 vid, bool *notified) { int err; spin_lock_bh(&br->hash_lock); - err = fdb_delete_by_addr_and_port(br, p, addr, vid); + err = fdb_delete_by_addr_and_port(br, p, addr, vid, notified); spin_unlock_bh(&br->hash_lock); return err; @@ -1316,7 +1317,7 @@ static int __br_fdb_delete(struct net_bridge *br, /* Remove neighbor entry with RTM_DELNEIGH */ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, - const unsigned char *addr, u16 vid, + const unsigned char *addr, u16 vid, bool *notified, struct netlink_ext_ack *extack) { struct net_bridge_vlan_group *vg; @@ -1339,19 +1340,19 @@ int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[], } if (vid) { - err = __br_fdb_delete(br, p, addr, vid); + err = __br_fdb_delete(br, p, addr, vid, notified); } else { struct net_bridge_vlan *v; err = -ENOENT; - err &= __br_fdb_delete(br, p, addr, 0); + err &= __br_fdb_delete(br, p, addr, 0, notified); if (!vg || !vg->num_vlans) return err; list_for_each_entry(v, &vg->vlan_list, vlist) { if (!br_vlan_should_use(v)) continue; - err &= __br_fdb_delete(br, p, addr, v->vid); + err &= __br_fdb_delete(br, p, addr, v->vid, notified); } } diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index ebfc59049ec1..9853cfbb9d14 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -853,7 +853,7 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source, int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[], struct net_device *dev, const unsigned char *addr, u16 vid, - struct netlink_ext_ack *extack); + bool *notified, struct netlink_ext_ack *extack); int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev, struct netlink_ext_ack *extack); int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[], struct net_device *dev, diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 09d5085d4f7f..860993aa1b06 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -4588,11 +4588,13 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, if ((!ndm->ndm_flags || ndm->ndm_flags & NTF_MASTER) && netif_is_bridge_port(dev)) { struct net_device *br_dev = netdev_master_upper_dev_get(dev); + bool notified = false; ops = br_dev->netdev_ops; if (!del_bulk) { if (ops->ndo_fdb_del) - err = ops->ndo_fdb_del(ndm, tb, dev, addr, vid, extack); + err = ops->ndo_fdb_del(ndm, tb, dev, addr, vid, + ¬ified, extack); } else { if (ops->ndo_fdb_del_bulk) err = ops->ndo_fdb_del_bulk(nlh, dev, extack); @@ -4606,10 +4608,13 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, /* Embedded bridge, macvlan, and any other device support */ if (ndm->ndm_flags & NTF_SELF) { + bool notified = false; + ops = dev->netdev_ops; if (!del_bulk) { if (ops->ndo_fdb_del) - err = ops->ndo_fdb_del(ndm, tb, dev, addr, vid, extack); + err = ops->ndo_fdb_del(ndm, tb, dev, addr, vid, + ¬ified, extack); else err = ndo_dflt_fdb_del(ndm, tb, dev, addr, vid); } else { @@ -4620,7 +4625,7 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, } if (!err) { - if (!del_bulk) + if (!del_bulk && !notified) rtnl_fdb_notify(dev, addr, vid, RTM_DELNEIGH, ndm->ndm_state); ndm->ndm_flags &= ~NTF_SELF; From patchwork Mon Nov 11 17:08:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13870997 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2069.outbound.protection.outlook.com [40.107.236.69]) (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 2D2711A4F1B; Mon, 11 Nov 2024 17:12:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345127; cv=fail; b=uh/pQ8gNG0Bu53apISR1fyIVehDpxkW6r/6R6XswcvCG2JePia7i3iy6WW8lQot8ax/QTXqh+W0OiwkTX9c43H4CaYwPlEj2nvw2yJJ2YiB3738dMIX8Mir2Qjdi27i1GmTlgtL1X9QQ5NsoWF+GOOX2Z5Ov1n5TfLNg0UAZXRU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345127; c=relaxed/simple; bh=3ZfWdtTvPyMpZTakc0Gwfzt/1QyfrPAAl7qK0gavtHs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cy/3vTZ1fLXa+ukbrVqw4wGHkE1EXIKPAGNVf0m9hSDkk0hdsnrL3om+KwvwrvofvNpGX1VIFNiuqMr03nzcvIOnxUtljvMI1uUXJ73ciEoScD0QIMW7/G5ltb2hImPDtyE9xlUJ9EI8lE4mzSnQXSLGJWR9eBJ5rW7IG5egJGk= 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=Sil2jZzf; arc=fail smtp.client-ip=40.107.236.69 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="Sil2jZzf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=e5ZzgbGLkHs7vj7hQjI/TUXgMXsu+vCtjwmjDTCb5mWuCFlVhSBEgVl+8N4D5AfIdJh+Dv19p9E+pXwYqaBpIBtw/Qi00QPH/SK6cfi0HVkK8m0bgPoVvWy4Ff4zFWfVpockPfscdovjaFN+VNUItqtx9a80oLN//Ho/WPjxMo1GbjO29LIv1tQL6wTWkTNcbNoSyvm+j6lHltKwYRt91zbYPjkrMk7OYgSCgzfJAg5JxMHUdpYUuR/rJgZIrJVOrfqiIob7ZwDBUrN7CwZEpdDj0bfk5lPb1dguBN93u8weK6xspUWWRGjbBoDk92MqXA+ltAFENMXQXfjNroVNsw== 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=YD6zqn2kMbHyPquhEmL/7TNRjNgDHXSmBbaIweEFVMQ=; b=FVuqDmo1+q3xjgZnGMXvqcRyBwgsdwPZCMidFCe8yB+CBPfI0L2eMXL0u5t8Hky08ZoY5iKXvTzkA07NiraKDjJJ8JJmXzMXh0fSqSnHn6SFVe9EnBAvy7m3CXlHw4GViaq0XCaFpYNJC/cJxiV95RRRowhL2/1W5bRlEh+pI6I8IiR28LEWfJA4lJ2FLkYVj3m1JZIIynouDrWLl6Yub2nEFhL8NUtqYWiLM4t7u2AGGNVCW852o5ux6LM0GTsCVJn9V34CmU+yoZXRWTcEWbSLYul8o4rvVNlzaosZkwA+N91EJpYbosx4UeqPwSi9h3vn3E3xzj5+FgD7msBYnA== 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=YD6zqn2kMbHyPquhEmL/7TNRjNgDHXSmBbaIweEFVMQ=; b=Sil2jZzfo5mzQiD/XFER13qpc/CtTj0n41NC8dvHX7JcLuQ+lB0t22dPmG7K+pfCVBQmKH8CYuJ3EBmd7IXQeGPL5KMXn9w+drB0GTSktMHZmJLTAEsLl8/LPsjLWXqfdw3ysQl07gdX3oWCUnRbJOA0vH175RjaWsuEhVtBy+Sof29+0HnuY7RO+Mai+5v1z412Ml6K3kLtiFD2fiG27R5+OjGwUpUikQzhTLKIdwgAsn04FM4yFS3+zWbAt2b+R2AIOMAMVnraVr1b4lv842pBZyj5iIKJpVIbsndU1nMWyk1OE7X3U5g29/7qPAym+vpadDfULuHoofNGS0q1Pg== Received: from BN0PR04CA0026.namprd04.prod.outlook.com (2603:10b6:408:ee::31) by SJ2PR12MB8977.namprd12.prod.outlook.com (2603:10b6:a03:539::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.26; Mon, 11 Nov 2024 17:12:01 +0000 Received: from MN1PEPF0000F0DF.namprd04.prod.outlook.com (2603:10b6:408:ee:cafe::5d) by BN0PR04CA0026.outlook.office365.com (2603:10b6:408:ee::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28 via Frontend Transport; Mon, 11 Nov 2024 17:12:00 +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 MN1PEPF0000F0DF.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 11 Nov 2024 17:11:59 +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; Mon, 11 Nov 2024 09:11:43 -0800 Received: from localhost.localdomain (10.126.230.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; Mon, 11 Nov 2024 09:11:36 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , Amit Cohen , Vladimir Oltean , Andy Roulin , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next v3 3/7] selftests: net: lib: Move logging from forwarding/lib.sh here Date: Mon, 11 Nov 2024 18:08:57 +0100 Message-ID: <617f172428a18f697bfe8bebc01516a5b9f08a44.1731342342.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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0DF:EE_|SJ2PR12MB8977:EE_ X-MS-Office365-Filtering-Correlation-Id: a0f486c7-7329-4872-0c3e-08dd0273f44d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|82310400026|7416014|1800799024; X-Microsoft-Antispam-Message-Info: 5lXLnOY+0sZqOQKjJCY+Yhd2uhp63p6/LoJ6GTp2zv06nqp722mn6MQ0jD5kpraU1apaghn7O6FtfvZfS5Ey5Vl1EuAxWDvsyNqCAxRGxZ00swNXThJGyw3g7jIrtYZbM9RzknsWKbB4OV6x82eizLsgzfBAQ6lWyj6Efjbt96FTw3aabTWxX2Fq9IcXgylOQprsi7RNg9JZfAYzLSOsnvowZKNql5fvFNB7SwCHdtQTJWSpakTYSZLIhP+mO6J6mfs7SDkLa3MATBuguJOONdGYlxx+jahlf4uLgo39qq1wuXroG7tb6tsLG6A3ijvzuQ6Z47pqpnKR2qp8j8TxMOPZXF7EGAYxQUCPFuwzvUc0vOrsSuZ83CRQzQUdTuJhSFPo2OP4nAWJiYCSC0Nx/7H8LORNN6O/BvovymFT2yIO+NuNqKTpMdefdxR8/3KJ5vTPJLQhBTnuSv2MwX7nmUyPLgr5X9AHkgPwApM6Lpu6WlEGZp2meLdtrHAF6ub83RNIntccJKsyUGsrDuPYHcWslfHTmaOVAqszwZUNYKlgz3crnC8dOEDdrsktNgQcKT10FYfY5Z5uC9ynokxy92h1zWJEuFVfiSKhTU+SddTvqYZQrFaOZ+0oNrixax7eYxOdPkpJQUNvF6NtXgO6j3Py7Fj0o8oifzBTw051nHkS154OdaEsDfyO4ABH7TEN0NOGPuk35cviM1QPIyaYvF9+5ObRbqtsdjvcrIdyvV25q1jHnfmpvFsSRbXqmC0ap0x6SlR7tTO48W/0Wvg344LYM/vXKWJKpPjI5R5CrkJBeYvNAswuzW/yxUa/L6cI9cW6lcDRjHPrfaXN8e0smf58xFtRg4KCUW3tRM+fJPl4O0vjgObysV02AtNT3U2CyYYd0PlI/VZxH1hJN2qFD0lL0sxCDpjc/tnApizTbthcDx6ErJytebeNMWgiKgc3t4ie6RAU01S8+c8zCvUsyv3jVIA72XYvwI5nh06oOxJEBPArB33wX7CEsh16Oew7ZQRHoBpMUbUCCA8zkucJ4P85P2PIKwtE8PxsDuED7Lz32oXn9qbAEcTuRrMWP7Vwbp95wNxTtSriLu0QbtA/RosW71IZDqKdUDk2qiIgg98OswPGMSnUudluDReyrwCncbY4uSzjfCxio3yDDYp5PcU4qC1G5vZz6GPBJTWycb5D8lN9kj0qd+DH6yIDVuIQ1/I//90xzxIqIgIJ3vch03Ij9E1Sf97hjzDxakklusntONBF6osKyIi3Ho4tnYlLPrqQXLMl3lwBJJJPWI67WScdzK67aQdCDlB/BoV/GS7dRad3La7k4u/3tj95pEo+6q0T3/YwiDoUMeKweeFG6DxuqKgFjTR05ZANrbrc9lLwaRjpUcBcOTtmUgcGlSZOj8Upr+R/bIH3BVjlNf6DcQ== 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)(82310400026)(7416014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 17:11:59.7631 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0f486c7-7329-4872-0c3e-08dd0273f44d 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: MN1PEPF0000F0DF.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8977 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 Mon Nov 11 17:08:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13870998 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2082.outbound.protection.outlook.com [40.107.94.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02E8C1B95B; Mon, 11 Nov 2024 17:12:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.82 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345136; cv=fail; b=WMFrg+qmXtje9AXlZB2PuhEaMzHqTZyTztLRENGYBGUldOy/zFJ/MVPu5wPkwEt3pR9Lrkv8V3HhfayEznDM77NcF3zjkfKukIxB3ruF5RB59jnfmegyyaLA/hksNGwZE1NRs8BDiESaqZzYkZbz0jd2PPnnkwojeEBU6PnsjRc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345136; c=relaxed/simple; bh=u034UZiNhiJu/r2dn8swqac1RxTUeAtyHs8A0b2YlLo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=b1d7DOexfco21P2QuTfPTpnIg1T9GmUXedJDlCRCf5/zVNDDfKkzZk7X1AqtM0zc4NuDiBa4jIDCDwsxrudGX6VWPWRhqmGrTgjqDmUslc7CW3+MdNEg3V/PGCWR4L9fEu+YxVy1K5YS5rJvfTuk2qdmvW97I+dkBdYZk6bZb/s= 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=BeMuBNNd; arc=fail smtp.client-ip=40.107.94.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="BeMuBNNd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vc4Mo+pDTwnsCCGn/+T4//SOrL/uZHNn8MwfZf9PxQsEW0uSw3MNEuWc8PJGD7S60qH4UXk8NopcZ/E9ay8klfggLCG8QcF3FX1LP483YxRvz5FlsvQqHlyawOLy9YowX9eo4NjHtYJbWeWHDRm2jJ4JIlon0INqVN8F96443eCqNqv3vUCnSVygyIw8HqGObtu0rUTUKZeJTI8nqYeTk/bBDcWpoVa0D2GH8XHx0SVlnIdyLNr79TXJEyxjfoPIRxgH2YsGbZLd9BqvW5YWOvJcMNnWR2TXB/dRD0URd6yelcMWuZrUlJM17UikHQFsNwdIfOVCZURj6Z/iiaTfpQ== 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=0knMJxu5lwi7AglwJNczxaI1E/3P2LBzh1dlVNdMhyQ=; b=fgGLehLaGi5RFs10hjD3ZJuvVO7fQEwefPvZ0xe7L/an1UfvMW5XbvSjJs1ItKvdyoVpB3oFck6JrlhQ39WniR7qWAvY4kiwjWHG31wMU/L7VeE+hKHl323t3VHTf6jDzXJdIojRGCW2oP4ju+3Kr7kHblf15SUNdnCaf4bKIZzQUEJp3+NMGHaYtugVdZRr5lzIrQ5NJKQe83VX0d/mhB+PcQH16pFZYn8B79UcCKeYRKJ6FP+26mTGUR8FTvFaAXRXZbguWjNtxn4LzBXMIYDR0/zdRIIz7M/TqwY3lMHV2k7f1Lh3pJetRnwZpmgkX+KRZwwhrfQ+2Jr0BlLa6Q== 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=0knMJxu5lwi7AglwJNczxaI1E/3P2LBzh1dlVNdMhyQ=; b=BeMuBNNdLgzxgixI6+3Q60qKxKLTxIpALpFwMwfOFmQaBVR2l/H4vTJabVRlBDl6U2eEHT7n6axdneKyO3SgXpjoTR6HudaJo95GBXGzoG8lsOXvc8rADlhxyhT34IKjHMxqEgq9C3Phbi/PK/kmzqkrPkhTS5vAqcQDX3nBKQHmM9i0hTRndjE0FOyWbnPh6nWmzoRh08uSwNbzRNWdUyai1HtlUxaCeUtOqCP3h06asuR3sIR65yZoSRJMBHGCmGgUoE8uY0I2HTHxPPS5/Ou8fzkhQ+tZp4h2mlMz/80BwQGUxxu7CaUJqJX/BEqJ4o3RN/3LqIfePUHgqADvsA== Received: from MW3PR06CA0024.namprd06.prod.outlook.com (2603:10b6:303:2a::29) by DS7PR12MB6239.namprd12.prod.outlook.com (2603:10b6:8:95::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Mon, 11 Nov 2024 17:12:08 +0000 Received: from CO1PEPF000075EF.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::9a) by MW3PR06CA0024.outlook.office365.com (2603:10b6:303:2a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.26 via Frontend Transport; Mon, 11 Nov 2024 17:12:08 +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 CO1PEPF000075EF.mail.protection.outlook.com (10.167.249.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 11 Nov 2024 17:12:08 +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; Mon, 11 Nov 2024 09:11:50 -0800 Received: from localhost.localdomain (10.126.230.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; Mon, 11 Nov 2024 09:11:43 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , Amit Cohen , Vladimir Oltean , Andy Roulin , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next v3 4/7] selftests: net: lib: Move tests_run from forwarding/lib.sh here Date: Mon, 11 Nov 2024 18:08:58 +0100 Message-ID: <669983e424e61cf7ddebc8a391ddf0dcbe53d80e.1731342342.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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075EF:EE_|DS7PR12MB6239:EE_ X-MS-Office365-Filtering-Correlation-Id: aec62466-e0dc-4a3b-05ee-08dd0273f93d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: yg2PFlcWK2nx+acKxmzULM+ivUjoBtEZtRvKgSDu1jwTWJr3KTuK0pfD5gb1++3IY0cZR8CtCmA1/nBLznsYspmldijIjuUl5VDuKmPm9vq/Kl5sYgQ9j8vDnUQb16QFtp7/rG2yAtVurTz+D/Jas4rvPFWuVP1wDVmYbCvIpxFzogVlK2+akbSfAQR/hWgb5BM6ckWIab8HQcKNWpEq8yEwxRxW0b+J+1qI+g+fs5Wq+WUCvxxw/+JflCxkknHCbI7nN17lKHQoAbUs90LjXeDr724mMumqhqfkFdABEZjFzqWG0uN9UXyfu0WyrkQIyzH2hs2Oh0SGSImFHZ9aNUS5lA1o531jOdn7Yi4NS30lRVGrsssBZAIoeIjjhJ74onfTPT2VImVUAnSwac1612PMDc20YMDZwc04wmLDYGrjQETZ50k84Pt4ytTiehqeqG/w2BwCgVyKA7xIVabuNiS7KpCj82cg0VSnOraKdHz1R+ef0R2d0klhff+Xj0tpH/XycFQlwS9UE31Yu+I2++ter+Sto2fnFWfXRoV2eMxn9V3eqd+/O90bQV8wkfYQu/QQCwYANpGxRtkg5cySQAqJZZwOzFsZJldhz1bJP4hs3Xo7vCSHdj46bQQkUX4Z6JI8k5Pdqd07J1VtVkNRiWY24bW36dDunyPd9QNLWQ3IYINA5W+IYySZeIMJc6OldIErCSZo8lp4lK81pu5B5zdNhQj/4QYtMyyPp2K5Mg1SHyUh4IPf/s+Uhr6R4R4wzcBF/fFjFQPGVgEtEgYW03D0uo5CkWgBMSfkWnvgAXmzQzsFrpadahzCFeeAh3vQ+A7kGwlnWIvYZyPyHCbeAAD1iaFVtdFRfI8YKwWbw/3XVMsYeNRTinDJFBitx81aZIJ3ijWhlDSi9Ts99Cbq5X9PQRc8sjvzzreranaKlkBqrW0AdlvgouGo4/6Jj9NYlVF43VjnakdIzUnqbTbEOZND6TuYFAklR7QANAdc5TZ27cr2ETf0yoaet5RWJUVlX+gnukXzmwnlzpRaF/AhIMhc8y/xLDz87PuzXW46Z0uWl8T1eaESxGT0cIqhkBoUJ/O6AaUh4BQDa9raP16HhqlG1CbThSwDBfwdNZn3r9fQZxMWxvwr7Md4dO/IbchO08RcyD+Q3iD1YTULFsSjnw/TEbuOXQXbybGiEJqvx35q2cNk1zWd/AcwfkewPeZKL05MA0bEVpbljBLRl7X9/v4epUZ9sVavzEQsTYLf1+ExqIc1R1g5INcHmmv86m9nnK3gXGSZ4HS5RkP3iEpHI44Lu6yL3Wu72d/PPl1QCSkn07SSZXxMAqllLx5y3C6SiCM3+s+hBktMdVnJlGRcsPLXTd2KPI08pKGSdP9A6fe4zDZv7BOoCuGsP/H7nCc/+Kulj5N3KCVIjbSKDaeEDQ== 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)(1800799024)(376014)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 17:12:08.0467 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aec62466-e0dc-4a3b-05ee-08dd0273f93d 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: CO1PEPF000075EF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6239 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 Mon Nov 11 17:08:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13870999 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2070.outbound.protection.outlook.com [40.107.243.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F0221B95B; Mon, 11 Nov 2024 17:12:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345144; cv=fail; b=CffFDrHT016a8kqZ0oO9P9dFQN4EccTjoUftjZEds2892VvC6LQTyslZ2dvCW7G1KCMe0/4mYL4PscA38CP61wa3G/yObsXXkJj0Rg4M/2kb4SlMGyzGVK2LUgyNz6n7osMH5T7QvWryafackvby+FkKl7gCP1jlhwLEyFJA4us= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345144; c=relaxed/simple; bh=W1Jbsrl3SASOFhpOFkg6RFsRhT9Nixy5sz1Lwc1l+ZA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nHyAbF7WSc6Ax/prrPeMMsF6WRRa88enoro7QSm1Xa8wwUb+nmbZ2eu66OcWpeWrS1AKLtbOwGdQh1efMPpV+Ug1LVWvJY+5TCVFmrv2tRKmtCKBym6XLA5Owg+DCvXJCK5OeVYozcuuhCXghdOrAa3qHyQ1npLN9nZLmGsvMio= 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=R56EpXIv; arc=fail smtp.client-ip=40.107.243.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="R56EpXIv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xfh7dvPwwQBRmjF6CvUAa2Bm15ty5PqyJ5JDTx/3rkgcVenRWvsU6heMDCl+7m8c9QNaUraQw/0qrXc7uAZQJk3fl233ErZilucrOI9A/YcJb00YHBcswYFwanfRUZVWxbQSk0voqambUyiRdzgqfTKz9Cg7pp9tAwEOosSBvARCjvmVHd7HR1gqFvlNRKS/q7lKeaegxzJKdnExlR1lvfiuaNnmH9Yog+p1TIDJj1gAwbdbR2uXekKmxv2Ztk+M7MQSuiRyrtsvj8uBtxbJzZWHrgQ7qd8dKCb587oXhTWx1BwknNF+TgommQH2bhwJCrR9WfwwyDloQjJURnth1A== 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=0Ybb3cQn8Fb6xON+SG8hrDFabuFGISwWdDVgxn/JRk8=; b=vR9fkFNYYr1nI++3QzQXSQH9Sxza0GkAnUQu2XE4UJpStfanEd2NxdpM2sLGRBL55POeUCw1DZ4WwKaeQUXrBm6z2bu5ZisNaVCz1/kuM82qnWaMcKxl34oUhRa2WS8lQrfNo3P4glnSC4m5iz4qV81NviJyUtCSPk2MpvxtnjLO1no0pkFvjxCJiSWyT6YJ3JhdwpiK7+CSsyWvXicQ2uWaeNcTktW/C8xA3Qm9WlNuWqXz4NRTIAIuGQnBHUthHbbJjv2AhRzsWPGGcp1lPlBHqQsZfOyBZb5vqHK4xzo7J19i3SbTmJG9Wc47YjVPuMhcWHHJc8s3l/XUDIC3SQ== 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=0Ybb3cQn8Fb6xON+SG8hrDFabuFGISwWdDVgxn/JRk8=; b=R56EpXIvNexEwcm7tlNa8wK5vthJsvzo6Z3oCFjuGfgTiYpJnrsbQDYVe8H3+7krlnMJ0+1l4ST6PDnNpha8xrwtlV/WqgdXvh0sPgzKjbjr/W1HImG9Q68Y3oqfcs4/l93fjA0KhnkuZ7pm4j7VSbxLnveK0y9PtVIEOo21l4oL1R67LxZWNQNxIDkbY7m2QHi1JmhDIym3m3d40gQF1V2zlBKjgpGi8ZMEFBHk6WYdBv1d+Q7e7O8QrEAj0tfZ7AGb1oU2Urv1MhNdWZumVODLPbxWU3Tmdapig0L0zJYsF9mPT7ARdX1wUBpD+XohJGjnD55wHtkyUmeSyaeYPg== Received: from BN9PR03CA0552.namprd03.prod.outlook.com (2603:10b6:408:138::17) by DS7PR12MB9043.namprd12.prod.outlook.com (2603:10b6:8:db::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27; Mon, 11 Nov 2024 17:12:16 +0000 Received: from MN1PEPF0000F0E5.namprd04.prod.outlook.com (2603:10b6:408:138:cafe::e) by BN9PR03CA0552.outlook.office365.com (2603:10b6:408:138::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27 via Frontend Transport; Mon, 11 Nov 2024 17:12:16 +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 MN1PEPF0000F0E5.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 11 Nov 2024 17:12:15 +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; Mon, 11 Nov 2024 09:11:57 -0800 Received: from localhost.localdomain (10.126.230.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; Mon, 11 Nov 2024 09:11:50 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , Amit Cohen , Vladimir Oltean , Andy Roulin , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next v3 5/7] selftests: net: lib: Move checks from forwarding/lib.sh here Date: Mon, 11 Nov 2024 18:08:59 +0100 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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E5:EE_|DS7PR12MB9043:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f6300d3-c8cd-4a73-e82f-08dd0273fdac X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|82310400026|376014; X-Microsoft-Antispam-Message-Info: UKERRKjBLyj+BFRebDY0S25nyaHpQlbBqgYoVwxabKuRkeFE8IVn7oeVWXkHfnGVKMySMQhvqdd60ydGV2WNOkPVjCk/puRZuf1cM0k8xH8b0YRK5YMXB5j3z72P5YnPMm12r2YN/StSJqFIcZsKfeexz/pUpt8Eau/BNMStL/+3IkdXkJafq6z1o8ceImBdyRXpHHEkQr/JgKfGuZKh+F+4llEOPJmpJMNJxPyh4A1vO+JMp7Kqt4uJ7lCw2RKLUl/0ZjPhExYCvYLSU/JvAx4uXDJ1jSP+PjK0qi8KuK+qmpBmdZyc10mFItyQh/Pgas/zSJ80qz+Sp8R+v4eqAW5YHfAT1dlDK2XfO99mW+P4qlERqzbde1e27aJS4Ze8EeO/9kBLfdIAvQCUcrAylOAU3Hur277cu/jPZv2KTjojW9aT/B7b2ALMGq1s0XYLWRsYwS0bEVvMcgSUhjwUrGoD9dpR+D8+0doG5HB5vPXHezKV3S5jGt5K7K4wRh74qdq9Ek0Jr0NIMIozBCkuHzmoptgyTieTCF24wZhSmKvayM9t7BP8dJk6LWOExwtjIDVsStLAXEnDpo8VCCwjVNgJw/hIDbiG72P2t8jAkvT/nM8JouvWhlPonRPAJ3HXjybkntFMhu/X5UOZdalV/EvZAmNJJ2z94nzmTb5ueF40NzJQ6Ae5LU+aU0BHMI3GtdAtTginifnCCtDJ0hmGvOyHv7hXx0sTSH8GfgbSvo4qs3ohpzET8R6Atdwx72vjadUYRiyKSYHUkIaberYC9mJPGXPHmoj0sd4Q33rYt/hUrFNA+y9r6ibzu8r2+cXAtb73c3+Zq3qvWTQfuWoCi0N6BaFGf0SimQYYXfiJnCFFIUcY7jh+cOuRKIMD0Dhj2n1LBBhqf2jgK2h2SIYek11zMYUpzE2q6gjP1ljFI9erYxe4ojdMcimsvGTjMwzQnl/gWLh0Od4yQ6sxmTgGNqi9RMY38+VtyhA9/62IdQhYvRN2qlWmLqDsZYxYbW5WHHYLbwT1iwtnQdJg/QKspooeDNwDJdK8d2fzEM6OcjrS7qmD6ZuAoiHF/YzAebeY1Vx0+u/2K0i1nQevJV3xWamU0eruuyWGd/Vt1rLkA55yYKdNTRDH7ycmIKI8vPxgSXeqM7aplTEzyzTnqL92O6Qh003f/wiivhJo5kutDEWttB05V17QDqGEHWbC181AmufTgStrfqrW3htol37iHQfeabh0Sl/K3tnxDsAAC+FBUi7u38WTaQtSb1d8OBDfOQKBpRsg35oKinmr/+Ry7cUZb1lHp1wuHcvfP10lo59GkaewU1vz2PH7KGca0jR/9mbe8rns3henpIHRJKAkfRRvBLkNIgtOqQnucDwP91mBrvu0u64qS+pxN49LkxN6K+VAUFytPKBDFi1Gc1blNQ== 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)(1800799024)(36860700013)(7416014)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 17:12:15.4752 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f6300d3-c8cd-4a73-e82f-08dd0273fdac 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: MN1PEPF0000F0E5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB9043 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 Mon Nov 11 17:09:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13871000 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2046.outbound.protection.outlook.com [40.107.223.46]) (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 67425184556; Mon, 11 Nov 2024 17:12:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.223.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345149; cv=fail; b=eLU8QKQzEmzi55Tl9nKpI2EGk3vG1qfkcgObB36RLJ4SVxpSHUSGtD0vf1b+dd2c8tXgv1N2Mp4w2xopYThQcjrHX1jGc9jB+Gpun6+sNLtohgKNVNZqV2ZlfHzKamsFcnG/B+zHmbCuIKVw4C/Th6s+Vux0eAPd3NU2O/Y3TBQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345149; c=relaxed/simple; bh=792cE3F7FT7Q8JnDuxa7P2ra7m8ilj9UEgxnE1f0haE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TZmhnP2SNnxtJLCQwOIo8K1Qq41zSji0aBRIaGXhvXdus8AB4E7pZGEbjt6n/IoucgtVv5Wk2tr9FvR8oRJI00PwKQnSCU5NsVBJxUChMA6+jy064o+Dh4XWatN5HVBnhpw068dqV/PQBZSCp5W63S5TZ7Ev8pED52kdSY36D70= 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=YmsOxvmn; arc=fail smtp.client-ip=40.107.223.46 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="YmsOxvmn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DiMjB1r0o7o7/khb4Wzh+/thlMTVSGXc+Wjdferil+Ttmk47yIb0ud8orXFBJkZp2dH/a3Yynrm/J/YQBOBbofgEl2p6XWBjdDlgew9xDvr5653JQlFM97nXxge39wSSDYW91xvMg4bwYtlFeokq7BfLW8P1t80GbnKVYQTGhIIIgYaBz06+nKFrCGmoNZ02cC64ctRn9E5i4OkdMnOopBlXxU14CdHqdf/PJhoPMMBP//ddDh62HvGE7KE4yUG9lvKrvgmPHu19ApDFwm/RN2jhRsre+OH2oENrlekVS8FBOhSAGUTDF9I4JUMVqTkQCPuv381ZS+mju5FyP1DQjQ== 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=a+M7JV+EJfAv5VX8yUMf1PJm9BEK/oRTXDHcSdWSh5E=; b=qjd5o9hShX8u59hE0KDwcDtGPaP+agAf4TWT317kmjVahduyYep9ZJAuUZTEVF0bYvwcLdzLxQH5f2R/KqHhjpGqbEO86fm+hKxFKwUQD87Gh3syePMImKZIsevIvwA1ennZR1y8BhG+eTQyerL1P5qOKOIOz0b8TRZuKJH8sWNsnmo2i6FZm+Sch1473pT/kbNlMr7LteYBmmIOpZNGhL51N3diJHlTPtiRxxjnfLHiJakAVUsNfHHXP5VC/vFcoeOr5yMZ9oSUhDDcIQwi6/y/b8K6KLOJkTzuLEZkYOFPIq4gZUXxRk/CmDJ/R8V7GsRtnM29aFp3LA8QkNTJAw== 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=a+M7JV+EJfAv5VX8yUMf1PJm9BEK/oRTXDHcSdWSh5E=; b=YmsOxvmn3KgNlWs+bTCzv6lTgruBueSvsVacjiebruf79P/gvjsxIgmatTogmMRrsTAGKdNNK8QDCSNGwCAvqP/FPYii44Kl4yQITzT9FRu7pOPkch6nuc4OSDiuhvesHZa33IFAeke5b2dg/r4DTj8LcY+svZRhPn9UldPfnYqSNs5zYhcfkti0AaXtIC80uyIYuFr1rqwi16irzkDd0KWpt9q+AjU6NAF4Ipv2RhwKE+lTPlyHU5sN1ZcRDMFIDOmwlS5ml7o2ecnj/YVDzI5lunKxUDb7RaJnlLfmVqsaA/7juTj/Jyiq95QXkWTVxrrdm4F8WkLexAJFAuvexg== Received: from MW3PR06CA0002.namprd06.prod.outlook.com (2603:10b6:303:2a::7) by PH7PR12MB5973.namprd12.prod.outlook.com (2603:10b6:510:1d8::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Mon, 11 Nov 2024 17:12:22 +0000 Received: from CO1PEPF000075EF.namprd03.prod.outlook.com (2603:10b6:303:2a:cafe::62) by MW3PR06CA0002.outlook.office365.com (2603:10b6:303:2a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27 via Frontend Transport; Mon, 11 Nov 2024 17:12:22 +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 CO1PEPF000075EF.mail.protection.outlook.com (10.167.249.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 11 Nov 2024 17:12:22 +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; Mon, 11 Nov 2024 09:12:05 -0800 Received: from localhost.localdomain (10.126.230.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; Mon, 11 Nov 2024 09:11:57 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , 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 v3 6/7] selftests: net: lib: Add kill_process Date: Mon, 11 Nov 2024 18:09:00 +0100 Message-ID: <3adabd35bb82aa363eb85ea2f5d2be9a16da607c.1731342342.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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075EF:EE_|PH7PR12MB5973:EE_ X-MS-Office365-Filtering-Correlation-Id: 709938a4-36ca-4e1c-2aa3-08dd027401c0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: quKX6RSSl7QbgQ0iRfvec+pLaM/m7c7Kzc0neGVD5pDWqh7WiPA3J39cT/c4p0PX3UP/BAkp/msUp+ZKgPyYH2cnsPBv4C2/v2xehPxsdOfmnDIravxVjhFUbabydLbb5XQqCvWuhs2h9NO5o3I2vpX0LYIyhugonye8hvscMRJq7Utdtat9UZWlKrn8CHrWvXLyuP5U7mJnz1IcSOfTecEb2UHW/ioqQsK+hJ3A1NagSMprqEU4FYzKxYri1FNLgdgvBoXyy8RcHnT0NixdVb3Zw+4U5OCVTDIAnt0Dq/Phx0pEjMBtW+TH6PdhlglFYObZJ4rKcXFNtjkB1Gem7dU5IlJ2HNIXekPgupHVmH2k/BoJOaO/ySBIUg+rCCBilBd8Zw9zgGkYgfzldaLzOBNqX4swReYWl61d4bTBOUc/TrXD5nBeWooZj+mfkiEIwcCvbgIb+YQlc9mn3lIBWTonBRpQyB2zCgrD7QGbtjswq7zr73OS2c4/fgASw2dsPg31ZdxyHl2CSlujU/Rtg5rXaIlzOgTLewZ0/WztkFrw+0JUEgDLiYYFEF1F9+PFbDh2SlHFOqfuJ0iF6oOqtaqOWRyrLoDbCW7n5QhLaX8UI4GVxKzoDlHfo5MgYXzoPYdc7+fDe91INqdzEBZicdGSeut6jOk0u2kov2kSfw7o2STOmofEDOenkKpIL1sLHESYIXf0x/T8duKeo2UeVwtnV3C5frhV8eev5Ju7xmxOZJfB5XoZKlmjJPmZ3hZL6O0t693Dzm5xSbADAGfIt+KqeEX3n+5zvtqrXGqTYjeZHvo3IgJAqEWjYjLHiUghKrG65fttQ8wx2FJFgXzHQpXuac8bp1BNdWp9zpx/ZZQMnBF7qm0q0V81oE/Z2W9UblMVbpyn8o9muTGWQxnHsbxFTKTi9ITtdy7Byl3/6rpJyJybxQvwYnY+rBj5OrdSnEUc8r6GoMywR4YCNxAfT7rVI/w68OKQtAOY04ocjQTf1H/4q+Q3uG7+kD8Shbb0LaWHip9TFVHsNcvNnPdUXqMFMxMZtYVpiY+vVL3bFOV0Nipzaaya0AOrt3u1pHMi4ZKSzjkprZAKSFr9SYKy+SBnzPttlM+ePseas5WAy0C24qJ/0uyigYP7lIiXfHzHTfMxVIV0PZ/fgetEwG5Y5INNkJqnwb5PLppioZthfdrIvbIdERGSDQbit0O2kO0pLlLew7N7RH1j6ptQd8c0nJmFouXCVCn6BfTcDnG1PeegaH24qRgSM0JgZfSa+XhEFsV1ej3/3Oi9ywHeGZYRdnBbsqmjrN6uKT3KiJ/Q1A77AXdDEYO/e+/hRK3OaE1hDZ8G049sFuupmcEdoqN7JuTuWpFEOZY0kzK32CH5EOeYyD9u8rhrJMyXTVqSBhN4bAzyCKp49vbejMqLhv1E4g== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 17:12:22.3905 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 709938a4-36ca-4e1c-2aa3-08dd027401c0 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: CO1PEPF000075EF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5973 X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Amit Cohen --- 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 Mon Nov 11 17:09:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 13871001 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2069.outbound.protection.outlook.com [40.107.243.69]) (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 F3910184556; Mon, 11 Nov 2024 17:12:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.243.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345156; cv=fail; b=tQ6zjyhd3hpvRwthF8jRskn4FXCR85wATAo5JC4dXpwwiONojOMGaeBoOMirNik/h4CHT+0tJbuLsG2SwOC926C+kGFVyS22TbjEYCD3vPJo8kvNt21iMGXEcHSCDle3g+fmspglUab1k1b7oDVmIvN0i3iAsabSYkfiINVBpBU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731345156; c=relaxed/simple; bh=pENITIt7/CLg4RZ7fnoBqkbo7fRavKBlcU2Gh85U3f0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OnmyHe0Np8pWy60n6HcTHKob+pqVNIxAvx4kzrbR/+nUil7vh8FC1japneOFGucXdsVo+jbZwPKccxpQTAHFVuytIhzvWUAz5PPD8LfG0lscltl07BcoZFfOoC/s1eMGQ9R0dSpjhbDwMQZS/f+jAvA3B+nLzddAPXA+c5qppdo= 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=Kb49bsN1; arc=fail smtp.client-ip=40.107.243.69 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="Kb49bsN1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ge4USRQGkZONP1mmzzsnSRvhYXG6Zvf3eLENX/Nog9tJvZ74Zy+s/g6KGxOSxeDNk6qVVTzwKIaDXCO7WMBCcq31HCgMPW6smPDGYAXD9ojswM9QYZQQ1jM3DxgXReJ0fvgD9JuPnuhdpmo8AGEnyjengbUmb3OMHfANA1Ie+XZ7QmHRCtGfO+Of/L2vQqKk0AyaUp1hCo/HNaGg8yhIut2ffAOlGdX+n2t1qgrYZVBDLhnp6FTP4G9bGV9uDy2NQVY7u6j5zihMp2FHZlUa8VRZk69BNUbjN+10CUCHIC+CTP7HHLz1oAfVz4rWfybUH6hehuMfKRJPGCqm/r++/A== 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=xVQihhtYWLrg1OTqdWtB8VuH7PoGIhINHuZ/rWXhYkY=; b=f6MrEalrhk6Cc73uVUygkv3fornX6djMg656PBNK38oGs2VINnT/RezYGms7H6ZOx+lIOttsCfjiUErc52yp6SzN7Qz8d7/D66R9h7L9R3Mmpmre0IoG4a4sA/oPcGbcJsb9Y5WrHayIY23KjWcGzQaoy/gDEq4ZOpfDNh5ywGEoQrWLSIw8zpp/D1fNN/d15+xaLaYlbUVcp1P8MAGLnTFof6CXVC/JUpkqM78l5VpWkgcSQ9LHCqJ7IYD+bWx5NxVLcBgZKAk/m+YSYymUG879fAzu1kLNTn7bv8+IF1hnn0kUKpZwHVYb9jdWFJ/MAcOkl2zAgkzYTfyS7nMlPw== 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=xVQihhtYWLrg1OTqdWtB8VuH7PoGIhINHuZ/rWXhYkY=; b=Kb49bsN17iCwQkpZ8xypCnRItV60l6M91qCL9AC2e/ZVYZFKn5sebjBJspRuDRjmjxzOdI2OIWvTk8AtRbw/9CAae6slvXz07YtYkVA/iommkLxY3hi3GArrPW+d0v734gSZtUpLg0opbQwiLp5D/S5sT/gKi5vKy3PKB0Rtm5IJgX5QNlBzrE9NVI+NjJaXm04aFLnqON/e2lF64oTt8acBjtW2Y1TwxQF6dPcN+et+FWPF2bTZUANiL+slMuip+XMHXJ5iK8HkkG5bxQ4HZrCXhYv4hkILy24FUcXfHg5nzLXYLSSrRog0bbw9bUCRf/U20wv12OAV3RUY8BgqPg== Received: from MW4P221CA0010.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::15) by DM6PR12MB4314.namprd12.prod.outlook.com (2603:10b6:5:211::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28; Mon, 11 Nov 2024 17:12:30 +0000 Received: from CO1PEPF000075F3.namprd03.prod.outlook.com (2603:10b6:303:8b:cafe::56) by MW4P221CA0010.outlook.office365.com (2603:10b6:303:8b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.28 via Frontend Transport; Mon, 11 Nov 2024 17:12:29 +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 CO1PEPF000075F3.mail.protection.outlook.com (10.167.249.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.14 via Frontend Transport; Mon, 11 Nov 2024 17:12:29 +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; Mon, 11 Nov 2024 09:12:12 -0800 Received: from localhost.localdomain (10.126.230.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; Mon, 11 Nov 2024 09:12:05 -0800 From: Petr Machata To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , CC: Simon Horman , Ido Schimmel , "Petr Machata" , Amit Cohen , Vladimir Oltean , Andy Roulin , , Shuah Khan , Shuah Khan , Benjamin Poirier , Hangbin Liu , , Jiri Pirko Subject: [PATCH net-next v3 7/7] selftests: net: fdb_notify: Add a test for FDB notifications Date: Mon, 11 Nov 2024 18:09:01 +0100 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: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000075F3:EE_|DM6PR12MB4314:EE_ X-MS-Office365-Filtering-Correlation-Id: f369eef1-7cf4-4ebe-1839-08dd027405f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: DTjT1XSJozJz//RH1vHaPfWmCbYTForVs8urxjwAbmTxFOpOg6A2W8jvxwgMQgIM7YY8vDJYD6kNEfsdC2QFC4bLD0YKQMbcQout/OGqBzz4Ii2ONvOrFB7pnDLeLMSeOjSexuSasgofejcRznb336Y+NxB+vzNWW/1uziFLhdMa9eR8gebRNk0ZH1bkOLEHSA4K4+FbrWWyWbMDj1IiLhNA54cGmAkFNXMwi7pVSZ2OEKsrKGQ2ABja+dzjXVy5e00HpJ8Bqxux6IRDgCAIN1NuZ8WwUUrwHzEMObyaDJijN4ajfTUCLp4IRvDlmv3FgxAjZsEO1MXjjbs2h47JkXcnFCnp8TsUKoDwqUUP50Uf0H0CNoOWrERNZO8wsiN4IbgHVuOwLuwB8T1LiQ5WHb29aaTdD1NB9KtVwhKh4l+UmKOwh5fbRLxaQtSBy36lakIce5XXWzrCUyIZvTnZnG51HqAp9ycbJqet4HzjOTWeeiXF1n0iFpISQvAxyjuICeJm+nrhX5TxLepDaBqVZ0lCRpIFraAOkRGD31rrjbgxlPmuyVUWjFqZsi3iFTgTuqWdYETcY6N2FxOVQWxvyfS/XcSegaI2YbodscLWRnekVwfyL+25P3xZHMYBbxR0Sr1yUcpF2tyxqDZLnvCTQOKTRoeKf5z+5QTnRaE1fEBIqqrwvPwhwhK/OC0fx8HDCoWAvskRycKkyXCpQ4RmwiSkVNVBtRscjW+Qn3ef51TWn6khGrdrZ4L16E11ajzDzstwFkJ+XFXAUx9gq31tJR4OsGdQEmOjZn3Ea0AJlXMpTi9ePvVoCj8xifM/fOsAOYpo+K48V2Jeo/u1s/KGJFdiP0ePB4MWKZu5P02unzMRifMLcTrano3iivBTJXA2b36sDlcDYzEGirTUIR+6swaKsS4sDe6LQFUyXeuMDYFanxpnTWe5vYNqsiZKil4ZV5agkONA3/XypH/+Q+DsIIGuXyTolMLbbco4y0F+XsrnE3Fz3AWAoHcQBBwt0pJ3vZXvB7epqQjrqGnximKDYtaTCxaMxmtFzn8EFAw69j2IZmAnLiKB8v1h4cZmA5bbHI+CGQFBuyhuD5NgnzDyHzKtG1V/tYENawaIIwJu/0Rxm7j529LNec1myeVV+dwtADrJjd7reIdDSSR8KinkLkPyxknSSlDWjO9QRzeM6zOj3HvecGFO17ZCdItLOHbtioUcD7sYI+hSpGu92NG0jG4m5y7Q2iLOvFO6Fo+mZILHWtC9skor6kyb6xisjK4y+z23rOodqQVTSqOc+4sioUCH3c+o4KpK+CAvfedMZ/KoRx15ocpoNXnR6Lsrpqmg6teLyF49CM3MdqFECrfSFZSox8na0XeuR/NwtKzX/y5qWmxd5YYLFPNrum8lNpGoBEUNo6g9hHYytI6hH5lCXA== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2024 17:12:29.4064 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f369eef1-7cf4-4ebe-1839-08dd027405f1 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: CO1PEPF000075F3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4314 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 +}