DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] pipeline: fix packet mirroring configuration
@ 2022-06-13 17:23 Cristian Dumitrescu
  2022-06-13 17:28 ` [PATCH V2] " Cristian Dumitrescu
  0 siblings, 1 reply; 3+ messages in thread
From: Cristian Dumitrescu @ 2022-06-13 17:23 UTC (permalink / raw)
  To: dev

Fix segmentation fault due to null pointer dereferencing inside the
"mirror" instruction when number of mirroring slots is set to 0. This
was taking place when the "mirror" instruction was used without the
mirror feature being properly configured, i.e. the API function
rte_swx_pipeline_mirroring_config was not called at initialization.

Fixes: dac0ecd9098 (" pipeline: support packet mirroring")

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/pipeline/rte_swx_pipeline.c |  5 ++---
 lib/pipeline/rte_swx_pipeline.h | 10 ++++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index 659d8726d1..066356684e 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -612,9 +612,6 @@ mirroring_build(struct rte_swx_pipeline *p)
 {
 	uint32_t i;
 
-	if (!p->n_mirroring_slots || !p->n_mirroring_sessions)
-		return 0;
-
 	for (i = 0; i < RTE_SWX_PIPELINE_THREADS_MAX; i++) {
 		struct thread *t = &p->threads[i];
 
@@ -9772,6 +9769,8 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)
 	TAILQ_INIT(&pipeline->metarrays);
 
 	pipeline->n_structs = 1; /* Struct 0 is reserved for action_data. */
+	pipeline->n_mirroring_slots = RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT;
+	pipeline->n_mirroring_sessions = RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT;
 	pipeline->numa_node = numa_node;
 
 	status = port_in_types_register(pipeline);
diff --git a/lib/pipeline/rte_swx_pipeline.h b/lib/pipeline/rte_swx_pipeline.h
index adc7fa53b7..184027ba44 100644
--- a/lib/pipeline/rte_swx_pipeline.h
+++ b/lib/pipeline/rte_swx_pipeline.h
@@ -163,6 +163,16 @@ rte_swx_pipeline_port_out_config(struct rte_swx_pipeline *p,
  * Packet mirroring
  */
 
+/** Default number of packet mirroring slots. */
+#ifndef RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT
+#define RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT 4
+#endif
+
+/** Default maxiumum number of packet mirroring sessions. */
+#ifndef RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT
+#define RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT 64
+#endif
+
 /** Packet mirroring parameters. */
 struct rte_swx_pipeline_mirroring_params {
 	/** Number of packet mirroring slots. */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH V2] pipeline: fix packet mirroring configuration
  2022-06-13 17:23 [PATCH] pipeline: fix packet mirroring configuration Cristian Dumitrescu
@ 2022-06-13 17:28 ` Cristian Dumitrescu
  2022-06-20 14:05   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Cristian Dumitrescu @ 2022-06-13 17:28 UTC (permalink / raw)
  To: dev

Fix segmentation fault due to null pointer dereferencing inside the
"mirror" instruction when number of mirroring slots is set to 0. This
was taking place when the "mirror" instruction was used without the
mirror feature being properly configured, i.e. the API function
rte_swx_pipeline_mirroring_config was not called at initialization.

Fixes: dac0ecd9098 (" pipeline: support packet mirroring")

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/pipeline/rte_swx_pipeline.c |  5 ++---
 lib/pipeline/rte_swx_pipeline.h | 10 ++++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index 659d8726d1..066356684e 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -612,9 +612,6 @@ mirroring_build(struct rte_swx_pipeline *p)
 {
 	uint32_t i;
 
-	if (!p->n_mirroring_slots || !p->n_mirroring_sessions)
-		return 0;
-
 	for (i = 0; i < RTE_SWX_PIPELINE_THREADS_MAX; i++) {
 		struct thread *t = &p->threads[i];
 
@@ -9772,6 +9769,8 @@ rte_swx_pipeline_config(struct rte_swx_pipeline **p, int numa_node)
 	TAILQ_INIT(&pipeline->metarrays);
 
 	pipeline->n_structs = 1; /* Struct 0 is reserved for action_data. */
+	pipeline->n_mirroring_slots = RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT;
+	pipeline->n_mirroring_sessions = RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT;
 	pipeline->numa_node = numa_node;
 
 	status = port_in_types_register(pipeline);
diff --git a/lib/pipeline/rte_swx_pipeline.h b/lib/pipeline/rte_swx_pipeline.h
index adc7fa53b7..9299f27094 100644
--- a/lib/pipeline/rte_swx_pipeline.h
+++ b/lib/pipeline/rte_swx_pipeline.h
@@ -163,6 +163,16 @@ rte_swx_pipeline_port_out_config(struct rte_swx_pipeline *p,
  * Packet mirroring
  */
 
+/** Default number of packet mirroring slots. */
+#ifndef RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT
+#define RTE_SWX_PACKET_MIRRORING_SLOTS_DEFAULT 4
+#endif
+
+/** Default maximum number of packet mirroring sessions. */
+#ifndef RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT
+#define RTE_SWX_PACKET_MIRRORING_SESSIONS_DEFAULT 64
+#endif
+
 /** Packet mirroring parameters. */
 struct rte_swx_pipeline_mirroring_params {
 	/** Number of packet mirroring slots. */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] pipeline: fix packet mirroring configuration
  2022-06-13 17:28 ` [PATCH V2] " Cristian Dumitrescu
@ 2022-06-20 14:05   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2022-06-20 14:05 UTC (permalink / raw)
  To: Cristian Dumitrescu; +Cc: dev

13/06/2022 19:28, Cristian Dumitrescu:
> Fix segmentation fault due to null pointer dereferencing inside the
> "mirror" instruction when number of mirroring slots is set to 0. This
> was taking place when the "mirror" instruction was used without the
> mirror feature being properly configured, i.e. the API function
> rte_swx_pipeline_mirroring_config was not called at initialization.
> 
> Fixes: dac0ecd9098 (" pipeline: support packet mirroring")
> 
> Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-20 14:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 17:23 [PATCH] pipeline: fix packet mirroring configuration Cristian Dumitrescu
2022-06-13 17:28 ` [PATCH V2] " Cristian Dumitrescu
2022-06-20 14:05   ` 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).