* [PATCH net] ethtool: Check for vlan etype or vlan tci when parsing flow_rule
@ 2019-05-30 14:08 Maxime Chevallier
2019-05-30 14:09 ` Pablo Neira Ayuso
2019-05-30 22:05 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Maxime Chevallier @ 2019-05-30 14:08 UTC (permalink / raw)
To: davem, Pablo Neira Ayuso, Florian Fainelli, Jiri Pirko, Jakub Kicinski
Cc: Maxime Chevallier, netdev, linux-kernel, Antoine Tenart,
thomas.petazzoni
When parsing an ethtool flow spec to build a flow_rule, the code checks
if both the vlan etype and the vlan tci are specified by the user to add
a FLOW_DISSECTOR_KEY_VLAN match.
However, when the user only specified a vlan etype or a vlan tci, this
check silently ignores these parameters.
For example, the following rule :
ethtool -N eth0 flow-type udp4 vlan 0x0010 action -1 loc 0
will result in no error being issued, but the equivalent rule will be
created and passed to the NIC driver :
ethtool -N eth0 flow-type udp4 action -1 loc 0
In the end, neither the NIC driver using the rule nor the end user have
a way to know that these keys were dropped along the way, or that
incorrect parameters were entered.
This kind of check should be left to either the driver, or the ethtool
flow spec layer.
This commit makes so that ethtool parameters are forwarded as-is to the
NIC driver.
Since none of the users of ethtool_rx_flow_rule_create are using the
VLAN dissector, I don't think this qualifies as a regression.
Fixes: eca4205f9ec3 ("ethtool: add ethtool_rx_flow_spec to flow_rule structure translator")
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
This patch was previously sent as :
"ethtool: Drop check for vlan etype and vlan tci when parsing flow_rule"
Following Pablo's review, we don't drop the check anymore, hence the
more fitting subject.
net/core/ethtool.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 4a593853cbf2..43e9add58340 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -3010,11 +3010,12 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input)
const struct ethtool_flow_ext *ext_h_spec = &fs->h_ext;
const struct ethtool_flow_ext *ext_m_spec = &fs->m_ext;
- if (ext_m_spec->vlan_etype &&
- ext_m_spec->vlan_tci) {
+ if (ext_m_spec->vlan_etype) {
match->key.vlan.vlan_tpid = ext_h_spec->vlan_etype;
match->mask.vlan.vlan_tpid = ext_m_spec->vlan_etype;
+ }
+ if (ext_m_spec->vlan_tci) {
match->key.vlan.vlan_id =
ntohs(ext_h_spec->vlan_tci) & 0x0fff;
match->mask.vlan.vlan_id =
@@ -3024,7 +3025,10 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input)
(ntohs(ext_h_spec->vlan_tci) & 0xe000) >> 13;
match->mask.vlan.vlan_priority =
(ntohs(ext_m_spec->vlan_tci) & 0xe000) >> 13;
+ }
+ if (ext_m_spec->vlan_etype ||
+ ext_m_spec->vlan_tci) {
match->dissector.used_keys |=
BIT(FLOW_DISSECTOR_KEY_VLAN);
match->dissector.offset[FLOW_DISSECTOR_KEY_VLAN] =
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] ethtool: Check for vlan etype or vlan tci when parsing flow_rule
2019-05-30 14:08 [PATCH net] ethtool: Check for vlan etype or vlan tci when parsing flow_rule Maxime Chevallier
@ 2019-05-30 14:09 ` Pablo Neira Ayuso
2019-05-30 22:05 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2019-05-30 14:09 UTC (permalink / raw)
To: Maxime Chevallier
Cc: davem, Florian Fainelli, Jiri Pirko, Jakub Kicinski, netdev,
linux-kernel, Antoine Tenart, thomas.petazzoni
On Thu, May 30, 2019 at 04:08:40PM +0200, Maxime Chevallier wrote:
> When parsing an ethtool flow spec to build a flow_rule, the code checks
> if both the vlan etype and the vlan tci are specified by the user to add
> a FLOW_DISSECTOR_KEY_VLAN match.
>
> However, when the user only specified a vlan etype or a vlan tci, this
> check silently ignores these parameters.
>
> For example, the following rule :
>
> ethtool -N eth0 flow-type udp4 vlan 0x0010 action -1 loc 0
>
> will result in no error being issued, but the equivalent rule will be
> created and passed to the NIC driver :
>
> ethtool -N eth0 flow-type udp4 action -1 loc 0
>
> In the end, neither the NIC driver using the rule nor the end user have
> a way to know that these keys were dropped along the way, or that
> incorrect parameters were entered.
>
> This kind of check should be left to either the driver, or the ethtool
> flow spec layer.
>
> This commit makes so that ethtool parameters are forwarded as-is to the
> NIC driver.
>
> Since none of the users of ethtool_rx_flow_rule_create are using the
> VLAN dissector, I don't think this qualifies as a regression.
>
> Fixes: eca4205f9ec3 ("ethtool: add ethtool_rx_flow_spec to flow_rule structure translator")
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Acked-by: Pablo Neira Ayuso <pablo@gnumonks.org>
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] ethtool: Check for vlan etype or vlan tci when parsing flow_rule
2019-05-30 14:08 [PATCH net] ethtool: Check for vlan etype or vlan tci when parsing flow_rule Maxime Chevallier
2019-05-30 14:09 ` Pablo Neira Ayuso
@ 2019-05-30 22:05 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-05-30 22:05 UTC (permalink / raw)
To: maxime.chevallier
Cc: pablo, f.fainelli, jiri, jakub.kicinski, netdev, linux-kernel,
antoine.tenart, thomas.petazzoni
From: Maxime Chevallier <maxime.chevallier@bootlin.com>
Date: Thu, 30 May 2019 16:08:40 +0200
> When parsing an ethtool flow spec to build a flow_rule, the code checks
> if both the vlan etype and the vlan tci are specified by the user to add
> a FLOW_DISSECTOR_KEY_VLAN match.
>
> However, when the user only specified a vlan etype or a vlan tci, this
> check silently ignores these parameters.
>
> For example, the following rule :
>
> ethtool -N eth0 flow-type udp4 vlan 0x0010 action -1 loc 0
>
> will result in no error being issued, but the equivalent rule will be
> created and passed to the NIC driver :
>
> ethtool -N eth0 flow-type udp4 action -1 loc 0
>
> In the end, neither the NIC driver using the rule nor the end user have
> a way to know that these keys were dropped along the way, or that
> incorrect parameters were entered.
>
> This kind of check should be left to either the driver, or the ethtool
> flow spec layer.
>
> This commit makes so that ethtool parameters are forwarded as-is to the
> NIC driver.
>
> Since none of the users of ethtool_rx_flow_rule_create are using the
> VLAN dissector, I don't think this qualifies as a regression.
>
> Fixes: eca4205f9ec3 ("ethtool: add ethtool_rx_flow_spec to flow_rule structure translator")
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Applied, thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-30 22:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30 14:08 [PATCH net] ethtool: Check for vlan etype or vlan tci when parsing flow_rule Maxime Chevallier
2019-05-30 14:09 ` Pablo Neira Ayuso
2019-05-30 22:05 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®