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 14:07:57 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifndef _INET_ECN_H_
|
|
|
|
#define _INET_ECN_H_
|
|
|
|
|
|
|
|
#include <linux/ip.h>
|
2005-11-05 20:14:04 +00:00
|
|
|
#include <linux/skbuff.h>
|
sched: consistently handle layer3 header accesses in the presence of VLANs
There are a couple of places in net/sched/ that check skb->protocol and act
on the value there. However, in the presence of VLAN tags, the value stored
in skb->protocol can be inconsistent based on whether VLAN acceleration is
enabled. The commit quoted in the Fixes tag below fixed the users of
skb->protocol to use a helper that will always see the VLAN ethertype.
However, most of the callers don't actually handle the VLAN ethertype, but
expect to find the IP header type in the protocol field. This means that
things like changing the ECN field, or parsing diffserv values, stops
working if there's a VLAN tag, or if there are multiple nested VLAN
tags (QinQ).
To fix this, change the helper to take an argument that indicates whether
the caller wants to skip the VLAN tags or not. When skipping VLAN tags, we
make sure to skip all of them, so behaviour is consistent even in QinQ
mode.
To make the helper usable from the ECN code, move it to if_vlan.h instead
of pkt_sched.h.
v3:
- Remove empty lines
- Move vlan variable definitions inside loop in skb_protocol()
- Also use skb_protocol() helper in IP{,6}_ECN_decapsulate() and
bpf_skb_ecn_set_ce()
v2:
- Use eth_type_vlan() helper in skb_protocol()
- Also fix code that reads skb->protocol directly
- Change a couple of 'if/else if' statements to switch constructs to avoid
calling the helper twice
Reported-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Fixes: d8b9605d2697 ("net: sched: fix skb->protocol use in case of accelerated vlan path")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-03 20:26:43 +00:00
|
|
|
#include <linux/if_vlan.h>
|
2005-12-27 04:43:12 +00:00
|
|
|
|
|
|
|
#include <net/inet_sock.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <net/dsfield.h>
|
2020-12-11 14:26:38 +00:00
|
|
|
#include <net/checksum.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
INET_ECN_NOT_ECT = 0,
|
|
|
|
INET_ECN_ECT_1 = 1,
|
|
|
|
INET_ECN_ECT_0 = 2,
|
|
|
|
INET_ECN_CE = 3,
|
|
|
|
INET_ECN_MASK = 3,
|
|
|
|
};
|
|
|
|
|
2012-09-25 11:02:48 +00:00
|
|
|
extern int sysctl_tunnel_ecn_log;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static inline int INET_ECN_is_ce(__u8 dsfield)
|
|
|
|
{
|
|
|
|
return (dsfield & INET_ECN_MASK) == INET_ECN_CE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int INET_ECN_is_not_ect(__u8 dsfield)
|
|
|
|
{
|
|
|
|
return (dsfield & INET_ECN_MASK) == INET_ECN_NOT_ECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int INET_ECN_is_capable(__u8 dsfield)
|
|
|
|
{
|
2010-09-22 20:43:57 +00:00
|
|
|
return dsfield & INET_ECN_ECT_0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2011-10-22 05:25:23 +00:00
|
|
|
/*
|
|
|
|
* RFC 3168 9.1.1
|
|
|
|
* The full-functionality option for ECN encapsulation is to copy the
|
|
|
|
* ECN codepoint of the inside header to the outside header on
|
|
|
|
* encapsulation if the inside header is not-ECT or ECT, and to set the
|
|
|
|
* ECN codepoint of the outside header to ECT(0) if the ECN codepoint of
|
|
|
|
* the inside header is CE.
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner)
|
|
|
|
{
|
|
|
|
outer &= ~INET_ECN_MASK;
|
|
|
|
outer |= !INET_ECN_is_ce(inner) ? (inner & INET_ECN_MASK) :
|
|
|
|
INET_ECN_ECT_0;
|
|
|
|
return outer;
|
|
|
|
}
|
|
|
|
|
2011-05-06 23:44:46 +00:00
|
|
|
static inline void INET_ECN_xmit(struct sock *sk)
|
|
|
|
{
|
|
|
|
inet_sk(sk)->tos |= INET_ECN_ECT_0;
|
|
|
|
if (inet6_sk(sk) != NULL)
|
|
|
|
inet6_sk(sk)->tclass |= INET_ECN_ECT_0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void INET_ECN_dontxmit(struct sock *sk)
|
|
|
|
{
|
|
|
|
inet_sk(sk)->tos &= ~INET_ECN_MASK;
|
|
|
|
if (inet6_sk(sk) != NULL)
|
|
|
|
inet6_sk(sk)->tclass &= ~INET_ECN_MASK;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#define IP6_ECN_flow_init(label) do { \
|
|
|
|
(label) &= ~htonl(INET_ECN_MASK << 20); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define IP6_ECN_flow_xmit(sk, label) do { \
|
2008-04-14 06:40:51 +00:00
|
|
|
if (INET_ECN_is_capable(inet6_sk(sk)->tclass)) \
|
2006-11-03 08:55:35 +00:00
|
|
|
(label) |= htonl(INET_ECN_ECT_0 << 20); \
|
2005-04-16 22:20:36 +00:00
|
|
|
} while (0)
|
|
|
|
|
2005-11-05 20:14:04 +00:00
|
|
|
static inline int IP_ECN_set_ce(struct iphdr *iph)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
u32 ecn = (iph->tos + 1) & INET_ECN_MASK;
|
2020-12-11 14:26:38 +00:00
|
|
|
__be16 check_add;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* After the last operation we have (in binary):
|
|
|
|
* INET_ECN_NOT_ECT => 01
|
|
|
|
* INET_ECN_ECT_1 => 10
|
|
|
|
* INET_ECN_ECT_0 => 11
|
|
|
|
* INET_ECN_CE => 00
|
|
|
|
*/
|
|
|
|
if (!(ecn & 2))
|
2005-11-05 20:14:04 +00:00
|
|
|
return !ecn;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The following gives us:
|
|
|
|
* INET_ECN_ECT_1 => check += htons(0xFFFD)
|
|
|
|
* INET_ECN_ECT_0 => check += htons(0xFFFE)
|
|
|
|
*/
|
2020-12-11 14:26:38 +00:00
|
|
|
check_add = (__force __be16)((__force u16)htons(0xFFFB) +
|
|
|
|
(__force u16)htons(ecn));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2020-12-11 14:26:38 +00:00
|
|
|
iph->check = csum16_add(iph->check, check_add);
|
2005-04-16 22:20:36 +00:00
|
|
|
iph->tos |= INET_ECN_CE;
|
2005-11-05 20:14:04 +00:00
|
|
|
return 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2020-04-27 14:11:05 +00:00
|
|
|
static inline int IP_ECN_set_ect1(struct iphdr *iph)
|
|
|
|
{
|
|
|
|
if ((iph->tos & INET_ECN_MASK) != INET_ECN_ECT_0)
|
|
|
|
return 0;
|
|
|
|
|
2020-12-11 14:26:38 +00:00
|
|
|
iph->check = csum16_add(iph->check, htons(0x1));
|
2020-04-27 14:11:05 +00:00
|
|
|
iph->tos ^= INET_ECN_MASK;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static inline void IP_ECN_clear(struct iphdr *iph)
|
|
|
|
{
|
|
|
|
iph->tos &= ~INET_ECN_MASK;
|
|
|
|
}
|
|
|
|
|
2007-11-14 05:40:13 +00:00
|
|
|
static inline void ipv4_copy_dscp(unsigned int dscp, struct iphdr *inner)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-11-14 05:40:13 +00:00
|
|
|
dscp &= ~INET_ECN_MASK;
|
2005-04-16 22:20:36 +00:00
|
|
|
ipv4_change_dsfield(inner, INET_ECN_MASK, dscp);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ipv6hdr;
|
|
|
|
|
2016-01-15 12:56:56 +00:00
|
|
|
/* Note:
|
|
|
|
* IP_ECN_set_ce() has to tweak IPV4 checksum when setting CE,
|
|
|
|
* meaning both changes have no effect on skb->csum if/when CHECKSUM_COMPLETE
|
|
|
|
* In IPv6 case, no checksum compensates the change in IPv6 header,
|
|
|
|
* so we have to update skb->csum.
|
|
|
|
*/
|
|
|
|
static inline int IP6_ECN_set_ce(struct sk_buff *skb, struct ipv6hdr *iph)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2016-01-15 12:56:56 +00:00
|
|
|
__be32 from, to;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (INET_ECN_is_not_ect(ipv6_get_dsfield(iph)))
|
2005-11-05 20:14:04 +00:00
|
|
|
return 0;
|
2016-01-15 12:56:56 +00:00
|
|
|
|
|
|
|
from = *(__be32 *)iph;
|
|
|
|
to = from | htonl(INET_ECN_CE << 20);
|
|
|
|
*(__be32 *)iph = to;
|
|
|
|
if (skb->ip_summed == CHECKSUM_COMPLETE)
|
2016-08-12 05:48:21 +00:00
|
|
|
skb->csum = csum_add(csum_sub(skb->csum, (__force __wsum)from),
|
|
|
|
(__force __wsum)to);
|
2005-11-05 20:14:04 +00:00
|
|
|
return 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2020-04-27 14:11:05 +00:00
|
|
|
static inline int IP6_ECN_set_ect1(struct sk_buff *skb, struct ipv6hdr *iph)
|
|
|
|
{
|
|
|
|
__be32 from, to;
|
|
|
|
|
|
|
|
if ((ipv6_get_dsfield(iph) & INET_ECN_MASK) != INET_ECN_ECT_0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
from = *(__be32 *)iph;
|
|
|
|
to = from ^ htonl(INET_ECN_MASK << 20);
|
|
|
|
*(__be32 *)iph = to;
|
|
|
|
if (skb->ip_summed == CHECKSUM_COMPLETE)
|
|
|
|
skb->csum = csum_add(csum_sub(skb->csum, (__force __wsum)from),
|
|
|
|
(__force __wsum)to);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-11-14 05:40:13 +00:00
|
|
|
static inline void ipv6_copy_dscp(unsigned int dscp, struct ipv6hdr *inner)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2007-11-14 05:40:13 +00:00
|
|
|
dscp &= ~INET_ECN_MASK;
|
2005-04-16 22:20:36 +00:00
|
|
|
ipv6_change_dsfield(inner, INET_ECN_MASK, dscp);
|
|
|
|
}
|
|
|
|
|
2005-11-05 20:14:04 +00:00
|
|
|
static inline int INET_ECN_set_ce(struct sk_buff *skb)
|
|
|
|
{
|
sched: consistently handle layer3 header accesses in the presence of VLANs
There are a couple of places in net/sched/ that check skb->protocol and act
on the value there. However, in the presence of VLAN tags, the value stored
in skb->protocol can be inconsistent based on whether VLAN acceleration is
enabled. The commit quoted in the Fixes tag below fixed the users of
skb->protocol to use a helper that will always see the VLAN ethertype.
However, most of the callers don't actually handle the VLAN ethertype, but
expect to find the IP header type in the protocol field. This means that
things like changing the ECN field, or parsing diffserv values, stops
working if there's a VLAN tag, or if there are multiple nested VLAN
tags (QinQ).
To fix this, change the helper to take an argument that indicates whether
the caller wants to skip the VLAN tags or not. When skipping VLAN tags, we
make sure to skip all of them, so behaviour is consistent even in QinQ
mode.
To make the helper usable from the ECN code, move it to if_vlan.h instead
of pkt_sched.h.
v3:
- Remove empty lines
- Move vlan variable definitions inside loop in skb_protocol()
- Also use skb_protocol() helper in IP{,6}_ECN_decapsulate() and
bpf_skb_ecn_set_ce()
v2:
- Use eth_type_vlan() helper in skb_protocol()
- Also fix code that reads skb->protocol directly
- Change a couple of 'if/else if' statements to switch constructs to avoid
calling the helper twice
Reported-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Fixes: d8b9605d2697 ("net: sched: fix skb->protocol use in case of accelerated vlan path")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-03 20:26:43 +00:00
|
|
|
switch (skb_protocol(skb, true)) {
|
2009-02-15 06:58:35 +00:00
|
|
|
case cpu_to_be16(ETH_P_IP):
|
2013-05-28 20:34:25 +00:00
|
|
|
if (skb_network_header(skb) + sizeof(struct iphdr) <=
|
|
|
|
skb_tail_pointer(skb))
|
2007-04-21 05:47:35 +00:00
|
|
|
return IP_ECN_set_ce(ip_hdr(skb));
|
2005-11-05 20:14:04 +00:00
|
|
|
break;
|
|
|
|
|
2009-02-15 06:58:35 +00:00
|
|
|
case cpu_to_be16(ETH_P_IPV6):
|
2013-05-28 20:34:25 +00:00
|
|
|
if (skb_network_header(skb) + sizeof(struct ipv6hdr) <=
|
|
|
|
skb_tail_pointer(skb))
|
2016-01-15 12:56:56 +00:00
|
|
|
return IP6_ECN_set_ce(skb, ipv6_hdr(skb));
|
2005-11-05 20:14:04 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-27 14:11:05 +00:00
|
|
|
static inline int INET_ECN_set_ect1(struct sk_buff *skb)
|
|
|
|
{
|
sched: consistently handle layer3 header accesses in the presence of VLANs
There are a couple of places in net/sched/ that check skb->protocol and act
on the value there. However, in the presence of VLAN tags, the value stored
in skb->protocol can be inconsistent based on whether VLAN acceleration is
enabled. The commit quoted in the Fixes tag below fixed the users of
skb->protocol to use a helper that will always see the VLAN ethertype.
However, most of the callers don't actually handle the VLAN ethertype, but
expect to find the IP header type in the protocol field. This means that
things like changing the ECN field, or parsing diffserv values, stops
working if there's a VLAN tag, or if there are multiple nested VLAN
tags (QinQ).
To fix this, change the helper to take an argument that indicates whether
the caller wants to skip the VLAN tags or not. When skipping VLAN tags, we
make sure to skip all of them, so behaviour is consistent even in QinQ
mode.
To make the helper usable from the ECN code, move it to if_vlan.h instead
of pkt_sched.h.
v3:
- Remove empty lines
- Move vlan variable definitions inside loop in skb_protocol()
- Also use skb_protocol() helper in IP{,6}_ECN_decapsulate() and
bpf_skb_ecn_set_ce()
v2:
- Use eth_type_vlan() helper in skb_protocol()
- Also fix code that reads skb->protocol directly
- Change a couple of 'if/else if' statements to switch constructs to avoid
calling the helper twice
Reported-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Fixes: d8b9605d2697 ("net: sched: fix skb->protocol use in case of accelerated vlan path")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-03 20:26:43 +00:00
|
|
|
switch (skb_protocol(skb, true)) {
|
2020-04-27 14:11:05 +00:00
|
|
|
case cpu_to_be16(ETH_P_IP):
|
|
|
|
if (skb_network_header(skb) + sizeof(struct iphdr) <=
|
|
|
|
skb_tail_pointer(skb))
|
|
|
|
return IP_ECN_set_ect1(ip_hdr(skb));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cpu_to_be16(ETH_P_IPV6):
|
|
|
|
if (skb_network_header(skb) + sizeof(struct ipv6hdr) <=
|
|
|
|
skb_tail_pointer(skb))
|
|
|
|
return IP6_ECN_set_ect1(skb, ipv6_hdr(skb));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-25 11:02:48 +00:00
|
|
|
/*
|
2014-05-05 00:55:39 +00:00
|
|
|
* RFC 6040 4.2
|
2012-09-25 11:02:48 +00:00
|
|
|
* To decapsulate the inner header at the tunnel egress, a compliant
|
|
|
|
* tunnel egress MUST set the outgoing ECN field to the codepoint at the
|
|
|
|
* intersection of the appropriate arriving inner header (row) and outer
|
|
|
|
* header (column) in Figure 4
|
|
|
|
*
|
|
|
|
* +---------+------------------------------------------------+
|
|
|
|
* |Arriving | Arriving Outer Header |
|
|
|
|
* | Inner +---------+------------+------------+------------+
|
|
|
|
* | Header | Not-ECT | ECT(0) | ECT(1) | CE |
|
|
|
|
* +---------+---------+------------+------------+------------+
|
|
|
|
* | Not-ECT | Not-ECT |Not-ECT(!!!)|Not-ECT(!!!)| <drop>(!!!)|
|
|
|
|
* | ECT(0) | ECT(0) | ECT(0) | ECT(1) | CE |
|
|
|
|
* | ECT(1) | ECT(1) | ECT(1) (!) | ECT(1) | CE |
|
|
|
|
* | CE | CE | CE | CE(!!!)| CE |
|
|
|
|
* +---------+---------+------------+------------+------------+
|
|
|
|
*
|
|
|
|
* Figure 4: New IP in IP Decapsulation Behaviour
|
|
|
|
*
|
|
|
|
* returns 0 on success
|
|
|
|
* 1 if something is broken and should be logged (!!! above)
|
|
|
|
* 2 if packet should be dropped
|
|
|
|
*/
|
2018-10-17 08:53:12 +00:00
|
|
|
static inline int __INET_ECN_decapsulate(__u8 outer, __u8 inner, bool *set_ce)
|
2012-09-25 11:02:48 +00:00
|
|
|
{
|
|
|
|
if (INET_ECN_is_not_ect(inner)) {
|
|
|
|
switch (outer & INET_ECN_MASK) {
|
|
|
|
case INET_ECN_NOT_ECT:
|
|
|
|
return 0;
|
|
|
|
case INET_ECN_ECT_0:
|
|
|
|
case INET_ECN_ECT_1:
|
|
|
|
return 1;
|
|
|
|
case INET_ECN_CE:
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-17 08:53:12 +00:00
|
|
|
*set_ce = INET_ECN_is_ce(outer);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int INET_ECN_decapsulate(struct sk_buff *skb,
|
|
|
|
__u8 outer, __u8 inner)
|
|
|
|
{
|
|
|
|
bool set_ce = false;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = __INET_ECN_decapsulate(outer, inner, &set_ce);
|
2020-04-27 14:11:05 +00:00
|
|
|
if (!rc) {
|
|
|
|
if (set_ce)
|
|
|
|
INET_ECN_set_ce(skb);
|
|
|
|
else if ((outer & INET_ECN_MASK) == INET_ECN_ECT_1)
|
|
|
|
INET_ECN_set_ect1(skb);
|
|
|
|
}
|
2012-09-25 11:02:48 +00:00
|
|
|
|
2018-10-17 08:53:12 +00:00
|
|
|
return rc;
|
2012-09-25 11:02:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int IP_ECN_decapsulate(const struct iphdr *oiph,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
__u8 inner;
|
|
|
|
|
sched: consistently handle layer3 header accesses in the presence of VLANs
There are a couple of places in net/sched/ that check skb->protocol and act
on the value there. However, in the presence of VLAN tags, the value stored
in skb->protocol can be inconsistent based on whether VLAN acceleration is
enabled. The commit quoted in the Fixes tag below fixed the users of
skb->protocol to use a helper that will always see the VLAN ethertype.
However, most of the callers don't actually handle the VLAN ethertype, but
expect to find the IP header type in the protocol field. This means that
things like changing the ECN field, or parsing diffserv values, stops
working if there's a VLAN tag, or if there are multiple nested VLAN
tags (QinQ).
To fix this, change the helper to take an argument that indicates whether
the caller wants to skip the VLAN tags or not. When skipping VLAN tags, we
make sure to skip all of them, so behaviour is consistent even in QinQ
mode.
To make the helper usable from the ECN code, move it to if_vlan.h instead
of pkt_sched.h.
v3:
- Remove empty lines
- Move vlan variable definitions inside loop in skb_protocol()
- Also use skb_protocol() helper in IP{,6}_ECN_decapsulate() and
bpf_skb_ecn_set_ce()
v2:
- Use eth_type_vlan() helper in skb_protocol()
- Also fix code that reads skb->protocol directly
- Change a couple of 'if/else if' statements to switch constructs to avoid
calling the helper twice
Reported-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Fixes: d8b9605d2697 ("net: sched: fix skb->protocol use in case of accelerated vlan path")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-03 20:26:43 +00:00
|
|
|
switch (skb_protocol(skb, true)) {
|
|
|
|
case htons(ETH_P_IP):
|
2012-09-25 11:02:48 +00:00
|
|
|
inner = ip_hdr(skb)->tos;
|
sched: consistently handle layer3 header accesses in the presence of VLANs
There are a couple of places in net/sched/ that check skb->protocol and act
on the value there. However, in the presence of VLAN tags, the value stored
in skb->protocol can be inconsistent based on whether VLAN acceleration is
enabled. The commit quoted in the Fixes tag below fixed the users of
skb->protocol to use a helper that will always see the VLAN ethertype.
However, most of the callers don't actually handle the VLAN ethertype, but
expect to find the IP header type in the protocol field. This means that
things like changing the ECN field, or parsing diffserv values, stops
working if there's a VLAN tag, or if there are multiple nested VLAN
tags (QinQ).
To fix this, change the helper to take an argument that indicates whether
the caller wants to skip the VLAN tags or not. When skipping VLAN tags, we
make sure to skip all of them, so behaviour is consistent even in QinQ
mode.
To make the helper usable from the ECN code, move it to if_vlan.h instead
of pkt_sched.h.
v3:
- Remove empty lines
- Move vlan variable definitions inside loop in skb_protocol()
- Also use skb_protocol() helper in IP{,6}_ECN_decapsulate() and
bpf_skb_ecn_set_ce()
v2:
- Use eth_type_vlan() helper in skb_protocol()
- Also fix code that reads skb->protocol directly
- Change a couple of 'if/else if' statements to switch constructs to avoid
calling the helper twice
Reported-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Fixes: d8b9605d2697 ("net: sched: fix skb->protocol use in case of accelerated vlan path")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-03 20:26:43 +00:00
|
|
|
break;
|
|
|
|
case htons(ETH_P_IPV6):
|
2012-09-25 11:02:48 +00:00
|
|
|
inner = ipv6_get_dsfield(ipv6_hdr(skb));
|
sched: consistently handle layer3 header accesses in the presence of VLANs
There are a couple of places in net/sched/ that check skb->protocol and act
on the value there. However, in the presence of VLAN tags, the value stored
in skb->protocol can be inconsistent based on whether VLAN acceleration is
enabled. The commit quoted in the Fixes tag below fixed the users of
skb->protocol to use a helper that will always see the VLAN ethertype.
However, most of the callers don't actually handle the VLAN ethertype, but
expect to find the IP header type in the protocol field. This means that
things like changing the ECN field, or parsing diffserv values, stops
working if there's a VLAN tag, or if there are multiple nested VLAN
tags (QinQ).
To fix this, change the helper to take an argument that indicates whether
the caller wants to skip the VLAN tags or not. When skipping VLAN tags, we
make sure to skip all of them, so behaviour is consistent even in QinQ
mode.
To make the helper usable from the ECN code, move it to if_vlan.h instead
of pkt_sched.h.
v3:
- Remove empty lines
- Move vlan variable definitions inside loop in skb_protocol()
- Also use skb_protocol() helper in IP{,6}_ECN_decapsulate() and
bpf_skb_ecn_set_ce()
v2:
- Use eth_type_vlan() helper in skb_protocol()
- Also fix code that reads skb->protocol directly
- Change a couple of 'if/else if' statements to switch constructs to avoid
calling the helper twice
Reported-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Fixes: d8b9605d2697 ("net: sched: fix skb->protocol use in case of accelerated vlan path")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-03 20:26:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-09-25 11:02:48 +00:00
|
|
|
return 0;
|
sched: consistently handle layer3 header accesses in the presence of VLANs
There are a couple of places in net/sched/ that check skb->protocol and act
on the value there. However, in the presence of VLAN tags, the value stored
in skb->protocol can be inconsistent based on whether VLAN acceleration is
enabled. The commit quoted in the Fixes tag below fixed the users of
skb->protocol to use a helper that will always see the VLAN ethertype.
However, most of the callers don't actually handle the VLAN ethertype, but
expect to find the IP header type in the protocol field. This means that
things like changing the ECN field, or parsing diffserv values, stops
working if there's a VLAN tag, or if there are multiple nested VLAN
tags (QinQ).
To fix this, change the helper to take an argument that indicates whether
the caller wants to skip the VLAN tags or not. When skipping VLAN tags, we
make sure to skip all of them, so behaviour is consistent even in QinQ
mode.
To make the helper usable from the ECN code, move it to if_vlan.h instead
of pkt_sched.h.
v3:
- Remove empty lines
- Move vlan variable definitions inside loop in skb_protocol()
- Also use skb_protocol() helper in IP{,6}_ECN_decapsulate() and
bpf_skb_ecn_set_ce()
v2:
- Use eth_type_vlan() helper in skb_protocol()
- Also fix code that reads skb->protocol directly
- Change a couple of 'if/else if' statements to switch constructs to avoid
calling the helper twice
Reported-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Fixes: d8b9605d2697 ("net: sched: fix skb->protocol use in case of accelerated vlan path")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-03 20:26:43 +00:00
|
|
|
}
|
2012-09-25 11:02:48 +00:00
|
|
|
|
|
|
|
return INET_ECN_decapsulate(skb, oiph->tos, inner);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int IP6_ECN_decapsulate(const struct ipv6hdr *oipv6h,
|
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
__u8 inner;
|
|
|
|
|
sched: consistently handle layer3 header accesses in the presence of VLANs
There are a couple of places in net/sched/ that check skb->protocol and act
on the value there. However, in the presence of VLAN tags, the value stored
in skb->protocol can be inconsistent based on whether VLAN acceleration is
enabled. The commit quoted in the Fixes tag below fixed the users of
skb->protocol to use a helper that will always see the VLAN ethertype.
However, most of the callers don't actually handle the VLAN ethertype, but
expect to find the IP header type in the protocol field. This means that
things like changing the ECN field, or parsing diffserv values, stops
working if there's a VLAN tag, or if there are multiple nested VLAN
tags (QinQ).
To fix this, change the helper to take an argument that indicates whether
the caller wants to skip the VLAN tags or not. When skipping VLAN tags, we
make sure to skip all of them, so behaviour is consistent even in QinQ
mode.
To make the helper usable from the ECN code, move it to if_vlan.h instead
of pkt_sched.h.
v3:
- Remove empty lines
- Move vlan variable definitions inside loop in skb_protocol()
- Also use skb_protocol() helper in IP{,6}_ECN_decapsulate() and
bpf_skb_ecn_set_ce()
v2:
- Use eth_type_vlan() helper in skb_protocol()
- Also fix code that reads skb->protocol directly
- Change a couple of 'if/else if' statements to switch constructs to avoid
calling the helper twice
Reported-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Fixes: d8b9605d2697 ("net: sched: fix skb->protocol use in case of accelerated vlan path")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-03 20:26:43 +00:00
|
|
|
switch (skb_protocol(skb, true)) {
|
|
|
|
case htons(ETH_P_IP):
|
2012-09-25 11:02:48 +00:00
|
|
|
inner = ip_hdr(skb)->tos;
|
sched: consistently handle layer3 header accesses in the presence of VLANs
There are a couple of places in net/sched/ that check skb->protocol and act
on the value there. However, in the presence of VLAN tags, the value stored
in skb->protocol can be inconsistent based on whether VLAN acceleration is
enabled. The commit quoted in the Fixes tag below fixed the users of
skb->protocol to use a helper that will always see the VLAN ethertype.
However, most of the callers don't actually handle the VLAN ethertype, but
expect to find the IP header type in the protocol field. This means that
things like changing the ECN field, or parsing diffserv values, stops
working if there's a VLAN tag, or if there are multiple nested VLAN
tags (QinQ).
To fix this, change the helper to take an argument that indicates whether
the caller wants to skip the VLAN tags or not. When skipping VLAN tags, we
make sure to skip all of them, so behaviour is consistent even in QinQ
mode.
To make the helper usable from the ECN code, move it to if_vlan.h instead
of pkt_sched.h.
v3:
- Remove empty lines
- Move vlan variable definitions inside loop in skb_protocol()
- Also use skb_protocol() helper in IP{,6}_ECN_decapsulate() and
bpf_skb_ecn_set_ce()
v2:
- Use eth_type_vlan() helper in skb_protocol()
- Also fix code that reads skb->protocol directly
- Change a couple of 'if/else if' statements to switch constructs to avoid
calling the helper twice
Reported-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Fixes: d8b9605d2697 ("net: sched: fix skb->protocol use in case of accelerated vlan path")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-03 20:26:43 +00:00
|
|
|
break;
|
|
|
|
case htons(ETH_P_IPV6):
|
2012-09-25 11:02:48 +00:00
|
|
|
inner = ipv6_get_dsfield(ipv6_hdr(skb));
|
sched: consistently handle layer3 header accesses in the presence of VLANs
There are a couple of places in net/sched/ that check skb->protocol and act
on the value there. However, in the presence of VLAN tags, the value stored
in skb->protocol can be inconsistent based on whether VLAN acceleration is
enabled. The commit quoted in the Fixes tag below fixed the users of
skb->protocol to use a helper that will always see the VLAN ethertype.
However, most of the callers don't actually handle the VLAN ethertype, but
expect to find the IP header type in the protocol field. This means that
things like changing the ECN field, or parsing diffserv values, stops
working if there's a VLAN tag, or if there are multiple nested VLAN
tags (QinQ).
To fix this, change the helper to take an argument that indicates whether
the caller wants to skip the VLAN tags or not. When skipping VLAN tags, we
make sure to skip all of them, so behaviour is consistent even in QinQ
mode.
To make the helper usable from the ECN code, move it to if_vlan.h instead
of pkt_sched.h.
v3:
- Remove empty lines
- Move vlan variable definitions inside loop in skb_protocol()
- Also use skb_protocol() helper in IP{,6}_ECN_decapsulate() and
bpf_skb_ecn_set_ce()
v2:
- Use eth_type_vlan() helper in skb_protocol()
- Also fix code that reads skb->protocol directly
- Change a couple of 'if/else if' statements to switch constructs to avoid
calling the helper twice
Reported-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Fixes: d8b9605d2697 ("net: sched: fix skb->protocol use in case of accelerated vlan path")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-03 20:26:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-09-25 11:02:48 +00:00
|
|
|
return 0;
|
sched: consistently handle layer3 header accesses in the presence of VLANs
There are a couple of places in net/sched/ that check skb->protocol and act
on the value there. However, in the presence of VLAN tags, the value stored
in skb->protocol can be inconsistent based on whether VLAN acceleration is
enabled. The commit quoted in the Fixes tag below fixed the users of
skb->protocol to use a helper that will always see the VLAN ethertype.
However, most of the callers don't actually handle the VLAN ethertype, but
expect to find the IP header type in the protocol field. This means that
things like changing the ECN field, or parsing diffserv values, stops
working if there's a VLAN tag, or if there are multiple nested VLAN
tags (QinQ).
To fix this, change the helper to take an argument that indicates whether
the caller wants to skip the VLAN tags or not. When skipping VLAN tags, we
make sure to skip all of them, so behaviour is consistent even in QinQ
mode.
To make the helper usable from the ECN code, move it to if_vlan.h instead
of pkt_sched.h.
v3:
- Remove empty lines
- Move vlan variable definitions inside loop in skb_protocol()
- Also use skb_protocol() helper in IP{,6}_ECN_decapsulate() and
bpf_skb_ecn_set_ce()
v2:
- Use eth_type_vlan() helper in skb_protocol()
- Also fix code that reads skb->protocol directly
- Change a couple of 'if/else if' statements to switch constructs to avoid
calling the helper twice
Reported-by: Ilya Ponetayev <i.ponetaev@ndmsystems.com>
Fixes: d8b9605d2697 ("net: sched: fix skb->protocol use in case of accelerated vlan path")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-03 20:26:43 +00:00
|
|
|
}
|
2012-09-25 11:02:48 +00:00
|
|
|
|
|
|
|
return INET_ECN_decapsulate(skb, ipv6_get_dsfield(oipv6h), inner);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|