ipv6: Add net.ipv6.conf.*.accept_ra_defrtr_table sysctl.
Subsystems (5)
RFC PATCH 1/1 ipv6: Add net.ipv6.conf.*.accept_ra_defrtr_table sysctl.
Allows configuration of the routing table to which default routes from RAs are added on a per-interface basis.
One use case where this is required is a multi-homed router advertising multiple prefixes, one for each upstream. The proper routing policy is something like:
0: from all lookup local
10: from all lookup main
20: from <prefix1> lookup provider1
30: from <prefix2> lookup provider2
with directly connected and internal routes in main, and default routes from providers 1 and 2 in their respective tables. With static routes this is straightforward; if the route for either or both providers is received via RA this configuration option becomes necessary to put the routes in the appropriate tables.
---
Patch is against v3.5.2, but applies cleanly to master as of today.
Looking for feedback on:
* Is this a worthwhile feature? Did I miss a good way to do this in userspace?
* Is a sysctl the right place to configure it? I know it's discouraged to add new ones, but it seems to fit best with the other similar configuration options.
* Is the rt6_purge_dflt_routers behavior correct? Should addrconf_fixup_forwarding be modified so that in the single device case it only purges from that device's table?
Documentation/networking/ip-sysctl.txt | 6 +++++ include/linux/ipv6.h | 2 ++ include/linux/sysctl.h | 1 + kernel/sysctl_binary.c | 1 + net/ipv6/addrconf.c | 10 +++++++ net/ipv6/route.c | 45 ++++++++++++++++++++++---------- 6 files changed, 51 insertions(+), 14 deletions(-)
Documentation/networking/ip-sysctl.txt +6 -0
@@ -1085,6 +1085,12 @@ accept_ra_defrtr - BOOLEAN Functional default: enabled if accept_ra is enabled. disabled if accept_ra is disabled. +accept_ra_defrtr_table - INTEGER + Routing table into which to put default route learned via Router + Advertisement. + + Functional default: "main" routing table (254) + accept_ra_pinfo - BOOLEAN Learn Prefix Information in Router Advertisement.
include/linux/ipv6.h +2 -0
@@ -153,6 +153,7 @@ struct ipv6_devconf {#endif __s32 max_addresses;__s32 accept_ra_defrtr; +__s32 accept_ra_defrtr_table;__s32 accept_ra_pinfo;#ifdef CONFIG_IPV6_ROUTER_PREF __s32 accept_ra_rtr_pref;
@@ -202,6 +203,7 @@ enum {DEVCONF_MAX_ADDRESSES ,DEVCONF_FORCE_MLD_VERSION ,DEVCONF_ACCEPT_RA_DEFRTR , +DEVCONF_ACCEPT_RA_DEFRTR_TABLE ,DEVCONF_ACCEPT_RA_PINFO ,DEVCONF_ACCEPT_RA_RTR_PREF , DEVCONF_RTR_PROBE_INTERVAL,
include/linux/sysctl.h +1 -0
@@ -568,6 +568,7 @@ enum {NET_IPV6_ACCEPT_RA_RT_INFO_MAX_PLEN =22 ,NET_IPV6_PROXY_NDP =23 ,NET_IPV6_ACCEPT_SOURCE_ROUTE =25 , +NET_IPV6_ACCEPT_RA_DEFRTR_TABLE =26 , __NET_IPV6_MAX };
kernel/sysctl_binary.c +1 -0
@@ -517,6 +517,7 @@ static const struct bin_table bin_net_ipv6_conf_var_table[] = { { CTL_INT, NET_IPV6_MAX_ADDRESSES, "max_addresses" }, { CTL_INT, NET_IPV6_FORCE_MLD_VERSION, "force_mld_version" }, { CTL_INT, NET_IPV6_ACCEPT_RA_DEFRTR, "accept_ra_defrtr" }, + { CTL_INT, NET_IPV6_ACCEPT_RA_DEFRTR_TABLE, "accept_ra_defrtr_table" }, { CTL_INT, NET_IPV6_ACCEPT_RA_PINFO, "accept_ra_pinfo" }, { CTL_INT, NET_IPV6_ACCEPT_RA_RTR_PREF, "accept_ra_rtr_pref" }, { CTL_INT, NET_IPV6_RTR_PROBE_INTERVAL, "router_probe_interval" },
net/ipv6/addrconf.c +10 -0
@@ -188,6 +188,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {#endif .max_addresses = IPV6_MAX_ADDRESSES, .accept_ra_defrtr = 1, + .accept_ra_defrtr_table = RT6_TABLE_DFLT, .accept_ra_pinfo =1 , #ifdef CONFIG_IPV6_ROUTER_PREF .accept_ra_rtr_pref = 1,
@@ -222,6 +223,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {#endif .max_addresses = IPV6_MAX_ADDRESSES, .accept_ra_defrtr = 1, + .accept_ra_defrtr_table = RT6_TABLE_DFLT, .accept_ra_pinfo =1 , #ifdef CONFIG_IPV6_ROUTER_PREF .accept_ra_rtr_pref = 1,
@@ -3894,6 +3896,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,#endif array[DEVCONF_MAX_ADDRESSES ] = cnf->max_addresses; array[DEVCONF_ACCEPT_RA_DEFRTR ] = cnf->accept_ra_defrtr; + array[DEVCONF_ACCEPT_RA_DEFRTR_TABLE ] = cnf->accept_ra_defrtr_table; array[DEVCONF_ACCEPT_RA_PINFO ] = cnf->accept_ra_pinfo;#ifdef CONFIG_IPV6_ROUTER_PREF array[DEVCONF_ACCEPT_RA_RTR_PREF ] = cnf->accept_ra_rtr_pref;
@@ -4496,6 +4499,13 @@ static struct addrconf_sysctl_table .proc_handler = proc_dointvec, }, { + .procname = "accept_ra_defrtr_table", + .data = &ipv6_devconf.accept_ra_defrtr_table, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, + { .procname = "accept_ra_pinfo", .data = &ipv6_devconf.accept_ra_pinfo, .maxlen = sizeof(int),
net/ipv6/route.c +31 -14
76 lines not on this page · raw message
Signature · 1 line
1.7.9.5