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 <[email protected]> Cc: Lorenzo Colitti <[email protected]> Cc: Patrick Rohr <[email protected]> Cc: David Ahern <[email protected]> Cc: YOSHIFUJI Hideaki / 吉藤英明 <[email protected]> Cc: Jakub Kicinski <[email protected]> Signed-off-by: Maciej Żenczykowski <[email protected]> Fixes: 048c796 ("ipv6: adjust ndisc_is_useropt() to also return true for PIO") Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent b9e7fc0 commit a46c68d

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

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)