netconsole: move egress_dev() as netcons_egress_dev()

move egress_dev() from netpoll to netconsole, and append 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-7-a5f7691db81c@debian.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Breno Leitao 2026-07-24 08:04:15 -07:00 committed by Paolo Abeni
parent 80fcfc3538
commit cf6de67ba4
3 changed files with 23 additions and 25 deletions

View File

@ -353,6 +353,22 @@ static void netconsole_skb_pool_flush(struct netconsole_target *nt)
skb_queue_purge_reason(&nt->skb_pool, SKB_CONSUMED);
}
/*
* Returns a pointer to a string representation of the identifier used
* to select the egress interface for the given netpoll instance. buf
* is used to format np->dev_mac when np->dev_name is empty; bufsz must
* be at least MAC_ADDR_STR_LEN + 1 to fit the formatted MAC address
* and its NUL terminator.
*/
static char *netcons_egress_dev(struct netpoll *np, char *buf, size_t bufsz)
{
if (np->dev_name[0])
return np->dev_name;
snprintf(buf, bufsz, "%pM", np->dev_mac);
return buf;
}
/*
* Take the IPv6 from ndev and populate local_ip structure in netpoll
*/
@ -364,7 +380,7 @@ static int netcons_take_ipv6(struct netpoll *np, struct net_device *ndev)
if (!IS_ENABLED(CONFIG_IPV6)) {
np_err(np, "IPv6 is not supported %s, aborting\n",
egress_dev(np, buf, sizeof(buf)));
netcons_egress_dev(np, buf, sizeof(buf)));
return -EINVAL;
}
@ -386,7 +402,7 @@ static int netcons_take_ipv6(struct netpoll *np, struct net_device *ndev)
}
if (err) {
np_err(np, "no IPv6 address for %s, aborting\n",
egress_dev(np, buf, sizeof(buf)));
netcons_egress_dev(np, buf, sizeof(buf)));
return err;
}
@ -406,14 +422,14 @@ static int netcons_take_ipv4(struct netpoll *np, struct net_device *ndev)
in_dev = __in_dev_get_rtnl(ndev);
if (!in_dev) {
np_err(np, "no IP address for %s, aborting\n",
egress_dev(np, buf, sizeof(buf)));
netcons_egress_dev(np, buf, sizeof(buf)));
return -EDESTADDRREQ;
}
ifa = rtnl_dereference(in_dev->ifa_list);
if (!ifa) {
np_err(np, "no IP address for %s, aborting\n",
egress_dev(np, buf, sizeof(buf)));
netcons_egress_dev(np, buf, sizeof(buf)));
return -EDESTADDRREQ;
}
@ -456,7 +472,7 @@ static int netcons_netpoll_setup(struct netpoll *np)
if (!ndev) {
np_err(np, "%s doesn't exist, aborting\n",
egress_dev(np, buf, sizeof(buf)));
netcons_egress_dev(np, buf, sizeof(buf)));
err = -ENODEV;
goto unlock;
}
@ -464,14 +480,14 @@ static int netcons_netpoll_setup(struct netpoll *np)
if (netdev_master_upper_dev_get(ndev)) {
np_err(np, "%s is a slave device, aborting\n",
egress_dev(np, buf, sizeof(buf)));
netcons_egress_dev(np, buf, sizeof(buf)));
err = -EBUSY;
goto put;
}
if (!netif_running(ndev)) {
np_info(np, "device %s not up yet, forcing it\n",
egress_dev(np, buf, sizeof(buf)));
netcons_egress_dev(np, buf, sizeof(buf)));
err = dev_open(ndev, NULL);
if (err) {

View File

@ -73,7 +73,6 @@ netdev_tx_t netpoll_send_skb(struct netpoll *np, struct sk_buff *skb);
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);
#ifdef CONFIG_NETPOLL
static inline void *netpoll_poll_lock(struct napi_struct *napi)

View File

@ -392,23 +392,6 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
}
EXPORT_SYMBOL_GPL(__netpoll_setup);
/*
* Returns a pointer to a string representation of the identifier used
* to select the egress interface for the given netpoll instance. buf
* is used to format np->dev_mac when np->dev_name is empty; bufsz must
* be at least MAC_ADDR_STR_LEN + 1 to fit the formatted MAC address
* and its NUL terminator.
*/
char *egress_dev(struct netpoll *np, char *buf, size_t bufsz)
{
if (np->dev_name[0])
return np->dev_name;
snprintf(buf, bufsz, "%pM", np->dev_mac);
return buf;
}
EXPORT_SYMBOL_GPL(egress_dev);
void netpoll_wait_carrier(struct netpoll *np, struct net_device *ndev)
{
unsigned long atmost;