[PATCH] net: ipv6: Fix IPv6 netmask parsing

Ramon Fried rfried.dev at gmail.com
Tue Jan 10 18:02:47 CET 2023


On Mon, Jan 9, 2023 at 9:59 AM Vyacheslav V. Mitrofanov
<v.v.mitrofanov at yadro.com> wrote:
>
> On Fri, 2023-01-06 at 14:22 -0800, seanedmond at linux.microsoft.com
> wrote:
> > From: Sean Edmond <seanedmond at microsoft.com>
> >
> > It should be possible to specify a netmask when
> > setting a static IPv6 address.  For example:
> > setenv ip6addr 2001:cafe:cafe:cafe::100/64
> >
> > The net_prefix_length and net_ip6 should be updated
> > properly.
> >
> > Signed-off-by: Sean Edmond <seanedmond at microsoft.com>
> > ---
> >  net/net6.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/net/net6.c b/net/net6.c
> > index fdea078788..75577bcea1 100644
> > --- a/net/net6.c
> > +++ b/net/net6.c
> > @@ -47,10 +47,13 @@ static int on_ip6addr(const char *name, const
> > char *value, enum env_op op,
> >         }
> >
> >         mask = strchr(value, '/');
> > -       len = strlen(value);
> >
> > -       if (mask)
> > -               net_prefix_length = simple_strtoul(value + len, NULL,
> > 10);
> > +       if (mask) {
> > +               net_prefix_length = simple_strtoul(mask + 1, NULL,
> > 10);
> > +               len = mask - value;
> > +       } else {
> > +               len = strlen(value);
> > +       }
> >
> >         return string_to_ip6(value, len, &net_ip6);
> >  }
> > --
> > 2.39.0
> I do agree with your changes.Thanks
>
> Reviewed-by: Viacheslav Mitrofanov <v.v.mitrofanov at yadro.com>
Reviewed-by: Ramon Fried <rfried.dev at gmail.com>


More information about the U-Boot mailing list