This commit adds a new sysctl accept_ra_rt_info_min_plen that defines the minimum acceptable prefix length of Route Information Options. The new sysctl is intended to be used together with accept_ra_rt_info_max_plen to configure a range of acceptable prefix lengths. It is useful to prevent misconfigurations from unintentionally blackholing too much of the IPv6 address space (e.g., home routers announcing RIOs for fc00::/7, which is incorrect).
Unified · Split
| @@ -1461,11 +1461,20 @@ accept_ra_pinfo - BOOLEAN · 1460 unmodified lines | ||
| 1461 | 1461 | Functional default: enabled if accept_ra is enabled. |
| 1462 | 1462 | disabled if accept_ra is disabled. |
| 1463 | 1463 | |
| 1464 | +accept_ra_rt_info_min_plen - INTEGER | |
| 1465 | + Minimum prefix length of Route Information in RA. | |
| 1466 | + | |
| 1467 | + Route Information w/ prefix smaller than this variable shall | |
| 1468 | + be ignored. | |
| 1469 | + | |
| 1470 | + Functional default: 0 if accept_ra_rtr_pref is enabled. | |
| 1471 | + -1 if accept_ra_rtr_pref is disabled. | |
| 1472 | + | |
| 1464 | 1473 | accept_ra_rt_info_max_plen - INTEGER |
| 1465 | 1474 | Maximum prefix length of Route Information in RA. |
| 1466 | 1475 | |
| 1467 | − Route Information w/ prefix larger than or equal to this | |
| 1468 | − variable shall be ignored. | |
| 1476 | + Route Information w/ prefix larger than this variable shall | |
| 1477 | + be ignored. | |
| 1469 | 1478 | |
| 1470 | 1479 | Functional default: 0 if accept_ra_rtr_pref is enabled. |
| 1471 | 1480 | -1 if accept_ra_rtr_pref is disabled. |
| @@ -37,6 +37,7 @@ struct ipv6_devconf { · 36 unmodified lines | ||
| 37 | 37 | __s32 accept_ra_rtr_pref; |
| 38 | 38 | __s32 rtr_probe_interval; |
| 39 | 39 | #ifdef CONFIG_IPV6_ROUTE_INFO |
| 40 | + __s32 accept_ra_rt_info_min_plen; | |
| 40 | 41 | __s32 accept_ra_rt_info_max_plen; |
| 41 | 42 | #endif |
| 42 | 43 | #endif |
| @@ -184,6 +184,7 @@ enum { · 183 unmodified lines | ||
| 184 | 184 | DEVCONF_ENHANCED_DAD, |
| 185 | 185 | DEVCONF_ADDR_GEN_MODE, |
| 186 | 186 | DEVCONF_DISABLE_POLICY, |
| 187 | + DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN, | |
| 187 | 188 | DEVCONF_MAX |
| 188 | 189 | }; |
| 189 | 190 | |
| @@ -568,6 +568,7 @@ enum { · 567 unmodified lines | ||
| 568 | 568 | NET_IPV6_PROXY_NDP=23, |
| 569 | 569 | NET_IPV6_ACCEPT_SOURCE_ROUTE=25, |
| 570 | 570 | NET_IPV6_ACCEPT_RA_FROM_LOCAL=26, |
| 571 | + NET_IPV6_ACCEPT_RA_RT_INFO_MIN_PLEN=27, | |
| 571 | 572 | __NET_IPV6_MAX |
| 572 | 573 | }; |
| 573 | 574 | |
| @@ -224,6 +224,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = { · 223 unmodified lines | ||
| 224 | 224 | .accept_ra_rtr_pref = 1, |
| 225 | 225 | .rtr_probe_interval = 60 * HZ, |
| 226 | 226 | #ifdef CONFIG_IPV6_ROUTE_INFO |
| 227 | + .accept_ra_rt_info_min_plen = 0, | |
| 227 | 228 | .accept_ra_rt_info_max_plen = 0, |
| 228 | 229 | #endif |
| 229 | 230 | #endif |
| @@ -277,6 +278,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = { · 47 unmodified lines | ||
| 277 | 278 | .accept_ra_rtr_pref = 1, |
| 278 | 279 | .rtr_probe_interval = 60 * HZ, |
| 279 | 280 | #ifdef CONFIG_IPV6_ROUTE_INFO |
| 281 | + .accept_ra_rt_info_min_plen = 0, | |
| 280 | 282 | .accept_ra_rt_info_max_plen = 0, |
| 281 | 283 | #endif |
| 282 | 284 | #endif |
| @@ -4979,6 +4981,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, · 4696 unmodified lines | ||
| 4979 | 4981 | array[DEVCONF_RTR_PROBE_INTERVAL] = |
| 4980 | 4982 | jiffies_to_msecs(cnf->rtr_probe_interval); |
| 4981 | 4983 | #ifdef CONFIG_IPV6_ROUTE_INFO |
| 4984 | + array[DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN] = cnf->accept_ra_rt_info_min_plen; | |
| 4982 | 4985 | array[DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN] = cnf->accept_ra_rt_info_max_plen; |
| 4983 | 4986 | #endif |
| 4984 | 4987 | #endif |
| @@ -6121,6 +6124,13 @@ static const struct ctl_table addrconf_sysctl[] = { · 1136 unmodified lines | ||
| 6121 | 6124 | .proc_handler = proc_dointvec_jiffies, |
| 6122 | 6125 | }, |
| 6123 | 6126 | #ifdef CONFIG_IPV6_ROUTE_INFO |
| 6127 | + { | |
| 6128 | + .procname = "accept_ra_rt_info_min_plen", | |
| 6129 | + .data = &ipv6_devconf.accept_ra_rt_info_min_plen, | |
| 6130 | + .maxlen = sizeof(int), | |
| 6131 | + .mode = 0644, | |
| 6132 | + .proc_handler = proc_dointvec, | |
| 6133 | + }, | |
| 6124 | 6134 | { |
| 6125 | 6135 | .procname = "accept_ra_rt_info_max_plen", |
| 6126 | 6136 | .data = &ipv6_devconf.accept_ra_rt_info_max_plen, |
| @@ -1418,6 +1418,8 @@ skip_linkparms: · 1417 unmodified lines | ||
| 1418 | 1418 | if (ri->prefix_len == 0 && |
| 1419 | 1419 | !in6_dev->cnf.accept_ra_defrtr) |
| 1420 | 1420 | continue; |
| 1421 | + if (ri->prefix_len < in6_dev->cnf.accept_ra_rt_info_min_plen) | |
| 1422 | + continue; | |
| 1421 | 1423 | if (ri->prefix_len > in6_dev->cnf.accept_ra_rt_info_max_plen) |
| 1422 | 1424 | continue; |
| 1423 | 1425 | rt6_route_rcv(skb->dev, (u8 *)p, (p->nd_opt_len) << 3, |