net: ethtool: Allow matching on vlan CFI bit
Subsystems (2)
PATCH 1/1 net: ethtool: Allow matching on vlan CFI bit
Using ethtool, users can specify a classification action matching on the full vlan tag, which includes the CFI bit.
However, when converting the ethool_flow_spec to a flow_rule, we use dissector keys to represent the matching patterns.
Since the vlan dissector key doesn't include the CFI bit, this information was silently discarded when translating the ethtool flow spec in to a flow_rule.
This commit adds the CFI bit into the vlan dissector key, and allows propagating the information to the driver when parsing the ethtool flow spec.
---
Hi all,
Although this prevents information to be silently discarded when parsing an ethtool_flow_spec, this information doesn't seem to be used by any driver that converts an ethtool_flow_spec to a flow_rule, hence I'm not sure this is suitable for -net.
Thanks,
Maxime
include/net/flow_dissector.h | 1 + net/core/ethtool.c | 5 +++++ 2 files changed, 6 insertions(+)
include/net/flow_dissector.h +1 -0
@@ -46,6 +46,7 @@ struct flow_dissector_key_tags {struct flow_dissector_key_vlan {u16 vlan_id:12 , + vlan_cfi:1 , vlan_priority:3 ;__be16 vlan_tpid; };
net/core/ethtool.c +5 -0
@@ -3020,6 +3020,11 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input) match->mask.vlan.vlan_id =ntohs (ext_m_spec->vlan_tci) &0x0fff ; + match->key.vlan.vlan_cfi = + !!(ntohs (ext_h_spec->vlan_tci) &0x1000 ); + match->mask.vlan.vlan_cfi = + !!(ntohs (ext_m_spec->vlan_tci) &0x1000 ); + match->key.vlan.vlan_priority = (ntohs (ext_h_spec->vlan_tci) &0xe000 ) >>13 ; match->mask.vlan.vlan_priority =
Signature · 1 line
2.20.1
Quoted 50 lines · Maxime Chevallier
Using ethtool, users can specify a classification action matching on the full vlan tag, which includes the CFI bit.
However, when converting the
ethool_flow_specto aflow_rule, we use dissector keys to represent the matching patterns.Since the vlan dissector key doesn't include the CFI bit, this information was silently discarded when translating the ethtool flow spec in to a
flow_rule.This commit adds the CFI bit into the vlan dissector key, and allows propagating the information to the driver when parsing the ethtool flow spec.
Fixes eca4205f9ec3 ("ethtool: add ethtool_rx_flow_spec to flow_rule structure translator")Reported-by Michał Mirosław <[email protected]>Signed-off-by Maxime Chevallier <[email protected]>---
Hi all,Although this prevents information to be silently discarded when parsing an
ethtool_flow_spec, this information doesn't seem to be used by any driver that converts anethtool_flow_specto aflow_rule, hence I'm not sure this is suitable for -net.Thanks,
Maxime
include/net/flow_dissector.h | 1 + net/core/ethtool.c | 5 +++++ 2 files changed, 6 insertions(+)include/net/flow_dissector.h +1
-0@@ -46,6 +46,7 @@ struct flow_dissector_key_tags {struct flow_dissector_key_vlan {u16 vlan_id:12 , + vlan_cfi:1 , vlan_priority:3 ;__be16 vlan_tpid; };net/core/ethtool.c +0
-0
net/core/ethtool.c ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input) · line 3026
Quoted 7 lines
net/core/ethtool.c +4
-0@@ -3020,6 +3020,11 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input) match->mask.vlan.vlan_id =ntohs (ext_m_spec->vlan_tci) &0x0fff ; + match->key.vlan.vlan_cfi = + !!(ntohs (ext_h_spec->vlan_tci) &0x1000 ); + match->mask.vlan.vlan_cfi = + !!(ntohs (ext_m_spec->vlan_tci) &0x1000 );
nit: since you're only using the output as a boolean, you can apply the
byteswap to the constant and have it performed at build time. Another option is be16_get_bits() from linux/bitfield.h.
Quoted 3 lines
net/core/ethtool.c +0
-0match->key.vlan.vlan_priority = (ntohs (ext_h_spec->vlan_tci) &0xe000 ) >>13 ; match->mask.vlan.vlan_priority =
Quoted 38 lines · Maxime Chevallier
Using ethtool, users can specify a classification action matching on the full vlan tag, which includes the CFI bit.
However, when converting the
ethool_flow_specto aflow_rule, we use dissector keys to represent the matching patterns.Since the vlan dissector key doesn't include the CFI bit, this information was silently discarded when translating the ethtool flow spec in to a
flow_rule.This commit adds the CFI bit into the vlan dissector key, and allows propagating the information to the driver when parsing the ethtool flow spec.
Fixes eca4205f9ec3 ("ethtool: add ethtool_rx_flow_spec to flow_rule structure translator")Reported-by Michał Mirosław <[email protected]>Signed-off-by Maxime Chevallier <[email protected]>---
Hi all,Although this prevents information to be silently discarded when parsing an
ethtool_flow_spec, this information doesn't seem to be used by any driver that converts anethtool_flow_specto aflow_rule, hence I'm not sure this is suitable for -net.Thanks,
Maxime
include/net/flow_dissector.h | 1 + net/core/ethtool.c | 5 +++++ 2 files changed, 6 insertions(+)include/net/flow_dissector.h +0
-0
include/net/flow_dissector.h struct flow_dissector_key_tags { · line 49
Quoted 4 lines
include/net/flow_dissector.h +1
-0@@ -46,6 +46,7 @@ struct flow_dissector_key_tags {struct flow_dissector_key_vlan {u16 vlan_id:12 , + vlan_cfi:1,
Current IEEE 802.1Q defines this bit as DEI not CFI, so IMO this should be vlan_dei.
Toshiaki Makita