Skip to contentSkip to conversation

lib/distributor: fix segfaults in flush

PATCH Superseded David Hunt 4 participants 5 messages Apr 13, 2017 – Apr 20, 2017

lore
Share & tools
lore

David Hunt

author
#0 lore raw

PATCH 1/1 lib/distributor: fix segfaults in flush

A segfault when flushing packets has been revealed by further testing when using distributor in single packet mode. This patch resolves that.

Fixes 775003ad2f96 ("distributor: add new burst-capable library")
---
 lib/librte_distributor/rte_distributor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/librte_distributor/rte_distributor.c +4 -1
index 4725904..e4dfa7f 100644
@@ -555,7 +555,7 @@ total_outstanding(const struct rte_distributor *d)
 int
 rte_distributor_flush_v1705(struct rte_distributor *d)
 {
-	const unsigned int flushed = total_outstanding(d);
+	unsigned int flushed;
 	unsigned int wkr;
 
 	if (d->alg_type == RTE_DIST_ALG_SINGLE) {
@@ -563,6 +563,8 @@ rte_distributor_flush_v1705(struct rte_distributor *d)
 		return rte_distributor_flush_v20(d->d_v20);
 	}
 
+	flushed = total_outstanding(d);
+
 	while (total_outstanding(d) > 0)
 		rte_distributor_process(d, NULL, 0);
 
@@ -590,6 +592,7 @@ rte_distributor_clear_returns_v1705(struct rte_distributor *d)
 	if (d->alg_type == RTE_DIST_ALG_SINGLE) {
 		/* Call the old API */
 		rte_distributor_clear_returns_v20(d->d_v20);
+		return;
 	}
 
 	/* throw away returns, so workers can exit */
Signature · 1 line
2.7.4
Tested-by on v1 1/1
#1 lore raw
Quoted 7 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of David Hunt
Sent: Thursday, April 13, 2017 4:36 PM
To: [email protected]
Cc: Hunt, David <[email protected]>
Subject: [dpdk-dev] [PATCH v1] lib/distributor: fix segfaults in flush

Quoted 8 lines

A segfault when flushing packets has been revealed by further testing when using distributor in single packet mode. This patch resolves that.

Fixes 775003ad2f96 ("distributor: add new burst-capable library")

---

Acked-by on v1 1/1
#2 lore raw
In reply to David Hunt
Quoted 7 lines · David Hunt

A segfault when flushing packets has been revealed by further testing when using distributor in single packet mode. This patch resolves that.

Fixes 775003ad2f96 ("distributor: add new burst-capable library")

Hi Dave,

I think you could do with giving more details in the commit messaage on how/why the error occurs and how exactly this patch fixes it.

With expanded commit log message:

author
#3 lore raw

PATCH v2 1/1 lib/distributor: fix segfaults in flush

In reply to David Hunt

Occasionally, the distributor single-packet-at-a-time mode will segfault because it inadvertently calls some burst mode code when flushing packets.

This patch ensures that only the v20 (single mode) codepath is used, and returns without falling through to the burst mode code.

Fixes 775003ad2f96 ("distributor: add new burst-capable library")

v2: Extented commit message. Patch remains the same.

---
 lib/librte_distributor/rte_distributor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/librte_distributor/rte_distributor.c +4 -1
index 4725904..e4dfa7f 100644
@@ -555,7 +555,7 @@ total_outstanding(const struct rte_distributor *d)
 int
 rte_distributor_flush_v1705(struct rte_distributor *d)
 {
-	const unsigned int flushed = total_outstanding(d);
+	unsigned int flushed;
 	unsigned int wkr;
 
 	if (d->alg_type == RTE_DIST_ALG_SINGLE) {
@@ -563,6 +563,8 @@ rte_distributor_flush_v1705(struct rte_distributor *d)
 		return rte_distributor_flush_v20(d->d_v20);
 	}
 
+	flushed = total_outstanding(d);
+
 	while (total_outstanding(d) > 0)
 		rte_distributor_process(d, NULL, 0);
 
@@ -590,6 +592,7 @@ rte_distributor_clear_returns_v1705(struct rte_distributor *d)
 	if (d->alg_type == RTE_DIST_ALG_SINGLE) {
 		/* Call the old API */
 		rte_distributor_clear_returns_v20(d->d_v20);
+		return;
 	}
 
 	/* throw away returns, so workers can exit */
Signature · 1 line
2.7.4
#4 lore raw

14/04/2017 10:59, David Hunt:

Quoted 7 lines

Occasionally, the distributor single-packet-at-a-time mode will segfault because it inadvertently calls some burst mode code when flushing packets.

This patch ensures that only the v20 (single mode) codepath is used, and returns without falling through to the burst mode code.

Quoted 7 lines
Fixes 775003ad2f96 ("distributor: add new burst-capable library")

v2: Extented commit message. Patch remains the same.

Applied, thanks