[v2,1/2] net/tap: fix missing _SC_IOV_MAX

Message ID 20190308155547.1695-1-olegp123@walla.co.il (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series [v2,1/2] net/tap: fix missing _SC_IOV_MAX |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing fail Performance Testing issues
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

olegpoly123 March 8, 2019, 3:55 p.m. UTC
  If the value _SC_IOV_MAX is missing, sysconf returns -1.
In this case, iov_max is set to a default value of 1024.

Cc: stable@dpdk.org

Signed-off-by: Oeg Polyakov <opolyakov@northforgeinc.com>
---
 drivers/net/tap/rte_eth_tap.c | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Stephen Hemminger March 8, 2019, 5:29 p.m. UTC | #1
On Fri,  8 Mar 2019 10:55:46 -0500
olegpoly123 <olegp123@walla.co.il> wrote:

> diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
> index 6f5109fca..cd48b2b2a 100644
> --- a/drivers/net/tap/rte_eth_tap.c
> +++ b/drivers/net/tap/rte_eth_tap.c
> @@ -1326,6 +1326,11 @@ 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 1024 as default\n");
> +		iov_max = 1024;
> +	}

Blank line between declarations and code please.

This should never happen except for redhat bug: https://bugzilla.redhat.com/show_bug.cgi?id=1504165
  

Patch

diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c
index 6f5109fca..cd48b2b2a 100644
--- a/drivers/net/tap/rte_eth_tap.c
+++ b/drivers/net/tap/rte_eth_tap.c
@@ -1326,6 +1326,11 @@  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 1024 as default\n");
+		iov_max = 1024;
+	}
 	uint16_t nb_desc = RTE_MIN(nb_rx_desc, iov_max - 1);
 	struct iovec (*iovecs)[nb_desc + 1];
 	int data_off = RTE_PKTMBUF_HEADROOM;