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 <kuniyu@google.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Tested-by: Chris J Arges <carges@cloudflare.com>
Link: https://patch.msgid.link/20261001204752.2572265-4-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Kuniyuki Iwashima 2026-10-01 20:47:15 +00:00 committed by Jakub Kicinski
parent 3d51928a88
commit 2e65372a2b
5 changed files with 17 additions and 17 deletions

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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;