[dpdk-dev] [PATCH] examples/l3fwd: fix validation for queue id of config tuple

Reshma Pattan reshma.pattan at intel.com
Fri Mar 18 11:35:21 CET 2016


Added validation for queue id of config parameter tuple.

This validation enforces user to enter queue ids of a port
from 0 and in sequence.

This additional validation on queue ids avoids ixgbe crash caused by null
rxq pointer access inside ixgbe_dev_rx_init.

Reason for null rxq is, L3fwd application allocates memory only for queues passed by user.
But rte_eth_dev_start  tries to initialize rx queues in sequence from 0 to nb_rx_queues,
which is not true and coredump while accessing the unallocated queue .

Fixes: Commit af75078f

Signed-off-by: Reshma Pattan <reshma.pattan at intel.com>
---
 examples/l3fwd/main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 0e33039..f148d4e 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -264,8 +264,14 @@ get_port_n_rx_queues(const uint8_t port)
 
 	for (i = 0; i < nb_lcore_params; ++i) {
 		if (lcore_params[i].port_id == port &&
-			lcore_params[i].queue_id > queue)
+			lcore_params[i].queue_id > queue &&
+			lcore_params[i].queue_id == queue+1)
 			queue = lcore_params[i].queue_id;
+		else if (lcore_params[i].port_id == port &&
+				lcore_params[i].queue_id != queue+1)
+			rte_exit(EXIT_FAILURE, "queue ids of the port %d must be"
+					" in sequence and must start with 0",
+					lcore_params[i].port_id);
 	}
 	return (uint8_t)(++queue);
 }
-- 
2.5.0



More information about the dev mailing list