From: Kuniyuki Iwashima <kuniyu@google.com>
To: David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
Chris J Arges <carges@cloudflare.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
Kuniyuki Iwashima <kuni1840@gmail.com>,
netdev@vger.kernel.org
Subject: [PATCH v3 net-next 3/6] net: Rename dev_isalive() to netif_is_alive().
Date: Thu, 1 Oct 2026 20:47:15 +0000 [thread overview]
Message-ID: <20261001204752.2572265-4-kuniyu@google.com> (raw)
In-Reply-To: <20261001204752.2572265-1-kuniyu@google.com>
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
next prev parent reply other threads:[~2026-10-01 20:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 20:47 [PATCH v3 net-next 0/6] ip: Batch flushing uncached routes per batched device unregistration Kuniyuki Iwashima
2026-10-01 20:47 ` [PATCH v3 net-next 1/6] net: Order blackhole_netdev_init(), inet_init(), and inet6_init() Kuniyuki Iwashima
2026-10-05 12:18 ` Fernando Fernandez Mancera
2026-10-01 20:47 ` [PATCH v3 net-next 2/6] ipv4: Inline inet_blackhole_dev_init() to devinet_init() Kuniyuki Iwashima
2026-10-04 23:02 ` netdev-bot+sashiko
2026-10-01 20:47 ` Kuniyuki Iwashima [this message]
2026-10-01 20:47 ` [PATCH v3 net-next 4/6] xfrm: Check netif_is_alive() in xfrm_bundle_create() and xfrm_create_dummy_bundle() Kuniyuki Iwashima
2026-10-01 20:47 ` [PATCH v3 net-next 5/6] ipv4: Batch rt_flush_dev() in netdev_run_todo() Kuniyuki Iwashima
2026-10-04 23:02 ` netdev-bot+sashiko
2026-10-05 0:51 ` Kuniyuki Iwashima
2026-10-01 20:47 ` [PATCH v3 net-next 6/6] ipv6: Batch rt6_uncached_list_flush_dev() " Kuniyuki Iwashima
2026-10-04 23:02 ` netdev-bot+sashiko
2026-10-05 0:49 ` Kuniyuki Iwashima
2026-10-06 8:12 ` [PATCH v3 net-next 0/6] ip: Batch flushing uncached routes per batched device unregistration Ido Schimmel
2026-10-06 17:45 ` Kuniyuki Iwashima
2026-10-06 20:07 ` Chris Arges
2026-10-06 23:10 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261001204752.2572265-4-kuniyu@google.com \
--to=kuniyu@google.com \
--cc=andrew+netdev@lunn.ch \
--cc=carges@cloudflare.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox