diff options
| author | Jakub Kicinski <kuba@kernel.org> | 2023-07-28 21:36:00 +0300 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2023-07-28 21:36:00 +0300 |
| commit | 5bdc312c1d06fb4ef02bd62fd077e4fa722012e6 (patch) | |
| tree | b977b7a1bda1dfea681cdcc02acdfd6f51ec7d41 /include | |
| parent | 083476a2023ce64991e17565707e205a1bf78d63 (diff) | |
| parent | 84e00d9bd4e472bd9b145ed40dbd132dd7a15462 (diff) | |
| download | linux-5bdc312c1d06fb4ef02bd62fd077e4fa722012e6.tar.xz | |
Merge branch 'net-store-netdevs-in-an-xarray'
Jakub Kicinski says:
====================
net: store netdevs in an xarray
One of more annoying developer experience gaps we have in netlink
is iterating over netdevs. It's painful. Add an xarray to make
it trivial.
v1: https://lore.kernel.org/all/20230722014237.4078962-1-kuba@kernel.org/
====================
Link: https://lore.kernel.org/r/20230726185530.2247698-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/netdevice.h | 3 | ||||
| -rw-r--r-- | include/net/net_namespace.h | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 32a4cdf37dd4..84c36a7f873f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -3016,6 +3016,9 @@ extern rwlock_t dev_base_lock; /* Device list lock */ if (netdev_master_upper_dev_get_rcu(slave) == (bond)) #define net_device_entry(lh) list_entry(lh, struct net_device, dev_list) +#define for_each_netdev_dump(net, d, ifindex) \ + xa_for_each_start(&(net)->dev_by_index, (ifindex), (d), (ifindex)) + static inline struct net_device *next_net_device(struct net_device *dev) { struct list_head *lh; diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 78beaa765c73..9f6add96de2d 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -42,6 +42,7 @@ #include <linux/idr.h> #include <linux/skbuff.h> #include <linux/notifier.h> +#include <linux/xarray.h> struct user_namespace; struct proc_dir_entry; @@ -69,7 +70,7 @@ struct net { atomic_t dev_unreg_count; unsigned int dev_base_seq; /* protected by rtnl_mutex */ - int ifindex; + u32 ifindex; spinlock_t nsid_lock; atomic_t fnhe_genid; @@ -110,6 +111,7 @@ struct net { struct hlist_head *dev_name_head; struct hlist_head *dev_index_head; + struct xarray dev_by_index; struct raw_notifier_head netdev_chain; /* Note that @hash_mix can be read millions times per second, |
