History

ipv6: sysctl to restrict candidate source addresses

Per RFC 6724, section 4, "Candidate Source Addresses": It is RECOMMENDED that the candidate source addresses be the set of unicast addresses assigned to the interface that will be used to send to the destination (the "outgoing" interface). Add a sysctl to enable this behaviour.

Erik Kline committed 11 years ago

Commit 3985e8a1 parent fb02eb44 files · +28 −3Browse files

Unified · Split

4 files
  1. Documentation/networking/ip-sysctl.txt +7 −0
  2. include/linux/ipv6.h +1 −0
  3. include/uapi/linux/ipv6.h +1 −0
  4. net/ipv6/addrconf.c +19 −3
Documentation/networking/ip-sysctl.txt+7−0
@@ -1460,6 +1460,13 @@ router_solicitations - INTEGER · 1459 unmodified lines
1460 routers are present.1460 routers are present.
1461 Default: 31461 Default: 3
1462 1462
1463use_oif_addrs_only - BOOLEAN
1464 When enabled, the candidate source addresses for destinations
1465 routed via this interface are restricted to the set of addresses
1466 configured on this interface (vis. RFC 6724, section 4).
1467
1468 Default: false
1469
1463use_tempaddr - INTEGER1470use_tempaddr - INTEGER
1464 Preference for Privacy Extensions (RFC3041).1471 Preference for Privacy Extensions (RFC3041).
1465 <= 0 : disable Privacy Extensions1472 <= 0 : disable Privacy Extensions
include/linux/ipv6.h+1−0
@@ -57,6 +57,7 @@ struct ipv6_devconf { · 56 unmodified lines
57 bool initialized;57 bool initialized;
58 struct in6_addr secret;58 struct in6_addr secret;
59 } stable_secret;59 } stable_secret;
60 __s32 use_oif_addrs_only;
60 void *sysctl;61 void *sysctl;
61};62};
62 63
include/uapi/linux/ipv6.h+1−0
@@ -171,6 +171,7 @@ enum { · 170 unmodified lines
171 DEVCONF_USE_OPTIMISTIC,171 DEVCONF_USE_OPTIMISTIC,
172 DEVCONF_ACCEPT_RA_MTU,172 DEVCONF_ACCEPT_RA_MTU,
173 DEVCONF_STABLE_SECRET,173 DEVCONF_STABLE_SECRET,
174 DEVCONF_USE_OIF_ADDRS_ONLY,
174 DEVCONF_MAX175 DEVCONF_MAX
175};176};
176 177
net/ipv6/addrconf.c+19−3
@@ -211,7 +211,8 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = { · 210 unmodified lines
211 .accept_ra_mtu = 1,211 .accept_ra_mtu = 1,
212 .stable_secret = {212 .stable_secret = {
213 .initialized = false,213 .initialized = false,
214 }214 },
215 .use_oif_addrs_only = 0,
215};216};
216 217
217static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {218static 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 .stable_secret = {254 .stable_secret = {
254 .initialized = false,255 .initialized = false,
255 },256 },
257 .use_oif_addrs_only = 0,
256};258};
257 259
258/* Check if a valid qdisc is available */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 * include addresses assigned to interfaces1474 * include addresses assigned to interfaces
1473 * belonging to the same site as the outgoing1475 * belonging to the same site as the outgoing
1474 * interface.)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 if (dst_dev) {1482 if (dst_dev) {
1483 idev = __in6_dev_get(dst_dev);
1477 if ((dst_type & IPV6_ADDR_MULTICAST) ||1484 if ((dst_type & IPV6_ADDR_MULTICAST) ||
1478 dst.scope <= IPV6_ADDR_SCOPE_LINKLOCAL) {1485 dst.scope <= IPV6_ADDR_SCOPE_LINKLOCAL ||
1479 idev = __in6_dev_get(dst_dev);1486 (idev && idev->cnf.use_oif_addrs_only)) {
1480 use_oif_addr = true;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 array[DEVCONF_ACCEPT_RA_FROM_LOCAL] = cnf->accept_ra_from_local;4614 array[DEVCONF_ACCEPT_RA_FROM_LOCAL] = cnf->accept_ra_from_local;
4608 array[DEVCONF_ACCEPT_RA_MTU] = cnf->accept_ra_mtu;4615 array[DEVCONF_ACCEPT_RA_MTU] = cnf->accept_ra_mtu;
4609 /* we omit DEVCONF_STABLE_SECRET for now */4616 /* we omit DEVCONF_STABLE_SECRET for now */
4617 array[DEVCONF_USE_OIF_ADDRS_ONLY] = cnf->use_oif_addrs_only;
4610}4618}
4611 4619
4612static inline size_t inet6_ifla6_size(void)4620static inline size_t inet6_ifla6_size(void)
@@ -5605,6 +5613,14 @@ static struct addrconf_sysctl_table · 992 unmodified lines
5605 .mode = 0600,5613 .mode = 0600,
5606 .proc_handler = addrconf_sysctl_stable_secret,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 /* sentinel */5625 /* sentinel */
5610 }5626 }