Skip to contentSkip to conversation

app/testpmd: fix DCB set failure in FreeBSD by clang

PATCH Superseded Ting Xu 8 participants 20 messages May 11, 2020 – May 18, 2020

lore
Share & tools
lore

Ting Xu

author
#0 lore raw

PATCH 1/1 app/testpmd: fix DCB set failure in FreeBSD by clang

When set DCB in testpmd by clang, there is a segmentation fault. It is because the local variable rss_conf in get_eth_dcb_conf() is not cleared, so that the pointer member variable rss_key has a random address, which leads to an error in the following processing. This patch initialized the local variable rss_conf to avoid random address.

Fixes b57b66a97ebf ("app/testpmd: support mbuf dynamic flag")
---
 app/test-pmd/testpmd.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/testpmd.c +1 -0
index 99bacddbf..1276476ca 100644
@@ -3408,6 +3408,7 @@ get_eth_dcb_conf(portid_t pid, struct rte_eth_conf *eth_conf,
 	int32_t rc;
 	struct rte_eth_rss_conf rss_conf;
 
+	memset(&rss_conf, 0, sizeof(struct rte_eth_rss_conf));
 	/*
 	 * Builds up the correct configuration for dcb+vt based on the vlan tags array
 	 * given above, and the number of traffic classes available for use.
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 37 lines

-----Original Message-----
From: Xu, Ting <[email protected]>
Sent: Monday, May 11, 2020 6:25 PM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Xing, Beilei <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]
Subject: [PATCH v1] app/testpmd: fix DCB set failure in FreeBSD by clang

When set DCB in testpmd by clang, there is a segmentation fault. It is because the local variable rss_conf in get_eth_dcb_conf() is not cleared, so that the pointer member variable rss_key has a random address, which leads to an error in the following processing. This patch initialized the local variable rss_conf to avoid random address.

Fixes b57b66a97ebf ("app/testpmd: support mbuf dynamic flag")
---
 app/test-pmd/testpmd.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

99bacddbf..1276476ca 100644

app/test-pmd/testpmd.c +1 -0
@@ -3408,6 +3408,7 @@ get_eth_dcb_conf(portid_t pid, struct rte_eth_conf
 *eth_conf,
 	int32_t rc;
 	struct rte_eth_rss_conf rss_conf;
 
+	memset(&rss_conf, 0, sizeof(struct rte_eth_rss_conf));
 	/*
 	 * Builds up the correct configuration for dcb+vt based on the vlan
Quoted 4 lines

tags array
* given above, and the number of traffic classes available for use.
--
2.17.1

Tested-by on v1 1/1
#2 lore raw
In reply to Ting Xu

Regards,
HuangZhiMin

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ting Xu
Sent: Monday, May 11, 2020 6:25 PM
To: [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Xing, Beilei <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v1] app/testpmd: fix DCB set failure in FreeBSD by clang

When set DCB in testpmd by clang, there is a segmentation fault.
It is because the local variable rss_conf in get_eth_dcb_conf() is not cleared, so that the pointer member variable rss_key has a random address, which leads to an error in the following processing. This patch initialized the local variable rss_conf to avoid random address.

Fixes b57b66a97ebf ("app/testpmd: support mbuf dynamic flag")
---
 app/test-pmd/testpmd.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/testpmd.c +1 -0
@@ -3408,6 +3408,7 @@ get_eth_dcb_conf(portid_t pid, struct rte_eth_conf *eth_conf,
 	int32_t rc;
 	struct rte_eth_rss_conf rss_conf;
 
+	memset(&rss_conf, 0, sizeof(struct rte_eth_rss_conf));
 	/*
 	 * Builds up the correct configuration for dcb+vt based on the vlan tags array
 	 * given above, and the number of traffic classes available for use.

--
2.17.1

#3 lore raw
In reply to Ting Xu
Quoted 6 lines · Ting Xu

When set DCB in testpmd by clang, there is a segmentation fault. It is because the local variable rss_conf in get_eth_dcb_conf() is not cleared, so that the pointer member variable rss_key has a random address, which leads to an error in the following processing. This patch initialized the local variable rss_conf to avoid random address.

This is nothing really FreeBSD or clang issue, although it may be reproduced that environment, this is a pointer with random value issue. We may drop FreeBSD and clang reference to not create confusion.

Quoted 2 lines
Fixes b57b66a97ebf ("app/testpmd: support mbuf dynamic flag")

This commit looks unrelated, if not can you please explain why above commit causing the issue?

Quoted 12 lines
---
 app/test-pmd/testpmd.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/testpmd.c +0 -0
index 99bacddbf..1276476ca 100644

app/test-pmd/testpmd.c get_eth_dcb_conf(portid_t pid, struct rte_eth_conf *eth_conf, · line 3411

Quoted 4 lines
app/test-pmd/testpmd.c +1 -0
@@ -3408,6 +3408,7 @@ get_eth_dcb_conf(portid_t pid, struct rte_eth_conf *eth_conf,
 	int32_t rc;
 	struct rte_eth_rss_conf rss_conf;
 
+	memset(&rss_conf, 0, sizeof(struct rte_eth_rss_conf));

The variable is used in the 'else' leg, memset can be moved there, but more importantly should this be done in the 'rte_eth_dev_rss_hash_conf_get()' API.

@Andrew, @Thomas,

What do you think 'rte_eth_dev_rss_hash_conf_get()' memset the 'rss_conf' param before passing it to the PMD? To prevent issues like above in user application.

author
#4 lore raw
Quoted 20 lines

-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Tuesday, May 12, 2020 12:29 AM
To: Xu, Ting <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Xing, Beilei <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]; Andrew Rybchenko <[email protected]>; Thomas Monjalon <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1] app/testpmd: fix DCB set failure in FreeBSD by clang

Quoted 5 lines · Ting Xu

When set DCB in testpmd by clang, there is a segmentation fault. It is because the local variable rss_conf in get_eth_dcb_conf() is not cleared, so that the pointer member variable rss_key has a random address, which leads to an error in the following processing. This patch initialized the local variable rss_conf to avoid random address.

Quoted 4 lines

This is nothing really FreeBSD or clang issue, although it may be reproduced that environment, this is a pointer with random value issue. We may drop FreeBSD and clang reference to not create confusion.

OK, I will modify the commit log.

Quoted 6 lines
Quoted 2 lines
Fixes b57b66a97ebf ("app/testpmd: support mbuf dynamic flag")

This commit looks unrelated, if not can you please explain why above commit causing the issue?

This is the bad commit the validation team find for this issue. Honestly speaking, I did not find the relation between this commit and the issue either.

Quoted 21 lines

app/test-pmd/testpmd.c get_eth_dcb_conf(portid_t pid, struct

Quoted 12 lines
---
 app/test-pmd/testpmd.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

99bacddbf..1276476ca 100644

app/test-pmd/testpmd.c +0 -0
@@ -3408,6 +3408,7 @@ get_eth_dcb_conf(portid_t pid, struct

rte_eth_conf *eth_conf,

app/test-pmd/testpmd.c get_eth_dcb_conf(portid_t pid, struct rte_eth_conf *eth_conf, · line 3411

Quoted 4 lines
app/test-pmd/testpmd.c +1 -0
 	int32_t rc;
 	struct rte_eth_rss_conf rss_conf;
 
+	memset(&rss_conf, 0, sizeof(struct rte_eth_rss_conf));

The variable is used in the 'else' leg, memset can be moved there, but more importantly should this be done in the 'rte_eth_dev_rss_hash_conf_get()' API.

Quoted 5 lines

@Andrew, @Thomas,

What do you think 'rte_eth_dev_rss_hash_conf_get()' memset the 'rss_conf' param before passing it to the PMD? To prevent issues like above in user application.

I will move it to the else leg first in the v2 patch. Wait for more comments. Thanks!

#5 lore raw

Hi Ting,

Quoted 68 lines

-----Original Message-----
From: Xu, Ting <[email protected]>
Sent: Tuesday, May 12, 2020 3:17 AM
To: Yigit, Ferruh <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Xing, Beilei <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]; Andrew Rybchenko <[email protected]>; Thomas Monjalon <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v1] app/testpmd: fix DCB set failure in FreeBSD by clang

Quoted 8 lines

-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Tuesday, May 12, 2020 12:29 AM
To: Xu, Ting <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>; Xing, Beilei <[email protected]>; Iremonger, Bernard <[email protected]>; [email protected]; Andrew Rybchenko <[email protected]>; Thomas Monjalon

<[email protected]>

Quoted 10 lines

Subject: Re: [dpdk-dev] [PATCH v1] app/testpmd: fix DCB set failure in FreeBSD by clang

Quoted 5 lines · Ting Xu

When set DCB in testpmd by clang, there is a segmentation fault. It is because the local variable rss_conf in get_eth_dcb_conf() is not cleared, so that the pointer member variable rss_key has a random address, which leads to an error in the following processing. This patch initialized the local variable rss_conf to avoid random address.

Quoted 4 lines

This is nothing really FreeBSD or clang issue, although it may be reproduced that environment, this is a pointer with random value issue. We may drop FreeBSD and clang reference to not create confusion.

OK, I will modify the commit log.

Quoted 6 lines
Quoted 2 lines
Fixes b57b66a97ebf ("app/testpmd: support mbuf dynamic flag")

This commit looks unrelated, if not can you please explain why above commit causing the issue?

This is the bad commit the validation team find for this issue. Honestly speaking, I did not find the relation between this commit and the issue either.

Quoted 18 lines

app/test-pmd/testpmd.c get_eth_dcb_conf(portid_t pid, struct

Quoted 12 lines
---
 app/test-pmd/testpmd.c | 1 +
 1 file changed, 1 insertion(+)
app/test-pmd/testpmd.c index renamed from app/test-pmd/testpmd.c +0 -0

99bacddbf..1276476ca 100644

app/test-pmd/testpmd.c +0 -0
@@ -3408,6 +3408,7 @@ get_eth_dcb_conf(portid_t pid, struct

rte_eth_conf *eth_conf,

Quoted 4 lines
app/test-pmd/testpmd.c +1 -0
 int32_t rc;
 struct rte_eth_rss_conf rss_conf;
 
+memset(&rss_conf, 0, sizeof(struct rte_eth_rss_conf));
Quoted 10 lines
Quoted 2 lines

The variable is used in the 'else' leg, memset can be moved there, but more importantly should this be done in the

'rte_eth_dev_rss_hash_conf_get()' API.

Quoted 4 lines

@Andrew, @Thomas,

What do you think 'rte_eth_dev_rss_hash_conf_get()' memset the

'rss_conf'

Quoted 2 lines

param before passing it to the PMD? To prevent issues like above in user application.

Seems like a good idea to me, to fix it in rte_eth_dev_rss_hash_conf_get() instead of in testpmd.

Quoted 3 lines

I will move it to the else leg first in the v2 patch. Wait for more comments. Thanks!

Regards,

Bernard.

author
#6 lore raw

PATCH v2 1/1 app/testpmd: fix DCB set failure

In reply to Ting Xu

When set DCB in testpmd, there is a segmentation fault. It is because the local variable rss_conf in get_eth_dcb_conf() is not cleared, so that the pointer member variable rss_key has a random address, which leads to an error in the following processing. This patch initialized the local variable rss_conf to avoid this situation.

Fixes ac7c491c3fec ("app/testpmd: fix DCB config")

---
v1->v2: modify commit log, move memset to else leg

---
 app/test-pmd/testpmd.c | 2 ++
 1 file changed, 2 insertions(+)
app/test-pmd/testpmd.c +2 -0
index a2d0be56b..9ad34421c 100644
@@ -3448,6 +3448,8 @@ get_eth_dcb_conf(portid_t pid, struct rte_eth_conf *eth_conf,
 		struct rte_eth_dcb_tx_conf *tx_conf =
 				&eth_conf->tx_adv_conf.dcb_tx_conf;
 
+		memset(&rss_conf, 0, sizeof(struct rte_eth_rss_conf));
+
 		rc = rte_eth_dev_rss_hash_conf_get(pid, &rss_conf);
 		if (rc != 0)
 			return rc;
Signature · 1 line
2.17.1
Reviewed-by on v2 1/1 Applied
#7 lore raw

Re: [dpdk-dev] [PATCH v2] app/testpmd: fix DCB set failure

Quoted 11 lines · Ting Xu

When set DCB in testpmd, there is a segmentation fault. It is because the local variable rss_conf in get_eth_dcb_conf() is not cleared, so that the pointer member variable rss_key has a random address, which leads to an error in the following processing. This patch initialized the local variable rss_conf to avoid this situation.

Fixes ac7c491c3fec ("app/testpmd: fix DCB config")

Applied to dpdk-next-net/master, thanks.

author
#8 lore raw

PATCH v3 1/1 app/testpmd: fix DCB set failure

In reply to Ting Xu

When set DCB in testpmd, there is a segmentation fault. It is because the local variable rss_conf in get_eth_dcb_conf() is not cleared, so that the pointer member variable rss_key has a random address, which leads to an error in the following processing. This patch initialized the local variable rss_conf to avoid this situation.

Fixes ac7c491c3fec ("app/testpmd: fix DCB config")

---
v2->v3: move memset to rte_eth_dev_rss_hash_conf_get from testpmd v1->v2: modify commit log, move memset to else leg

---
 lib/librte_ethdev/rte_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_ethdev/rte_ethdev.c +2 -0
index 8e10a6fc3..6c86d7a73 100644
@@ -3549,6 +3549,8 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
 {
 	struct rte_eth_dev *dev;
 
+	memset(&rss_conf, 0, sizeof(struct rte_eth_rss_conf));
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
Signature · 1 line
2.17.1
author
#9 lore raw

PATCH v4 1/1 app/testpmd: fix DCB set failure

In reply to Ting Xu

When set DCB in testpmd, there is a segmentation fault. It is because the local variable rss_conf in get_eth_dcb_conf() is not cleared, so that the pointer member variable rss_key has a random address, which leads to an error in the following processing. This patch initialized the local variable rss_conf to avoid this situation.

Fixes ac7c491c3fec ("app/testpmd: fix DCB config")

---
V3->v4: fix build failure
v2->v3: move memset to rte_eth_dev_rss_hash_conf_get from testpmd v1->v2: modify commit log, move memset to else leg

---
 lib/librte_ethdev/rte_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_ethdev/rte_ethdev.c +2 -0
index 8e10a6fc3..1f6ca742a 100644
@@ -3549,6 +3549,8 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
 {
 	struct rte_eth_dev *dev;
 
+	memset(rss_conf, 0, sizeof(*rss_conf));
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
Signature · 1 line
2.17.1
#10 lore raw

Re: [dpdk-dev] [PATCH v4] app/testpmd: fix DCB set failure

Hi Ting,

Quoted 7 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ting Xu
Sent: Wednesday, May 13, 2020 11:08 AM
To: [email protected]
Cc: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]
Subject: [dpdk-dev] [PATCH v4] app/testpmd: fix DCB set failure

The fix is no longer in testpmd, so the commit line should be "ethdev: fix DCB set failure".

Quoted 5 lines

When set DCB in testpmd, there is a segmentation fault. It is because the local variable rss_conf in get_eth_dcb_conf() is not cleared, so that the pointer member variable rss_key has a random address, which leads to an error in the following processing. This patch initialized the local variable rss_conf to avoid this situation.

The commit message should probably be revised.

Quoted 2 lines
Fixes ac7c491c3fec ("app/testpmd: fix DCB config")

Also the Fixes line may need to change.

Quoted 17 lines

---
V3->v4: fix build failure
v2->v3: move memset to rte_eth_dev_rss_hash_conf_get from testpmd v1->v2: modify commit log, move memset to else leg

---
 lib/librte_ethdev/rte_ethdev.c | 2 ++
 1 file changed, 2 insertions(+)
lib/librte_ethdev/rte_ethdev.c +0 -0
index 8e10a6fc3..1f6ca742a 100644

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_rss_hash_conf_get(uint16_t port_id, · line 3552

Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +1 -0
@@ -3549,6 +3549,8 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
 {
 	struct rte_eth_dev *dev;
 
+	memset(rss_conf, 0, sizeof(*rss_conf));

The memset call should be moved to after the error checks to just before the function is called.

Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +1 -2
+
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get,
-ENOTSUP);
--

2.17.1

Regards,

Bernard.

#11 lore raw

Re: [dpdk-dev] [PATCH v4] app/testpmd: fix DCB set failure

13/05/2020 10:54, Iremonger, Bernard:

Quoted 1 line

The fix is no longer in testpmd, so the commit line should be "ethdev: fix DCB set failure".

In general, the word "failure" (or error, etc) is not needed. Because it is a fix, we know there was a failure before :)

And specifically here, you are not fixing just DCB.

author
#12 lore raw

PATCH v5 1/1 ethdev: fix DCB set failure

In reply to Ting Xu

When rte_eth_dev_rss_hash_conf_get() is called, if the variable rss_conf is not initialized, the pointer member variable rss_key may have a random address, which leads to an error in the following processing. This patch initialized the variable rss_conf to avoid this situation.

Fixes 16321de09396 ("ethdev: allow to get RSS hash functions and key")

---
v4->v5: modify commit log
V3->v4: fix build failure
v2->v3: move memset to rte_eth_dev_rss_hash_conf_get from testpmd v1->v2: modify commit log, move memset to else leg

---
 lib/librte_ethdev/rte_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_ethdev/rte_ethdev.c +1 -0
index 8e10a6fc3..b20c6bb2d 100644
@@ -3552,6 +3552,7 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
+	memset(rss_conf, 0, sizeof(*rss_conf));
 	return eth_err(port_id, (*dev->dev_ops->rss_hash_conf_get)(dev,
 								   rss_conf));
 }
Signature · 1 line
2.17.1
Reviewed-by on v5 1/1 Applied
#13 lore raw

Re: [dpdk-dev] [PATCH v5] ethdev: fix DCB set failure

Quoted 11 lines · Ting Xu

When rte_eth_dev_rss_hash_conf_get() is called, if the variable rss_conf is not initialized, the pointer member variable rss_key may have a random address, which leads to an error in the following processing. This patch initialized the variable rss_conf to avoid this situation.

Fixes 16321de09396 ("ethdev: allow to get RSS hash functions and key")

Applied to dpdk-next-net/master, thanks.

#14 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v5] ethdev: fix DCB set failure

Quoted 10 lines · Ferruh Yigit
Quoted 9 lines · Ting Xu

When rte_eth_dev_rss_hash_conf_get() is called, if the variable rss_conf is not initialized, the pointer member variable rss_key may have a random address, which leads to an error in the following processing. This patch initialized the variable rss_conf to avoid this situation.

Fixes 16321de09396 ("ethdev: allow to get RSS hash functions and key")
Quoted 7 lines
Quoted 2 lines

Applied to dpdk-next-net/master, thanks.

Dropped from next-net.

Reviewed-by on v5 1/1
#15 lore raw

Re: [dpdk-dev] [PATCH v5] ethdev: fix DCB set failure

In reply to Ting Xu
Quoted 43 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ting Xu
Sent: Wednesday, May 13, 2020 6:16 PM
To: [email protected]
Cc: [email protected]; Yigit, Ferruh <[email protected]>; [email protected]; [email protected]
Subject: [dpdk-dev] [PATCH v5] ethdev: fix DCB set failure

When rte_eth_dev_rss_hash_conf_get() is called, if the variable rss_conf is not initialized, the pointer member variable rss_key may have a random address, which leads to an error in the following processing. This patch initialized the variable rss_conf to avoid this situation.

Fixes 16321de09396 ("ethdev: allow to get RSS hash functions and key")

---
v4->v5: modify commit log
V3->v4: fix build failure
v2->v3: move memset to rte_eth_dev_rss_hash_conf_get from testpmd v1->v2: modify commit log, move memset to else leg

---
 lib/librte_ethdev/rte_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_ethdev/rte_ethdev.c +1 -2
index 8e10a6fc3..b20c6bb2d 100644
@@ -3552,6 +3552,7 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get,
-ENOTSUP);
+	memset(rss_conf, 0, sizeof(*rss_conf));
 	return eth_err(port_id, (*dev->dev_ops->rss_hash_conf_get)(dev,
 								   rss_conf));
 }
--
Quoted 1 line

2.17.1

The commit line should probably be reworded to describe the revised fix.

Otherwise

#16 lore raw

Re: [dpdk-dev] [PATCH v5] ethdev: fix DCB set failure

In reply to Ting Xu

CC net/nfp maintainer

Quoted 26 lines · Ting Xu

When rte_eth_dev_rss_hash_conf_get() is called, if the variable rss_conf is not initialized, the pointer member variable rss_key may have a random address, which leads to an error in the following processing. This patch initialized the variable rss_conf to avoid this situation.

Fixes 16321de09396 ("ethdev: allow to get RSS hash functions and key")

---
v4->v5: modify commit log
V3->v4: fix build failure
v2->v3: move memset to rte_eth_dev_rss_hash_conf_get from testpmd v1->v2: modify commit log, move memset to else leg

---
 lib/librte_ethdev/rte_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_ethdev/rte_ethdev.c +0 -0
index 8e10a6fc3..b20c6bb2d 100644

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_rss_hash_conf_get(uint16_t port_id, · line 3558

Quoted 7 lines
lib/librte_ethdev/rte_ethdev.c +1 -0
@@ -3552,6 +3552,7 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
+	memset(rss_conf, 0, sizeof(*rss_conf));
 	return eth_err(port_id, (*dev->dev_ops->rss_hash_conf_get)(dev,
 								   rss_conf));
 }

The patch breaks getting of RSS key since it resets rss_conf->rss_key to NULL, but all drivers treat it as
a pointer to buffer to copy RSS key to.
Almost all driver just skip RSS key copy if the pointer
is NULL.

I think it should be removed from next-net or improved to reset rss_hf only since rss_key_len may be treated as a size of rss_key buffer. The API is not clear at the place.

It looks like net/nfp is the only driver which does not check that that pointer is not NULL before coping key to it.

#17 lore raw

Re: [dpdk-dev] [PATCH v5] ethdev: fix DCB set failure

Hi

From: Andrew Rybchenko

Quoted 44 lines

CC net/nfp maintainer

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_rss_hash_conf_get(uint16_t

Quoted 26 lines · Ting Xu

When rte_eth_dev_rss_hash_conf_get() is called, if the variable rss_conf is not initialized, the pointer member variable rss_key may have a random address, which leads to an error in the following processing. This patch initialized the variable rss_conf to avoid this situation.

Fixes 16321de09396 ("ethdev: allow to get RSS hash functions and

key")
Cc: [email protected]

---
v4->v5: modify commit log
V3->v4: fix build failure
v2->v3: move memset to rte_eth_dev_rss_hash_conf_get from testpmd v1->v2: modify commit log, move memset to else leg

---
 lib/librte_ethdev/rte_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/lib/librte_ethdev/rte_ethdev.c index 8e10a6fc3..b20c6bb2d 100644

lib/librte_ethdev/rte_ethdev.c +0 -0
@@ -3552,6 +3552,7 @@ rte_eth_dev_rss_hash_conf_get(uint16_t

port_id,

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_rss_hash_conf_get(uint16_t port_id,

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.c +0 -0
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get,

-ENOTSUP);

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_rss_hash_conf_get(uint16_t port_id, · line 3558

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +1 -0
+	memset(rss_conf, 0, sizeof(*rss_conf));
 	return eth_err(port_id, (*dev->dev_ops->rss_hash_conf_get)(dev,
 								   rss_conf));
 }

The patch breaks getting of RSS key since it resets rss_conf->rss_key to NULL, but all drivers treat it as a pointer to buffer to copy RSS key to. Almost all driver just skip RSS key copy if the pointer is NULL.

Quoted 6 lines

I think it should be removed from next-net or improved to reset rss_hf only since rss_key_len may be treated as a size of rss_key buffer. The API is not clear at the place.

It looks like net/nfp is the only driver which does not check that that pointer is not NULL before coping key to it.

+1

Looks like this breaks also Testpmd "show port 0 rss-hash key" command.

Matan

#18 lore raw

Re: [dpdk-dev] [PATCH v5] ethdev: fix DCB set failure

Quoted 52 lines · Matan Azrad

Hi

From: Andrew Rybchenko

Quoted 48 lines

CC net/nfp maintainer

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_rss_hash_conf_get(uint16_t

Quoted 26 lines · Ting Xu

When rte_eth_dev_rss_hash_conf_get() is called, if the variable rss_conf is not initialized, the pointer member variable rss_key may have a random address, which leads to an error in the following processing. This patch initialized the variable rss_conf to avoid this situation.

Fixes 16321de09396 ("ethdev: allow to get RSS hash functions and

key")
Cc: [email protected]

---
v4->v5: modify commit log
V3->v4: fix build failure
v2->v3: move memset to rte_eth_dev_rss_hash_conf_get from testpmd v1->v2: modify commit log, move memset to else leg

---
 lib/librte_ethdev/rte_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/lib/librte_ethdev/rte_ethdev.c index 8e10a6fc3..b20c6bb2d 100644

lib/librte_ethdev/rte_ethdev.c +0 -0
@@ -3552,6 +3552,7 @@ rte_eth_dev_rss_hash_conf_get(uint16_t

port_id,

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_rss_hash_conf_get(uint16_t port_id,

Quoted 3 lines
lib/librte_ethdev/rte_ethdev.c +0 -0
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get,

-ENOTSUP);

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_rss_hash_conf_get(uint16_t port_id, · line 3558

Quoted 5 lines
lib/librte_ethdev/rte_ethdev.c +1 -0
+	memset(rss_conf, 0, sizeof(*rss_conf));
 	return eth_err(port_id, (*dev->dev_ops->rss_hash_conf_get)(dev,
 								   rss_conf));
 }

The patch breaks getting of RSS key since it resets rss_conf->rss_key to NULL, but all drivers treat it as a pointer to buffer to copy RSS key to. Almost all driver just skip RSS key copy if the pointer is NULL.

I think it should be removed from next-net or improved to reset rss_hf only since rss_key_len may be treated as a size of rss_key buffer. The API is not clear at the place.

Quoted 8 lines
Quoted 2 lines

It looks like net/nfp is the only driver which does not check that that pointer is not NULL before coping key to it.

+1

Looks like this breaks also Testpmd "show port 0 rss-hash key" command.

Hi Matan, it is clearly wrong, I will drop it.

#19 lore raw

Re: [dpdk-dev] [PATCH v5] ethdev: fix DCB set failure

In reply to Andrew Rybchenko
Quoted 32 lines · Andrew Rybchenko

CC net/nfp maintainer

Quoted 29 lines · Ting Xu

When rte_eth_dev_rss_hash_conf_get() is called, if the variable rss_conf is not initialized, the pointer member variable rss_key may have a random address, which leads to an error in the following processing. This patch initialized the variable rss_conf to avoid this situation.

Fixes 16321de09396 ("ethdev: allow to get RSS hash functions and key")

---
v4->v5: modify commit log
V3->v4: fix build failure
v2->v3: move memset to rte_eth_dev_rss_hash_conf_get from testpmd v1->v2: modify commit log, move memset to else leg

---
 lib/librte_ethdev/rte_ethdev.c | 1 +
 1 file changed, 1 insertion(+)
lib/librte_ethdev/rte_ethdev.c +1 -0
index 8e10a6fc3..b20c6bb2d 100644
@@ -3552,6 +3552,7 @@ rte_eth_dev_rss_hash_conf_get(uint16_t port_id,
 	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
 	dev = &rte_eth_devices[port_id];
 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rss_hash_conf_get, -ENOTSUP);
+	memset(rss_conf, 0, sizeof(*rss_conf));
Quoted 8 lines

lib/librte_ethdev/rte_ethdev.c rte_eth_dev_rss_hash_conf_get(uint16_t port_id, · line 3558

Quoted 4 lines
lib/librte_ethdev/rte_ethdev.c +0 -0
 	return eth_err(port_id, (*dev->dev_ops->rss_hash_conf_get)(dev,
 								   rss_conf));
 }

The patch breaks getting of RSS key since it resets rss_conf->rss_key to NULL, but all drivers treat it as
a pointer to buffer to copy RSS key to.

:(
Of course it is a pointer to copy the RSS key, no idea what I was thinking.

Thanks for catching this before goes into main repo.

Quoted 4 lines

Almost all driver just skip RSS key copy if the pointer is NULL.

I think it should be removed from next-net or improved

+1, I will drop the ethdev patch, and replace it with the testpmd one.

Quoted 8 lines

to reset rss_hf only since rss_key_len may be treated as a size of rss_key buffer. The API is not clear at the place.

It looks like net/nfp is the only driver which does not check that that pointer is not NULL before coping key to it.