examples/l3fwd: Fix core dump with multiple socket

Message ID 20240703075038.1594523-1-kaiwenx.deng@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series examples/l3fwd: Fix core dump with multiple socket |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS

Commit Message

Kaiwen Deng July 3, 2024, 7:50 a.m. UTC
Setting acl will clear the acl config of other sockets, which
will result in core dump.

This commit will no longer clear the acl config when setting acl.

Fixes: 6de0ea50e9b9 ("examples/l3fwd: merge l3fwd-acl example")
Cc: stable@dpdk.org

Signed-off-by: Kaiwen Deng <kaiwenx.deng@intel.com>
---
 examples/l3fwd/l3fwd_acl.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Li, HongboX July 3, 2024, 10:09 a.m. UTC | #1
> -----Original Message-----
> From: Kaiwen Deng <kaiwenx.deng@intel.com>
> Sent: Wednesday, July 3, 2024 3:51 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Zhou, YidingX <yidingx.zhou@intel.com>; Deng, KaiwenX
> <kaiwenx.deng@intel.com>; Sean Morrissey <sean.morrissey@intel.com>
> Subject: [PATCH] examples/l3fwd: Fix core dump with multiple socket
> 
> Setting acl will clear the acl config of other sockets, which will result in core
> dump.
> 
> This commit will no longer clear the acl config when setting acl.
> 
> Fixes: 6de0ea50e9b9 ("examples/l3fwd: merge l3fwd-acl example")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Kaiwen Deng <kaiwenx.deng@intel.com>
> ---

Tested-by: Li, Hongbo <hongbox.li@intel.com>
  
Konstantin Ananyev July 3, 2024, 10:11 a.m. UTC | #2
> 
> Setting acl will clear the acl config of other sockets, which
> will result in core dump.
> 
> This commit will no longer clear the acl config when setting acl.
> 
> Fixes: 6de0ea50e9b9 ("examples/l3fwd: merge l3fwd-acl example")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Kaiwen Deng <kaiwenx.deng@intel.com>
> ---
>  examples/l3fwd/l3fwd_acl.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/examples/l3fwd/l3fwd_acl.c b/examples/l3fwd/l3fwd_acl.c
> index 401692bcec..c8958f59fc 100644
> --- a/examples/l3fwd/l3fwd_acl.c
> +++ b/examples/l3fwd/l3fwd_acl.c
> @@ -962,8 +962,6 @@ setup_acl(const int socket_id)
>  	acl_log("IPv6 ACL entries %u:\n", acl_num_ipv6);
>  	dump_ipv6_rules((struct acl6_rule *)acl_base_ipv6, acl_num_ipv6, 1);
> 
> -	memset(&acl_config, 0, sizeof(acl_config));
> -
>  	/* Check sockets a context should be created on */
>  	if (socket_id >= NB_SOCKETS) {
>  		acl_log("Socket %d is out "
> @@ -973,6 +971,9 @@ setup_acl(const int socket_id)
>  		return;
>  	}
> 
> +	rte_acl_free(acl_config.acx_ipv4[socket_id]);
> +	rte_acl_free(acl_config.acx_ipv6[socket_id]);
> +
>  	acl_config.acx_ipv4[socket_id] = app_acl_init(route_base_ipv4,
>  		acl_base_ipv4, route_num_ipv4, acl_num_ipv4,
>  		0, socket_id);
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
 
> 2.34.1
  
Thomas Monjalon July 23, 2024, 4:09 p.m. UTC | #3
03/07/2024 12:11, Konstantin Ananyev:
> 
> > 
> > Setting acl will clear the acl config of other sockets, which
> > will result in core dump.
> > 
> > This commit will no longer clear the acl config when setting acl.
> > 
> > Fixes: 6de0ea50e9b9 ("examples/l3fwd: merge l3fwd-acl example")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Kaiwen Deng <kaiwenx.deng@intel.com>
> 
> Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>

Applied, thanks.

Maybe we should have made clear which kind of socket we are talking about.
  

Patch

diff --git a/examples/l3fwd/l3fwd_acl.c b/examples/l3fwd/l3fwd_acl.c
index 401692bcec..c8958f59fc 100644
--- a/examples/l3fwd/l3fwd_acl.c
+++ b/examples/l3fwd/l3fwd_acl.c
@@ -962,8 +962,6 @@  setup_acl(const int socket_id)
 	acl_log("IPv6 ACL entries %u:\n", acl_num_ipv6);
 	dump_ipv6_rules((struct acl6_rule *)acl_base_ipv6, acl_num_ipv6, 1);
 
-	memset(&acl_config, 0, sizeof(acl_config));
-
 	/* Check sockets a context should be created on */
 	if (socket_id >= NB_SOCKETS) {
 		acl_log("Socket %d is out "
@@ -973,6 +971,9 @@  setup_acl(const int socket_id)
 		return;
 	}
 
+	rte_acl_free(acl_config.acx_ipv4[socket_id]);
+	rte_acl_free(acl_config.acx_ipv6[socket_id]);
+
 	acl_config.acx_ipv4[socket_id] = app_acl_init(route_base_ipv4,
 		acl_base_ipv4, route_num_ipv4, acl_num_ipv4,
 		0, socket_id);