* [PATCH net-next v2] net: ethtool: Allow parsing ETHER_FLOW types when using flow_rule
@ 2019-06-27 8:52 Maxime Chevallier
2019-06-27 11:02 ` Pablo Neira Ayuso
2019-06-27 16:39 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Maxime Chevallier @ 2019-06-27 8:52 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_rx_flow_spec, users can specify an ethernet flow
which could contain matches based on the ethernet header, such as the
MAC address, the VLAN tag or the ethertype.
ETHER_FLOW uses the src and dst ethernet addresses, along with the
ethertype as keys. Matches based on the vlan tag are also possible, but
they are specified using the special FLOW_EXT flag.
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
V2 : Add src and dst mac address parsing, as suggested by Pablo.
net/core/ethtool.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 4d1011b2e24f..6288e69e94fc 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -2883,6 +2883,30 @@ ethtool_rx_flow_rule_create(const struct ethtool_rx_flow_spec_input *input)
match->mask.basic.n_proto = htons(0xffff);
switch (fs->flow_type & ~(FLOW_EXT | FLOW_MAC_EXT | FLOW_RSS)) {
+ case ETHER_FLOW: {
+ const struct ethhdr *ether_spec, *ether_m_spec;
+
+ ether_spec = &fs->h_u.ether_spec;
+ ether_m_spec = &fs->m_u.ether_spec;
+
+ if (!is_zero_ether_addr(ether_m_spec->h_source)) {
+ ether_addr_copy(match->key.eth_addrs.src,
+ ether_spec->h_source);
+ ether_addr_copy(match->mask.eth_addrs.src,
+ ether_m_spec->h_source);
+ }
+ if (!is_zero_ether_addr(ether_m_spec->h_dest)) {
+ ether_addr_copy(match->key.eth_addrs.dst,
+ ether_spec->h_dest);
+ ether_addr_copy(match->mask.eth_addrs.dst,
+ ether_m_spec->h_dest);
+ }
+ if (ether_m_spec->h_proto) {
+ match->key.basic.n_proto = ether_spec->h_proto;
+ match->mask.basic.n_proto = ether_m_spec->h_proto;
+ }
+ }
+ break;
case TCP_V4_FLOW:
case UDP_V4_FLOW: {
const struct ethtool_tcpip4_spec *v4_spec, *v4_m_spec;
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next v2] net: ethtool: Allow parsing ETHER_FLOW types when using flow_rule
2019-06-27 8:52 [PATCH net-next v2] net: ethtool: Allow parsing ETHER_FLOW types when using flow_rule Maxime Chevallier
@ 2019-06-27 11:02 ` Pablo Neira Ayuso
2019-06-27 16:39 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2019-06-27 11:02 UTC (permalink / raw)
To: Maxime Chevallier
Cc: davem, Florian Fainelli, Jiri Pirko, Jakub Kicinski, netdev,
linux-kernel, Antoine Tenart, thomas.petazzoni
On Thu, Jun 27, 2019 at 10:52:26AM +0200, Maxime Chevallier wrote:
> When parsing an ethtool_rx_flow_spec, users can specify an ethernet flow
> which could contain matches based on the ethernet header, such as the
> MAC address, the VLAN tag or the ethertype.
>
> ETHER_FLOW uses the src and dst ethernet addresses, along with the
> ethertype as keys. Matches based on the vlan tag are also possible, but
> they are specified using the special FLOW_EXT flag.
>
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Acked-by: Pablo Neira Ayuso <pablo@gnumonks.org>
Thanks Maxime.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v2] net: ethtool: Allow parsing ETHER_FLOW types when using flow_rule
2019-06-27 8:52 [PATCH net-next v2] net: ethtool: Allow parsing ETHER_FLOW types when using flow_rule Maxime Chevallier
2019-06-27 11:02 ` Pablo Neira Ayuso
@ 2019-06-27 16:39 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-06-27 16:39 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, 27 Jun 2019 10:52:26 +0200
> When parsing an ethtool_rx_flow_spec, users can specify an ethernet flow
> which could contain matches based on the ethernet header, such as the
> MAC address, the VLAN tag or the ethertype.
>
> ETHER_FLOW uses the src and dst ethernet addresses, along with the
> ethertype as keys. Matches based on the vlan tag are also possible, but
> they are specified using the special FLOW_EXT flag.
>
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
> ---
> V2 : Add src and dst mac address parsing, as suggested by Pablo.
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-27 16:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-27 8:52 [PATCH net-next v2] net: ethtool: Allow parsing ETHER_FLOW types when using flow_rule Maxime Chevallier
2019-06-27 11:02 ` Pablo Neira Ayuso
2019-06-27 16:39 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox