Re: [PATCH net-next 1/4] netconsole: add an address family to struct inet_addr

From: Gustavo Luiz Duarte

Date: Fri Aug 07 2026 - 07:22:02 EST


On Thu, Aug 6, 2026 at 4:49 PM Breno Leitao <leitao@xxxxxxxxxx> wrote:
>
> On Wed, Aug 05, 2026 at 10:33:01PM +0100, Gustavo Luiz Duarte wrote:
> > @@ -731,7 +733,7 @@ static void netconsole_print_banner(struct netconsole_target *nt)
> > /* Parse the string and populate the `inet_addr` union. Return 0 if IPv4 is
> ^-> there is no more union.
>
> I think there are other references for union that needs to be updated as
> well.

I fixed this in the next patch, but let me do it here for consistency.
I didn't find any other reference to union.

>
> > +static int netpoll_parse_ip_addr(const char *str, struct inet_addr *addr)
> ...
> > return -1;
>
> Should the failure path set addr->family = AF_UNSPEC?

The failure path leaves addr untouched, so if the user writes an invalid value
to local_ip or remote_ip the write fails and the original value is maintained.

>
> > +++ b/include/linux/netpoll.h
> > +struct inet_addr {
> > + /* Address family: AF_UNSPEC when unset, else AF_INET or AF_INET6 */
> > + u8 family;
> > + union {
> > + __be32 ip;
> > + struct in6_addr in6;
> > + };
> > };
>
> Since a1116396476f6 ("netconsole: move local_ip/remote_ip/ipv6 to
> netconsole_target") struct netpoll has no address member, and netconsole
> is the only user left in the tree:
>
> drivers/net/netconsole.c: union inet_addr local_ip, remote_ip;
> drivers/net/netconsole.c:static int netpoll_parse_ip_addr(const char *str, union inet_addr *addr)
>
> Since you touched it, can you move it to netconsole headers, please?

Sure, will do it in v2.