From 2e65372a2b64a1d6d1e27dff0579b3a609b2e405 Mon Sep 17 00:00:00 2001 From: Kuniyuki Iwashima Date: Thu, 1 Oct 2026 20:47:15 +0000 Subject: [PATCH] net: Rename dev_isalive() to netif_is_alive(). The next patch needs to use dev_isalive() in xfrm. We should try to avoid using the dev_ prefix on APIs we export via include/linux/. Let's move it to include/linux/netdevice.h and rename to netif_is_alive(). Signed-off-by: Kuniyuki Iwashima Reviewed-by: Ido Schimmel Tested-by: Chris J Arges Link: https://patch.msgid.link/20261001204752.2572265-4-kuniyu@google.com Signed-off-by: Jakub Kicinski --- include/linux/netdevice.h | 6 ++++++ net/core/dev.h | 6 ------ net/core/net-sysfs.c | 16 ++++++++-------- net/core/netdev_work.c | 4 ++-- net/core/rtnetlink.c | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index f61c97231309..8cae9b00211e 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -5715,6 +5715,12 @@ static inline const char *netdev_name(const struct net_device *dev) return dev->name; } +/* Caller holds RTNL, netdev->lock or RCU */ +static inline bool netif_is_alive(const struct net_device *dev) +{ + return READ_ONCE(dev->reg_state) <= NETREG_REGISTERED; +} + static inline const char *netdev_reg_state(const struct net_device *dev) { u8 reg_state = READ_ONCE(dev->reg_state); diff --git a/net/core/dev.h b/net/core/dev.h index 4793a994f7f1..4e9e8cd15697 100644 --- a/net/core/dev.h +++ b/net/core/dev.h @@ -419,10 +419,4 @@ int dev_get_hwtstamp_phylib(struct net_device *dev, struct kernel_hwtstamp_config *cfg); int net_hwtstamp_validate(const struct kernel_hwtstamp_config *cfg); -/* Caller holds RTNL, netdev->lock or RCU */ -static inline bool dev_isalive(const struct net_device *dev) -{ - return READ_ONCE(dev->reg_state) <= NETREG_REGISTERED; -} - #endif diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 728ff0a68248..fa6f821c8846 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c @@ -100,7 +100,7 @@ static int sysfs_rtnl_lock(struct kobject *kobj, struct attribute *attr, /* Check dismantle on the device hasn't started, otherwise deny the * operation. */ - if (!dev_isalive(ndev)) { + if (!netif_is_alive(ndev)) { rtnl_unlock(); ret = -ENODEV; goto unbreak; @@ -143,7 +143,7 @@ static int sysfs_get_link_ksettings(struct device *dev, } netdev_lock_ops(netdev); - if (!dev_isalive(netdev)) { + if (!netif_is_alive(netdev)) { ret = -ENODEV; goto unlock; } @@ -170,7 +170,7 @@ static ssize_t netdev_show(const struct device *dev, ssize_t ret = -EINVAL; rcu_read_lock(); - if (dev_isalive(ndev)) + if (netif_is_alive(ndev)) ret = (*format)(ndev, buf); rcu_read_unlock(); @@ -247,7 +247,7 @@ netdev_lock_store(struct device *dev, struct device_attribute *attr, netdev_lock(netdev); - if (dev_isalive(netdev)) { + if (netif_is_alive(netdev)) { ret = (*set)(netdev, new); if (ret == 0) ret = len; @@ -303,7 +303,7 @@ static ssize_t address_show(struct device *dev, struct device_attribute *attr, down_read(&dev_addr_sem); rcu_read_lock(); - if (dev_isalive(ndev)) + if (netif_is_alive(ndev)) ret = sysfs_format_mac(buf, ndev->dev_addr, ndev->addr_len); rcu_read_unlock(); @@ -319,7 +319,7 @@ static ssize_t broadcast_show(struct device *dev, int ret = -EINVAL; rcu_read_lock(); - if (dev_isalive(ndev)) + if (netif_is_alive(ndev)) ret = sysfs_format_mac(buf, ndev->broadcast, ndev->addr_len); rcu_read_unlock(); return ret; @@ -747,7 +747,7 @@ static ssize_t threaded_show(struct device *dev, rcu_read_lock(); - if (dev_isalive(netdev)) + if (netif_is_alive(netdev)) ret = sysfs_emit(buf, fmt_dec, READ_ONCE(netdev->threaded)); rcu_read_unlock(); @@ -824,7 +824,7 @@ static ssize_t netstat_show(const struct device *d, offset % sizeof(u64) != 0); rcu_read_lock(); - if (dev_isalive(dev)) { + if (netif_is_alive(dev)) { struct rtnl_link_stats64 temp; const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp); diff --git a/net/core/netdev_work.c b/net/core/netdev_work.c index c99967907e18..1b11bcbeb196 100644 --- a/net/core/netdev_work.c +++ b/net/core/netdev_work.c @@ -30,7 +30,7 @@ static void netdev_work_enqueue(struct net_device *dev, unsigned long events, return; spin_lock_bh(&netdev_work_lock); - if (!dev_isalive(dev)) { + if (!netif_is_alive(dev)) { spin_unlock_bh(&netdev_work_lock); return; } @@ -154,7 +154,7 @@ static void netdev_work_proc(struct work_struct *work) /* We took another ref above */ netdev_put(dev, &dev->work_tracker); - if (!dev_isalive(dev)) + if (!netif_is_alive(dev)) core = events = 0; } spin_unlock_bh(&netdev_work_lock); diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 5bbebce0c2f5..15bffafbf0a9 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -4360,7 +4360,7 @@ static int rtnl_getlink(struct sk_buff *skb, struct nlmsghdr *nlh, retry: if (need_rtnl) { rtnl_lock(); - if (!dev_isalive(dev)) { + if (!netif_is_alive(dev)) { err = -ENODEV; nskb = NULL; goto unlock;