i40e: explicitly fail on extended MAC field for ethtool_rx_flow_spec
Subsystems (2)
PATCH 10/11 i40e: explicitly fail on extended MAC field for ethtool_rx_flow_spec
Although we will fail the filter later due to checking flow_type which will have a bogus invalid type, it is possible future refactoring will remove this hidden failure case. Avoid a possible issue in the future by explicitly checking the flow type at the start.
--- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +4 -0
@@ -2733,6 +2733,10 @@ static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi, fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; +/* Extended MAC field is not supported */ +if (fsp->flow_type &FLOW_MAC_EXT ) +return -EINVAL ; +if (fsp->location >= (pf->hw.func_caps.fd_filters_best_effort + pf->hw.func_caps.fd_filters_guaranteed)) {return -EINVAL ;
Signature · 1 line
2.12.0.rc0.151.g8a5726c42288
PATCH 11/11 i40e: always remove old filter when adding new FDir filter
The previous code relied on i40e_match_fdir_input_set to determine when determining whether to free the old filter. Change this code so that we simply unconditionally delete the old filter, even if it's identical to the new filter. This ensures that we don't leak any memory, and that we always update the filters as expected.
--- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 32 ++++++-------------------- 1 file changed, 7 insertions(+), 25 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +7 -25
@@ -2582,24 +2582,6 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)return 0 ; } -/** -* i40e_match_fdir_input_set - Match a new filter against an existing one -* @rule: The filter already added -* @input: The new filter to comapre against -* -* Returns true if the two input set match -**/ -static bool i40e_match_fdir_input_set (struct i40e_fdir_filter *rule, -struct i40e_fdir_filter *input) -{ -if ((rule->dst_ip != input->dst_ip) || - (rule->src_ip != input->src_ip) || - (rule->dst_port != input->dst_port) || - (rule->src_port != input->src_port)) -return false; -return true; -} -/** * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry * @vsi: Pointer to the targeted VSI
@@ -2635,22 +2617,22 @@ static int i40e_update_ethtool_fdir_entry(struct i40e_vsi *vsi,/* if there is an old rule occupying our place remove it */ if (rule && (rule->fd_id == sw_idx)) { -if (input && !i40e_match_fdir_input_set (rule, input)) - err =i40e_add_del_fdir (vsi, rule, false); -else if (!input) - err =i40e_add_del_fdir (vsi, rule, false); +/* Remove this rule, since we're either deleting it, or +* replacing it. +*/ + err =i40e_add_del_fdir (vsi, rule, false);hlist_del (&rule->fdir_node);kfree (rule); pf->fdir_pf_active_filters--; } -/* If no input this was a delete, err should be 0 if a rule was -* successfully found and removed from the list else -EINVAL +/* If we weren't given an input, this is a delete, so just return the +* error code indicating if there was an entry at the requested slot */ if (!input)return err; -/* initialize node and set software index */ +/* Otherwise, install the new rule as requested */ INIT_HLIST_NODE (&input->fdir_node);/* add filter to the list */
Signature · 1 line
2.12.0.rc0.151.g8a5726c42288
Bowers
PATCH 11/11 i40e: always remove old filter when adding new FDir filter
Quoted 14 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, February 6, 2017 2:39 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PART1 PATCH 11/11] i40e: always remove old filter when adding new FDir filterThe previous code relied on
i40e_match_fdir_input_setto determine when determining whether to free the old filter. Change this code so that we simply unconditionally delete the old filter, even if it's identical to the new filter. This ensures that we don't leak any memory, and that we always update the filters as expected.
Quoted 4 lines
Signed-off-by Jacob Keller <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 32 ++++++-------------------- 1 file changed, 7 insertions(+), 25 deletions(-)
Bowers
PATCH 10/11 i40e: explicitly fail on extended MAC field for ethtool_rx_flow_spec
In reply to Jacob KellerQuoted 13 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at lists.osuosl.org] On Behalf Of Jacob Keller
Sent: Monday, February 6, 2017 2:39 PM
To: Intel Wired LAN <[email protected]>
Subject: [Intel-wired-lan] [PART1 PATCH 10/11] i40e: explicitly fail on extended MAC field forethtool_rx_flow_specAlthough we will fail the filter later due to checking
flow_typewhich will have a bogus invalid type, it is possible future refactoring will remove this hidden failure case. Avoid a possible issue in the future by explicitly checking the flow type at the start.
Quoted 5 lines
Signed-off-by Jacob Keller <[email protected]>Change-Id Ia98eb26f7b93ccbe38c7141e8f203ef496fc6598--- drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 4 ++++ 1 file changed, 4 insertions(+)