From patchwork Tue Oct 15 16:59:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Naaman X-Patchwork-Id: 13836752 X-Patchwork-Delegate: kuba@kernel.org Received: from dispatch1-eu1.ppe-hosted.com (dispatch1-eu1.ppe-hosted.com [185.183.29.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40A5F1F76C6 for ; Tue, 15 Oct 2024 16:59:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=185.183.29.34 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729011595; cv=fail; b=NFuNr+DaHONrCHUULCalxY2dCoYB9ll/1OPLhTuae0suHz/9+oo60aYLbdnvD/jq5clJR5kk4OrVmCtAbBPAhIJaUyTDKQP6fc7A/8lZzTmQ/vLIrFHPfFk+uS2Sh3/hy33UrHSI6W8MR0+vLdm0Mw+/G31kHVs4jkir7E7a/Cg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729011595; c=relaxed/simple; bh=cZ0xkR96fkOBNvwl2CPTUoEDacUmIp5i3LzzsO9AEcE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=kobR1cHbcfd+HZA8vzQRMMU9P6LjPFGEzHSW4gMU3AjjEUaV8AcfAbMDuRCN8q89ILonXIGISPRLuu9L6axeaIW+7uHd8ijMR5nqK2c+5EAzMFwz6nAoGrbFpH3PVm9C21JvIUn2AQ4KvkaTXepql68rXWCAw8SYY9SaAcbfbqg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=drivenets.com; spf=pass smtp.mailfrom=drivenets.com; dkim=pass (1024-bit key) header.d=drivenets.onmicrosoft.com header.i=@drivenets.onmicrosoft.com header.b=Np0BgQaH; arc=fail smtp.client-ip=185.183.29.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=drivenets.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=drivenets.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=drivenets.onmicrosoft.com header.i=@drivenets.onmicrosoft.com header.b="Np0BgQaH" X-Virus-Scanned: Proofpoint Essentials engine Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2106.outbound.protection.outlook.com [104.47.17.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1-eu1.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 6057920005A; Tue, 15 Oct 2024 16:59:45 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OLbxjO5OsJXJWneTs6pkS+yNVgQ4AVlz4ggJSJqCm2gww8+T17hHho2bdlEcgj3A0QNmkI2vByqN499JOu0ZyUPz4asaRuTFdKeCS3WSkqfivHT6IuAYQSHC/5p02w3F49QqbthT34HQ1e5dq0HWl5Yz91rtrYDGVZc53PUfGcY986C8HEb9m7I8Of2Cp7HBSgdFUDtZfGxnOz1ungwEVDwN8NoCKsC8TJQ8cvMgZRrYJKy83hnmSEMNsx5+d7BFIxesAmW/PDMbxdUDXzNv0jKHv8PLz6irF2dIqEeNq0F7miabDgGEgtwiUPwwavHuxPaPYE42dFaO/kYu7H8oRQ== 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=J9ssrDYMpF4+bD825oiW+rpMkk5jMJRW3sohGoIXtvg=; b=GRaXy4p9wEGdfgn4dwlBmLHB0n0YYlTFPH+AhAyQ8n4hbJ16ei4ttmhpv/ceoUGmd1aTktiGK9TbXrMBCNM9OcEtdNepqG9X65EGyFUCo/HycVgelqIMEu4zlnR0HRHDtjaQbN1Jc8vpWNM2i3uJzByzvo60nW4t5ownRNhEwT0AbId62RUeHxuT8JENj+Cq0kPg3SyIWQf4eHHhIXrJJ7h3KgvkTFgrLS1Yb3i01QjZIi3TblNwoXW4o71hErehRSF79aRAjV6bM6aT5NXUmMmH84PFLwbETKg9tJ3Z52SIGQvzt7CRwFsbSyk35oDhwvHlA4FqexRn+hvB8NyqYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=drivenets.com; dmarc=pass action=none header.from=drivenets.com; dkim=pass header.d=drivenets.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=drivenets.onmicrosoft.com; s=selector2-drivenets-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J9ssrDYMpF4+bD825oiW+rpMkk5jMJRW3sohGoIXtvg=; b=Np0BgQaHNXgIPVbmTJEmSnYlADLgz2Chnctz+lf+oJpGF+f8XddFKTgbPyasJJfdyBg9vqk5PdCKzqSwZlHEn4xqw1I+c8wHcQ/WVbJl1pKVm1Jt+iPMyXSsSBJsJiTntnAg8de8fvibJ8QBIyJtg3htZ+UWbMMBKnz48MN6qW8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=drivenets.com; Received: from DB8PR08MB5388.eurprd08.prod.outlook.com (2603:10a6:10:11c::7) by AS8PR08MB8249.eurprd08.prod.outlook.com (2603:10a6:20b:53f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Tue, 15 Oct 2024 16:59:44 +0000 Received: from DB8PR08MB5388.eurprd08.prod.outlook.com ([fe80::29dd:6773:4977:dc4e]) by DB8PR08MB5388.eurprd08.prod.outlook.com ([fe80::29dd:6773:4977:dc4e%5]) with mapi id 15.20.8069.016; Tue, 15 Oct 2024 16:59:44 +0000 From: Gilad Naaman To: netdev , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Gilad Naaman , Kuniyuki Iwashima Subject: [PATCH net-next v4 3/6] Convert neigh_* seq_file functions to use hlist Date: Tue, 15 Oct 2024 16:59:23 +0000 Message-ID: <20241015165929.3203216-4-gnaaman@drivenets.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241015165929.3203216-1-gnaaman@drivenets.com> References: <20241015165929.3203216-1-gnaaman@drivenets.com> X-ClientProxiedBy: LO2P265CA0059.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::23) To DB8PR08MB5388.eurprd08.prod.outlook.com (2603:10a6:10:11c::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB8PR08MB5388:EE_|AS8PR08MB8249:EE_ X-MS-Office365-Filtering-Correlation-Id: b283ec86-412e-4413-4761-08dced3ac48d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: uSF17XTBGYU7RuqO5FQIplCUADHQxq8Vmdjpwzw+dryCrz1GBbYLZlCEGteTk7ge1oM8pG1AGRnBauJ7yOx8faR9y0nWiywrajewgCkXxuu1MXGgdCs1n7st8PpxerNd/jQeJJY/Uyl/arSyr4ZkLyS6UOzQmV0yKgL0p+veUr6SDG+Tfdc8POFg6Jx5vkiompoRzlscb6NvTd1+fGVGRySHxM3HXCeFR4toxl+rl1FTKjK76TSbQ5gBlvTClCQpXlrEXJtY2ajClHzxKtNLvJR/Ry/dMrzTWryC5H7Q1gK9cxS6vOOviCaAK0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CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB8PR08MB5388.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RCgfI3XkwlLTT/3a84nFsdOHVMrRG4Fh98ZGDiBGvoVG8c4GTWugPQdWNikTi2zWn8mnB03JFf2saPjKQc/5uCOfKhNs8FyfK0GIIB/XuTQAqpJsMFcdd5lPVRbSlTPsvgGvI1jaPnKCgE75dMH7G1PXgWfNilxIl6T2OFsQsVumGHJXqlHm+BpTuRnlb4oHOKaxi+GYUBqeoSMiRPrbTTOoJM9BnjA8H4j+9NNVVzewBjYAx0HRzoImJJLAzfS4OHJLuDstFoareUXOVfZPdG4QA+NAYxc2TqGe6dNcgbxthMlmW1YVgsF4Y0kYUwCpB4tphh4vp8Qj0lkFYd4yZRs10pPAQrivl0y1NNVD89Sl91cXdRp57KqQ6zZ6xKMJg99vmpBQxALWJsdi3EI7KVE0bbZU6GjaVriq7OXdolAuyW88U4KIZARafOAYDT9pYe6wt5l9UL37steAHqxXamZbFzlXCSpD095syZjG+PjZaP11Wm2MRxEl6Pa+yBf6ff3TdzZ7Yypi1ynApDbukAuhA+T6FAclAL31p8dj3jSRxnJ+n0vNk4Kb+kANnBedn+ufX396iH56hXUp8gR3JRj9xn/Yl/FxezL9RnNcdHEr8NHdSFh1Jtlyk4aNiMz6Jy5qFWAfr+Y+IbPAISVgeKkPlsCtOOjgFFRtgBs72GlJDWeW1FuIfx48+z7d6j//TTKC0oXQMeIESdmxXd8Ts6SkWuCrkRMNQDV4b/6kopjSC/o+Xzp8cFIXF8K+sWQeNbq7raDPkB1s8ioMzBuwGJ76h+4JSpF15ChCoGFHdIT58VGwcMZpbnf0gXEyQUkMyp1cgYucK20dX40ARLgP3gSbPpztS9IC/ut9wgD7HM6ICxnOY1M8+SmrlEPriBGdxe6f8HMBkpHDqJAUm8YeaWlE+AfTRMU7XDmduYPhT+6RBoU9phleNCIH0i/HOzNcE2evWGGyChJ3o/hgmzVqSWSpPkme29RDwqtBSGLlPAESqCCjlXtkgCrjxyYp7joqiwyLq+zQz/7phn1iS8WUQTr1BmcLQ6dbF+V/jtU+BClJ7jgwuDmC8gT4UB7c9rW21b9u5SoZpC8lv/h6cEy24+fHr7dS6bbmS7lxT+c9j08OUscxM6ucLz3SJcTWenWujyL9/vgWqsG8VFB1DbHZBqZk7MBw7xY3aNMD98m6Pqygtw7fZ5+gUYtyQzsaigCpeCMlg2yFIRn1uCGfRTmzJYmPabeY++XMHXdgdeKIP0VkORkUxec8ySr94JRPBpCGFAwpp0JzRm6PYO/2F+9uvlNPtd/145W+q6qsc4g+BPE2FCelAxKfXUydh+R+gnElQeVL89ktBaa4CdORxHa6BysNQKAGAlr4wut75H9Ew1KZAuCr5sQ1W/CsFbXkKPCub0kSGkIwP9HzlrXOkgMqo/S0fbEz70JMvJml784eN8VvyMmiSToB69R7bM6zBd1FAZnMHEVOSGghxlWOnnrTRf3KijxBcd2TTEJMj3LkQSTwe38fHJ6lCU0bmWho90Djkuzl3MLA+658B2+CJbhRkjrrtvmwykRp600uFDp1kfp89lr0MLERbTKtfovBZpGZAcI83DBkVhyOYyJSL3pReQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: jy9H+DFbzbghi4Eejwam5z8tGvkUOhD3AhWko0VL9ipffuwNTslfeG//wTlpk9kptANSW7OSjGyqW23GE/zq9y/wZuRcT9D6wpuZe39T8xnN3jHlQq5QsieqNiC2UXtpdetd/bGuIr6TLoql96H3uxF64fGGKac9uadeNCQfFO5aKjXKz0lP7iCbh5YPyGfimp+6rcMd+19Tw+VsSTi81jOhxl7gT4OKB0zX43FjdcXtxtWnmIzUg1oh9AL2b4QfiqG4bvPRI93bT68b5n8WHRfHmJ/GkE5Vwh7/MdhF2rUfxv7I9tUTLf2StK94KLBh3k0fjhQYv6HYXwx+J/Kv1Foj6kRLNEFS3Pexa1Hv/f8AMOoPbBBSMYYu2ujav2ReLMrpQGel8nHQ00wu5Dngg9JPdPTHm00977XyX7Cawza5tWMimLDyxSm6DFL1VVwpV0pV4c86W5ICGnWEkM+gfiZNV8OhUHwME3aeFG3kZMjGcRue5+y5PcHzkUowfhaHlE7BbEVggJUmrU2Ueuv8UQiAesJiVDCUdPvnoln8UWTkGuQMBB69Je3sewga/udfUlg2GU5x05wJIHrI5Nky4ibU87Jc1NE3P6/sKjiExHwgnsbnMXFbUfdCadBOjWv7 X-OriginatorOrg: drivenets.com X-MS-Exchange-CrossTenant-Network-Message-Id: b283ec86-412e-4413-4761-08dced3ac48d X-MS-Exchange-CrossTenant-AuthSource: DB8PR08MB5388.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 16:59:44.2502 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 662f82da-cf45-4bdf-b295-33b083f5d229 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: leRPBA09SCSRKE9YK8PdQ50psrqvdzziT9ISO+GjfiWlgvfkJOykowhFV2jMODWb9pI8djGkLzmbJt96JDjacg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8249 X-MDID: 1729011586-a7Gou46vFKQv X-MDID-O: eu1;ams;1729011586;a7Gou46vFKQv;;495c1e7a27a6c3e35a5fabc922783896 X-PPE-TRUSTED: V=1;DIR=OUT; X-Patchwork-Delegate: kuba@kernel.org Convert seq_file-related neighbour functionality to use neighbour::hash and the related for_each macro. Signed-off-by: Gilad Naaman --- include/net/neighbour.h | 4 ++++ net/core/neighbour.c | 26 ++++++++++---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 2f4cb9e51364..7dc0d4d6a4a8 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -279,6 +279,10 @@ static inline void *neighbour_priv(const struct neighbour *n) extern const struct nla_policy nda_policy[]; #define neigh_for_each(pos, head) hlist_for_each_entry(pos, head, hash) +#define neigh_hlist_entry(n) hlist_entry_safe(n, struct neighbour, hash) +#define neigh_first_rcu(bucket) \ + neigh_hlist_entry(rcu_dereference(hlist_first_rcu(bucket))) + static inline bool neigh_key_eq32(const struct neighbour *n, const void *pkey) { diff --git a/net/core/neighbour.c b/net/core/neighbour.c index e91105a4c5ee..4bdf7649ca57 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -3207,25 +3207,21 @@ static struct neighbour *neigh_get_first(struct seq_file *seq) state->flags &= ~NEIGH_SEQ_IS_PNEIGH; for (bucket = 0; bucket < (1 << nht->hash_shift); bucket++) { - n = rcu_dereference(nht->hash_buckets[bucket]); - - while (n) { + neigh_for_each(n, &nht->hash_heads[bucket]) { if (!net_eq(dev_net(n->dev), net)) - goto next; + continue; if (state->neigh_sub_iter) { loff_t fakep = 0; void *v; v = state->neigh_sub_iter(state, n, &fakep); if (!v) - goto next; + continue; } if (!(state->flags & NEIGH_SEQ_SKIP_NOARP)) break; if (READ_ONCE(n->nud_state) & ~NUD_NOARP) break; -next: - n = rcu_dereference(n->next); } if (n) @@ -3249,34 +3245,32 @@ static struct neighbour *neigh_get_next(struct seq_file *seq, if (v) return n; } - n = rcu_dereference(n->next); while (1) { - while (n) { + hlist_for_each_entry_continue_rcu(n, hash) { if (!net_eq(dev_net(n->dev), net)) - goto next; + continue; if (state->neigh_sub_iter) { void *v = state->neigh_sub_iter(state, n, pos); if (v) return n; - goto next; + continue; } if (!(state->flags & NEIGH_SEQ_SKIP_NOARP)) break; if (READ_ONCE(n->nud_state) & ~NUD_NOARP) break; -next: - n = rcu_dereference(n->next); } if (n) break; - if (++state->bucket >= (1 << nht->hash_shift)) - break; + while (!n && ++state->bucket < (1 << nht->hash_shift)) + n = neigh_first_rcu(&nht->hash_heads[state->bucket]); - n = rcu_dereference(nht->hash_buckets[state->bucket]); + if (!n) + break; } if (n && pos)