License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 08:07:57 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-16 16:20:36 -06: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 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2011-07-15 09:47:34 -06:00
|
|
|
#include <linux/export.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <net/ndisc.h>
|
|
|
|
#include <net/ipv6.h>
|
|
|
|
#include <net/addrconf.h>
|
2007-10-15 03:33:45 -06:00
|
|
|
#include <net/inet_frag.h>
|
2018-03-02 09:32:18 -07:00
|
|
|
#include <net/netevent.h>
|
2016-06-27 13:06:17 -06:00
|
|
|
#ifdef CONFIG_NETLABEL
|
|
|
|
#include <net/calipso.h>
|
|
|
|
#endif
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2019-07-01 07:39:36 -06:00
|
|
|
static int flowlabel_reflect_max = 0x7;
|
2015-07-31 17:52:12 -06:00
|
|
|
static int auto_flowlabels_min;
|
|
|
|
static int auto_flowlabels_max = IP6_AUTO_FLOW_LABEL_MAX;
|
|
|
|
|
2018-03-02 09:32:18 -07:00
|
|
|
static int proc_rt6_multipath_hash_policy(struct ctl_table *table, int write,
|
|
|
|
void __user *buffer, size_t *lenp,
|
|
|
|
loff_t *ppos)
|
|
|
|
{
|
|
|
|
struct net *net;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
net = container_of(table->data, struct net,
|
|
|
|
ipv6.sysctl.multipath_hash_policy);
|
|
|
|
ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
|
|
|
|
if (write && ret == 0)
|
|
|
|
call_netevent_notifiers(NETEVENT_IPV6_MPATH_HASH_UPDATE, net);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2014-09-02 07:49:25 -06:00
|
|
|
|
2013-06-12 00:04:25 -06:00
|
|
|
static struct ctl_table ipv6_table_template[] = {
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
.procname = "bindv6only",
|
2008-01-10 03:54:53 -07:00
|
|
|
.data = &init_net.ipv6.sysctl.bindv6only,
|
2005-04-16 16:20:36 -06:00
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
2008-11-03 19:21:05 -07:00
|
|
|
.proc_handler = proc_dointvec
|
2005-04-16 16:20:36 -06:00
|
|
|
},
|
2014-01-07 06:57:27 -07:00
|
|
|
{
|
|
|
|
.procname = "anycast_src_echo_reply",
|
2014-01-13 07:59:01 -07:00
|
|
|
.data = &init_net.ipv6.sysctl.anycast_src_echo_reply,
|
2014-01-07 06:57:27 -07:00
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
2014-01-17 09:15:05 -07:00
|
|
|
{
|
|
|
|
.procname = "flowlabel_consistency",
|
|
|
|
.data = &init_net.ipv6.sysctl.flowlabel_consistency,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
2014-07-01 22:33:10 -06:00
|
|
|
{
|
|
|
|
.procname = "auto_flowlabels",
|
|
|
|
.data = &init_net.ipv6.sysctl.auto_flowlabels,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
2015-07-31 17:52:12 -06:00
|
|
|
.proc_handler = proc_dointvec_minmax,
|
|
|
|
.extra1 = &auto_flowlabels_min,
|
|
|
|
.extra2 = &auto_flowlabels_max
|
2014-07-01 22:33:10 -06:00
|
|
|
},
|
2014-05-13 11:17:33 -06:00
|
|
|
{
|
|
|
|
.procname = "fwmark_reflect",
|
|
|
|
.data = &init_net.ipv6.sysctl.fwmark_reflect,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
2015-03-23 16:36:05 -06: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-29 16:33:21 -06:00
|
|
|
{
|
|
|
|
.procname = "flowlabel_state_ranges",
|
|
|
|
.data = &init_net.ipv6.sysctl.flowlabel_state_ranges,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
2015-07-08 17:58:22 -06:00
|
|
|
{
|
|
|
|
.procname = "ip_nonlocal_bind",
|
|
|
|
.data = &init_net.ipv6.sysctl.ip_nonlocal_bind,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
2017-08-23 01:55:41 -06:00
|
|
|
{
|
|
|
|
.procname = "flowlabel_reflect",
|
|
|
|
.data = &init_net.ipv6.sysctl.flowlabel_reflect,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
2019-06-27 20:37:14 -06:00
|
|
|
.proc_handler = proc_dointvec_minmax,
|
proc/sysctl: add shared variables for range check
In the sysctl code the proc_dointvec_minmax() function is often used to
validate the user supplied value between an allowed range. This
function uses the extra1 and extra2 members from struct ctl_table as
minimum and maximum allowed value.
On sysctl handler declaration, in every source file there are some
readonly variables containing just an integer which address is assigned
to the extra1 and extra2 members, so the sysctl range is enforced.
The special values 0, 1 and INT_MAX are very often used as range
boundary, leading duplication of variables like zero=0, one=1,
int_max=INT_MAX in different source files:
$ git grep -E '\.extra[12].*&(zero|one|int_max)' |wc -l
248
Add a const int array containing the most commonly used values, some
macros to refer more easily to the correct array member, and use them
instead of creating a local one for every object file.
This is the bloat-o-meter output comparing the old and new binary
compiled with the default Fedora config:
# scripts/bloat-o-meter -d vmlinux.o.old vmlinux.o
add/remove: 2/2 grow/shrink: 0/2 up/down: 24/-188 (-164)
Data old new delta
sysctl_vals - 12 +12
__kstrtab_sysctl_vals - 12 +12
max 14 10 -4
int_max 16 - -16
one 68 - -68
zero 128 28 -100
Total: Before=20583249, After=20583085, chg -0.00%
[mcroce@redhat.com: tipc: remove two unused variables]
Link: http://lkml.kernel.org/r/20190530091952.4108-1-mcroce@redhat.com
[akpm@linux-foundation.org: fix net/ipv6/sysctl_net_ipv6.c]
[arnd@arndb.de: proc/sysctl: make firmware loader table conditional]
Link: http://lkml.kernel.org/r/20190617130014.1713870-1-arnd@arndb.de
[akpm@linux-foundation.org: fix fs/eventpoll.c]
Link: http://lkml.kernel.org/r/20190430180111.10688-1-mcroce@redhat.com
Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Aaron Tomlin <atomlin@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-18 16:58:50 -06:00
|
|
|
.extra1 = SYSCTL_ZERO,
|
2019-07-01 07:39:36 -06:00
|
|
|
.extra2 = &flowlabel_reflect_max,
|
2017-08-23 01:55:41 -06:00
|
|
|
},
|
2017-10-30 15:16:00 -06:00
|
|
|
{
|
|
|
|
.procname = "max_dst_opts_number",
|
|
|
|
.data = &init_net.ipv6.sysctl.max_dst_opts_cnt,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "max_hbh_opts_number",
|
|
|
|
.data = &init_net.ipv6.sysctl.max_hbh_opts_cnt,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "max_dst_opts_length",
|
|
|
|
.data = &init_net.ipv6.sysctl.max_dst_opts_len,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "max_hbh_length",
|
|
|
|
.data = &init_net.ipv6.sysctl.max_hbh_opts_len,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
2018-03-02 09:32:18 -07:00
|
|
|
{
|
|
|
|
.procname = "fib_multipath_hash_policy",
|
|
|
|
.data = &init_net.ipv6.sysctl.multipath_hash_policy,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_rt6_multipath_hash_policy,
|
proc/sysctl: add shared variables for range check
In the sysctl code the proc_dointvec_minmax() function is often used to
validate the user supplied value between an allowed range. This
function uses the extra1 and extra2 members from struct ctl_table as
minimum and maximum allowed value.
On sysctl handler declaration, in every source file there are some
readonly variables containing just an integer which address is assigned
to the extra1 and extra2 members, so the sysctl range is enforced.
The special values 0, 1 and INT_MAX are very often used as range
boundary, leading duplication of variables like zero=0, one=1,
int_max=INT_MAX in different source files:
$ git grep -E '\.extra[12].*&(zero|one|int_max)' |wc -l
248
Add a const int array containing the most commonly used values, some
macros to refer more easily to the correct array member, and use them
instead of creating a local one for every object file.
This is the bloat-o-meter output comparing the old and new binary
compiled with the default Fedora config:
# scripts/bloat-o-meter -d vmlinux.o.old vmlinux.o
add/remove: 2/2 grow/shrink: 0/2 up/down: 24/-188 (-164)
Data old new delta
sysctl_vals - 12 +12
__kstrtab_sysctl_vals - 12 +12
max 14 10 -4
int_max 16 - -16
one 68 - -68
zero 128 28 -100
Total: Before=20583249, After=20583085, chg -0.00%
[mcroce@redhat.com: tipc: remove two unused variables]
Link: http://lkml.kernel.org/r/20190530091952.4108-1-mcroce@redhat.com
[akpm@linux-foundation.org: fix net/ipv6/sysctl_net_ipv6.c]
[arnd@arndb.de: proc/sysctl: make firmware loader table conditional]
Link: http://lkml.kernel.org/r/20190617130014.1713870-1-arnd@arndb.de
[akpm@linux-foundation.org: fix fs/eventpoll.c]
Link: http://lkml.kernel.org/r/20190430180111.10688-1-mcroce@redhat.com
Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Aaron Tomlin <atomlin@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-18 16:58:50 -06:00
|
|
|
.extra1 = SYSCTL_ZERO,
|
|
|
|
.extra2 = SYSCTL_ONE,
|
2018-03-02 09:32:18 -07:00
|
|
|
},
|
ipv6: sr: Compute flowlabel for outer IPv6 header of seg6 encap mode
ECMP (equal-cost multipath) hashes are typically computed on the packets'
5-tuple(src IP, dst IP, src port, dst port, L4 proto).
For encapsulated packets, the L4 data is not readily available and ECMP
hashing will often revert to (src IP, dst IP). This will lead to traffic
polarization on a single ECMP path, causing congestion and waste of network
capacity.
In IPv6, the 20-bit flow label field is also used as part of the ECMP hash.
In the lack of L4 data, the hashing will be on (src IP, dst IP, flow
label). Having a non-zero flow label is thus important for proper traffic
load balancing when L4 data is unavailable (i.e., when packets are
encapsulated).
Currently, the seg6_do_srh_encap() function extracts the original packet's
flow label and set it as the outer IPv6 flow label. There are two issues
with this behaviour:
a) There is no guarantee that the inner flow label is set by the source.
b) If the original packet is not IPv6, the flow label will be set to
zero (e.g., IPv4 or L2 encap).
This patch adds a function, named seg6_make_flowlabel(), that computes a
flow label from a given skb. It supports IPv6, IPv4 and L2 payloads, and
leverages the per namespace 'seg6_flowlabel" sysctl value.
The currently support behaviours are as follows:
-1 set flowlabel to zero.
0 copy flowlabel from Inner paceket in case of Inner IPv6
(Set flowlabel to 0 in case IPv4/L2)
1 Compute the flowlabel using seg6_make_flowlabel()
This patch has been tested for IPv6, IPv4, and L2 traffic.
Signed-off-by: Ahmed Abdelsalam <amsalam20@gmail.com>
Acked-by: David Lebrun <dlebrun@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-04-24 12:23:16 -06:00
|
|
|
{
|
|
|
|
.procname = "seg6_flowlabel",
|
|
|
|
.data = &init_net.ipv6.sysctl.seg6_flowlabel,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec
|
|
|
|
},
|
2009-11-05 14:32:03 -07:00
|
|
|
{ }
|
2008-05-19 14:53:30 -06:00
|
|
|
};
|
|
|
|
|
2013-06-12 00:04:25 -06:00
|
|
|
static struct ctl_table ipv6_rotable[] = {
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
.procname = "mld_max_msf",
|
|
|
|
.data = &sysctl_mld_max_msf,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
2008-11-03 19:21:05 -07:00
|
|
|
.proc_handler = proc_dointvec
|
2005-04-16 16:20:36 -06:00
|
|
|
},
|
2014-09-02 07:49:25 -06:00
|
|
|
{
|
|
|
|
.procname = "mld_qrv",
|
|
|
|
.data = &sysctl_mld_qrv,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec_minmax,
|
proc/sysctl: add shared variables for range check
In the sysctl code the proc_dointvec_minmax() function is often used to
validate the user supplied value between an allowed range. This
function uses the extra1 and extra2 members from struct ctl_table as
minimum and maximum allowed value.
On sysctl handler declaration, in every source file there are some
readonly variables containing just an integer which address is assigned
to the extra1 and extra2 members, so the sysctl range is enforced.
The special values 0, 1 and INT_MAX are very often used as range
boundary, leading duplication of variables like zero=0, one=1,
int_max=INT_MAX in different source files:
$ git grep -E '\.extra[12].*&(zero|one|int_max)' |wc -l
248
Add a const int array containing the most commonly used values, some
macros to refer more easily to the correct array member, and use them
instead of creating a local one for every object file.
This is the bloat-o-meter output comparing the old and new binary
compiled with the default Fedora config:
# scripts/bloat-o-meter -d vmlinux.o.old vmlinux.o
add/remove: 2/2 grow/shrink: 0/2 up/down: 24/-188 (-164)
Data old new delta
sysctl_vals - 12 +12
__kstrtab_sysctl_vals - 12 +12
max 14 10 -4
int_max 16 - -16
one 68 - -68
zero 128 28 -100
Total: Before=20583249, After=20583085, chg -0.00%
[mcroce@redhat.com: tipc: remove two unused variables]
Link: http://lkml.kernel.org/r/20190530091952.4108-1-mcroce@redhat.com
[akpm@linux-foundation.org: fix net/ipv6/sysctl_net_ipv6.c]
[arnd@arndb.de: proc/sysctl: make firmware loader table conditional]
Link: http://lkml.kernel.org/r/20190617130014.1713870-1-arnd@arndb.de
[akpm@linux-foundation.org: fix fs/eventpoll.c]
Link: http://lkml.kernel.org/r/20190430180111.10688-1-mcroce@redhat.com
Signed-off-by: Matteo Croce <mcroce@redhat.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Aaron Tomlin <atomlin@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-07-18 16:58:50 -06:00
|
|
|
.extra1 = SYSCTL_ONE
|
2014-09-02 07:49:25 -06:00
|
|
|
},
|
2016-06-27 13:06:17 -06:00
|
|
|
#ifdef CONFIG_NETLABEL
|
|
|
|
{
|
|
|
|
.procname = "calipso_cache_enable",
|
|
|
|
.data = &calipso_cache_enabled,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.procname = "calipso_cache_bucket_size",
|
|
|
|
.data = &calipso_cache_bucketsize,
|
|
|
|
.maxlen = sizeof(int),
|
|
|
|
.mode = 0644,
|
|
|
|
.proc_handler = proc_dointvec,
|
|
|
|
},
|
|
|
|
#endif /* CONFIG_NETLABEL */
|
2009-11-05 14:32:03 -07:00
|
|
|
{ }
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
2010-01-16 20:35:32 -07:00
|
|
|
static int __net_init ipv6_sysctl_net_init(struct net *net)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-01-10 03:53:43 -07: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 07:37:09 -06:00
|
|
|
ipv6_table[0].data = &net->ipv6.sysctl.bindv6only;
|
2014-01-13 07:59:01 -07:00
|
|
|
ipv6_table[1].data = &net->ipv6.sysctl.anycast_src_echo_reply;
|
2014-01-17 09:15:05 -07:00
|
|
|
ipv6_table[2].data = &net->ipv6.sysctl.flowlabel_consistency;
|
2014-07-01 22:33:10 -06:00
|
|
|
ipv6_table[3].data = &net->ipv6.sysctl.auto_flowlabels;
|
2014-08-05 19:46:26 -06:00
|
|
|
ipv6_table[4].data = &net->ipv6.sysctl.fwmark_reflect;
|
2015-03-23 16:36:05 -06: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-29 16:33:21 -06:00
|
|
|
ipv6_table[7].data = &net->ipv6.sysctl.flowlabel_state_ranges;
|
2015-07-08 17:58:22 -06:00
|
|
|
ipv6_table[8].data = &net->ipv6.sysctl.ip_nonlocal_bind;
|
2017-08-23 01:55:41 -06:00
|
|
|
ipv6_table[9].data = &net->ipv6.sysctl.flowlabel_reflect;
|
2017-10-30 15:16:00 -06:00
|
|
|
ipv6_table[10].data = &net->ipv6.sysctl.max_dst_opts_cnt;
|
|
|
|
ipv6_table[11].data = &net->ipv6.sysctl.max_hbh_opts_cnt;
|
|
|
|
ipv6_table[12].data = &net->ipv6.sysctl.max_dst_opts_len;
|
|
|
|
ipv6_table[13].data = &net->ipv6.sysctl.max_hbh_opts_len;
|
2018-03-02 09:32:18 -07:00
|
|
|
ipv6_table[14].data = &net->ipv6.sysctl.multipath_hash_policy,
|
ipv6: sr: Compute flowlabel for outer IPv6 header of seg6 encap mode
ECMP (equal-cost multipath) hashes are typically computed on the packets'
5-tuple(src IP, dst IP, src port, dst port, L4 proto).
For encapsulated packets, the L4 data is not readily available and ECMP
hashing will often revert to (src IP, dst IP). This will lead to traffic
polarization on a single ECMP path, causing congestion and waste of network
capacity.
In IPv6, the 20-bit flow label field is also used as part of the ECMP hash.
In the lack of L4 data, the hashing will be on (src IP, dst IP, flow
label). Having a non-zero flow label is thus important for proper traffic
load balancing when L4 data is unavailable (i.e., when packets are
encapsulated).
Currently, the seg6_do_srh_encap() function extracts the original packet's
flow label and set it as the outer IPv6 flow label. There are two issues
with this behaviour:
a) There is no guarantee that the inner flow label is set by the source.
b) If the original packet is not IPv6, the flow label will be set to
zero (e.g., IPv4 or L2 encap).
This patch adds a function, named seg6_make_flowlabel(), that computes a
flow label from a given skb. It supports IPv6, IPv4 and L2 payloads, and
leverages the per namespace 'seg6_flowlabel" sysctl value.
The currently support behaviours are as follows:
-1 set flowlabel to zero.
0 copy flowlabel from Inner paceket in case of Inner IPv6
(Set flowlabel to 0 in case IPv4/L2)
1 Compute the flowlabel using seg6_make_flowlabel()
This patch has been tested for IPv6, IPv4, and L2 traffic.
Signed-off-by: Ahmed Abdelsalam <amsalam20@gmail.com>
Acked-by: David Lebrun <dlebrun@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-04-24 12:23:16 -06:00
|
|
|
ipv6_table[15].data = &net->ipv6.sysctl.seg6_flowlabel;
|
2008-01-10 03:53:43 -07: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 07:37:09 -06:00
|
|
|
net->ipv6.sysctl.hdr = register_net_sysctl(net, "net/ipv6", ipv6_table);
|
|
|
|
if (!net->ipv6.sysctl.hdr)
|
2008-01-10 03:53:43 -07:00
|
|
|
goto out_ipv6_icmp_table;
|
|
|
|
|
2012-04-19 07:37:09 -06: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 03:53:43 -07:00
|
|
|
err = 0;
|
|
|
|
out:
|
|
|
|
return err;
|
2012-04-19 07:37:09 -06: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 03:53:43 -07: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-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2010-01-16 20:35:32 -07:00
|
|
|
static void __net_exit ipv6_sysctl_net_exit(struct net *net)
|
2008-01-10 03:49:34 -07:00
|
|
|
{
|
2008-01-10 03:53:43 -07:00
|
|
|
struct ctl_table *ipv6_table;
|
|
|
|
struct ctl_table *ipv6_route_table;
|
|
|
|
struct ctl_table *ipv6_icmp_table;
|
|
|
|
|
2012-04-19 07:37:09 -06: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 03:53:43 -07:00
|
|
|
|
2012-04-19 07:37:09 -06: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 03:53:43 -07:00
|
|
|
|
|
|
|
kfree(ipv6_table);
|
|
|
|
kfree(ipv6_route_table);
|
|
|
|
kfree(ipv6_icmp_table);
|
2008-01-10 03:49:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct pernet_operations ipv6_sysctl_net_ops = {
|
|
|
|
.init = ipv6_sysctl_net_init,
|
|
|
|
.exit = ipv6_sysctl_net_exit,
|
|
|
|
};
|
|
|
|
|
2008-05-19 14:53:30 -06:00
|
|
|
static struct ctl_table_header *ip6_header;
|
|
|
|
|
2008-01-10 03:49:34 -07:00
|
|
|
int ipv6_sysctl_register(void)
|
|
|
|
{
|
2009-01-07 19:09:08 -07:00
|
|
|
int err = -ENOMEM;
|
2008-05-19 14:53:30 -06:00
|
|
|
|
2012-04-19 07:22:55 -06:00
|
|
|
ip6_header = register_net_sysctl(&init_net, "net/ipv6", ipv6_rotable);
|
2015-03-29 07:00:04 -06:00
|
|
|
if (!ip6_header)
|
2008-05-19 14:53:30 -06: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 03:49:34 -07:00
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
void ipv6_sysctl_unregister(void)
|
|
|
|
{
|
2008-05-19 14:53:30 -06:00
|
|
|
unregister_net_sysctl_table(ip6_header);
|
2008-01-10 03:49:34 -07:00
|
|
|
unregister_pernet_subsys(&ipv6_sysctl_net_ops);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|