DPDK patches and discussions
 help / color / mirror / Atom feed
From: Martzki <mars14850@gmail.com>
To: dev@dpdk.org
Cc: stephen@networkplumber.org, Martzki <mars14850@gmail.com>,
	Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>,
	Ruifeng Wang <ruifeng.wang@arm.com>
Subject: [PATCH v3] lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
Date: Mon,  6 Mar 2023 23:42:15 +0800	[thread overview]
Message-ID: <20230306154216.41154-1-mars14850@gmail.com> (raw)
In-Reply-To: <20230306153218.40320-1-mars14850@gmail.com>

The library libpcap has their function 'bpf_validate' either so there would
be a multiple definition issue when linking with librte_bpf.a and libpcap.a
statically (Same as http://dpdk.org/patch/52631). So just rename the
function names to avoid such issue.

Signed-off-by: Martzki <mars14850@gmail.com>

---
v3:
* Rewrite the commit message.
v2:
* Rename all functions in bpf_impl.h.
* Adjust the commit message.
---
 lib/bpf/bpf.c           |  6 +++---
 lib/bpf/bpf_convert.c   |  3 ---
 lib/bpf/bpf_impl.h      | 10 ++++------
 lib/bpf/bpf_jit_arm64.c |  2 +-
 lib/bpf/bpf_jit_x86.c   |  2 +-
 lib/bpf/bpf_load.c      |  4 ++--
 lib/bpf/bpf_validate.c  |  2 +-
 7 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/lib/bpf/bpf.c b/lib/bpf/bpf.c
index 1e1dd42a58..f218a8f2b0 100644
--- a/lib/bpf/bpf.c
+++ b/lib/bpf/bpf.c
@@ -31,14 +31,14 @@ rte_bpf_get_jit(const struct rte_bpf *bpf, struct rte_bpf_jit *jit)
 }
 
 int
-bpf_jit(struct rte_bpf *bpf)
+rte_bpf_jit(struct rte_bpf *bpf)
 {
 	int32_t rc;
 
 #if defined(RTE_ARCH_X86_64)
-	rc = bpf_jit_x86(bpf);
+	rc = rte_bpf_jit_x86(bpf);
 #elif defined(RTE_ARCH_ARM64)
-	rc = bpf_jit_arm64(bpf);
+	rc = rte_bpf_jit_arm64(bpf);
 #else
 	rc = -ENOTSUP;
 #endif
diff --git a/lib/bpf/bpf_convert.c b/lib/bpf/bpf_convert.c
index 9563274c9c..d441be6663 100644
--- a/lib/bpf/bpf_convert.c
+++ b/lib/bpf/bpf_convert.c
@@ -23,11 +23,8 @@
 #include <rte_malloc.h>
 #include <rte_errno.h>
 
-/* Workaround name conflicts with libpcap */
-#define bpf_validate(f, len) bpf_validate_libpcap(f, len)
 #include <pcap/pcap.h>
 #include <pcap/bpf.h>
-#undef bpf_validate
 
 #include "bpf_impl.h"
 #include "bpf_def.h"
diff --git a/lib/bpf/bpf_impl.h b/lib/bpf/bpf_impl.h
index b4d8e87c6d..e955b74181 100644
--- a/lib/bpf/bpf_impl.h
+++ b/lib/bpf/bpf_impl.h
@@ -17,12 +17,10 @@ struct rte_bpf {
 	uint32_t stack_sz;
 };
 
-extern int bpf_validate(struct rte_bpf *bpf);
-
-extern int bpf_jit(struct rte_bpf *bpf);
-
-extern int bpf_jit_x86(struct rte_bpf *);
-extern int bpf_jit_arm64(struct rte_bpf *);
+extern int rte_bpf_validate(struct rte_bpf *bpf);
+extern int rte_bpf_jit(struct rte_bpf *bpf);
+extern int rte_bpf_jit_x86(struct rte_bpf *bpf);
+extern int rte_bpf_jit_arm64(struct rte_bpf *bpf);
 
 extern int rte_bpf_logtype;
 
diff --git a/lib/bpf/bpf_jit_arm64.c b/lib/bpf/bpf_jit_arm64.c
index db79ff7385..d1ab5f8fbf 100644
--- a/lib/bpf/bpf_jit_arm64.c
+++ b/lib/bpf/bpf_jit_arm64.c
@@ -1393,7 +1393,7 @@ emit(struct a64_jit_ctx *ctx, struct rte_bpf *bpf)
  * Produce a native ISA version of the given BPF code.
  */
 int
-bpf_jit_arm64(struct rte_bpf *bpf)
+rte_bpf_jit_arm64(struct rte_bpf *bpf)
 {
 	struct a64_jit_ctx ctx;
 	size_t size;
diff --git a/lib/bpf/bpf_jit_x86.c b/lib/bpf/bpf_jit_x86.c
index c1a30e0386..182004ac7d 100644
--- a/lib/bpf/bpf_jit_x86.c
+++ b/lib/bpf/bpf_jit_x86.c
@@ -1490,7 +1490,7 @@ emit(struct bpf_jit_state *st, const struct rte_bpf *bpf)
  * produce a native ISA version of the given BPF code.
  */
 int
-bpf_jit_x86(struct rte_bpf *bpf)
+rte_bpf_jit_x86(struct rte_bpf *bpf)
 {
 	int32_t rc;
 	uint32_t i;
diff --git a/lib/bpf/bpf_load.c b/lib/bpf/bpf_load.c
index 1e17df6ce0..2c4bca3586 100644
--- a/lib/bpf/bpf_load.c
+++ b/lib/bpf/bpf_load.c
@@ -108,9 +108,9 @@ rte_bpf_load(const struct rte_bpf_prm *prm)
 		return NULL;
 	}
 
-	rc = bpf_validate(bpf);
+	rc = rte_bpf_validate(bpf);
 	if (rc == 0) {
-		bpf_jit(bpf);
+		rte_bpf_jit(bpf);
 		if (mprotect(bpf, bpf->sz, PROT_READ) != 0)
 			rc = -ENOMEM;
 	}
diff --git a/lib/bpf/bpf_validate.c b/lib/bpf/bpf_validate.c
index 61cbb42216..2d3d899966 100644
--- a/lib/bpf/bpf_validate.c
+++ b/lib/bpf/bpf_validate.c
@@ -2302,7 +2302,7 @@ evaluate(struct bpf_verifier *bvf)
 }
 
 int
-bpf_validate(struct rte_bpf *bpf)
+rte_bpf_validate(struct rte_bpf *bpf)
 {
 	int32_t rc;
 	struct bpf_verifier bvf;
-- 
2.37.1 (Apple Git-137.1)


  reply	other threads:[~2023-03-06 15:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-03 13:56 [PATCH] lib/bpf: Rename 'bpf_validate' " Martzki
2023-03-05 17:16 ` Stephen Hemminger
2023-03-05 17:31   ` Stephen Hemminger
2023-03-06 15:32 ` [PATCH v2] lib/bpf: Rename bpf function names " Martzki
2023-03-06 15:42   ` Martzki [this message]
2023-03-11  9:18     ` [PATCH v3] " Thomas Monjalon
2023-03-12  6:20     ` [PATCH v4] " J.J. Martzki
2023-03-12 14:02       ` Konstantin Ananyev
2023-03-13  1:50         ` J.J. Mars
2023-03-13 14:55         ` J.J. Martzki
2023-03-13 15:54           ` Stephen Hemminger
2023-03-13 17:07           ` Konstantin Ananyev
2023-03-13 17:22             ` Stephen Hemminger
2023-03-14  2:21               ` 马尔斯
2023-03-14 14:20       ` [PATCH v5] " J.J. Martzki
2023-03-16  0:58         ` Konstantin Ananyev
2023-03-20 11:50           ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230306154216.41154-1-mars14850@gmail.com \
    --to=mars14850@gmail.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.v.ananyev@yandex.ru \
    --cc=ruifeng.wang@arm.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).