]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/5.1.7/ethtool-check-for-vlan-etype-or-vlan-tci-when-parsing-flow_rule.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 5.1.7 / ethtool-check-for-vlan-etype-or-vlan-tci-when-parsing-flow_rule.patch
1 From foo@baz Fri 31 May 2019 03:16:39 PM PDT
2 From: Maxime Chevallier <maxime.chevallier@bootlin.com>
3 Date: Thu, 30 May 2019 16:08:40 +0200
4 Subject: ethtool: Check for vlan etype or vlan tci when parsing flow_rule
5
6 From: Maxime Chevallier <maxime.chevallier@bootlin.com>
7
8 [ Upstream commit b73484b2fc0d0ba84a13e9d86eb4adcae718163b ]
9
10 When parsing an ethtool flow spec to build a flow_rule, the code checks
11 if both the vlan etype and the vlan tci are specified by the user to add
12 a FLOW_DISSECTOR_KEY_VLAN match.
13
14 However, when the user only specified a vlan etype or a vlan tci, this
15 check silently ignores these parameters.
16
17 For example, the following rule :
18
19 ethtool -N eth0 flow-type udp4 vlan 0x0010 action -1 loc 0
20
21 will result in no error being issued, but the equivalent rule will be
22 created and passed to the NIC driver :
23
24 ethtool -N eth0 flow-type udp4 action -1 loc 0
25
26 In the end, neither the NIC driver using the rule nor the end user have
27 a way to know that these keys were dropped along the way, or that
28 incorrect parameters were entered.
29
30 This kind of check should be left to either the driver, or the ethtool
31 flow spec layer.
32
33 This commit makes so that ethtool parameters are forwarded as-is to the
34 NIC driver.
35
36 Since none of the users of ethtool_rx_flow_rule_create are using the
37 VLAN dissector, I don't think this qualifies as a regression.
38
39 Fixes: eca4205f9ec3 ("ethtool: add ethtool_rx_flow_spec to flow_rule structure translator")
40 Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
41 Acked-by: Pablo Neira Ayuso <pablo@gnumonks.org>
42 Signed-off-by: David S. Miller <davem@davemloft.net>
43 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
44 ---
45 net/core/ethtool.c | 8 ++++++--
46 1 file changed, 6 insertions(+), 2 deletions(-)
47
48 --- a/net/core/ethtool.c
49 +++ b/net/core/ethtool.c
50 @@ -3008,11 +3008,12 @@ ethtool_rx_flow_rule_create(const struct
51 const struct ethtool_flow_ext *ext_h_spec = &fs->h_ext;
52 const struct ethtool_flow_ext *ext_m_spec = &fs->m_ext;
53
54 - if (ext_m_spec->vlan_etype &&
55 - ext_m_spec->vlan_tci) {
56 + if (ext_m_spec->vlan_etype) {
57 match->key.vlan.vlan_tpid = ext_h_spec->vlan_etype;
58 match->mask.vlan.vlan_tpid = ext_m_spec->vlan_etype;
59 + }
60
61 + if (ext_m_spec->vlan_tci) {
62 match->key.vlan.vlan_id =
63 ntohs(ext_h_spec->vlan_tci) & 0x0fff;
64 match->mask.vlan.vlan_id =
65 @@ -3022,7 +3023,10 @@ ethtool_rx_flow_rule_create(const struct
66 (ntohs(ext_h_spec->vlan_tci) & 0xe000) >> 13;
67 match->mask.vlan.vlan_priority =
68 (ntohs(ext_m_spec->vlan_tci) & 0xe000) >> 13;
69 + }
70
71 + if (ext_m_spec->vlan_etype ||
72 + ext_m_spec->vlan_tci) {
73 match->dissector.used_keys |=
74 BIT(FLOW_DISSECTOR_KEY_VLAN);
75 match->dissector.offset[FLOW_DISSECTOR_KEY_VLAN] =