iavf: fix FDIR rule fields masks validation
Subsystems (2)
PATCH 1/1 iavf: fix FDIR rule fields masks validation
Return an error if a field's mask is neither full nor empty. When a mask is only partial the field is not being used for rule programming but it gives a wrong impression it is used. Fix by returning an error on any partial mask to make it clear they are not supported.
The ip_ver assignment is moved earlier in code to allow using it in iavf_validate_fdir_fltr_masks.
--- .../net/ethernet/intel/iavf/iavf_ethtool.c | 10 +++ drivers/net/ethernet/intel/iavf/iavf_fdir.c | 77 ++++++++++++++++++- drivers/net/ethernet/intel/iavf/iavf_fdir.h | 2 + 3 files changed, 85 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_ethtool.c +10 -0
@@ -1289,6 +1289,7 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe fltr->ip_mask.src_port = fsp->m_u.tcp_ip4_spec.psrc; fltr->ip_mask.dst_port = fsp->m_u.tcp_ip4_spec.pdst; fltr->ip_mask.tos = fsp->m_u.tcp_ip4_spec.tos; + fltr->ip_ver =4 ;break ;case AH_V4_FLOW :case ESP_V4_FLOW :
@@ -1300,6 +1301,7 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe fltr->ip_mask.v4_addrs.dst_ip = fsp->m_u.ah_ip4_spec.ip4dst; fltr->ip_mask.spi = fsp->m_u.ah_ip4_spec.spi; fltr->ip_mask.tos = fsp->m_u.ah_ip4_spec.tos; + fltr->ip_ver =4 ;break ;case IPV4_USER_FLOW : fltr->ip_data.v4_addrs.src_ip = fsp->h_u.usr_ip4_spec.ip4src;
@@ -1312,6 +1314,7 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe fltr->ip_mask.l4_header = fsp->m_u.usr_ip4_spec.l4_4_bytes; fltr->ip_mask.tos = fsp->m_u.usr_ip4_spec.tos; fltr->ip_mask.proto = fsp->m_u.usr_ip4_spec.proto; + fltr->ip_ver =4 ;break ;case TCP_V6_FLOW :case UDP_V6_FLOW :
@@ -1330,6 +1333,7 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe fltr->ip_mask.src_port = fsp->m_u.tcp_ip6_spec.psrc; fltr->ip_mask.dst_port = fsp->m_u.tcp_ip6_spec.pdst; fltr->ip_mask.tclass = fsp->m_u.tcp_ip6_spec.tclass; + fltr->ip_ver =6 ;break ;case AH_V6_FLOW :case ESP_V6_FLOW :
@@ -1345,6 +1349,7 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe sizeof(struct in6_addr)); fltr->ip_mask.spi = fsp->m_u.ah_ip6_spec.spi; fltr->ip_mask.tclass = fsp->m_u.ah_ip6_spec.tclass; + fltr->ip_ver =6 ;break ;case IPV6_USER_FLOW : memcpy(&fltr->ip_data.v6_addrs.src_ip, fsp->h_u.usr_ip6_spec.ip6src,
@@ -1361,6 +1366,7 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spe fltr->ip_mask.l4_header = fsp->m_u.usr_ip6_spec.l4_4_bytes; fltr->ip_mask.tclass = fsp->m_u.usr_ip6_spec.tclass; fltr->ip_mask.proto = fsp->m_u.usr_ip6_spec.l4_proto; + fltr->ip_ver =6 ;break ;case ETHER_FLOW : fltr->eth_data.etype = fsp->h_u.ether_spec.h_proto;
@@ -1371,6 +1377,10 @@ iavf_add_fdir_fltr_info(struct iavf_adapter *adapter, struct ethtool_rx_flow_spereturn -EINVAL ; } + err =iavf_validate_fdir_fltr_masks (adapter, fltr); +if (err) +return err; +if (iavf_fdir_is_dup_fltr (adapter, fltr))return -EEXIST ;
drivers/net/ethernet/intel/iavf/iavf_fdir.c +73 -4
95 lines not on this page · raw message
drivers/net/ethernet/intel/iavf/iavf_fdir.h +2 -0
@@ -110,6 +110,8 @@ struct iavf_fdir_fltr {struct virtchnl_fdir_add vc_add_msg; }; +int iavf_validate_fdir_fltr_masks (struct iavf_adapter *adapter, +struct iavf_fdir_fltr *fltr);int iavf_fill_fdir_add_msg (struct iavf_adapter *adapter,struct iavf_fdir_fltr *fltr);void iavf_print_fdir_fltr (struct iavf_adapter *adapter,struct iavf_fdir_fltr *fltr);bool iavf_fdir_is_dup_fltr (struct iavf_adapter *adapter,struct iavf_fdir_fltr *fltr);
Signature · 6 lines
2.34.1 _______________________________________________ Intel-wired-lan mailing list [email protected] https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
drivers/net/ethernet/intel/iavf/iavf_ethtool.c
Quoted 29 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Piotr Gardocki
Sent: poniedziałek, 7 sierpnia 2023 16:46
To: [email protected]
Subject: [Intel-wired-lan] [PATCH iwl-net] iavf: fix FDIR rule fields masks validationReturn an error if a field's mask is neither full nor empty. When a mask is only partial the field is not being used for rule programming but it gives a wrong impression it is used. Fix by returning an error on any partial mask to make it clear they are not supported.
Theip_verassignment is moved earlier in code to allow using it iniavf_validate_fdir_fltr_masks.Fixes 527691bf0682 ("iavf: Support IPv4 Flow Director filters")Fixes e90cbc257a6f ("iavf: Support IPv6 Flow Director filters")Signed-off-by Piotr Gardocki <[email protected]>--- .../net/ethernet/intel/iavf/iavf_ethtool.c | 10 +++ drivers/net/ethernet/intel/iavf/iavf_fdir.c | 77 ++++++++++++++++++- drivers/net/ethernet/intel/iavf/iavf_fdir.h | 2 + 3 files changed, 85 insertions(+), 4 deletions(-)drivers/net/ethernet/intel/iavf/iavf_ethtool.c +0
-0
_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan