Skip to content

Commit 127fe53

Browse files
Alexander Duyckdavem330
authored andcommitted
v3 ethtool: add ntuple flow specifier data to network flow classifier
This change is meant to add an ntuple data extensions to the rx network flow classification specifiers. The idea is to allow ntuple to be displayed via the network flow classification interface. The first patch had some left over stuff from the original flow extension flags I had added. That bit is removed in this patch. The second had some left over comments that stated we ignored bits in the masks when we actually match them. This work is based on input from Ben Hutchings. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Reviewed-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5d9f11c commit 127fe53

2 files changed

Lines changed: 39 additions & 28 deletions

File tree

‎include/linux/ethtool.h‎

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -380,27 +380,42 @@ struct ethtool_usrip4_spec {
380380
__u8 proto;
381381
};
382382

383+
union ethtool_flow_union {
384+
struct ethtool_tcpip4_spec tcp_ip4_spec;
385+
struct ethtool_tcpip4_spec udp_ip4_spec;
386+
struct ethtool_tcpip4_spec sctp_ip4_spec;
387+
struct ethtool_ah_espip4_spec ah_ip4_spec;
388+
struct ethtool_ah_espip4_spec esp_ip4_spec;
389+
struct ethtool_usrip4_spec usr_ip4_spec;
390+
struct ethhdr ether_spec;
391+
__u8 hdata[60];
392+
};
393+
394+
struct ethtool_flow_ext {
395+
__be16 vlan_etype;
396+
__be16 vlan_tci;
397+
__be32 data[2];
398+
};
399+
383400
/**
384401
* struct ethtool_rx_flow_spec - specification for RX flow filter
385402
* @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW
386403
* @h_u: Flow fields to match (dependent on @flow_type)
387-
* @m_u: Masks for flow field bits to be ignored
404+
* @h_ext: Additional fields to match
405+
* @m_u: Masks for flow field bits to be matched
406+
* @m_ext: Masks for additional field bits to be matched
407+
* Note, all additional fields must be ignored unless @flow_type
408+
* includes the %FLOW_EXT flag.
388409
* @ring_cookie: RX ring/queue index to deliver to, or %RX_CLS_FLOW_DISC
389410
* if packets should be discarded
390411
* @location: Index of filter in hardware table
391412
*/
392413
struct ethtool_rx_flow_spec {
393414
__u32 flow_type;
394-
union {
395-
struct ethtool_tcpip4_spec tcp_ip4_spec;
396-
struct ethtool_tcpip4_spec udp_ip4_spec;
397-
struct ethtool_tcpip4_spec sctp_ip4_spec;
398-
struct ethtool_ah_espip4_spec ah_ip4_spec;
399-
struct ethtool_ah_espip4_spec esp_ip4_spec;
400-
struct ethtool_usrip4_spec usr_ip4_spec;
401-
struct ethhdr ether_spec;
402-
__u8 hdata[72];
403-
} h_u, m_u;
415+
union ethtool_flow_union h_u;
416+
struct ethtool_flow_ext h_ext;
417+
union ethtool_flow_union m_u;
418+
struct ethtool_flow_ext m_ext;
404419
__u64 ring_cookie;
405420
__u32 location;
406421
};
@@ -458,16 +473,10 @@ struct ethtool_rxnfc {
458473

459474
struct compat_ethtool_rx_flow_spec {
460475
u32 flow_type;
461-
union {
462-
struct ethtool_tcpip4_spec tcp_ip4_spec;
463-
struct ethtool_tcpip4_spec udp_ip4_spec;
464-
struct ethtool_tcpip4_spec sctp_ip4_spec;
465-
struct ethtool_ah_espip4_spec ah_ip4_spec;
466-
struct ethtool_ah_espip4_spec esp_ip4_spec;
467-
struct ethtool_usrip4_spec usr_ip4_spec;
468-
struct ethhdr ether_spec;
469-
u8 hdata[72];
470-
} h_u, m_u;
476+
union ethtool_flow_union h_u;
477+
struct ethtool_flow_ext h_ext;
478+
union ethtool_flow_union m_u;
479+
struct ethtool_flow_ext m_ext;
471480
compat_u64 ring_cookie;
472481
u32 location;
473482
};
@@ -1072,6 +1081,8 @@ struct ethtool_ops {
10721081
#define IPV4_FLOW 0x10 /* hash only */
10731082
#define IPV6_FLOW 0x11 /* hash only */
10741083
#define ETHER_FLOW 0x12 /* spec only (ether_spec) */
1084+
/* Flag to enable additional fields in struct ethtool_rx_flow_spec */
1085+
#define FLOW_EXT 0x80000000
10751086

10761087
/* L3-L4 network traffic flow hash options */
10771088
#define RXH_L2DA (1 << 1)

‎net/socket.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2643,21 +2643,21 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
26432643
return -EFAULT;
26442644

26452645
if (convert_in) {
2646-
/* We expect there to be holes between fs.m_u and
2646+
/* We expect there to be holes between fs.m_ext and
26472647
* fs.ring_cookie and at the end of fs, but nowhere else.
26482648
*/
2649-
BUILD_BUG_ON(offsetof(struct compat_ethtool_rxnfc, fs.m_u) +
2650-
sizeof(compat_rxnfc->fs.m_u) !=
2651-
offsetof(struct ethtool_rxnfc, fs.m_u) +
2652-
sizeof(rxnfc->fs.m_u));
2649+
BUILD_BUG_ON(offsetof(struct compat_ethtool_rxnfc, fs.m_ext) +
2650+
sizeof(compat_rxnfc->fs.m_ext) !=
2651+
offsetof(struct ethtool_rxnfc, fs.m_ext) +
2652+
sizeof(rxnfc->fs.m_ext));
26532653
BUILD_BUG_ON(
26542654
offsetof(struct compat_ethtool_rxnfc, fs.location) -
26552655
offsetof(struct compat_ethtool_rxnfc, fs.ring_cookie) !=
26562656
offsetof(struct ethtool_rxnfc, fs.location) -
26572657
offsetof(struct ethtool_rxnfc, fs.ring_cookie));
26582658

26592659
if (copy_in_user(rxnfc, compat_rxnfc,
2660-
(void *)(&rxnfc->fs.m_u + 1) -
2660+
(void *)(&rxnfc->fs.m_ext + 1) -
26612661
(void *)rxnfc) ||
26622662
copy_in_user(&rxnfc->fs.ring_cookie,
26632663
&compat_rxnfc->fs.ring_cookie,
@@ -2674,7 +2674,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
26742674

26752675
if (convert_out) {
26762676
if (copy_in_user(compat_rxnfc, rxnfc,
2677-
(const void *)(&rxnfc->fs.m_u + 1) -
2677+
(const void *)(&rxnfc->fs.m_ext + 1) -
26782678
(const void *)rxnfc) ||
26792679
copy_in_user(&compat_rxnfc->fs.ring_cookie,
26802680
&rxnfc->fs.ring_cookie,

0 commit comments

Comments
 (0)