From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Cc: <netdev@vger.kernel.org>,
Piotr Skajewski <piotrx.skajewski@intel.com>,
<intel-wired-lan@lists.osuosl.org>, <anthony.l.nguyen@intel.com>
Subject: Re: [PATCH iwl-next 3/8] ixgbe: prevent adding duplicate FDIR perfect filter rules
Date: Fri, 8 May 2026 06:44:13 +0200 [thread overview]
Message-ID: <dd912f90-9087-4a85-8676-852679845f21@intel.com> (raw)
In-Reply-To: <20260508031226.3601800-4-aleksandr.loktionov@intel.com>
On 5/8/26 05:12, Aleksandr Loktionov wrote:
> From: Piotr Skajewski <piotrx.skajewski@intel.com>
>
> When the same flow specification is added twice (same 5-tuple with
> different sw_idx values), ixgbe_add_ethtool_fdir_entry() silently
> programs the duplicate into hardware using a second FDIR table slot.
> This wastes a scarce FDIR entry and can cause confusing behaviour
> when deleting rules.
>
> Add a helper ixgbe_match_ethtool_fdir_entry() that walks the in-kernel
> filter list before programming hardware. If an entry with an
> identical filter (excluding the sw_idx) already exists, the new add
> request is rejected with -EEXIST.
>
> Signed-off-by: Piotr Skajewski <piotrx.skajewski@intel.com>
> Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> ---
> .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 27 +++++++++++++++++--
> 1 file changed, 25 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> index ba049b3..a2009df 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
> @@ -2938,6 +2938,23 @@ static int ixgbe_flowspec_to_flow_type(struct ethtool_rx_flow_spec *fsp,
> return 1;
> }
>
> +static bool ixgbe_match_ethtool_fdir_entry(struct ixgbe_adapter *adapter,
> + struct ixgbe_fdir_filter *input)
> +{
> + struct ixgbe_fdir_filter *rule = NULL;
> +
> + hlist_for_each_entry(rule, &adapter->fdir_filter_list, fdir_node) {
> + if (rule->sw_idx == input->sw_idx)
> + continue;
this if makes it possible to add rule with the same filter AND the same
sw_idx
> + if (!memcmp(&rule->filter, &input->filter,
> + sizeof(rule->filter))) {
> + e_warn(drv, "FDIR filter already exists\n");
return code of -EEXIST returned to the user is enough,
no need for a warning here
if you really want a dmesg entry, then make it info and of not alarming
wording
> + return true;
> + }
> + }
> + return false;
> +}
> +
> static int ixgbe_add_ethtool_fdir_entry(struct ixgbe_adapter *adapter,
> struct ethtool_rxnfc *cmd)
> {
> @@ -2947,7 +2964,7 @@ static int ixgbe_add_ethtool_fdir_entry(struct ixgbe_adapter *adapter,
> struct ixgbe_fdir_filter *input;
> union ixgbe_atr_input mask;
> u8 queue;
> - int err;
> + int err = -EINVAL;
RCT
>
> if (!(adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE))
> return -EOPNOTSUPP;
> @@ -3050,6 +3067,12 @@ static int ixgbe_add_ethtool_fdir_entry(struct ixgbe_adapter *adapter,
> /* apply mask and compute/store hash */
> ixgbe_atr_compute_perfect_hash_82599(&input->filter, &mask);
>
> + /* check for a duplicate filter */
> + if (ixgbe_match_ethtool_fdir_entry(adapter, input)) {
> + err = -EEXIST;
> + goto err_out_w_lock;
> + }
> +
> /* program filters to filter memory */
> err = ixgbe_fdir_write_perfect_filter_82599(hw,
> &input->filter, input->sw_idx, queue);
> @@ -3065,7 +3088,7 @@ static int ixgbe_add_ethtool_fdir_entry(struct ixgbe_adapter *adapter,
> spin_unlock(&adapter->fdir_perfect_lock);
> err_out:
> kfree(input);
> - return -EINVAL;
> + return err;
> }
>
> static int ixgbe_del_ethtool_fdir_entry(struct ixgbe_adapter *adapter,
next prev parent reply other threads:[~2026-05-08 4:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 3:12 [PATCH iwl-next 0/8] ixgbe: small cleanups and improvements Aleksandr Loktionov
2026-05-08 3:12 ` [PATCH iwl-next 1/8] ixgbe: rename numa_node to node in struct ixgbe_q_vector Aleksandr Loktionov
2026-05-11 15:27 ` Simon Horman
2026-05-08 3:12 ` [PATCH iwl-next 2/8] ixgbe: use int instead of u32 for error code variables Aleksandr Loktionov
2026-05-08 4:15 ` Przemek Kitszel
2026-05-08 3:12 ` [PATCH iwl-next 3/8] ixgbe: prevent adding duplicate FDIR perfect filter rules Aleksandr Loktionov
2026-05-08 4:44 ` Przemek Kitszel [this message]
2026-05-08 3:12 ` [PATCH iwl-next 4/8] ixgbe: increase SECRX_RDY polling frequency in ixgbe_disable_rx_buff_generic Aleksandr Loktionov
2026-05-11 15:30 ` Simon Horman
2026-05-08 3:12 ` [PATCH iwl-next 5/8] ixgbe: use ktime_get_real_ns() in ixgbe_ptp_reset() Aleksandr Loktionov
2026-05-08 3:12 ` [PATCH iwl-next 6/8] ixgbe: extract ixgbe_restart_auto_neg() to avoid code duplication Aleksandr Loktionov
2026-05-11 15:40 ` Simon Horman
2026-05-08 3:12 ` [PATCH iwl-next 7/8] ixgbe: limit ITR decrease in latency mode to prevent ACK overdrive Aleksandr Loktionov
2026-05-11 15:47 ` Simon Horman
2026-05-08 3:12 ` [PATCH iwl-next 8/8] ixgbe: add IXGBE_ITR_ADAPTIVE_MASK_USECS constant Aleksandr Loktionov
2026-05-11 15:52 ` Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dd912f90-9087-4a85-8676-852679845f21@intel.com \
--to=przemyslaw.kitszel@intel.com \
--cc=aleksandr.loktionov@intel.com \
--cc=anthony.l.nguyen@intel.com \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=netdev@vger.kernel.org \
--cc=piotrx.skajewski@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox