From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by dpdk.space (Postfix) with ESMTP id 7D53FA05FE
	for <public@inbox.dpdk.org>; Mon, 18 Mar 2019 19:20:52 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 0E20A4C95;
	Mon, 18 Mar 2019 19:20:51 +0100 (CET)
Received: from ubuntu64.mapleworks.com
 (modemcable226.69-70-69.static.videotron.ca [69.70.69.226])
 by dpdk.org (Postfix) with ESMTP id 32BF12C60;
 Mon, 18 Mar 2019 19:20:49 +0100 (CET)
Received: by ubuntu64.mapleworks.com (Postfix, from userid 1001)
 id 7AFAA3A00CA; Mon, 18 Mar 2019 14:20:48 -0400 (EDT)
From: olegpoly123 <olegp123@walla.co.il>
To: keith.wiles@intel.com,
	thomas@monjalon.net
Cc: dev@dpdk.org,
	olegpoly123 <olegp123@walla.co.il>,
	stable@dpdk.org
Date: Mon, 18 Mar 2019 14:20:47 -0400
Message-Id: <20190318182047.5210-1-olegp123@walla.co.il>
X-Mailer: git-send-email 2.14.1
Subject: [dpdk-dev] [PATCH v7] net/tap: fix missing _SC_IOV_MAX
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <20190318182047.LKMV9U3YnXmZNU_jv0sHd__xjl1qpLR4Jn8m93_B1rA@z>

If the value _SC_IOV_MAX is missing, sysconf returns -1.
In this case, iov_max is set to a default value of 1024.
This should never happen except for redhat bug:
   https://bugzilla.redhat.com/show_bug.cgi?id=1504165

Fixes: ec12df9504fe ("net/tap: fix support for large Rx queues")
Cc: stable@dpdk.org

Signed-off-by: Oleg Polyakov <olegp123@walla.co.il>
Acked-by: Keith Wiles <keith.wiles@intel.com>
---
 drivers/net/tap/rte_eth_tap.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 6f5109fca..9aae4c77f 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -68,6 +68,8 @@
 /* IPC key for queue fds sync */
 #define TAP_MP_KEY "tap_mp_sync_queues"
 
+#define TAP_IOV_DEFAULT_MAX 1024
+
 static int tap_devices_count;
 static struct rte_vdev_driver pmd_tap_drv;
 static struct rte_vdev_driver pmd_tun_drv;
@@ -1326,6 +1328,13 @@ tap_rx_queue_setup(struct rte_eth_dev *dev,
 	struct rx_queue *rxq = &internals->rxq[rx_queue_id];
 	struct rte_mbuf **tmp = &rxq->pool;
 	long iov_max = sysconf(_SC_IOV_MAX);
+
+	if (iov_max <= 0) {
+		TAP_LOG(WARNING,
+			"_SC_IOV_MAX is not defined. Using %d as default",
+			TAP_IOV_DEFAULT_MAX);
+		iov_max = TAP_IOV_DEFAULT_MAX;
+	}
 	uint16_t nb_desc = RTE_MIN(nb_rx_desc, iov_max - 1);
 	struct iovec (*iovecs)[nb_desc + 1];
 	int data_off = RTE_PKTMBUF_HEADROOM;
-- 
2.14.1