diff mbox

linux-gen: fix dpdk pktio init

Message ID 20170204203324.7704-1-maxim.uvarov@linaro.org
State Accepted
Commit 022cf4a7136c7369ee5f29f5d245ac8d052135e6
Headers show

Commit Message

Maxim Uvarov Feb. 4, 2017, 8:33 p.m. UTC
struct rte_eth_dev_info should be initialized before
usage with strcmp(dev_info.driver_name, "rte_ixgbe_pmd").
Patch fixes segfault on that compare.

CC: Elo Matias <matias.elo@nokia.com>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
 platform/linux-generic/pktio/dpdk.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.11.0.295.gd7dffce

Comments

Elo, Matias (Nokia - FI/Espoo) Feb. 6, 2017, 8:22 a.m. UTC | #1
Good catch.

Reviewed-and-tested-by: Matias Elo <matias.elo@nokia.com>

> On 4 Feb 2017, at 22:33, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

> 

> struct rte_eth_dev_info should be initialized before

> usage with strcmp(dev_info.driver_name, "rte_ixgbe_pmd").

> Patch fixes segfault on that compare.

> 

> CC: Elo Matias <matias.elo@nokia.com>

> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

> ---

> platform/linux-generic/pktio/dpdk.c | 14 +++++++-------

> 1 file changed, 7 insertions(+), 7 deletions(-)

> 

> diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c

> index 0eb025ae..9a9f7a4e 100644

> --- a/platform/linux-generic/pktio/dpdk.c

> +++ b/platform/linux-generic/pktio/dpdk.c

> @@ -560,19 +560,19 @@ static int dpdk_output_queues_config(pktio_entry_t *pktio_entry,

> 	return 0;

> }

> 

> -static void dpdk_init_capability(pktio_entry_t *pktio_entry)

> +static void dpdk_init_capability(pktio_entry_t *pktio_entry,

> +				 struct rte_eth_dev_info *dev_info)

> {

> 	pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk;

> 	odp_pktio_capability_t *capa = &pkt_dpdk->capa;

> -	struct rte_eth_dev_info dev_info;

> 

> -	memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));

> +	memset(dev_info, 0, sizeof(struct rte_eth_dev_info));

> 	memset(capa, 0, sizeof(odp_pktio_capability_t));

> 

> -	rte_eth_dev_info_get(pkt_dpdk->port_id, &dev_info);

> -	capa->max_input_queues = RTE_MIN(dev_info.max_rx_queues,

> +	rte_eth_dev_info_get(pkt_dpdk->port_id, dev_info);

> +	capa->max_input_queues = RTE_MIN(dev_info->max_rx_queues,

> 					 PKTIO_MAX_QUEUES);

> -	capa->max_output_queues = RTE_MIN(dev_info.max_tx_queues,

> +	capa->max_output_queues = RTE_MIN(dev_info->max_tx_queues,

> 					  PKTIO_MAX_QUEUES);

> 	capa->set_op.op.promisc_mode = 1;

> 

> @@ -631,7 +631,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED,

> 		return -1;

> 	}

> 

> -	dpdk_init_capability(pktio_entry);

> +	dpdk_init_capability(pktio_entry, &dev_info);

> 

> 	mtu = dpdk_mtu_get(pktio_entry);

> 	if (mtu == 0) {

> -- 

> 2.11.0.295.gd7dffce

>
Maxim Uvarov Feb. 6, 2017, 1:38 p.m. UTC | #2
Merged,
Maxim.


On 02/06/17 11:22, Elo, Matias (Nokia - FI/Espoo) wrote:
> Good catch.

> 

> Reviewed-and-tested-by: Matias Elo <matias.elo@nokia.com>

> 

>> On 4 Feb 2017, at 22:33, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:

>>

>> struct rte_eth_dev_info should be initialized before

>> usage with strcmp(dev_info.driver_name, "rte_ixgbe_pmd").

>> Patch fixes segfault on that compare.

>>

>> CC: Elo Matias <matias.elo@nokia.com>

>> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

>> ---

>> platform/linux-generic/pktio/dpdk.c | 14 +++++++-------

>> 1 file changed, 7 insertions(+), 7 deletions(-)

>>

>> diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c

>> index 0eb025ae..9a9f7a4e 100644

>> --- a/platform/linux-generic/pktio/dpdk.c

>> +++ b/platform/linux-generic/pktio/dpdk.c

>> @@ -560,19 +560,19 @@ static int dpdk_output_queues_config(pktio_entry_t *pktio_entry,

>> 	return 0;

>> }

>>

>> -static void dpdk_init_capability(pktio_entry_t *pktio_entry)

>> +static void dpdk_init_capability(pktio_entry_t *pktio_entry,

>> +				 struct rte_eth_dev_info *dev_info)

>> {

>> 	pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk;

>> 	odp_pktio_capability_t *capa = &pkt_dpdk->capa;

>> -	struct rte_eth_dev_info dev_info;

>>

>> -	memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));

>> +	memset(dev_info, 0, sizeof(struct rte_eth_dev_info));

>> 	memset(capa, 0, sizeof(odp_pktio_capability_t));

>>

>> -	rte_eth_dev_info_get(pkt_dpdk->port_id, &dev_info);

>> -	capa->max_input_queues = RTE_MIN(dev_info.max_rx_queues,

>> +	rte_eth_dev_info_get(pkt_dpdk->port_id, dev_info);

>> +	capa->max_input_queues = RTE_MIN(dev_info->max_rx_queues,

>> 					 PKTIO_MAX_QUEUES);

>> -	capa->max_output_queues = RTE_MIN(dev_info.max_tx_queues,

>> +	capa->max_output_queues = RTE_MIN(dev_info->max_tx_queues,

>> 					  PKTIO_MAX_QUEUES);

>> 	capa->set_op.op.promisc_mode = 1;

>>

>> @@ -631,7 +631,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED,

>> 		return -1;

>> 	}

>>

>> -	dpdk_init_capability(pktio_entry);

>> +	dpdk_init_capability(pktio_entry, &dev_info);

>>

>> 	mtu = dpdk_mtu_get(pktio_entry);

>> 	if (mtu == 0) {

>> -- 

>> 2.11.0.295.gd7dffce

>>

>
diff mbox

Patch

diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c
index 0eb025ae..9a9f7a4e 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -560,19 +560,19 @@  static int dpdk_output_queues_config(pktio_entry_t *pktio_entry,
 	return 0;
 }
 
-static void dpdk_init_capability(pktio_entry_t *pktio_entry)
+static void dpdk_init_capability(pktio_entry_t *pktio_entry,
+				 struct rte_eth_dev_info *dev_info)
 {
 	pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk;
 	odp_pktio_capability_t *capa = &pkt_dpdk->capa;
-	struct rte_eth_dev_info dev_info;
 
-	memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
+	memset(dev_info, 0, sizeof(struct rte_eth_dev_info));
 	memset(capa, 0, sizeof(odp_pktio_capability_t));
 
-	rte_eth_dev_info_get(pkt_dpdk->port_id, &dev_info);
-	capa->max_input_queues = RTE_MIN(dev_info.max_rx_queues,
+	rte_eth_dev_info_get(pkt_dpdk->port_id, dev_info);
+	capa->max_input_queues = RTE_MIN(dev_info->max_rx_queues,
 					 PKTIO_MAX_QUEUES);
-	capa->max_output_queues = RTE_MIN(dev_info.max_tx_queues,
+	capa->max_output_queues = RTE_MIN(dev_info->max_tx_queues,
 					  PKTIO_MAX_QUEUES);
 	capa->set_op.op.promisc_mode = 1;
 
@@ -631,7 +631,7 @@  static int dpdk_open(odp_pktio_t id ODP_UNUSED,
 		return -1;
 	}
 
-	dpdk_init_capability(pktio_entry);
+	dpdk_init_capability(pktio_entry, &dev_info);
 
 	mtu = dpdk_mtu_get(pktio_entry);
 	if (mtu == 0) {