| @@ -211,7 +211,8 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = { · 210 unmodified lines |
| 211 | 211 | .accept_ra_mtu = 1, |
| 212 | 212 | .stable_secret = { |
| 213 | 213 | .initialized = false, |
| 214 | | − } |
| 214 | + }, |
| 215 | + .use_oif_addrs_only = 0, |
| 215 | 216 | }; |
| 216 | 217 | |
| 217 | 218 | static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = { |
| @@ -253,6 +254,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = { · 35 unmodified lines |
| 253 | 254 | .stable_secret = { |
| 254 | 255 | .initialized = false, |
| 255 | 256 | }, |
| 257 | + .use_oif_addrs_only = 0, |
| 256 | 258 | }; |
| 257 | 259 | |
| 258 | 260 | /* Check if a valid qdisc is available */ |
| @@ -1472,11 +1474,16 @@ int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev, · 1213 unmodified lines |
| 1472 | 1474 | * include addresses assigned to interfaces |
| 1473 | 1475 | * belonging to the same site as the outgoing |
| 1474 | 1476 | * interface.) |
| 1477 | + * - "It is RECOMMENDED that the candidate source addresses |
| 1478 | + * be the set of unicast addresses assigned to the |
| 1479 | + * interface that will be used to send to the destination |
| 1480 | + * (the 'outgoing' interface)." (RFC 6724) |
| 1475 | 1481 | */ |
| 1476 | 1482 | if (dst_dev) { |
| 1483 | + idev = __in6_dev_get(dst_dev); |
| 1477 | 1484 | if ((dst_type & IPV6_ADDR_MULTICAST) || |
| 1478 | | − dst.scope <= IPV6_ADDR_SCOPE_LINKLOCAL) { |
| 1479 | | − idev = __in6_dev_get(dst_dev); |
| 1485 | + dst.scope <= IPV6_ADDR_SCOPE_LINKLOCAL || |
| 1486 | + (idev && idev->cnf.use_oif_addrs_only)) { |
| 1480 | 1487 | use_oif_addr = true; |
| 1481 | 1488 | } |
| 1482 | 1489 | } |
| @@ -4607,6 +4614,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, · 3124 unmodified lines |
| 4607 | 4614 | array[DEVCONF_ACCEPT_RA_FROM_LOCAL] = cnf->accept_ra_from_local; |
| 4608 | 4615 | array[DEVCONF_ACCEPT_RA_MTU] = cnf->accept_ra_mtu; |
| 4609 | 4616 | /* we omit DEVCONF_STABLE_SECRET for now */ |
| 4617 | + array[DEVCONF_USE_OIF_ADDRS_ONLY] = cnf->use_oif_addrs_only; |
| 4610 | 4618 | } |
| 4611 | 4619 | |
| 4612 | 4620 | static inline size_t inet6_ifla6_size(void) |
| @@ -5605,6 +5613,14 @@ static struct addrconf_sysctl_table · 992 unmodified lines |
| 5605 | 5613 | .mode = 0600, |
| 5606 | 5614 | .proc_handler = addrconf_sysctl_stable_secret, |
| 5607 | 5615 | }, |
| 5616 | + { |
| 5617 | + .procname = "use_oif_addrs_only", |
| 5618 | + .data = &ipv6_devconf.use_oif_addrs_only, |
| 5619 | + .maxlen = sizeof(int), |
| 5620 | + .mode = 0644, |
| 5621 | + .proc_handler = proc_dointvec, |
| 5622 | + |
| 5623 | + }, |
| 5608 | 5624 | { |
| 5609 | 5625 | /* sentinel */ |
| 5610 | 5626 | } |