diff options
| author | Gustavo Luiz Duarte <gustavold@gmail.com> | 2026-09-03 17:26:04 +0100 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-09-09 18:09:52 -0700 |
| commit | 56ddc8d48e75f48df938f5df80e2f99a0c3548d3 (patch) | |
| tree | 45d86b229445a9fc1436938901bf9cded6472362 | |
| parent | 32535a1ea962e9123506463ac3e0d1473d492059 (diff) | |
| download | linux-next-56ddc8d48e75f48df938f5df80e2f99a0c3548d3.tar.gz linux-next-56ddc8d48e75f48df938f5df80e2f99a0c3548d3.zip | |
netconsole: show empty string for an unset IP address
An unset address (local_ip/remote_ip), now denoted by AF_UNSPEC,
currently shows "0.0.0.0" in configfs. Print an empty string instead,
which is more clear.
In netconsole_print_banner() we can be even more explicit about it, as
we don't have the risk of userspace trying to parse it.
Reviewed-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Gustavo Luiz Duarte <gustavold@gmail.com>
Link: https://patch.msgid.link/20260903-netcons_ipv6-v4-5-bdd183c844d3@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| -rw-r--r-- | drivers/net/netconsole.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index abcc8515ddd2..1f18d0a7d2dd 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -718,14 +718,18 @@ static void netconsole_print_banner(struct netconsole_target *nt) struct netpoll *np = &nt->np; np_info(np, "local port %d\n", nt->local_port); - if (nt->local_ip.family == AF_INET6) + if (nt->local_ip.family == AF_UNSPEC) + np_info(np, "local IP unset\n"); + else if (nt->local_ip.family == AF_INET6) np_info(np, "local IPv6 address %pI6c\n", &nt->local_ip.in6); else np_info(np, "local IPv4 address %pI4\n", &nt->local_ip.ip); np_info(np, "interface name '%s'\n", np->dev_name); np_info(np, "local ethernet address '%pM'\n", np->dev_mac); np_info(np, "remote port %d\n", nt->remote_port); - if (nt->remote_ip.family == AF_INET6) + if (nt->remote_ip.family == AF_UNSPEC) + np_info(np, "remote IP unset\n"); + else if (nt->remote_ip.family == AF_INET6) np_info(np, "remote IPv6 address %pI6c\n", &nt->remote_ip.in6); else np_info(np, "remote IPv4 address %pI4\n", &nt->remote_ip.ip); @@ -863,6 +867,8 @@ static ssize_t local_ip_show(struct config_item *item, char *buf) { struct netconsole_target *nt = to_target(item); + if (nt->local_ip.family == AF_UNSPEC) + return sysfs_emit(buf, "\n"); if (nt->local_ip.family == AF_INET6) return sysfs_emit(buf, "%pI6c\n", &nt->local_ip.in6); else @@ -873,6 +879,8 @@ static ssize_t remote_ip_show(struct config_item *item, char *buf) { struct netconsole_target *nt = to_target(item); + if (nt->remote_ip.family == AF_UNSPEC) + return sysfs_emit(buf, "\n"); if (nt->remote_ip.family == AF_INET6) return sysfs_emit(buf, "%pI6c\n", &nt->remote_ip.in6); else |
