diff mbox

[dpdk-dev,RFC,04/21] net/pcap: add checks for max queue number

Message ID 1469121780-26099-5-git-send-email-ferruh.yigit@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Bruce Richardson
Headers show

Commit Message

Ferruh Yigit July 21, 2016, 5:22 p.m. UTC
Number of queues defined by devargs, a check added to be sure this
number is not bigger than configured queue length.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 34c779a..308b8bc 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -1010,12 +1010,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);
 	}
@@ -1027,14 +1036,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);
 	}