diff options
| author | Breno Leitao <leitao@debian.org> | 2025-08-11 11:13:25 -0700 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2025-08-12 17:32:42 -0700 |
| commit | fa38524ca5a783aa0cfc8ffa5730c5012edfccf4 (patch) | |
| tree | 5e1f5186feb7f3451fc9844216781a729c111a7a | |
| parent | net: mdio: mdio-bcm-unimac: Refine incorrect clock message (diff) | |
| download | linux-fa38524ca5a783aa0cfc8ffa5730c5012edfccf4.tar.gz linux-fa38524ca5a783aa0cfc8ffa5730c5012edfccf4.zip | |
netconsole: move netpoll_parse_ip_addr() earlier for reuse
Move netpoll_parse_ip_addr() earlier in the file to be reused in
other functions, such as local_ip_store(). This avoids duplicate
address parsing logic and centralizes validation for both IPv4
and IPv6 string input.
No functional changes intended.
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250811-netconsole_ref-v4-1-9c510d8713a2@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| -rw-r--r-- | drivers/net/netconsole.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index e3722de08ea9..8d1b93264e0f 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -300,6 +300,26 @@ static void netconsole_print_banner(struct netpoll *np) np_info(np, "remote ethernet address %pM\n", np->remote_mac); } +static int netpoll_parse_ip_addr(const char *str, union inet_addr *addr) +{ + const char *end; + + if (!strchr(str, ':') && + in4_pton(str, -1, (void *)addr, -1, &end) > 0) { + if (!*end) + return 0; + } + if (in6_pton(str, -1, addr->in6.s6_addr, -1, &end) > 0) { +#if IS_ENABLED(CONFIG_IPV6) + if (!*end) + return 1; +#else + return -1; +#endif + } + return -1; +} + #ifdef CONFIG_NETCONSOLE_DYNAMIC /* @@ -1742,26 +1762,6 @@ static void write_msg(struct console *con, const char *msg, unsigned int len) spin_unlock_irqrestore(&target_list_lock, flags); } -static int netpoll_parse_ip_addr(const char *str, union inet_addr *addr) -{ - const char *end; - - if (!strchr(str, ':') && - in4_pton(str, -1, (void *)addr, -1, &end) > 0) { - if (!*end) - return 0; - } - if (in6_pton(str, -1, addr->in6.s6_addr, -1, &end) > 0) { -#if IS_ENABLED(CONFIG_IPV6) - if (!*end) - return 1; -#else - return -1; -#endif - } - return -1; -} - static int netconsole_parser_cmdline(struct netpoll *np, char *opt) { bool ipversion_set = false; |
