[PATCH v3 net-next 3/6] net: Rename dev_isalive() to netif_is_alive().
flat view
COOLING4d
IN LINUX-NEXT
From: Kuniyuki Iwashima <kuniyu@google.com>
Date: 2026-10-01 20:47:59
Subsystem:
networking drivers, networking [general], the rest · Maintainers:
Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds
Queued in linux-next as 2e65372a2b64 on 2026-10-06.
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 <kuniyu@google.com> --- 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 d037faff7c44..971f1056aef0 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h@@ -5712,6 +5712,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 51921623fc0a..43beebddf22f 100644
--- a/net/core/dev.h
+++ b/net/core/dev.h@@ -412,10 +412,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 fa790e442570..e24a5154b212 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 e3444fd24061..62b4f18e37b8 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c@@ -4356,7 +4356,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;
--
2.56.0.rc1.315.gc6ed9934b7-goog