net/pcap: check max queue number
authorFerruh Yigit <ferruh.yigit@intel.com>
Fri, 26 Aug 2016 11:17:41 +0000 (12:17 +0100)
committerBruce Richardson <bruce.richardson@intel.com>
Fri, 30 Sep 2016 10:27:18 +0000 (12:27 +0200)
Number of queues is defined by devargs, a check added to be sure this
number is not bigger than configured max number of queue.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
drivers/net/pcap/rte_eth_pcap.c

index 4d0b26e..3bfb7f3 100644 (file)
@@ -1012,12 +1012,21 @@ rte_pmd_pcap_devinit(const char *name, const char *params)
         * We check whether we want to open a RX stream from a real NIC or a
         * pcap file
         */
-       if ((pcaps.num_of_queue = rte_kvargs_count(kvlist, ETH_PCAP_RX_PCAP_ARG))) {
+       pcaps.num_of_queue = rte_kvargs_count(kvlist, ETH_PCAP_RX_PCAP_ARG);
+
+       if (pcaps.num_of_queue) {
+               if (pcaps.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES)
+                       pcaps.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES;
+
                ret = rte_kvargs_process(kvlist, ETH_PCAP_RX_PCAP_ARG,
                                &open_rx_pcap, &pcaps);
        } else {
                pcaps.num_of_queue = rte_kvargs_count(kvlist,
                                ETH_PCAP_RX_IFACE_ARG);
+
+               if (pcaps.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES)
+                       pcaps.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES;
+
                ret = rte_kvargs_process(kvlist, ETH_PCAP_RX_IFACE_ARG,
                                &open_rx_iface, &pcaps);
        }
@@ -1029,14 +1038,22 @@ rte_pmd_pcap_devinit(const char *name, const char *params)
         * We check whether we want to open a TX stream to a real NIC or a
         * pcap file
         */
-       if ((dumpers.num_of_queue = rte_kvargs_count(kvlist,
-                       ETH_PCAP_TX_PCAP_ARG))) {
+       dumpers.num_of_queue = rte_kvargs_count(kvlist, ETH_PCAP_TX_PCAP_ARG);
+
+       if (dumpers.num_of_queue) {
+               if (dumpers.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES)
+                       dumpers.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES;
+
                ret = rte_kvargs_process(kvlist, ETH_PCAP_TX_PCAP_ARG,
                                &open_tx_pcap, &dumpers);
                using_dumpers = 1;
        } else {
                dumpers.num_of_queue = rte_kvargs_count(kvlist,
                                ETH_PCAP_TX_IFACE_ARG);
+
+               if (dumpers.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES)
+                       dumpers.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES;
+
                ret = rte_kvargs_process(kvlist, ETH_PCAP_TX_IFACE_ARG,
                                &open_tx_iface, &dumpers);
        }