Skip to contentSkip to conversation

net/i40e: fix core dumped when setting txq or rxq to 0 in VF

PATCH Superseded Andy Pei 3 participants 10 messages Jun 21, 2019 – Jul 4, 2019 Network drivers

lore
Share & tools
lore

Andy Pei

author
#0 lore raw

PATCH 1/1 net/i40e: fix core dumped when setting txq or rxq to 0 in VF

Testpmd stucked and core dumped
when set invalid VF queue number.
This patch fix this issue.

Fixes d6b19729093e ("i40evf: support configurable crc stripping")

---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

 drivers/net/i40e/i40e_ethdev_vf.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +28 -7
index 63dbe14..7096cc5 100644
@@ -573,7 +573,7 @@ struct rte_i40evf_xstats_name_off {
 {
 	txq_info->vsi_id = vsi_id;
 	txq_info->queue_id = queue_id;
-	if (queue_id < nb_txq) {
+	if ((queue_id < nb_txq) && txq) {
 		txq_info->ring_len = txq->nb_tx_desc;
 		txq_info->dma_ring_addr = txq->tx_ring_phys_addr;
 	}
@@ -590,7 +590,7 @@ struct rte_i40evf_xstats_name_off {
 	rxq_info->vsi_id = vsi_id;
 	rxq_info->queue_id = queue_id;
 	rxq_info->max_pkt_size = max_pkt_size;
-	if (queue_id < nb_rxq) {
+	if ((queue_id < nb_rxq) && rxq) {
 		rxq_info->ring_len = rxq->nb_rx_desc;
 		rxq_info->dma_ring_addr = rxq->rx_ring_phys_addr;
 		rxq_info->databuffer_size =
@@ -622,11 +622,32 @@ struct rte_i40evf_xstats_name_off {
 	vc_vqci->num_queue_pairs = nb_qp;
 
 	for (i = 0, vc_qpi = vc_vqci->qpair; i < nb_qp; i++, vc_qpi++) {
-		i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
-			vc_vqci->vsi_id, i, dev->data->nb_tx_queues, txq[i]);
-		i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
-			vc_vqci->vsi_id, i, dev->data->nb_rx_queues,
-					vf->max_pkt_len, rxq[i]);
+		if (!txq)
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_tx_queues,
+							NULL);
+		else
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_tx_queues,
+							txq[i]);
+		if (!rxq)
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_rx_queues,
+							vf->max_pkt_len,
+							NULL);
+		else
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_rx_queues,
+							vf->max_pkt_len,
+							rxq[i]);
 	}
 	memset(&args, 0, sizeof(args));
 	args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 3 lines · Andy Pei

Testpmd stucked and core dumped
when set invalid VF queue number.
This patch fix this issue.

It's better to wrap the commit message within 72 characters. Perhaps something like:

Testpmd would stuck and result in core dump when user specifies an invalid VF queue number. This patch fixes this issue.

What do you think?

Quoted 64 lines
Fixes d6b19729093e ("i40evf: support configurable crc stripping")

---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

drivers/net/i40e/i40e_ethdev_vf.c | 35 ++++++++++++++++++++++++++++-------

1 file changed, 28 insertions(+), 7 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +18 -7
index 63dbe14..7096cc5 100644
@@ -573,7 +573,7 @@ struct rte_i40evf_xstats_name_off {
 {
 	txq_info->vsi_id = vsi_id;
 	txq_info->queue_id = queue_id;
-	if (queue_id < nb_txq) {
+	if ((queue_id < nb_txq) && txq) {
 		txq_info->ring_len = txq->nb_tx_desc;
 		txq_info->dma_ring_addr = txq->tx_ring_phys_addr;
 	}
@@ -590,7 +590,7 @@ struct rte_i40evf_xstats_name_off {
 	rxq_info->vsi_id = vsi_id;
 	rxq_info->queue_id = queue_id;
 	rxq_info->max_pkt_size = max_pkt_size;
-	if (queue_id < nb_rxq) {
+	if ((queue_id < nb_rxq) && rxq) {
 		rxq_info->ring_len = rxq->nb_rx_desc;
 		rxq_info->dma_ring_addr = rxq->rx_ring_phys_addr;
 		rxq_info->databuffer_size =
@@ -622,11 +622,32 @@ struct rte_i40evf_xstats_name_off {
 	vc_vqci->num_queue_pairs = nb_qp;
 
 	for (i = 0, vc_qpi = vc_vqci->qpair; i < nb_qp; i++, vc_qpi++) {
-		i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
-			vc_vqci->vsi_id, i, dev->data->nb_tx_queues, txq[i]);
-		i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
-			vc_vqci->vsi_id, i, dev->data->nb_rx_queues,
-					vf->max_pkt_len, rxq[i]);
+		if (!txq)
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_tx_queues,
+							NULL);
+		else
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_tx_queues,
+							txq[i]);
+		if (!rxq)
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+							vc_vqci->vsi_id,
+							i,

drivers/net/i40e/i40e_ethdev_vf.c struct rte_i40evf_xstats_name_off { · line 650

Quoted 10 lines
drivers/net/i40e/i40e_ethdev_vf.c +10 -0
+							dev->data->nb_rx_queues,
+							vf->max_pkt_len,
+							NULL);
+		else
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_rx_queues,
+							vf->max_pkt_len,
+							rxq[i]);

No need to use one line for each parameter, I think you can still use the old format.

Thanks,
Xiaolong

Quoted 6 lines
drivers/net/i40e/i40e_ethdev_vf.c +0 -0
 	}
 	memset(&args, 0, sizeof(args));
 	args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
Signature · 1 line
1.8.3.1
author
#2 lore raw

HI Xiaolong,

Will do in this way in V2.

Thanks

-----Original Message-----
From: Ye, Xiaolong
Sent: Friday, June 21, 2019 7:42 PM
To: Pei, Andy <[email protected]>
Cc: [email protected]; Zhang, Helin <[email protected]>; [email protected]; Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix core dumped when setting txq or rxq to 0 in VF

Quoted 3 lines · Andy Pei

Testpmd stucked and core dumped
when set invalid VF queue number.
This patch fix this issue.

It's better to wrap the commit message within 72 characters. Perhaps something like:

Testpmd would stuck and result in core dump when user specifies an invalid VF queue number. This patch fixes this issue.

What do you think?

Quoted 65 lines
Fixes d6b19729093e ("i40evf: support configurable crc stripping")

---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

drivers/net/i40e/i40e_ethdev_vf.c | 35
++++++++++++++++++++++++++++-------

1 file changed, 28 insertions(+), 7 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +18 -7
index 63dbe14..7096cc5 100644
@@ -573,7 +573,7 @@ struct rte_i40evf_xstats_name_off {  {
 	txq_info->vsi_id = vsi_id;
 	txq_info->queue_id = queue_id;
-	if (queue_id < nb_txq) {
+	if ((queue_id < nb_txq) && txq) {
 		txq_info->ring_len = txq->nb_tx_desc;
 		txq_info->dma_ring_addr = txq->tx_ring_phys_addr;
 	}
@@ -590,7 +590,7 @@ struct rte_i40evf_xstats_name_off {
 	rxq_info->vsi_id = vsi_id;
 	rxq_info->queue_id = queue_id;
 	rxq_info->max_pkt_size = max_pkt_size;
-	if (queue_id < nb_rxq) {
+	if ((queue_id < nb_rxq) && rxq) {
 		rxq_info->ring_len = rxq->nb_rx_desc;
 		rxq_info->dma_ring_addr = rxq->rx_ring_phys_addr;
 		rxq_info->databuffer_size =
@@ -622,11 +622,32 @@ struct rte_i40evf_xstats_name_off {
 	vc_vqci->num_queue_pairs = nb_qp;
 
 	for (i = 0, vc_qpi = vc_vqci->qpair; i < nb_qp; i++, vc_qpi++) {
-		i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
-			vc_vqci->vsi_id, i, dev->data->nb_tx_queues, txq[i]);
-		i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
-			vc_vqci->vsi_id, i, dev->data->nb_rx_queues,
-					vf->max_pkt_len, rxq[i]);
+		if (!txq)
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_tx_queues,
+							NULL);
+		else
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_tx_queues,
+							txq[i]);
+		if (!rxq)
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+							vc_vqci->vsi_id,
+							i,

drivers/net/i40e/i40e_ethdev_vf.c struct rte_i40evf_xstats_name_off { · line 650

Quoted 10 lines
drivers/net/i40e/i40e_ethdev_vf.c +10 -0
+							dev->data->nb_rx_queues,
+							vf->max_pkt_len,
+							NULL);
+		else
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_rx_queues,
+							vf->max_pkt_len,
+							rxq[i]);

No need to use one line for each parameter, I think you can still use the old format.

Thanks,
Xiaolong

Quoted 6 lines
drivers/net/i40e/i40e_ethdev_vf.c +0 -1
 	}
 	memset(&args, 0, sizeof(args));
 	args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
--

1.8.3.1

author
#3 lore raw
In reply to Ye Xiaolong

HI

-----Original Message-----
From: Ye, Xiaolong
Sent: Friday, June 21, 2019 7:42 PM
To: Pei, Andy <[email protected]>
Cc: [email protected]; Zhang, Helin <[email protected]>; [email protected]; Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix core dumped when setting txq or rxq to 0 in VF

Quoted 3 lines · Andy Pei

Testpmd stucked and core dumped
when set invalid VF queue number.
This patch fix this issue.

It's better to wrap the commit message within 72 characters. Perhaps something like:

Testpmd would stuck and result in core dump when user specifies an invalid VF queue number. This patch fixes this issue.

What do you think?

Quoted 65 lines
Fixes d6b19729093e ("i40evf: support configurable crc stripping")

---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

drivers/net/i40e/i40e_ethdev_vf.c | 35
++++++++++++++++++++++++++++-------

1 file changed, 28 insertions(+), 7 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +18 -7
index 63dbe14..7096cc5 100644
@@ -573,7 +573,7 @@ struct rte_i40evf_xstats_name_off {  {
 	txq_info->vsi_id = vsi_id;
 	txq_info->queue_id = queue_id;
-	if (queue_id < nb_txq) {
+	if ((queue_id < nb_txq) && txq) {
 		txq_info->ring_len = txq->nb_tx_desc;
 		txq_info->dma_ring_addr = txq->tx_ring_phys_addr;
 	}
@@ -590,7 +590,7 @@ struct rte_i40evf_xstats_name_off {
 	rxq_info->vsi_id = vsi_id;
 	rxq_info->queue_id = queue_id;
 	rxq_info->max_pkt_size = max_pkt_size;
-	if (queue_id < nb_rxq) {
+	if ((queue_id < nb_rxq) && rxq) {
 		rxq_info->ring_len = rxq->nb_rx_desc;
 		rxq_info->dma_ring_addr = rxq->rx_ring_phys_addr;
 		rxq_info->databuffer_size =
@@ -622,11 +622,32 @@ struct rte_i40evf_xstats_name_off {
 	vc_vqci->num_queue_pairs = nb_qp;
 
 	for (i = 0, vc_qpi = vc_vqci->qpair; i < nb_qp; i++, vc_qpi++) {
-		i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
-			vc_vqci->vsi_id, i, dev->data->nb_tx_queues, txq[i]);
-		i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
-			vc_vqci->vsi_id, i, dev->data->nb_rx_queues,
-					vf->max_pkt_len, rxq[i]);
+		if (!txq)
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_tx_queues,
+							NULL);
+		else
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_tx_queues,
+							txq[i]);
+		if (!rxq)
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+							vc_vqci->vsi_id,
+							i,

drivers/net/i40e/i40e_ethdev_vf.c struct rte_i40evf_xstats_name_off { · line 650

Quoted 10 lines
drivers/net/i40e/i40e_ethdev_vf.c +10 -0
+							dev->data->nb_rx_queues,
+							vf->max_pkt_len,
+							NULL);
+		else
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_rx_queues,
+							vf->max_pkt_len,
+							rxq[i]);

No need to use one line for each parameter, I think you can still use the old format.

A tab is added at the beginning of the line, so the old format will exceed 80 characters. So I suggests for use a new format but not one line for each parameter.
A new line comes if the upper line is more than 80 characters.
I will do this in v3

Thanks,
Xiaolong

Quoted 6 lines
drivers/net/i40e/i40e_ethdev_vf.c +0 -1
 	}
 	memset(&args, 0, sizeof(args));
 	args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
--

1.8.3.1

author
#4 lore raw

PATCH v2 1/1 net/i40e: fix core dumped when setting txq or rxq to 0 in VF

In reply to Andy Pei

Testpmd would stuck and result in core dump when user specifies an invalid VF queue number. This patch fixes this issue.

Fixes d6b19729093e ("i40evf: support configurable crc stripping")

---
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

 drivers/net/i40e/i40e_ethdev_vf.c | 35 ++++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +28 -7
index 63dbe14..35df59e 100644
@@ -573,7 +573,7 @@ struct rte_i40evf_xstats_name_off {
 {
 	txq_info->vsi_id = vsi_id;
 	txq_info->queue_id = queue_id;
-	if (queue_id < nb_txq) {
+	if (queue_id < nb_txq && txq) {
 		txq_info->ring_len = txq->nb_tx_desc;
 		txq_info->dma_ring_addr = txq->tx_ring_phys_addr;
 	}
@@ -590,7 +590,7 @@ struct rte_i40evf_xstats_name_off {
 	rxq_info->vsi_id = vsi_id;
 	rxq_info->queue_id = queue_id;
 	rxq_info->max_pkt_size = max_pkt_size;
-	if (queue_id < nb_rxq) {
+	if (queue_id < nb_rxq && rxq) {
 		rxq_info->ring_len = rxq->nb_rx_desc;
 		rxq_info->dma_ring_addr = rxq->rx_ring_phys_addr;
 		rxq_info->databuffer_size =
@@ -622,11 +622,32 @@ struct rte_i40evf_xstats_name_off {
 	vc_vqci->num_queue_pairs = nb_qp;
 
 	for (i = 0, vc_qpi = vc_vqci->qpair; i < nb_qp; i++, vc_qpi++) {
-		i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
-			vc_vqci->vsi_id, i, dev->data->nb_tx_queues, txq[i]);
-		i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
-			vc_vqci->vsi_id, i, dev->data->nb_rx_queues,
-					vf->max_pkt_len, rxq[i]);
+		if (!txq)
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_tx_queues,
+							NULL);
+		else
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_tx_queues,
+							txq[i]);
+		if (!rxq)
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_rx_queues,
+							vf->max_pkt_len,
+							NULL);
+		else
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+							vc_vqci->vsi_id,
+							i,
+							dev->data->nb_rx_queues,
+							vf->max_pkt_len,
+							rxq[i]);
 	}
 	memset(&args, 0, sizeof(args));
 	args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
Signature · 1 line
1.8.3.1
author
#5 lore raw

PATCH v3 1/1 net/i40e: fix core dumped when setting txq or rxq to 0 in VF

Testpmd would stuck and result in core dump when user specifies an invalid VF queue number. This patch fixes this issue.

Fixes d6b19729093e ("i40evf: support configurable crc stripping")

---
v3:
* no need to use a new line for each parameter when call envoke a function. A new line comes when the current line is more than 80 characters.

v2:
* modify commit meaasage so one line contains not more than 72 characters.
* delete unnecessary parentheses around 'queue_id < nb_txq'
* delete unnecessary parentheses around 'queue_id < nb_rxq'

 drivers/net/i40e/i40e_ethdev_vf.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +18 -7
index 63dbe14..41097fd 100644
@@ -573,7 +573,7 @@ struct rte_i40evf_xstats_name_off {
 {
 	txq_info->vsi_id = vsi_id;
 	txq_info->queue_id = queue_id;
-	if (queue_id < nb_txq) {
+	if (queue_id < nb_txq && txq) {
 		txq_info->ring_len = txq->nb_tx_desc;
 		txq_info->dma_ring_addr = txq->tx_ring_phys_addr;
 	}
@@ -590,7 +590,7 @@ struct rte_i40evf_xstats_name_off {
 	rxq_info->vsi_id = vsi_id;
 	rxq_info->queue_id = queue_id;
 	rxq_info->max_pkt_size = max_pkt_size;
-	if (queue_id < nb_rxq) {
+	if (queue_id < nb_rxq && rxq) {
 		rxq_info->ring_len = rxq->nb_rx_desc;
 		rxq_info->dma_ring_addr = rxq->rx_ring_phys_addr;
 		rxq_info->databuffer_size =
@@ -622,11 +622,22 @@ struct rte_i40evf_xstats_name_off {
 	vc_vqci->num_queue_pairs = nb_qp;
 
 	for (i = 0, vc_qpi = vc_vqci->qpair; i < nb_qp; i++, vc_qpi++) {
-		i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
-			vc_vqci->vsi_id, i, dev->data->nb_tx_queues, txq[i]);
-		i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
-			vc_vqci->vsi_id, i, dev->data->nb_rx_queues,
-					vf->max_pkt_len, rxq[i]);
+		if (!txq)
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+				vc_vqci->vsi_id, i, dev->data->nb_tx_queues,
+				NULL);
+		else
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+				vc_vqci->vsi_id, i, dev->data->nb_tx_queues,
+				txq[i]);
+		if (!rxq)
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+				vc_vqci->vsi_id, i, dev->data->nb_rx_queues,
+				vf->max_pkt_len, NULL);
+		else
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+				vc_vqci->vsi_id, i, dev->data->nb_rx_queues,
+				vf->max_pkt_len, rxq[i]);
 	}
 	memset(&args, 0, sizeof(args));
 	args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
Signature · 1 line
1.8.3.1
#6 lore raw

Hi Andy:

Quoted 12 lines

-----Original Message-----
From: Pei, Andy
Sent: Friday, June 21, 2019 5:23 PM
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Helin <[email protected]>; [email protected]; Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: [PATCH v3] net/i40e: fix core dumped when setting txq or rxq to 0 in VF

Quoted 2 lines

Testpmd would stuck and result in core dump when user specifies an invalid VF queue number. This patch fixes this issue.

Is that the case, dev_start will core dump due to violate memory access if rxq or txq number is 0? It's better to have a more specific description of the issue..

Quoted 58 lines
Fixes d6b19729093e ("i40evf: support configurable crc stripping")

---
v3:
* no need to use a new line for each parameter when call envoke a function. A new line comes when the current line is more than 80 characters.

v2:
* modify commit meaasage so one line contains not more than 72 characters.
* delete unnecessary parentheses around 'queue_id < nb_txq'
* delete unnecessary parentheses around 'queue_id < nb_rxq'

 drivers/net/i40e/i40e_ethdev_vf.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +2 -5
index 63dbe14..41097fd 100644
@@ -573,7 +573,7 @@ struct rte_i40evf_xstats_name_off {  {
 	txq_info->vsi_id = vsi_id;
 	txq_info->queue_id = queue_id;
-	if (queue_id < nb_txq) {
+	if (queue_id < nb_txq && txq) {
 		txq_info->ring_len = txq->nb_tx_desc;
 		txq_info->dma_ring_addr = txq->tx_ring_phys_addr;
 	}
@@ -590,7 +590,7 @@ struct rte_i40evf_xstats_name_off {
 	rxq_info->vsi_id = vsi_id;
 	rxq_info->queue_id = queue_id;
 	rxq_info->max_pkt_size = max_pkt_size;
-	if (queue_id < nb_rxq) {
+	if (queue_id < nb_rxq && rxq) {
 		rxq_info->ring_len = rxq->nb_rx_desc;
 		rxq_info->dma_ring_addr = rxq->rx_ring_phys_addr;
 		rxq_info->databuffer_size =
@@ -622,11 +622,22 @@ struct rte_i40evf_xstats_name_off {
 	vc_vqci->num_queue_pairs = nb_qp;
 
 	for (i = 0, vc_qpi = vc_vqci->qpair; i < nb_qp; i++, vc_qpi++) {
-		i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
-			vc_vqci->vsi_id, i, dev->data->nb_tx_queues, txq[i]);
-		i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,

drivers/net/i40e/i40e_ethdev_vf.c struct rte_i40evf_xstats_name_off { · line 632

Quoted 10 lines
drivers/net/i40e/i40e_ethdev_vf.c +8 -2
-			vc_vqci->vsi_id, i, dev->data->nb_rx_queues,
-					vf->max_pkt_len, rxq[i]);
+		if (!txq)
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+				vc_vqci->vsi_id, i, dev->data->nb_tx_queues,
+				NULL);
+		else
+			i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
+				vc_vqci->vsi_id, i, dev->data->nb_tx_queues,
+				txq[i]);

Seems, we can simply to !txq?txq:txq[i] to avoid some duplicate, right?

Quoted 13 lines
drivers/net/i40e/i40e_ethdev_vf.c +8 -1
+		if (!rxq)
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+				vc_vqci->vsi_id, i, dev->data->nb_rx_queues,
+				vf->max_pkt_len, NULL);
+		else
+			i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
+				vc_vqci->vsi_id, i, dev->data->nb_rx_queues,
+				vf->max_pkt_len, rxq[i]);
 	}
 	memset(&args, 0, sizeof(args));
 	args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
--

1.8.3.1

author
#7 lore raw

PATCH v4 1/1 net/i40e: fix core dumped when setting txq or rxq to 0 in VF

In reply to Andy Pei

Testpmd would stuck and result in core dump when user specifies an invalid VF queue number, for example when setting txq or rxq to 0. When txq or rxq is set to 0, pointer of pointer rxq or txq in function i40evf_configure_vsi_queues is NULL. The usage of txq[i] or rxq[0] is valid. This patch fixes this issue.

Fixes d6b19729093e ("i40evf: support configurable crc stripping")

---
v4:
* use "txq ? txq[i] : txq" to avoid some duplicate.
* a more specific description of the issue in the commit message.

v3:
* no need to use a new line for each parameter when call envoke a function. A new line comes when the current line is more than 80 characters.

    v2:

* modify commit meaasage so one line contains not more than 72 characters.
* delete unnecessary parentheses around 'queue_id < nb_txq'
* delete unnecessary parentheses around 'queue_id < nb_rxq'

 drivers/net/i40e/i40e_ethdev_vf.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/net/i40e/i40e_ethdev_vf.c +5 -4
index d922a84..5be32b0 100644
@@ -573,7 +573,7 @@ struct rte_i40evf_xstats_name_off {
 {
 	txq_info->vsi_id = vsi_id;
 	txq_info->queue_id = queue_id;
-	if (queue_id < nb_txq) {
+	if (queue_id < nb_txq && txq) {
 		txq_info->ring_len = txq->nb_tx_desc;
 		txq_info->dma_ring_addr = txq->tx_ring_phys_addr;
 	}
@@ -590,7 +590,7 @@ struct rte_i40evf_xstats_name_off {
 	rxq_info->vsi_id = vsi_id;
 	rxq_info->queue_id = queue_id;
 	rxq_info->max_pkt_size = max_pkt_size;
-	if (queue_id < nb_rxq) {
+	if (queue_id < nb_rxq && rxq) {
 		rxq_info->ring_len = rxq->nb_rx_desc;
 		rxq_info->dma_ring_addr = rxq->rx_ring_phys_addr;
 		rxq_info->databuffer_size =
@@ -623,10 +623,11 @@ struct rte_i40evf_xstats_name_off {
 
 	for (i = 0, vc_qpi = vc_vqci->qpair; i < nb_qp; i++, vc_qpi++) {
 		i40evf_fill_virtchnl_vsi_txq_info(&vc_qpi->txq,
-			vc_vqci->vsi_id, i, dev->data->nb_tx_queues, txq[i]);
+			vc_vqci->vsi_id, i, dev->data->nb_tx_queues,
+			txq ? txq[i] : NULL);
 		i40evf_fill_virtchnl_vsi_rxq_info(&vc_qpi->rxq,
 			vc_vqci->vsi_id, i, dev->data->nb_rx_queues,
-					vf->max_pkt_len, rxq[i]);
+			vf->max_pkt_len, rxq ? rxq[i] : NULL);
 	}
 	memset(&args, 0, sizeof(args));
 	args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
Signature · 1 line
1.8.3.1
Acked-by on v4 1/1 Applied
#8 lore raw
Quoted 20 lines

-----Original Message-----
From: Pei, Andy
Sent: Thursday, July 4, 2019 9:39 AM
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Helin <[email protected]>; [email protected]; Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: [PATCH v4] net/i40e: fix core dumped when setting txq or rxq to 0 in VF

Testpmd would stuck and result in core dump when user specifies an invalid VF queue number, for example when setting txq or rxq to 0.
When txq or rxq is set to 0, pointer of pointer rxq or txq in function i40evf_configure_vsi_queues is NULL. The usage of txq[i] or rxq[0] is valid. This patch fixes this issue.

Quoted 5 lines
Fixes d6b19729093e ("i40evf: support configurable crc stripping")

Applied to dpdk-next-net-intel.

Thanks
Qi

author Acked-by Qi Zhang Applied
#9 lore raw

Thanks Qi

-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, July 4, 2019 2:18 PM
To: Pei, Andy <[email protected]>; [email protected]
Cc: Zhang, Helin <[email protected]>; [email protected]; Zhang, Roy Fan <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: RE: [PATCH v4] net/i40e: fix core dumped when setting txq or rxq to 0 in VF

Quoted 19 lines

-----Original Message-----
From: Pei, Andy
Sent: Thursday, July 4, 2019 9:39 AM
To: [email protected]
Cc: Pei, Andy <[email protected]>; Zhang, Helin <[email protected]>; [email protected]; Zhang, Roy Fan <[email protected]>; Zhang, Qi Z <[email protected]>; Wu, Jingjing <[email protected]>; Xing, Beilei <[email protected]>; Yigit, Ferruh <[email protected]>; Xu, Rosen <[email protected]>; Ye, Xiaolong <[email protected]>
Subject: [PATCH v4] net/i40e: fix core dumped when setting txq or rxq to 0 in VF

Testpmd would stuck and result in core dump when user specifies an invalid VF queue number, for example when setting txq or rxq to 0. When txq or rxq is set to 0, pointer of pointer rxq or txq in function i40evf_configure_vsi_queues is NULL. The usage of txq[i] or rxq[0] is valid. This patch fixes this issue.

Quoted 5 lines
Fixes d6b19729093e ("i40evf: support configurable crc stripping")

Applied to dpdk-next-net-intel.

Thanks
Qi