lib/bpf: Rename 'bpf_validate' to avoid potential conflict with libpcap
PATCH 1/1 lib/bpf: Rename 'bpf_validate' to avoid potential conflict with libpcap
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 staticly.
You can reproduce this issue by 'meson build -Dprefer_static=true -Denable_apps=test-pmd -Denable_drivers=net/af_xdp,net/af_packet'. Notice you need to have a static version of libpcap to reproduce this.
In 2019 there was a patch reported the same issue but not applied:
https://inbox.dpdk.org/stable/2601191342CEEE43887BDE71AB9772580148A95BE2@irsmsx105.ger.corp.intel.com/T
Since 'bpf_validate' is an internal function, I think adding an 'rte' prefix is not a good idea and rename it to 'bpf_do_validate' instead.
--- lib/bpf/bpf_impl.h | 2 +- lib/bpf/bpf_load.c | 2 +- lib/bpf/bpf_validate.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
lib/bpf/bpf_impl.h +1 -1
@@ -17,7 +17,7 @@ struct rte_bpf {uint32_t stack_sz; }; -extern int bpf_validate (struct rte_bpf *bpf); +extern int bpf_do_validate (struct rte_bpf *bpf);extern int bpf_jit (struct rte_bpf *bpf);
lib/bpf/bpf_load.c +1 -1
@@ -108,7 +108,7 @@ rte_bpf_load(const struct rte_bpf_prm *prm)return NULL ; } - rc =bpf_validate (bpf); + rc =bpf_do_validate (bpf);if (rc ==0 ) {bpf_jit (bpf);if (mprotect (bpf, bpf->sz,PROT_READ ) !=0 )
lib/bpf/bpf_validate.c +1 -1
@@ -2302,7 +2302,7 @@ evaluate(struct bpf_verifier *bvf) }int -bpf_validate (struct rte_bpf *bpf) +bpf_do_validate (struct rte_bpf *bpf) {int32_t rc;struct bpf_verifier bvf;
Signature · 1 line
2.37.1 (Apple Git-137.1)
Quoted 8 lines · On Fri, 3 Mar 2023 21:56:54 +0800 Martzki <[email protected]> wrote:
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 staticly.You can reproduce this issue by 'meson build -Dprefer_static=true -Denable_apps=test-pmd -Denable_drivers=net/af_xdp,net/af_packet'. Notice you need to have a static version of libpcap to reproduce this.
Quoted 7 lines
In 2019 there was a patch reported the same issue but not applied:
https://inbox.dpdk.org/stable/2601191342CEEE43887BDE71AB9772580148A95BE2@irsmsx105.ger.corp.intel.com/TSince '
bpf_validate' is an internal function, I think adding an 'rte' prefix is not a good idea and rename it to 'bpf_do_validate' instead.Signed-off-by Martzki <[email protected]>
Let's change all the function names here to rte_bpf_XXX.
Quoted 14 lines · On Sun, 5 Mar 2023 09:16:55 -0800 Stephen Hemminger…
Quoted 11 lines · On Fri, 3 Mar 2023 21:56:54 +0800 Martzki <[email protected]> wrote:
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 staticly.You can reproduce this issue by 'meson build -Dprefer_static=true -Denable_apps=test-pmd -Denable_drivers=net/af_xdp,net/af_packet'. Notice you need to have a static version of libpcap to reproduce this.
In 2019 there was a patch reported the same issue but not applied:
https://inbox.dpdk.org/stable/2601191342CEEE43887BDE71AB9772580148A95BE2@irsmsx105.ger.corp.intel.com/T
Quoted 6 lines
Quoted 4 lines
Since '
bpf_validate' is an internal function, I think adding an 'rte' prefix is not a good idea and rename it to 'bpf_do_validate' instead.Signed-off-by Martzki <[email protected]>Let's change all the function names here to
rte_bpf_XXX.
Something like this
lib/bpf/bpf.c +3 -3
@@ -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
lib/bpf/bpf_convert.c +0 -3
@@ -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"
lib/bpf/bpf_impl.h +4 -6
@@ -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 *); +extern int rte_bpf_jit_arm64 (struct rte_bpf *);extern int rte_bpf_logtype;
lib/bpf/bpf_jit_x86.c +1 -1
@@ -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;
lib/bpf/bpf_load.c +2 -2
@@ -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 ; }
lib/bpf/bpf_validate.c +1 -1
@@ -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;
PATCH v2 1/1 lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
In reply to MartzkiThanks for your review. In this v2 patch I renamed all functions in bpf_impl.h.
---
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(-)
lib/bpf/bpf.c +3 -3
@@ -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
lib/bpf/bpf_convert.c +0 -3
@@ -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"
lib/bpf/bpf_impl.h +4 -6
@@ -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;
lib/bpf/bpf_jit_arm64.c +1 -1
@@ -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;
lib/bpf/bpf_jit_x86.c +1 -1
@@ -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;
lib/bpf/bpf_load.c +2 -2
@@ -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 ; }
lib/bpf/bpf_validate.c +1 -1
@@ -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;
Signature · 1 line
2.37.1 (Apple Git-137.1)
PATCH v3 1/1 lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
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.
---
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(-)
lib/bpf/bpf.c +3 -3
@@ -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
lib/bpf/bpf_convert.c +0 -3
@@ -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"
lib/bpf/bpf_impl.h +4 -6
@@ -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;
lib/bpf/bpf_jit_arm64.c +1 -1
@@ -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;
lib/bpf/bpf_jit_x86.c +1 -1
@@ -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;
lib/bpf/bpf_load.c +2 -2
@@ -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 ; }
lib/bpf/bpf_validate.c +1 -1
@@ -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;
Signature · 1 line
2.37.1 (Apple Git-137.1)
Re: [PATCH v3] lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
06/03/2023 16:42, Martzki:
Quoted 6 lines
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 <[email protected]>
Please could you provide you first name and last name?
PATCH v4 1/1 lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
In reply to MartzkiThe 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.
---
v4:
* Update my name.
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(-)
lib/bpf/bpf.c +3 -3
@@ -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
lib/bpf/bpf_convert.c +0 -3
@@ -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"
lib/bpf/bpf_impl.h +4 -6
@@ -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;
lib/bpf/bpf_jit_arm64.c +1 -1
@@ -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;
lib/bpf/bpf_jit_x86.c +1 -1
@@ -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;
lib/bpf/bpf_load.c +2 -2
@@ -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 ; }
lib/bpf/bpf_validate.c +1 -1
@@ -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;
Signature · 1 line
2.37.1 (Apple Git-137.1)
Re: [PATCH v4] lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
12/03/2023 06:20, J.J. Martzki пишет:
Quoted 71 lines
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 J.J. Martzki <[email protected]>---
v4:
* Update my name.
v3:
* Rewrite the commit message.
v2:
* Rename all functions inbpf_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(-)lib/bpf/bpf.c +3
-3@@ -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 lib/bpf/bpf_convert.c +0
-3@@ -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" lib/bpf/bpf_impl.h +0
-0@@ -17,12 +17,10 @@ struct rte_bpf {uint32_t stack_sz; };
lib/bpf/bpf_impl.h struct rte_bpf { · line 23
Quoted 10 lines
lib/bpf/bpf_impl.h +4
-6-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);
I am still not quite ok to us 'rte_' prefix for internal library functions... Might be at least '_rte_', or '_bpf_'?
Another ask - can you put comment here with advise for future add-ons to avoid pure 'bpf_' prefix and why.
Konstantin
Quoted 57 lines
lib/bpf/bpf_impl.h +0
-0extern int rte_bpf_logtype;lib/bpf/bpf_jit_arm64.c +1
-1@@ -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;lib/bpf/bpf_jit_x86.c +1
-1@@ -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;lib/bpf/bpf_load.c +2
-2@@ -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 ; }lib/bpf/bpf_validate.c +1
-1@@ -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;
Re: [PATCH v4] lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
Actually I'm still hesitating about the 'rte_' prefix either. So I'll try a new prefix in the next version, comments will be added together :)
Quoted 150 lines · Konstantin Ananyev <[email protected]> 于2023年3月12日周日 22:02写道:
12/03/2023 06:20, J.J. Martzki пишет:
Quoted 71 lines
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 J.J. Martzki <[email protected]>---
v4:
* Update my name.
v3:
* Rewrite the commit message.
v2:
* Rename all functions inbpf_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(-)lib/bpf/bpf.c +3
-3@@ -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 lib/bpf/bpf_convert.c +0
-3@@ -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" lib/bpf/bpf_impl.h +0
-0@@ -17,12 +17,10 @@ struct rte_bpf {uint32_t stack_sz; };lib/bpf/bpf_impl.h struct rte_bpf { · line 23
Quoted 10 lines
lib/bpf/bpf_impl.h +4
-6-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);I am still not quite ok to us '
rte_' prefix for internal library functions...
Might be at least '_rte_', or '_bpf_'?
Another ask - can you put comment here with advise for future add-ons to avoid pure 'bpf_' prefix and why. KonstantinQuoted 57 lines
lib/bpf/bpf_impl.h +0
-0extern int rte_bpf_logtype;lib/bpf/bpf_jit_arm64.c +1
-1@@ -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;lib/bpf/bpf_jit_x86.c +1
-1@@ -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;lib/bpf/bpf_load.c +2
-2@@ -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 ; }lib/bpf/bpf_validate.c +1
-1@@ -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;
Re: [PATCH v4] lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
In reply to Konstantin AnanyevI've read the libbpf code again and I found some other functions with pure 'bpf_' prefix. Should we rename all the functions whose names start with pure 'bpf_'?
Quoted 150 lines · Konstantin Ananyev <[email protected]> 于2023年3月12日周日 22:02写道:
12/03/2023 06:20, J.J. Martzki пишет:
Quoted 71 lines
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 J.J. Martzki <[email protected]>---
v4:
* Update my name.
v3:
* Rewrite the commit message.
v2:
* Rename all functions inbpf_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(-)lib/bpf/bpf.c +3
-3@@ -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 lib/bpf/bpf_convert.c +0
-3@@ -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" lib/bpf/bpf_impl.h +0
-0@@ -17,12 +17,10 @@ struct rte_bpf {uint32_t stack_sz; };lib/bpf/bpf_impl.h struct rte_bpf { · line 23
Quoted 10 lines
lib/bpf/bpf_impl.h +4
-6-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);I am still not quite ok to us '
rte_' prefix for internal library functions...
Might be at least '_rte_', or '_bpf_'?
Another ask - can you put comment here with advise for future add-ons to avoid pure 'bpf_' prefix and why. KonstantinQuoted 57 lines
lib/bpf/bpf_impl.h +0
-0extern int rte_bpf_logtype;lib/bpf/bpf_jit_arm64.c +1
-1@@ -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;lib/bpf/bpf_jit_x86.c +1
-1@@ -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;lib/bpf/bpf_load.c +2
-2@@ -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 ; }lib/bpf/bpf_validate.c +1
-1@@ -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;
Re: [PATCH v4] lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
Quoted 3 lines · On Mon, 13 Mar 2023 22:55:34 +0800 "J.J. Martzki" <[email protected]> wrote:
I've read the libbpf code again and I found some other functions with pure '
bpf_' prefix. Should we rename all the functions whose names start with pure 'bpf_'?
Yes, all visible (ie non-static) functions should use a DPDK style prefix.
RE: [PATCH v4] lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
In reply to J.J. MartzkiQuoted 4 lines
I've read the libbpf code again and I found some other functions with pure '
bpf_' prefix. Should we rename all the functions whose names start with pure 'bpf_'?
I thought you already prefixed all non-static functions in the lib... Or do I miss something?
Quoted 151 lines
Quoted 150 lines · Konstantin Ananyev <[email protected]> 于2023年3月12日周日 22:02写道:
12/03/2023 06:20, J.J. Martzki пишет:
Quoted 71 lines
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 J.J. Martzki <[email protected]>---
v4:
* Update my name.
v3:
* Rewrite the commit message.
v2:
* Rename all functions inbpf_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(-)lib/bpf/bpf.c +3
-3@@ -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 lib/bpf/bpf_convert.c +0
-3@@ -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" lib/bpf/bpf_impl.h +0
-0@@ -17,12 +17,10 @@ struct rte_bpf {uint32_t stack_sz; };lib/bpf/bpf_impl.h struct rte_bpf { · line 23
Quoted 10 lines
lib/bpf/bpf_impl.h +4
-6-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);I am still not quite ok to us '
rte_' prefix for internal library functions...
Might be at least '_rte_', or '_bpf_'?
Another ask - can you put comment here with advise for future add-ons to avoid pure 'bpf_' prefix and why. KonstantinQuoted 57 lines
lib/bpf/bpf_impl.h +0
-0extern int rte_bpf_logtype;lib/bpf/bpf_jit_arm64.c +1
-1@@ -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;lib/bpf/bpf_jit_x86.c +1
-1@@ -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;lib/bpf/bpf_load.c +2
-2@@ -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 ; }lib/bpf/bpf_validate.c +1
-1@@ -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;
Re: [PATCH v4] lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
Quoted 6 lines · On Mon, 13 Mar 2023 17:07:29 +0000 Konstantin Ananyev…
Quoted 3 lines
I've read the libbpf code again and I found some other functions with pure '
bpf_' prefix. Should we rename all the functions whose names start with pure 'bpf_'?I thought you already prefixed all non-static functions in the lib... Or do I miss something?
Right, it was bpf_validate, bpf_jit_XXX that were not prefixed.
.../build/lib/librte_bpf.a.p $ nm * | grep ' T ' | grep -v 'rte_bpf' 0000000000000070 T bpf_jit
0000000000003210 T bpf_jit_x8600000000000021f0 T bpf_validate
Re: [PATCH v4] lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
Ok, that was my mistake. I’ll send the new patch later :)
Sent from my iPhone
Quoted 18 lines · Stephen Hemminger
On Mon, 13 Mar 2023 17:07:29 +0000
Quoted 6 lines · Konstantin Ananyev
Quoted 3 lines
I've read the libbpf code again and I found some other functions with pure '
bpf_' prefix. Should we rename all the functions whose names start with pure 'bpf_'?I thought you already prefixed all non-static functions in the lib... Or do I miss something?
Right, it was
bpf_validate,bpf_jit_XXXthat were not prefixed..../build/lib/librte_bpf.a.p $ nm * | grep ' T ' | grep -v '
rte_bpf' 0000000000000070 Tbpf_jit
0000000000003210 Tbpf_jit_x8600000000000021f0Tbpf_validate
PATCH v5 1/1 lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
In reply to J.J. MartzkiThe 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.
---
v5:
* Use '__rte' prefix.
* Add annotation for function naming.
v4:
* Update my name.
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 | 14 ++++++++------ 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, 16 insertions(+), 17 deletions(-)
lib/bpf/bpf.c +3 -3
@@ -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
lib/bpf/bpf_convert.c +0 -3
@@ -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"
lib/bpf/bpf_impl.h +8 -6
@@ -17,12 +17,14 @@ 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 *); +/* +* Use '__rte' prefix for non-static internal functions +* to avoid potential name conflict with other libraries. +*/ +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;
lib/bpf/bpf_jit_arm64.c +1 -1
@@ -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;
lib/bpf/bpf_jit_x86.c +1 -1
@@ -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;
lib/bpf/bpf_load.c +2 -2
@@ -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 ; }
lib/bpf/bpf_validate.c +1 -1
@@ -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;
Signature · 1 line
2.37.1 (Apple Git-137.1)
Re: [PATCH v5] lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
14/03/2023 14:20, J.J. Martzki пишет:
Quoted 138 lines
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 J.J. Martzki <[email protected]>---
v5:
* Use '__rte' prefix.
* Add annotation for function naming.
v4:
* Update my name.
v3:
* Rewrite the commit message.
v2:
* Rename all functions inbpf_impl.h.
* Adjust the commit message.--- lib/bpf/bpf.c | 6 +++--- lib/bpf/bpf_convert.c | 3 --- lib/bpf/bpf_impl.h | 14 ++++++++------ 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, 16 insertions(+), 17 deletions(-)lib/bpf/bpf.c +3
-3@@ -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 lib/bpf/bpf_convert.c +0
-3@@ -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" lib/bpf/bpf_impl.h +8
-6@@ -17,12 +17,14 @@ 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 *); +/* +* Use '__rte' prefix for non-static internal functions +* to avoid potential name conflict with other libraries. +*/ +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;lib/bpf/bpf_jit_arm64.c +1
-1@@ -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;lib/bpf/bpf_jit_x86.c +1
-1@@ -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;lib/bpf/bpf_load.c +2
-2@@ -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 ; }lib/bpf/bpf_validate.c +0
-0
lib/bpf/bpf_validate.c evaluate(struct bpf_verifier *bvf) · line 2308
Quoted 8 lines
lib/bpf/bpf_validate.c +1
-1@@ -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;
Thomas Monjalon
AppliedRe: [PATCH v5] lib/bpf: Rename bpf function names to avoid potential conflict with libpcap
16/03/2023 01:58, Konstantin Ananyev:
Quoted 9 lines
14/03/2023 14:20, J.J. Martzki пишет:
Quoted 6 lines
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 J.J. Martzki <[email protected]>
Applied, thanks.