2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* sysctl_net_ipv6.c: sysctl interface to net IPV6 subsystem.
|
|
|
|
*
|
|
|
|
* Changes:
|
|
|
|
* YOSHIFUJI Hideaki @USAGI: added icmp sysctl table.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/sysctl.h>
|
|
|
|
#include <linux/in6.h>
|
|
|
|
#include <linux/ipv6.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2011-07-15 23:47:34 +08:00
|
|
|
#include <linux/export.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <net/ndisc.h>
|
|
|
|
#include <net/ipv6.h>
|
|
|
|
#include <net/addrconf.h>
|
2007-10-15 17:33:45 +08:00
|
|
|
#include <net/inet_frag.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2014-09-02 21:49:25 +08:00
|
|
|
static int one = 1;
|
|
|
|
|
2013-06-12 14:04:25 +08:00
|
|
|
static struct ctl_table ipv6_table_template[] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.procname = "bindv6only",
|
2008-01-10 18:54:53 +08:00
|
|
|
.data = &init_net.ipv6.sysctl.bindv6only,
|
2005-04-17 06:20:36 +08:00
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
2008-11-04 10:21:05 +08:00
|
|
|
.proc_handler = proc_dointvec
|
2005-04-17 06:20:36 +08:00
|
|
|
},
|
2014-01-07 21:57:27 +08:00
|
|
|
{
|
|
|
|
.procname = "anycast_src_echo_reply",
|
2014-01-13 22:59:01 +08:00
|
|
|
.data = &init_net.ipv6.sysctl.anycast_src_echo_reply,
|
2014-01-07 21:57:27 +08:00
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
2014-01-18 00:15:05 +08:00
|
|
|
{
|
|
|
|
.procname = "flowlabel_consistency",
|
|
|
|
.data = &init_net.ipv6.sysctl.flowlabel_consistency,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
2014-07-02 12:33:10 +08:00
|
|
|
{
|
|
|
|
.procname = "auto_flowlabels",
|
|
|
|
.data = &init_net.ipv6.sysctl.auto_flowlabels,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
2014-05-14 01:17:33 +08:00
|
|
|
{
|
|
|
|
.procname = "fwmark_reflect",
|
|
|
|
.data = &init_net.ipv6.sysctl.fwmark_reflect,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
2015-03-24 06:36:05 +08:00
|
|
|
{
|
|
|
|
.procname = "idgen_retries",
|
|
|
|
.data = &init_net.ipv6.sysctl.idgen_retries,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "idgen_delay",
|
|
|
|
.data = &init_net.ipv6.sysctl.idgen_delay,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec_jiffies,
|
|
|
|
},
|
ipv6: Flow label state ranges
This patch divides the IPv6 flow label space into two ranges:
0-7ffff is reserved for flow label manager, 80000-fffff will be
used for creating auto flow labels (per RFC6438). This only affects how
labels are set on transmit, it does not affect receive. This range split
can be disbaled by systcl.
Background:
IPv6 flow labels have been an unmitigated disappointment thus far
in the lifetime of IPv6. Support in HW devices to use them for ECMP
is lacking, and OSes don't turn them on by default. If we had these
we could get much better hashing in IPv6 networks without resorting
to DPI, possibly eliminating some of the motivations to to define new
encaps in UDP just for getting ECMP.
Unfortunately, the initial specfications of IPv6 did not clarify
how they are to be used. There has always been a vague concept that
these can be used for ECMP, flow hashing, etc. and we do now have a
good standard how to this in RFC6438. The problem is that flow labels
can be either stateful or stateless (as in RFC6438), and we are
presented with the possibility that a stateless label may collide
with a stateful one. Attempts to split the flow label space were
rejected in IETF. When we added support in Linux for RFC6438, we
could not turn on flow labels by default due to this conflict.
This patch splits the flow label space and should give us
a path to enabling auto flow labels by default for all IPv6 packets.
This is an API change so we need to consider compatibility with
existing deployment. The stateful range is chosen to be the lower
values in hopes that most uses would have chosen small numbers.
Once we resolve the stateless/stateful issue, we can proceed to
look at enabling RFC6438 flow labels by default (starting with
scaled testing).
Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-04-30 06:33:21 +08:00
|
|
|
{
|
|
|
|
.procname = "flowlabel_state_ranges",
|
|
|
|
.data = &init_net.ipv6.sysctl.flowlabel_state_ranges,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
2009-11-06 05:32:03 +08:00
|
|
|
{ }
|
2008-05-20 04:53:30 +08:00
|
|
|
};
|
|
|
|
|
2013-06-12 14:04:25 +08:00
|
|
|
static struct ctl_table ipv6_rotable[] = {
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
.procname = "mld_max_msf",
|
|
|
|
.data = &sysctl_mld_max_msf,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
2008-11-04 10:21:05 +08:00
|
|
|
.proc_handler = proc_dointvec
|
2005-04-17 06:20:36 +08:00
|
|
|
},
|
2014-09-02 21:49:25 +08:00
|
|
|
{
|
|
|
|
.procname = "mld_qrv",
|
|
|
|
.data = &sysctl_mld_qrv,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec_minmax,
|
|
|
|
.extra1 = &one
|
|
|
|
},
|
2009-11-06 05:32:03 +08:00
|
|
|
{ }
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2010-01-17 11:35:32 +08:00
|
|
|
static int __net_init ipv6_sysctl_net_init(struct net *net)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-01-10 18:53:43 +08:00
|
|
|
struct ctl_table *ipv6_table;
|
|
|
|
struct ctl_table *ipv6_route_table;
|
|
|
|
struct ctl_table *ipv6_icmp_table;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = -ENOMEM;
|
|
|
|
ipv6_table = kmemdup(ipv6_table_template, sizeof(ipv6_table_template),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!ipv6_table)
|
|
|
|
goto out;
|
2012-04-19 21:37:09 +08:00
|
|
|
ipv6_table[0].data = &net->ipv6.sysctl.bindv6only;
|
2014-01-13 22:59:01 +08:00
|
|
|
ipv6_table[1].data = &net->ipv6.sysctl.anycast_src_echo_reply;
|
2014-01-18 00:15:05 +08:00
|
|
|
ipv6_table[2].data = &net->ipv6.sysctl.flowlabel_consistency;
|
2014-07-02 12:33:10 +08:00
|
|
|
ipv6_table[3].data = &net->ipv6.sysctl.auto_flowlabels;
|
2014-08-06 09:46:26 +08:00
|
|
|
ipv6_table[4].data = &net->ipv6.sysctl.fwmark_reflect;
|
2015-03-24 06:36:05 +08:00
|
|
|
ipv6_table[5].data = &net->ipv6.sysctl.idgen_retries;
|
|
|
|
ipv6_table[6].data = &net->ipv6.sysctl.idgen_delay;
|
ipv6: Flow label state ranges
This patch divides the IPv6 flow label space into two ranges:
0-7ffff is reserved for flow label manager, 80000-fffff will be
used for creating auto flow labels (per RFC6438). This only affects how
labels are set on transmit, it does not affect receive. This range split
can be disbaled by systcl.
Background:
IPv6 flow labels have been an unmitigated disappointment thus far
in the lifetime of IPv6. Support in HW devices to use them for ECMP
is lacking, and OSes don't turn them on by default. If we had these
we could get much better hashing in IPv6 networks without resorting
to DPI, possibly eliminating some of the motivations to to define new
encaps in UDP just for getting ECMP.
Unfortunately, the initial specfications of IPv6 did not clarify
how they are to be used. There has always been a vague concept that
these can be used for ECMP, flow hashing, etc. and we do now have a
good standard how to this in RFC6438. The problem is that flow labels
can be either stateful or stateless (as in RFC6438), and we are
presented with the possibility that a stateless label may collide
with a stateful one. Attempts to split the flow label space were
rejected in IETF. When we added support in Linux for RFC6438, we
could not turn on flow labels by default due to this conflict.
This patch splits the flow label space and should give us
a path to enabling auto flow labels by default for all IPv6 packets.
This is an API change so we need to consider compatibility with
existing deployment. The stateful range is chosen to be the lower
values in hopes that most uses would have chosen small numbers.
Once we resolve the stateless/stateful issue, we can proceed to
look at enabling RFC6438 flow labels by default (starting with
scaled testing).
Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-04-30 06:33:21 +08:00
|
|
|
ipv6_table[7].data = &net->ipv6.sysctl.flowlabel_state_ranges;
|
2008-01-10 18:53:43 +08:00
|
|
|
|
|
|
|
ipv6_route_table = ipv6_route_sysctl_init(net);
|
|
|
|
if (!ipv6_route_table)
|
|
|
|
goto out_ipv6_table;
|
|
|
|
|
|
|
|
ipv6_icmp_table = ipv6_icmp_sysctl_init(net);
|
|
|
|
if (!ipv6_icmp_table)
|
|
|
|
goto out_ipv6_route_table;
|
|
|
|
|
2012-04-19 21:37:09 +08:00
|
|
|
net->ipv6.sysctl.hdr = register_net_sysctl(net, "net/ipv6", ipv6_table);
|
|
|
|
if (!net->ipv6.sysctl.hdr)
|
2008-01-10 18:53:43 +08:00
|
|
|
goto out_ipv6_icmp_table;
|
|
|
|
|
2012-04-19 21:37:09 +08:00
|
|
|
net->ipv6.sysctl.route_hdr =
|
|
|
|
register_net_sysctl(net, "net/ipv6/route", ipv6_route_table);
|
|
|
|
if (!net->ipv6.sysctl.route_hdr)
|
|
|
|
goto out_unregister_ipv6_table;
|
|
|
|
|
|
|
|
net->ipv6.sysctl.icmp_hdr =
|
|
|
|
register_net_sysctl(net, "net/ipv6/icmp", ipv6_icmp_table);
|
|
|
|
if (!net->ipv6.sysctl.icmp_hdr)
|
|
|
|
goto out_unregister_route_table;
|
|
|
|
|
2008-01-10 18:53:43 +08:00
|
|
|
err = 0;
|
|
|
|
out:
|
|
|
|
return err;
|
2012-04-19 21:37:09 +08:00
|
|
|
out_unregister_route_table:
|
|
|
|
unregister_net_sysctl_table(net->ipv6.sysctl.route_hdr);
|
|
|
|
out_unregister_ipv6_table:
|
|
|
|
unregister_net_sysctl_table(net->ipv6.sysctl.hdr);
|
2008-01-10 18:53:43 +08:00
|
|
|
out_ipv6_icmp_table:
|
|
|
|
kfree(ipv6_icmp_table);
|
|
|
|
out_ipv6_route_table:
|
|
|
|
kfree(ipv6_route_table);
|
|
|
|
out_ipv6_table:
|
|
|
|
kfree(ipv6_table);
|
|
|
|
goto out;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2010-01-17 11:35:32 +08:00
|
|
|
static void __net_exit ipv6_sysctl_net_exit(struct net *net)
|
2008-01-10 18:49:34 +08:00
|
|
|
{
|
2008-01-10 18:53:43 +08:00
|
|
|
struct ctl_table *ipv6_table;
|
|
|
|
struct ctl_table *ipv6_route_table;
|
|
|
|
struct ctl_table *ipv6_icmp_table;
|
|
|
|
|
2012-04-19 21:37:09 +08:00
|
|
|
ipv6_table = net->ipv6.sysctl.hdr->ctl_table_arg;
|
|
|
|
ipv6_route_table = net->ipv6.sysctl.route_hdr->ctl_table_arg;
|
|
|
|
ipv6_icmp_table = net->ipv6.sysctl.icmp_hdr->ctl_table_arg;
|
2008-01-10 18:53:43 +08:00
|
|
|
|
2012-04-19 21:37:09 +08:00
|
|
|
unregister_net_sysctl_table(net->ipv6.sysctl.icmp_hdr);
|
|
|
|
unregister_net_sysctl_table(net->ipv6.sysctl.route_hdr);
|
|
|
|
unregister_net_sysctl_table(net->ipv6.sysctl.hdr);
|
2008-01-10 18:53:43 +08:00
|
|
|
|
|
|
|
kfree(ipv6_table);
|
|
|
|
kfree(ipv6_route_table);
|
|
|
|
kfree(ipv6_icmp_table);
|
2008-01-10 18:49:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct pernet_operations ipv6_sysctl_net_ops = {
|
|
|
|
.init = ipv6_sysctl_net_init,
|
|
|
|
.exit = ipv6_sysctl_net_exit,
|
|
|
|
};
|
|
|
|
|
2008-05-20 04:53:30 +08:00
|
|
|
static struct ctl_table_header *ip6_header;
|
|
|
|
|
2008-01-10 18:49:34 +08:00
|
|
|
int ipv6_sysctl_register(void)
|
|
|
|
{
|
2009-01-08 10:09:08 +08:00
|
|
|
int err = -ENOMEM;
|
2008-05-20 04:53:30 +08:00
|
|
|
|
2012-04-19 21:22:55 +08:00
|
|
|
ip6_header = register_net_sysctl(&init_net, "net/ipv6", ipv6_rotable);
|
2015-03-29 21:00:04 +08:00
|
|
|
if (!ip6_header)
|
2008-05-20 04:53:30 +08:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
err = register_pernet_subsys(&ipv6_sysctl_net_ops);
|
|
|
|
if (err)
|
|
|
|
goto err_pernet;
|
|
|
|
out:
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err_pernet:
|
|
|
|
unregister_net_sysctl_table(ip6_header);
|
|
|
|
goto out;
|
2008-01-10 18:49:34 +08:00
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
void ipv6_sysctl_unregister(void)
|
|
|
|
{
|
2008-05-20 04:53:30 +08:00
|
|
|
unregister_net_sysctl_table(ip6_header);
|
2008-01-10 18:49:34 +08:00
|
|
|
unregister_pernet_subsys(&ipv6_sysctl_net_ops);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|