netconsole: move netpoll_take_ipv6() as netcons_take_ipv6()

Move netpoll_take_ipv6() to netconsole, and add netcons_ prefix.

Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Gustavo Luiz Duarte <gustavold@gmail.com>
Link: https://patch.msgid.link/20260724-netconsole_move_more_final-v1-6-a5f7691db81c@debian.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Breno Leitao 2026-07-24 08:04:14 -07:00 committed by Paolo Abeni
parent 3aa9ff037b
commit 80fcfc3538
3 changed files with 43 additions and 44 deletions

View File

@ -40,6 +40,7 @@
#include <linux/inetdevice.h>
#include <linux/unaligned.h>
#include <net/ip6_checksum.h>
#include <net/addrconf.h>
#include <linux/configfs.h>
#include <linux/etherdevice.h>
#include <linux/hex.h>
@ -352,6 +353,47 @@ static void netconsole_skb_pool_flush(struct netconsole_target *nt)
skb_queue_purge_reason(&nt->skb_pool, SKB_CONSUMED);
}
/*
* Take the IPv6 from ndev and populate local_ip structure in netpoll
*/
static int netcons_take_ipv6(struct netpoll *np, struct net_device *ndev)
{
char buf[MAC_ADDR_STR_LEN + 1];
int err = -EDESTADDRREQ;
struct inet6_dev *idev;
if (!IS_ENABLED(CONFIG_IPV6)) {
np_err(np, "IPv6 is not supported %s, aborting\n",
egress_dev(np, buf, sizeof(buf)));
return -EINVAL;
}
idev = __in6_dev_get(ndev);
if (idev) {
struct inet6_ifaddr *ifp;
read_lock_bh(&idev->lock);
list_for_each_entry(ifp, &idev->addr_list, if_list) {
if (!!(ipv6_addr_type(&ifp->addr) & IPV6_ADDR_LINKLOCAL) !=
!!(ipv6_addr_type(&np->remote_ip.in6) & IPV6_ADDR_LINKLOCAL))
continue;
/* Got the IP, let's return */
np->local_ip.in6 = ifp->addr;
err = 0;
break;
}
read_unlock_bh(&idev->lock);
}
if (err) {
np_err(np, "no IPv6 address for %s, aborting\n",
egress_dev(np, buf, sizeof(buf)));
return err;
}
np_info(np, "local IPv6 %pI6c\n", &np->local_ip.in6);
return 0;
}
/*
* Take the IPv4 from ndev and populate local_ip structure in netpoll
*/
@ -448,7 +490,7 @@ static int netcons_netpoll_setup(struct netpoll *np)
if (err)
goto put;
} else {
err = netpoll_take_ipv6(np, ndev);
err = netcons_take_ipv6(np, ndev);
if (err)
goto put;
}

View File

@ -74,7 +74,6 @@ void netpoll_zap_completion_queue(void);
unsigned int netpoll_get_carrier_timeout(void);
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_ipv6(struct netpoll *np, struct net_device *ndev);
#ifdef CONFIG_NETPOLL
static inline void *netpoll_poll_lock(struct napi_struct *napi)

View File

@ -424,48 +424,6 @@ void netpoll_wait_carrier(struct netpoll *np, struct net_device *ndev)
}
EXPORT_SYMBOL_GPL(netpoll_wait_carrier);
/*
* Take the IPv6 from ndev and populate local_ip structure in netpoll
*/
int netpoll_take_ipv6(struct netpoll *np, struct net_device *ndev)
{
char buf[MAC_ADDR_STR_LEN + 1];
int err = -EDESTADDRREQ;
struct inet6_dev *idev;
if (!IS_ENABLED(CONFIG_IPV6)) {
np_err(np, "IPv6 is not supported %s, aborting\n",
egress_dev(np, buf, sizeof(buf)));
return -EINVAL;
}
idev = __in6_dev_get(ndev);
if (idev) {
struct inet6_ifaddr *ifp;
read_lock_bh(&idev->lock);
list_for_each_entry(ifp, &idev->addr_list, if_list) {
if (!!(ipv6_addr_type(&ifp->addr) & IPV6_ADDR_LINKLOCAL) !=
!!(ipv6_addr_type(&np->remote_ip.in6) & IPV6_ADDR_LINKLOCAL))
continue;
/* Got the IP, let's return */
np->local_ip.in6 = ifp->addr;
err = 0;
break;
}
read_unlock_bh(&idev->lock);
}
if (err) {
np_err(np, "no IPv6 address for %s, aborting\n",
egress_dev(np, buf, sizeof(buf)));
return err;
}
np_info(np, "local IPv6 %pI6c\n", &np->local_ip.in6);
return 0;
}
EXPORT_SYMBOL_GPL(netpoll_take_ipv6);
static void rcu_cleanup_netpoll_info(struct rcu_head *rcu_head)
{
struct netpoll_info *npinfo =