patch 'pipeline: fix table state memory allocation' has been queued to stable release 21.11.1

Kevin Traynor ktraynor at redhat.com
Mon Feb 21 16:36:24 CET 2022


Hi,

FYI, your patch has been queued to stable release 21.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/26/22. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/adfebc59b50ee65e2f0d4a75574ac3bc62e46317

Thanks.

Kevin

---
>From adfebc59b50ee65e2f0d4a75574ac3bc62e46317 Mon Sep 17 00:00:00 2001
From: Cristian Dumitrescu <cristian.dumitrescu at intel.com>
Date: Thu, 10 Feb 2022 19:45:08 +0000
Subject: [PATCH] pipeline: fix table state memory allocation

[ upstream commit eb3e2c11830e4d75ff5dff20cfa70599a1613f71 ]

The regular tables, selector tables and learner tables are all sharing
the table state array. The locations in this array were computed
incorrectly, leading to memory corruption issues.

Fixes: 4f59d3726147 ("pipeline: support learner tables")

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu at intel.com>
Signed-off-by: Harshad Narayane <harshad.suresh.narayane at intel.com>
Signed-off-by: Kamalakannan R <kamalakannan.r at intel.com>
Signed-off-by: Venkata Suresh Kumar P <venkata.suresh.kumar.p at intel.com>
---
 lib/pipeline/rte_swx_ctl.c      | 28 +++++++++++++++++-----------
 lib/pipeline/rte_swx_pipeline.c |  2 +-
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/lib/pipeline/rte_swx_ctl.c b/lib/pipeline/rte_swx_ctl.c
index 8e29d58cec..f52ccffd75 100644
--- a/lib/pipeline/rte_swx_ctl.c
+++ b/lib/pipeline/rte_swx_ctl.c
@@ -1022,5 +1022,5 @@ static void
 table_state_free(struct rte_swx_ctl_pipeline *ctl)
 {
-	uint32_t i;
+	uint32_t table_base_index, selector_base_index, learner_base_index, i;
 
 	if (!ctl->ts_next)
@@ -1028,7 +1028,8 @@ table_state_free(struct rte_swx_ctl_pipeline *ctl)
 
 	/* For each table, free its table state. */
+	table_base_index = 0;
 	for (i = 0; i < ctl->info.n_tables; i++) {
 		struct table *table = &ctl->tables[i];
-		struct rte_swx_table_state *ts = &ctl->ts_next[i];
+		struct rte_swx_table_state *ts = &ctl->ts_next[table_base_index + i];
 
 		/* Default action data. */
@@ -1041,6 +1042,7 @@ table_state_free(struct rte_swx_ctl_pipeline *ctl)
 
 	/* For each selector table, free its table state. */
+	selector_base_index = ctl->info.n_tables;
 	for (i = 0; i < ctl->info.n_selectors; i++) {
-		struct rte_swx_table_state *ts = &ctl->ts_next[i];
+		struct rte_swx_table_state *ts = &ctl->ts_next[selector_base_index + i];
 
 		/* Table object. */
@@ -1050,6 +1052,7 @@ table_state_free(struct rte_swx_ctl_pipeline *ctl)
 
 	/* For each learner table, free its table state. */
+	learner_base_index = ctl->info.n_tables + ctl->info.n_selectors;
 	for (i = 0; i < ctl->info.n_learners; i++) {
-		struct rte_swx_table_state *ts = &ctl->ts_next[i];
+		struct rte_swx_table_state *ts = &ctl->ts_next[learner_base_index + i];
 
 		/* Default action data. */
@@ -1064,8 +1067,8 @@ static int
 table_state_create(struct rte_swx_ctl_pipeline *ctl)
 {
+	uint32_t table_base_index, selector_base_index, learner_base_index, i;
 	int status = 0;
-	uint32_t i;
 
-	ctl->ts_next = calloc(ctl->info.n_tables + ctl->info.n_selectors,
+	ctl->ts_next = calloc(ctl->info.n_tables + ctl->info.n_selectors + ctl->info.n_learners,
 			      sizeof(struct rte_swx_table_state));
 	if (!ctl->ts_next) {
@@ -1075,8 +1078,9 @@ table_state_create(struct rte_swx_ctl_pipeline *ctl)
 
 	/* Tables. */
+	table_base_index = 0;
 	for (i = 0; i < ctl->info.n_tables; i++) {
 		struct table *table = &ctl->tables[i];
-		struct rte_swx_table_state *ts = &ctl->ts[i];
-		struct rte_swx_table_state *ts_next = &ctl->ts_next[i];
+		struct rte_swx_table_state *ts = &ctl->ts[table_base_index + i];
+		struct rte_swx_table_state *ts_next = &ctl->ts_next[table_base_index + i];
 
 		/* Table object. */
@@ -1111,7 +1115,8 @@ table_state_create(struct rte_swx_ctl_pipeline *ctl)
 
 	/* Selector tables. */
+	selector_base_index = ctl->info.n_tables;
 	for (i = 0; i < ctl->info.n_selectors; i++) {
 		struct selector *s = &ctl->selectors[i];
-		struct rte_swx_table_state *ts_next = &ctl->ts_next[ctl->info.n_tables + i];
+		struct rte_swx_table_state *ts_next = &ctl->ts_next[selector_base_index + i];
 
 		/* Table object. */
@@ -1124,8 +1129,9 @@ table_state_create(struct rte_swx_ctl_pipeline *ctl)
 
 	/* Learner tables. */
+	learner_base_index = ctl->info.n_tables + ctl->info.n_selectors;
 	for (i = 0; i < ctl->info.n_learners; i++) {
 		struct learner *l = &ctl->learners[i];
-		struct rte_swx_table_state *ts = &ctl->ts[i];
-		struct rte_swx_table_state *ts_next = &ctl->ts_next[i];
+		struct rte_swx_table_state *ts = &ctl->ts[learner_base_index + i];
+		struct rte_swx_table_state *ts_next = &ctl->ts_next[learner_base_index + i];
 
 		/* Table object: duplicate from the current table state. */
diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index 2145ca0a42..8d5073cf19 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -8532,5 +8532,5 @@ table_state_build(struct rte_swx_pipeline *p)
 	struct learner *l;
 
-	p->table_state = calloc(p->n_tables + p->n_selectors,
+	p->table_state = calloc(p->n_tables + p->n_selectors + p->n_learners,
 				sizeof(struct rte_swx_table_state));
 	CHECK(p->table_state, ENOMEM);
-- 
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-02-21 15:22:48.884407351 +0000
+++ 0195-pipeline-fix-table-state-memory-allocation.patch	2022-02-21 15:22:44.391704802 +0000
@@ -1 +1 @@
-From eb3e2c11830e4d75ff5dff20cfa70599a1613f71 Mon Sep 17 00:00:00 2001
+From adfebc59b50ee65e2f0d4a75574ac3bc62e46317 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit eb3e2c11830e4d75ff5dff20cfa70599a1613f71 ]
+
@@ -11 +12,0 @@
-Cc: stable at dpdk.org
@@ -107 +108 @@
-index 1a50c4bb72..f404ff1596 100644
+index 2145ca0a42..8d5073cf19 100644
@@ -110 +111 @@
-@@ -8568,5 +8568,5 @@ table_state_build(struct rte_swx_pipeline *p)
+@@ -8532,5 +8532,5 @@ table_state_build(struct rte_swx_pipeline *p)



More information about the stable mailing list