Thread (22 messages) flat view 22 messages, 3 authors, 8d ago
COOLING8d

[PATCH net-next 4/9] netconsole: move netpoll_local_ip_unset() as netcons_local_ip_unset()

From: Breno Leitao <leitao@debian.org>
Date: 2026-07-24 15:05:24
Also in: lkml
Subsystem: netconsole, networking drivers, networking [general], the rest · Maintainers: Breno Leitao, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

Move netpoll_local_ip_unset() from netpoll to netconsole and rename it
to netcons_local_ip_unset();

The body is otherwise unchanged, only the comment's setup-function
reference is updated.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/net/netconsole.c | 19 ++++++++++++++++++-
 include/linux/netpoll.h  |  1 -
 net/core/netpoll.c       | 18 ------------------
 3 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 3a7a2cafc6276..70f9c5bfb3720 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -351,6 +351,23 @@ static void netconsole_skb_pool_flush(struct netconsole_target *nt)
 	skb_queue_purge_reason(&nt->skb_pool, SKB_CONSUMED);
 }
 
+/*
+ * Test whether the caller left np->local_ip unset, so that
+ * netcons_netpoll_setup() should auto-populate it from the egress device.
+ *
+ * np->local_ip is a union of __be32 (IPv4) and struct in6_addr (IPv6),
+ * so an IPv6 address whose first 4 bytes are zero (e.g. ::1, ::2,
+ * IPv4-mapped ::ffff:a.b.c.d) must not be tested via the IPv4 arm 
+ * doing so would misclassify a caller-supplied address as unset and
+ * silently overwrite it with whatever address the device exposes.
+ */
+static bool netcons_local_ip_unset(const struct netpoll *np)
+{
+	if (np->ipv6)
+		return ipv6_addr_any(&np->local_ip.in6);
+	return !np->local_ip.ip;
+}
+
 static int netcons_netpoll_setup(struct netpoll *np)
 {
 	struct net *net = current->nsproxy->net_ns;
@@ -395,7 +412,7 @@ static int netcons_netpoll_setup(struct netpoll *np)
 		rtnl_lock();
 	}
 
-	if (netpoll_local_ip_unset(np)) {
+	if (netcons_local_ip_unset(np)) {
 		if (!np->ipv6) {
 			err = netpoll_take_ipv4(np, ndev);
 			if (err)
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index cd455a5a013d2..da05884f876e5 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -76,7 +76,6 @@ void netpoll_wait_carrier(struct netpoll *np, struct net_device *ndev);
 char *egress_dev(struct netpoll *np, char *buf, size_t bufsz);
 int netpoll_take_ipv4(struct netpoll *np, struct net_device *ndev);
 int netpoll_take_ipv6(struct netpoll *np, struct net_device *ndev);
-bool netpoll_local_ip_unset(const struct netpoll *np);
 
 #ifdef CONFIG_NETPOLL
 static inline void *netpoll_poll_lock(struct napi_struct *napi)
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index d50d48a82def6..f4b110cb04167 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -496,24 +496,6 @@ int netpoll_take_ipv4(struct netpoll *np, struct net_device *ndev)
 }
 EXPORT_SYMBOL_GPL(netpoll_take_ipv4);
 
-/*
- * Test whether the caller left np->local_ip unset, so that
- * netpoll_setup() should auto-populate it from the egress device.
- *
- * np->local_ip is a union of __be32 (IPv4) and struct in6_addr (IPv6),
- * so an IPv6 address whose first 4 bytes are zero (e.g. ::1, ::2,
- * IPv4-mapped ::ffff:a.b.c.d) must not be tested via the IPv4 arm 
- * doing so would misclassify a caller-supplied address as unset and
- * silently overwrite it with whatever address the device exposes.
- */
-bool netpoll_local_ip_unset(const struct netpoll *np)
-{
-	if (np->ipv6)
-		return ipv6_addr_any(&np->local_ip.in6);
-	return !np->local_ip.ip;
-}
-EXPORT_SYMBOL_GPL(netpoll_local_ip_unset);
-
 static void rcu_cleanup_netpoll_info(struct rcu_head *rcu_head)
 {
 	struct netpoll_info *npinfo =
-- 
2.53.0-Meta
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help