Skip to contentSkip to conversation

examples/tep_term: fix return value check

PATCH Superseded Xiaoyun Li 3 participants 12 messages Feb 10, 2020 – Feb 21, 2020

lore
Share & tools
lore

Xiaoyun Li

author
#0 lore raw

PATCH 1/1 examples/tep_term: fix return value check

Added return value check for 'rte_eth_dev_info_get()'.

Coverity issue: 349922

Fixes 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")
---
 examples/tep_termination/vxlan_setup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
examples/tep_termination/vxlan_setup.c +3 -1
index eca119a72..bd469f5f4 100644
@@ -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");
Signature · 1 line
2.17.1
#1 lore raw
Quoted 16 lines · Xiaoyun Li

Added return value check for 'rte_eth_dev_info_get()'.

Coverity issue: 349922

Fixes 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")

---
examples/tep_termination/vxlan_setup.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
examples/tep_termination/vxlan_setup.c +0 -0
index eca119a72..bd469f5f4 100644

examples/tep_termination/vxlan_setup.c vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool) · line 200

Quoted 7 lines
examples/tep_termination/vxlan_setup.c +3 -1
@@ -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

Quoted 6 lines
examples/tep_termination/vxlan_setup.c +0 -0
 		if ((dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0)
 			RTE_LOG(WARNING, PORT,
 				"hardware TSO offload is not supported\n");
Signature · 1 line
2.17.1
#2 lore raw

Hi

Quoted 28 lines

-----Original Message-----
From: Ye, Xiaolong
Sent: Monday, February 10, 2020 11:37
To: Li, Xiaoyun <[email protected]>
Cc: Kovacevic, Marko <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] examples/tep_term: fix return value check

Quoted 6 lines · Xiaoyun Li

Added return value check for 'rte_eth_dev_info_get()'.

Coverity issue: 349922

Fixes 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")

Review

Quoted 6 lines

---
examples/tep_termination/vxlan_setup.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/examples/tep_termination/vxlan_setup.c

examples/tep_termination/vxlan_setup.c vxlan_port_init(uint16_t port, struct rte_mempool

Quoted 4 lines

index eca119a72..bd469f5f4 100644

examples/tep_termination/vxlan_setup.c +0 -0
@@ -195,7 +195,9 @@ vxlan_port_init(uint16_t port, struct rte_mempool

*mbuf_pool)

Quoted 1 line
Quoted 8 lines

examples/tep_termination/vxlan_setup.c vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool) · line 200

Quoted 6 lines
	if (tso_segsz != 0) {
		struct rte_eth_dev_info dev_info;
examples/tep_termination/vxlan_setup.c +3 -1
-		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.

Quoted 11 lines

Thanks,
Xiaolong

Quoted 1 line

if ((dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO)

== 0)

Quoted 5 lines
			RTE_LOG(WARNING, PORT,
				"hardware TSO offload is not supported\n");

--
2.17.1

#3 lore raw
Quoted 39 lines · Xiaoyun

Hi

Quoted 28 lines

-----Original Message-----
From: Ye, Xiaolong
Sent: Monday, February 10, 2020 11:37
To: Li, Xiaoyun <[email protected]>
Cc: Kovacevic, Marko <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] examples/tep_term: fix return value check

Quoted 6 lines · Xiaoyun Li

Added return value check for 'rte_eth_dev_info_get()'.

Coverity issue: 349922

Fixes 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")

Review

Quoted 6 lines

---
examples/tep_termination/vxlan_setup.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/examples/tep_termination/vxlan_setup.c

examples/tep_termination/vxlan_setup.c vxlan_port_init(uint16_t port, struct rte_mempool

Quoted 4 lines

index eca119a72..bd469f5f4 100644

examples/tep_termination/vxlan_setup.c +0 -0
@@ -195,7 +195,9 @@ vxlan_port_init(uint16_t port, struct rte_mempool

*mbuf_pool)

Quoted 1 line
Quoted 8 lines

examples/tep_termination/vxlan_setup.c vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool) · line 200

Quoted 6 lines
	if (tso_segsz != 0) {
		struct rte_eth_dev_info dev_info;
examples/tep_termination/vxlan_setup.c +3 -1
-		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?

Quoted 8 lines

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

Quoted 11 lines
Quoted 11 lines

Thanks,
Xiaolong

Quoted 1 line

if ((dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO)

== 0)

Quoted 5 lines
			RTE_LOG(WARNING, PORT,
				"hardware TSO offload is not supported\n");

--
2.17.1

author
#4 lore raw

PATCH v2 1/1 examples/tep_term: fix return value check

In reply to Xiaoyun Li

Added return value check for 'rte_eth_dev_info_get()'.

Coverity issue: 349922

Fixes 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")
---
 examples/tep_termination/vxlan_setup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
examples/tep_termination/vxlan_setup.c +3 -1
index eca119a72..f8385b690 100644
@@ -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");
Signature · 1 line
2.17.1
Acked-by on v2 1/1
#5 lore raw
Quoted 29 lines · Xiaoyun Li

Added return value check for 'rte_eth_dev_info_get()'.

Coverity issue: 349922

Fixes 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")

---
examples/tep_termination/vxlan_setup.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
examples/tep_termination/vxlan_setup.c +3 -1
index eca119a72..f8385b690 100644
@@ -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");
Signature · 1 line
2.17.1
#6 lore raw
In reply to Xiaoyun Li
Quoted 5 lines · Xiaoyun Li

Added return value check for 'rte_eth_dev_info_get()'.

Coverity issue: 349922

Fixes 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")

rte_eth_dev_info_get() prototype changed in 19.11. Before this, it was a void.
So this Fixes: line is wrong.

Quoted 12 lines
---
 examples/tep_termination/vxlan_setup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
examples/tep_termination/vxlan_setup.c +0 -0
index eca119a72..f8385b690 100644

examples/tep_termination/vxlan_setup.c vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool) · line 203

Quoted 10 lines
examples/tep_termination/vxlan_setup.c +3 -1
@@ -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");

I had a look at this function, dev_info is populated for port earlier in the function, why do we need to check it again?
https://git.dpdk.org/dpdk/tree/examples/tep_termination/vxlan_setup.c?h=v20.02-rc2#n119

Signature · 1 line
David Marchand
#7 lore raw

Hi

Quoted 37 lines

-----Original Message-----
From: David Marchand [mailto:[email protected]]
Sent: Thursday, February 13, 2020 22:57
To: Li, Xiaoyun <[email protected]>
Cc: Ye, Xiaolong <[email protected]>; Kovacevic, Marko <[email protected]>; dev <[email protected]>; dpdk stable <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] examples/tep_term: fix return value check

Quoted 6 lines · Xiaoyun Li

Added return value check for 'rte_eth_dev_info_get()'.

Coverity issue: 349922

Fixes 2bb43bd4350a ("examples/tep_term: add TSO offload

configuration")

rte_eth_dev_info_get() prototype changed in 19.11. Before this, it was a void.
So this Fixes: line is wrong.

Quoted 15 lines
---
 examples/tep_termination/vxlan_setup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
examples/tep_termination/vxlan_setup.c +0 -0
index eca119a72..f8385b690 100644
@@ -195,7 +195,9 @@ vxlan_port_init(uint16_t port, struct rte_mempool
 *mbuf_pool)
 
Quoted 15 lines
Quoted 10 lines
examples/tep_termination/vxlan_setup.c +3 -1
        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");

I had a look at this function, dev_info is populated for port earlier in the function, why do we need to check it again?
https://git.dpdk.org/dpdk/tree/examples/tep_termination/vxlan_setup.c?h=v20
.02-rc2#n119

Yes. I saw it too. And since it only uses tx_offload_capa which is fixed nic capability, I think can use dev_info directly without calling rte_eth_dev_info_get again. Will send v3 as that. Then the fix line should be the same as this patch too.

Thanks.

Quoted 4 lines

--
David Marchand

author
#8 lore raw

PATCH v3 1/1 examples/tep_term: remove redundant info get

In reply to Xiaoyun Li

Removed redundant function call of 'rte_eth_dev_info_get()' since it has already been called earlier.

Coverity issue: 349922

Fixes 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")
---
 examples/tep_termination/vxlan_setup.c | 2 --
 1 file changed, 2 deletions(-)
examples/tep_termination/vxlan_setup.c +0 -2
index eca119a72..4b44ccc14 100644
@@ -194,8 +194,6 @@ vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool)
 			ports_eth_addr[port].addr_bytes[5]);
 
 	if (tso_segsz != 0) {
-		struct rte_eth_dev_info dev_info;
-		rte_eth_dev_info_get(port, &dev_info);
 		if ((dev_info.tx_offload_capa & DEV_TX_OFFLOAD_TCP_TSO) == 0)
 			RTE_LOG(WARNING, PORT,
 				"hardware TSO offload is not supported\n");
Signature · 1 line
2.17.1
#9 lore raw

Re: [dpdk-dev] [PATCH v3] examples/tep_term: remove redundant info get

Quoted 9 lines · Xiaoyun Li

Removed redundant function call of 'rte_eth_dev_info_get()' since it has already been called earlier.

Coverity issue: 349922

Fixes 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")

LGTM.
Xiaolong, you had reviewed it before, can you have a look? Thanks.

Signature · 1 line
David Marchand
Reviewed-by
#10 lore raw

Re: [dpdk-dev] [PATCH v3] examples/tep_term: remove redundant info get

Quoted 9 lines · David Marchand
Quoted 8 lines · Xiaoyun Li

Removed redundant function call of 'rte_eth_dev_info_get()' since it has already been called earlier.

Coverity issue: 349922

Fixes 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")
Quoted 9 lines
Quoted 1 line

LGTM.
Xiaolong, you had reviewed it before, can you have a look? Thanks.

Signature · 1 line
David Marchand

LGTM.

Reviewed-by Xiaolong Ye Acked-by on v3 1/1 Applied
#11 lore raw

Re: [dpdk-dev] [PATCH v3] examples/tep_term: remove redundant info get

In reply to Xiaoyun Li
Quoted 9 lines · Xiaoyun Li

Removed redundant function call of 'rte_eth_dev_info_get()' since it has already been called earlier.

Coverity issue: 349922

Fixes 2bb43bd4350a ("examples/tep_term: add TSO offload configuration")

Little comment, this patch solves a coverity issue.

Upon inspection of this example code, I can see no check on device capability when sending packets.
So I suppose it is broken when user asks for TSO, but the devices do not support TSO.
Can you investigate and fix this in the next release?

Applied, thanks.

--
David Marchand