[v6,1/5] ip_frag: use a dynamic logtype

Message ID 20230220185001.50714-2-stephen@networkplumber.org (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Replace use of RTE_LOGTYPE_USER1 in libraries |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Feb. 20, 2023, 6:49 p.m. UTC
  DPDK libraries should not be reusing RTE_LOGTYPE_USER1 in
lieu of doing proper logtype registration.

Acked-by: Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>
Fixes: 416707812c03 ("ip_frag: refactor reassembly code into a proper library")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/ip_frag/ip_frag_common.h     | 5 ++++-
 lib/ip_frag/rte_ip_frag_common.c | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)
  

Comments

David Marchand Feb. 21, 2023, 10:41 a.m. UTC | #1
On Mon, Feb 20, 2023 at 7:50 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> DPDK libraries should not be reusing RTE_LOGTYPE_USER1 in
> lieu of doing proper logtype registration.
>
> Acked-by: Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>
> Fixes: 416707812c03 ("ip_frag: refactor reassembly code into a proper library")
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/ip_frag/ip_frag_common.h     | 5 ++++-
>  lib/ip_frag/rte_ip_frag_common.c | 2 ++
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/lib/ip_frag/ip_frag_common.h b/lib/ip_frag/ip_frag_common.h
> index 9c0dbdeb6eb9..95f1689d476d 100644
> --- a/lib/ip_frag/ip_frag_common.h
> +++ b/lib/ip_frag/ip_frag_common.h
> @@ -8,9 +8,12 @@
>  #include "rte_ip_frag.h"
>  #include "ip_reassembly.h"
>
> +extern int ipfrag_logtype;
> +#define RTE_LOGTYPE_IPFRAG     ipfrag_logtype
> +
>  /* logging macros. */
>  #ifdef RTE_LIBRTE_IP_FRAG_DEBUG
> -#define        IP_FRAG_LOG(lvl, fmt, args...)  RTE_LOG(lvl, USER1, fmt, ##args)
> +#define        IP_FRAG_LOG(lvl, fmt, args...)  RTE_LOG(lvl, IPFRAG, fmt, ##args)
>  #else
>  #define        IP_FRAG_LOG(lvl, fmt, args...)  do {} while(0)
>  #endif /* IP_FRAG_DEBUG */
> diff --git a/lib/ip_frag/rte_ip_frag_common.c b/lib/ip_frag/rte_ip_frag_common.c
> index c1de2e81b6d0..e4af8d23ad10 100644
> --- a/lib/ip_frag/rte_ip_frag_common.c
> +++ b/lib/ip_frag/rte_ip_frag_common.c
> @@ -7,6 +7,8 @@
>
>  #include <rte_log.h>
>
> +RTE_LOG_REGISTER_DEFAULT(ipfrag_logtype, INFO);
> +
>  #include "ip_frag_common.h"
>
>  #define        IP_FRAG_HASH_FNUM       2

There are still some parts using USER1 in this library:

lib/ip_frag/rte_ip_frag_common.c:               RTE_LOG(ERR, USER1,
"%s: invalid input parameter\n", __func__);
lib/ip_frag/rte_ip_frag_common.c:               RTE_LOG(ERR, USER1,
lib/ip_frag/rte_ip_frag_common.c:       RTE_LOG(INFO, USER1, "%s:
allocated of %zu bytes at socket %d\n",
  

Patch

diff --git a/lib/ip_frag/ip_frag_common.h b/lib/ip_frag/ip_frag_common.h
index 9c0dbdeb6eb9..95f1689d476d 100644
--- a/lib/ip_frag/ip_frag_common.h
+++ b/lib/ip_frag/ip_frag_common.h
@@ -8,9 +8,12 @@ 
 #include "rte_ip_frag.h"
 #include "ip_reassembly.h"
 
+extern int ipfrag_logtype;
+#define RTE_LOGTYPE_IPFRAG	ipfrag_logtype
+
 /* logging macros. */
 #ifdef RTE_LIBRTE_IP_FRAG_DEBUG
-#define	IP_FRAG_LOG(lvl, fmt, args...)	RTE_LOG(lvl, USER1, fmt, ##args)
+#define	IP_FRAG_LOG(lvl, fmt, args...)	RTE_LOG(lvl, IPFRAG, fmt, ##args)
 #else
 #define	IP_FRAG_LOG(lvl, fmt, args...)	do {} while(0)
 #endif /* IP_FRAG_DEBUG */
diff --git a/lib/ip_frag/rte_ip_frag_common.c b/lib/ip_frag/rte_ip_frag_common.c
index c1de2e81b6d0..e4af8d23ad10 100644
--- a/lib/ip_frag/rte_ip_frag_common.c
+++ b/lib/ip_frag/rte_ip_frag_common.c
@@ -7,6 +7,8 @@ 
 
 #include <rte_log.h>
 
+RTE_LOG_REGISTER_DEFAULT(ipfrag_logtype, INFO);
+
 #include "ip_frag_common.h"
 
 #define	IP_FRAG_HASH_FNUM	2