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

Gustavo Luiz Duarte <[email protected]>
Newsgroups gmane.linux.network,gmane.linux.kernel
Message-ID <CAGSyskWqbUd9c9uFsdr4=L-O56cq6qctHVsXiVbS=xzVWBHHHA@mail.gmail.com>
On Thu, Aug 6, 2026 at 4:49 PM Breno Leitao <[email protected]> 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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.