* [PATCH] pipeline: fix emit instruction for invalid headers
@ 2022-04-27 21:56 Cristian Dumitrescu
2022-06-01 11:55 ` Thomas Monjalon
0 siblings, 1 reply; 2+ messages in thread
From: Cristian Dumitrescu @ 2022-04-27 21:56 UTC (permalink / raw)
To: dev; +Cc: stable, Venkata Suresh Kumar P, Yogesh Jangra
Fix the emit instruction for the pathological case of all headers to
be emitted being invalid. In this case, the for loop was essentially
skipped and the last emitted header (or an invalid memory location)
getting corrupted by setting its size to 0 through the assignment to
ho->n_bytes right after the for loop.
Fixes: d60dbdc88a3e ("pipeline: create inline functions for emit instruction")
Cc: stable@dpdk.org
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Venkata Suresh Kumar P <venkata.suresh.kumar.p@intel.com>
Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>
---
lib/pipeline/rte_swx_pipeline_internal.h | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/lib/pipeline/rte_swx_pipeline_internal.h b/lib/pipeline/rte_swx_pipeline_internal.h
index f8a6661f75..dd1d499f57 100644
--- a/lib/pipeline/rte_swx_pipeline_internal.h
+++ b/lib/pipeline/rte_swx_pipeline_internal.h
@@ -2010,9 +2010,9 @@ __instr_hdr_emit_many_exec(struct rte_swx_pipeline *p __rte_unused,
{
uint64_t valid_headers = t->valid_headers;
uint32_t n_headers_out = t->n_headers_out;
- struct header_out_runtime *ho = &t->headers_out[n_headers_out - 1];
+ struct header_out_runtime *ho = NULL;
uint8_t *ho_ptr = NULL;
- uint32_t ho_nbytes = 0, first = 1, i;
+ uint32_t ho_nbytes = 0, i;
for (i = 0; i < n_emit; i++) {
uint32_t header_id = ip->io.hdr.header_id[i];
@@ -2024,18 +2024,21 @@ __instr_hdr_emit_many_exec(struct rte_swx_pipeline *p __rte_unused,
uint8_t *hi_ptr = t->structs[struct_id];
- if (!MASK64_BIT_GET(valid_headers, header_id))
+ if (!MASK64_BIT_GET(valid_headers, header_id)) {
+ TRACE("[Thread %2u]: emit header %u (invalid)\n",
+ p->thread_id,
+ header_id);
+
continue;
+ }
- TRACE("[Thread %2u]: emit header %u\n",
+ TRACE("[Thread %2u]: emit header %u (valid)\n",
p->thread_id,
header_id);
/* Headers. */
- if (first) {
- first = 0;
-
- if (!t->n_headers_out) {
+ if (!ho) {
+ if (!n_headers_out) {
ho = &t->headers_out[0];
ho->ptr0 = hi_ptr0;
@@ -2048,6 +2051,8 @@ __instr_hdr_emit_many_exec(struct rte_swx_pipeline *p __rte_unused,
continue;
} else {
+ ho = &t->headers_out[n_headers_out - 1];
+
ho_ptr = ho->ptr;
ho_nbytes = ho->n_bytes;
}
@@ -2069,7 +2074,8 @@ __instr_hdr_emit_many_exec(struct rte_swx_pipeline *p __rte_unused,
}
}
- ho->n_bytes = ho_nbytes;
+ if (ho)
+ ho->n_bytes = ho_nbytes;
t->n_headers_out = n_headers_out;
}
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] pipeline: fix emit instruction for invalid headers
2022-04-27 21:56 [PATCH] pipeline: fix emit instruction for invalid headers Cristian Dumitrescu
@ 2022-06-01 11:55 ` Thomas Monjalon
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2022-06-01 11:55 UTC (permalink / raw)
To: Cristian Dumitrescu; +Cc: dev, stable, Venkata Suresh Kumar P, Yogesh Jangra
27/04/2022 23:56, Cristian Dumitrescu:
> Fix the emit instruction for the pathological case of all headers to
> be emitted being invalid. In this case, the for loop was essentially
> skipped and the last emitted header (or an invalid memory location)
> getting corrupted by setting its size to 0 through the assignment to
> ho->n_bytes right after the for loop.
>
> Fixes: d60dbdc88a3e ("pipeline: create inline functions for emit instruction")
> Cc: stable@dpdk.org
>
> Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
> Signed-off-by: Venkata Suresh Kumar P <venkata.suresh.kumar.p@intel.com>
> Signed-off-by: Yogesh Jangra <yogesh.jangra@intel.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-01 11:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27 21:56 [PATCH] pipeline: fix emit instruction for invalid headers Cristian Dumitrescu
2022-06-01 11:55 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).