examples/tep_term: fix return value check

Message ID 20200210030757.11426-1-xiaoyun.li@intel.com (mailing list archive)
State Superseded, archived
Headers
Series examples/tep_term: fix return value check |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation fail apply issues

Commit Message

Li, Xiaoyun Feb. 10, 2020, 3:07 a.m. UTC
  Added return value check for 'rte_eth_dev_info_get()'.

Coverity issue: 349922
Fixes: 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")
Cc: stable@dpdk.org

Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
---
 examples/tep_termination/vxlan_setup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Xiaolong Ye Feb. 10, 2020, 3:36 a.m. UTC | #1
On 02/10, Xiaoyun Li wrote:
>Added return value check for 'rte_eth_dev_info_get()'.
>
>Coverity issue: 349922
>Fixes: 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")
>Cc: stable@dpdk.org
>
>Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
>---
> examples/tep_termination/vxlan_setup.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c
>index eca119a72..bd469f5f4 100644
>--- a/examples/tep_termination/vxlan_setup.c
>+++ b/examples/tep_termination/vxlan_setup.c
>@@ -195,7 +195,9 @@ vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool)
> 
> 	if (tso_segsz != 0) {
> 		struct rte_eth_dev_info dev_info;
>-		rte_eth_dev_info_get(port, &dev_info);
>+		retval = rte_eth_dev_info_get(port, &dev_info);
>+		if (retval != 0)
>+			return -retval;

why return -retval not retval?

Thanks,
Xiaolong

> 		if ((dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0)
> 			RTE_LOG(WARNING, PORT,
> 				"hardware TSO offload is not supported\n");
>-- 
>2.17.1
>
  
Li, Xiaoyun Feb. 10, 2020, 5:04 a.m. UTC | #2
Hi

> -----Original Message-----
> From: Ye, Xiaolong
> Sent: Monday, February 10, 2020 11:37
> To: Li, Xiaoyun <xiaoyun.li@intel.com>
> Cc: Kovacevic, Marko <marko.kovacevic@intel.com>; dev@dpdk.org;
> stable@dpdk.org
> Subject: Re: [PATCH] examples/tep_term: fix return value check
> 
> On 02/10, Xiaoyun Li wrote:
> >Added return value check for 'rte_eth_dev_info_get()'.
> >
> >Coverity issue: 349922
> >Fixes: 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")
> >Cc: stable@dpdk.org
> >
> >Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
> >---
> > examples/tep_termination/vxlan_setup.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> >diff --git a/examples/tep_termination/vxlan_setup.c
> b/examples/tep_termination/vxlan_setup.c
> >index eca119a72..bd469f5f4 100644
> >--- a/examples/tep_termination/vxlan_setup.c
> >+++ b/examples/tep_termination/vxlan_setup.c
> >@@ -195,7 +195,9 @@ vxlan_port_init(uint16_t port, struct rte_mempool
> *mbuf_pool)
> >
> > 	if (tso_segsz != 0) {
> > 		struct rte_eth_dev_info dev_info;
> >-		rte_eth_dev_info_get(port, &dev_info);
> >+		retval = rte_eth_dev_info_get(port, &dev_info);
> >+		if (retval != 0)
> >+			return -retval;
> 
> why return -retval not retval?

The description of return value of rte_eth_dev_info_get() is like the following:
@return
 *   - (0) if successful.
 *   - (-ENOTSUP) if support for dev_infos_get() does not exist for the device.
 *   - (-ENODEV) if *port_id* invalid.
So -retval is the real err code.
But the check of this function (vxlan_port_init) is (overlay_options.port_configure(portid, mbuf_pool) != 0)
So return -retval or retval are both OK.
> 
> Thanks,
> Xiaolong
> 
> > 		if ((dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO)
> == 0)
> > 			RTE_LOG(WARNING, PORT,
> > 				"hardware TSO offload is not supported\n");
> >--
> >2.17.1
> >
  
Xiaolong Ye Feb. 10, 2020, 6:51 a.m. UTC | #3
On 02/10, Li, Xiaoyun wrote:
>Hi
>
>> -----Original Message-----
>> From: Ye, Xiaolong
>> Sent: Monday, February 10, 2020 11:37
>> To: Li, Xiaoyun <xiaoyun.li@intel.com>
>> Cc: Kovacevic, Marko <marko.kovacevic@intel.com>; dev@dpdk.org;
>> stable@dpdk.org
>> Subject: Re: [PATCH] examples/tep_term: fix return value check
>> 
>> On 02/10, Xiaoyun Li wrote:
>> >Added return value check for 'rte_eth_dev_info_get()'.
>> >
>> >Coverity issue: 349922
>> >Fixes: 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")
>> >Cc: stable@dpdk.org
>> >
>> >Signed-off-by: Xiaoyun Li <xiaoyun.li@intel.com>
>> >---
>> > examples/tep_termination/vxlan_setup.c | 4 +++-
>> > 1 file changed, 3 insertions(+), 1 deletion(-)
>> >
>> >diff --git a/examples/tep_termination/vxlan_setup.c
>> b/examples/tep_termination/vxlan_setup.c
>> >index eca119a72..bd469f5f4 100644
>> >--- a/examples/tep_termination/vxlan_setup.c
>> >+++ b/examples/tep_termination/vxlan_setup.c
>> >@@ -195,7 +195,9 @@ vxlan_port_init(uint16_t port, struct rte_mempool
>> *mbuf_pool)
>> >
>> > 	if (tso_segsz != 0) {
>> > 		struct rte_eth_dev_info dev_info;
>> >-		rte_eth_dev_info_get(port, &dev_info);
>> >+		retval = rte_eth_dev_info_get(port, &dev_info);
>> >+		if (retval != 0)
>> >+			return -retval;
>> 
>> why return -retval not retval?
>
>The description of return value of rte_eth_dev_info_get() is like the following:
>@return
> *   - (0) if successful.
> *   - (-ENOTSUP) if support for dev_infos_get() does not exist for the device.
> *   - (-ENODEV) if *port_id* invalid.
>So -retval is the real err code.
>But the check of this function (vxlan_port_init) is (overlay_options.port_configure(portid, mbuf_pool) != 0)
>So return -retval or retval are both OK.

Better to align with other return val checks in this function to return retval.

Thanks,
Xiaolong

>> 
>> Thanks,
>> Xiaolong
>> 
>> > 		if ((dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO)
>> == 0)
>> > 			RTE_LOG(WARNING, PORT,
>> > 				"hardware TSO offload is not supported\n");
>> >--
>> >2.17.1
>> >
  

Patch

diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c
index eca119a72..bd469f5f4 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -195,7 +195,9 @@  vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 
 	if (tso_segsz != 0) {
 		struct rte_eth_dev_info dev_info;
-		rte_eth_dev_info_get(port, &dev_info);
+		retval = rte_eth_dev_info_get(port, &dev_info);
+		if (retval != 0)
+			return -retval;
 		if ((dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0)
 			RTE_LOG(WARNING, PORT,
 				"hardware TSO offload is not supported\n");