Skip to content

Commit b73484b

Browse files
minimaxwelldavem330
authored andcommitted
ethtool: Check for vlan etype or vlan tci when parsing flow_rule
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: eca4205 ("ethtool: add ethtool_rx_flow_spec to flow_rule structure translator") Signed-off-by: Maxime Chevallier <[email protected]> Acked-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2b81f81 commit b73484b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/core/ethtool.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,11 +3010,12 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input)
30103010
const struct ethtool_flow_ext *ext_h_spec = &fs->h_ext;
30113011
const struct ethtool_flow_ext *ext_m_spec = &fs->m_ext;
30123012

3013-
if (ext_m_spec->vlan_etype &&
3014-
ext_m_spec->vlan_tci) {
3013+
if (ext_m_spec->vlan_etype) {
30153014
match->key.vlan.vlan_tpid = ext_h_spec->vlan_etype;
30163015
match->mask.vlan.vlan_tpid = ext_m_spec->vlan_etype;
3016+
}
30173017

3018+
if (ext_m_spec->vlan_tci) {
30183019
match->key.vlan.vlan_id =
30193020
ntohs(ext_h_spec->vlan_tci) & 0x0fff;
30203021
match->mask.vlan.vlan_id =
@@ -3024,7 +3025,10 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input)
30243025
(ntohs(ext_h_spec->vlan_tci) & 0xe000) >> 13;
30253026
match->mask.vlan.vlan_priority =
30263027
(ntohs(ext_m_spec->vlan_tci) & 0xe000) >> 13;
3028+
}
30273029

3030+
if (ext_m_spec->vlan_etype ||
3031+
ext_m_spec->vlan_tci) {
30283032
match->dissector.used_keys |=
30293033
BIT(FLOW_DISSECTOR_KEY_VLAN);
30303034
match->dissector.offset[FLOW_DISSECTOR_KEY_VLAN] =

0 commit comments

Comments
 (0)