net/mlx5: prevent querying aged flows on uninit port
Checks
Commit Message
In HWS template API, the aging mechanism doesn't support shared host
mode now. When the guest's counter is set to 0, the aging won't be
initialized.
The current implementation didn't prevent the user from querying the
aged flows on the uninitialized port. The access of invalid pointers
would cause a crash.
With this commit, the flag of the per port aging initialization will
be checked. This would help to get rid of the invalid accessing.
Fixes: 04a4de756e14 ("net/mlx5: support flow age action with HWS")
Cc: michaelba@nvidia.com
Cc: stable@dpdk.org
Signed-off-by: Bing Zhao <bingz@nvidia.com>
Acked-by: Suanming Mou <suanmingm@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_hw.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
Hi,
> -----Original Message-----
> From: Bing Zhao <bingz@nvidia.com>
> Sent: Wednesday, February 21, 2024 5:23 AM
> To: Suanming Mou <suanmingm@nvidia.com>; Raslan Darawsheh
> <rasland@nvidia.com>; dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Dariusz Sosnowski
> <dsosnowski@nvidia.com>; stable@dpdk.org; Michael Baum
> <michaelba@nvidia.com>
> Subject: [PATCH] net/mlx5: prevent querying aged flows on uninit port
>
> In HWS template API, the aging mechanism doesn't support shared host mode
> now. When the guest's counter is set to 0, the aging won't be initialized.
>
> The current implementation didn't prevent the user from querying the aged
> flows on the uninitialized port. The access of invalid pointers would cause a
> crash.
>
> With this commit, the flag of the per port aging initialization will be checked.
> This would help to get rid of the invalid accessing.
>
> Fixes: 04a4de756e14 ("net/mlx5: support flow age action with HWS")
> Cc: michaelba@nvidia.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Bing Zhao <bingz@nvidia.com>
> Acked-by: Suanming Mou <suanmingm@nvidia.com>
> ---[Raslan Darawsheh]
Patch applied to next-net-mlx
Kindest regards,
Raslan Darawsheh
@@ -10937,6 +10937,10 @@ flow_hw_get_q_aged_flows(struct rte_eth_dev *dev, uint32_t queue_id,
return rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
NULL, "empty context");
+ if (!priv->hws_age_req)
+ return rte_flow_error_set(error, ENOENT,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "No aging initialized");
if (priv->hws_strict_queue) {
if (queue_id >= age_info->hw_q_age->nb_rings)
return rte_flow_error_set(error, EINVAL,