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.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
This commit is contained in:
Jacob Keller 2017-02-06 14:39:13 -08:00 committed by Jeff Kirsher
parent 1ec8deac8c
commit c6da525de7

View file

@ -2620,24 +2620,6 @@ static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc)
return 0; 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 * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry
* @vsi: Pointer to the targeted VSI * @vsi: Pointer to the targeted VSI
@ -2673,22 +2655,22 @@ static int i40e_update_ethtool_fdir_entry(struct i40e_vsi *vsi,
/* if there is an old rule occupying our place remove it */ /* if there is an old rule occupying our place remove it */
if (rule && (rule->fd_id == sw_idx)) { if (rule && (rule->fd_id == sw_idx)) {
if (input && !i40e_match_fdir_input_set(rule, input)) /* Remove this rule, since we're either deleting it, or
err = i40e_add_del_fdir(vsi, rule, false); * replacing it.
else if (!input) */
err = i40e_add_del_fdir(vsi, rule, false); err = i40e_add_del_fdir(vsi, rule, false);
hlist_del(&rule->fdir_node); hlist_del(&rule->fdir_node);
kfree(rule); kfree(rule);
pf->fdir_pf_active_filters--; pf->fdir_pf_active_filters--;
} }
/* If no input this was a delete, err should be 0 if a rule was /* If we weren't given an input, this is a delete, so just return the
* successfully found and removed from the list else -EINVAL * error code indicating if there was an entry at the requested slot
*/ */
if (!input) if (!input)
return err; return err;
/* initialize node and set software index */ /* Otherwise, install the new rule as requested */
INIT_HLIST_NODE(&input->fdir_node); INIT_HLIST_NODE(&input->fdir_node);
/* add filter to the list */ /* add filter to the list */