Netdev List
 help / color / mirror / Atom feed
From: Tariq Toukan <tariqt@nvidia.com>
To: Artemii Mashanov <ralerrdirsardx@gmail.com>, netdev@vger.kernel.org
Cc: Tariq Toukan <tariqt@nvidia.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH net] net: mlx4_en: report the actual RX classification rule count
Date: Wed, 25 Nov 2026 08:51:27 +0200	[thread overview]
Message-ID: <45be0f94-53a5-4ac8-b00a-760a28fce293@nvidia.com> (raw)
In-Reply-To: <20261121001414.724236-1-ralerrdirsardx@gmail.com>



On 21/11/2026 2:14, Artemii Mashanov wrote:
> mlx4_en_get_rxnfc() treats the input rule_cnt as the number of
> rules it needs to find for ETHTOOL_GRXCLSRLALL.
> 
> With room for four locations and only one rule installed, the
> ioctl succeeds with rule_cnt still set to four and three extra
> zero entries. When the buffer has too few slots, the ioctl
> succeeds with an incomplete list.
> 
> Bound the scan by the rule table size, skip empty slots and
> propagate unexpected lookup errors. Return -EMSGSIZE when the next
> rule cannot fit and set rule_cnt to the number of copied locations
> on success.
> 
> The source-extracted ASan/UBSan regression tests passed.
> 
> Fixes: 820672812f82 ("net/mlx4_en: Manage flow steering rules with ethtool")
> Signed-off-by: Artemii Mashanov <ralerrdirsardx@gmail.com>
> ---
>   drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 16 +++++++++++-----
>   1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> index 4ba1947..463c1a4 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> @@ -1739,8 +1739,9 @@ static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
>   {
>   	struct mlx4_en_priv *priv = netdev_priv(dev);
>   	struct mlx4_en_dev *mdev = priv->mdev;
> +	u32 count = 0;
>   	int err = 0;
> -	int i = 0, priority = 0;
> +	int i;
>   
>   	if ((cmd->cmd == ETHTOOL_GRXCLSRLCNT ||
>   	     cmd->cmd == ETHTOOL_GRXCLSRULE ||
> @@ -1758,12 +1759,17 @@ static int mlx4_en_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
>   		break;
>   	case ETHTOOL_GRXCLSRLALL:
>   		cmd->data = MAX_NUM_OF_FS_RULES;
> -		while ((!err || err == -ENOENT) && priority < cmd->rule_cnt) {
> +		for (i = 0; i < MAX_NUM_OF_FS_RULES; i++) {
>   			err = mlx4_en_get_flow(dev, cmd, i);
> -			if (!err)
> -				rule_locs[priority++] = i;
> -			i++;
> +			if (err == -ENOENT)
> +				continue;
> +			if (err)
> +				return err;
> +			if (count == cmd->rule_cnt)
> +				return -EMSGSIZE;
> +			rule_locs[count++] = i;
>   		}
> +		cmd->rule_cnt = count;
>   		err = 0;
>   		break;
>   	default:

Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Thanks.

      parent reply	other threads:[~2026-11-25  6:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21  0:14 [PATCH net] net: mlx4_en: report the actual RX classification rule count Artemii Mashanov
2026-11-21  0:17 ` netdev-bot+sinfo
2026-11-21 20:56   ` Artemii Mashanov
2026-11-25  6:51 ` Tariq Toukan [this message]

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=45be0f94-53a5-4ac8-b00a-760a28fce293@nvidia.com \
    --to=tariqt@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ralerrdirsardx@gmail.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