net/ixgbe: add queue index check in filter
authorWei Zhao <wei.zhao1@intel.com>
Wed, 19 Jul 2017 03:34:33 +0000 (11:34 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 19 Jul 2017 13:25:43 +0000 (16:25 +0300)
Add queue index check when create filter rule, or
filter with invalid queue id can be created successfully.

Signed-off-by: Wei Zhao <wei.zhao1@intel.com>
drivers/net/ixgbe/ixgbe_flow.c

index bbe06e8..b34835a 100644 (file)
@@ -487,9 +487,7 @@ ixgbe_parse_ntuple_filter(struct rte_eth_dev *dev,
                return -rte_errno;
        }
 
-       if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM ||
-               filter->priority > IXGBE_5TUPLE_MAX_PRI ||
-               filter->priority < IXGBE_5TUPLE_MIN_PRI)
+       if (filter->queue >= dev->data->nb_rx_queues)
                return -rte_errno;
 
        /* fixed value for ixgbe */
@@ -706,7 +704,7 @@ ixgbe_parse_ethertype_filter(struct rte_eth_dev *dev,
                return -rte_errno;
        }
 
-       if (filter->queue >= IXGBE_MAX_RX_QUEUE_NUM) {
+       if (filter->queue >= dev->data->nb_rx_queues) {
                memset(filter, 0, sizeof(struct rte_eth_ethertype_filter));
                rte_flow_error_set(error, EINVAL,
                        RTE_FLOW_ERROR_TYPE_ITEM,
@@ -983,6 +981,9 @@ ixgbe_parse_syn_filter(struct rte_eth_dev *dev,
        ret = cons_parse_syn_filter(attr, pattern,
                                        actions, filter, error);
 
+       if (filter->queue >= dev->data->nb_rx_queues)
+               return -rte_errno;
+
        if (ret)
                return ret;
 
@@ -1176,6 +1177,9 @@ ixgbe_parse_l2_tn_filter(struct rte_eth_dev *dev,
                return -rte_errno;
        }
 
+       if (l2_tn_filter->pool >= dev->data->nb_rx_queues)
+               return -rte_errno;
+
        return ret;
 }
 
@@ -2551,6 +2555,10 @@ step_next:
        if (fdir_mode == RTE_FDIR_MODE_NONE ||
            fdir_mode != rule->mode)
                return -ENOTSUP;
+
+       if (rule->queue >= dev->data->nb_rx_queues)
+               return -ENOTSUP;
+
        return ret;
 }