Skip to content

Commit a46c68d

Browse files
zenczykowskiPaolo Abeni
authored andcommitted
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: Maciej Żenczykowski <maze@google.com> Fixes: 048c796 ("ipv6: adjust ndisc_is_useropt() to also return true for PIO") Link: https://patch.msgid.link/20240730001748.147636-1-maze@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent b9e7fc0 commit a46c68d

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

net/ipv6/ndisc.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
227227
return NULL;
228228
memset(ndopts, 0, sizeof(*ndopts));
229229
while (opt_len) {
230+
bool unknown = false;
230231
int l;
231232
if (opt_len < sizeof(struct nd_opt_hdr))
232233
return NULL;
@@ -262,22 +263,23 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
262263
break;
263264
#endif
264265
default:
265-
if (ndisc_is_useropt(dev, nd_opt)) {
266-
ndopts->nd_useropts_end = nd_opt;
267-
if (!ndopts->nd_useropts)
268-
ndopts->nd_useropts = nd_opt;
269-
} else {
270-
/*
271-
* Unknown options must be silently ignored,
272-
* to accommodate future extension to the
273-
* protocol.
274-
*/
275-
ND_PRINTK(2, notice,
276-
"%s: ignored unsupported option; type=%d, len=%d\n",
277-
__func__,
278-
nd_opt->nd_opt_type,
279-
nd_opt->nd_opt_len);
280-
}
266+
unknown = true;
267+
}
268+
if (ndisc_is_useropt(dev, nd_opt)) {
269+
ndopts->nd_useropts_end = nd_opt;
270+
if (!ndopts->nd_useropts)
271+
ndopts->nd_useropts = nd_opt;
272+
} else if (unknown) {
273+
/*
274+
* Unknown options must be silently ignored,
275+
* to accommodate future extension to the
276+
* protocol.
277+
*/
278+
ND_PRINTK(2, notice,
279+
"%s: ignored unsupported option; type=%d, len=%d\n",
280+
__func__,
281+
nd_opt->nd_opt_type,
282+
nd_opt->nd_opt_len);
281283
}
282284
next_opt:
283285
opt_len -= l;

0 commit comments

Comments
 (0)