Commit a46c68de authored by Maciej Żenczykowski's avatar Maciej Żenczykowski Committed by Paolo Abeni

ipv6: fix ndisc_is_useropt() handling for PIO

The current logic only works if the PIO is between two
other ND user options.  This fixes it so that the PIO
can also be either before or after other ND user options
(for example the first or last option in the RA).

side note: there's actually Android tests verifying
a portion of the old broken behaviour, so:
  https://android-review.googlesource.com/c/kernel/tests/+/3196704
fixes those up.

Cc: Jen Linkova <furry@google.com>
Cc: Lorenzo Colitti <lorenzo@google.com>
Cc: Patrick Rohr <prohr@google.com>
Cc: David Ahern <dsahern@kernel.org>
Cc: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>
Cc: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarMaciej Żenczykowski <maze@google.com>
Fixes: 048c796b ("ipv6: adjust ndisc_is_useropt() to also return true for PIO")
Link: https://patch.msgid.link/20240730001748.147636-1-maze@google.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent b9e7fc0a
......@@ -227,6 +227,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
return NULL;
memset(ndopts, 0, sizeof(*ndopts));
while (opt_len) {
bool unknown = false;
int l;
if (opt_len < sizeof(struct nd_opt_hdr))
return NULL;
......@@ -262,11 +263,13 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
break;
#endif
default:
unknown = true;
}
if (ndisc_is_useropt(dev, nd_opt)) {
ndopts->nd_useropts_end = nd_opt;
if (!ndopts->nd_useropts)
ndopts->nd_useropts = nd_opt;
} else {
} else if (unknown) {
/*
* Unknown options must be silently ignored,
* to accommodate future extension to the
......@@ -278,7 +281,6 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
nd_opt->nd_opt_type,
nd_opt->nd_opt_len);
}
}
next_opt:
opt_len -= l;
nd_opt = ((void *)nd_opt) + l;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment