From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4421441E90; Tue, 14 Mar 2023 15:20:58 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D2EC940F18; Tue, 14 Mar 2023 15:20:57 +0100 (CET) Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by mails.dpdk.org (Postfix) with ESMTP id 6470140A7E for ; Tue, 14 Mar 2023 15:20:56 +0100 (CET) Received: by mail-ed1-f51.google.com with SMTP id r11so11090617edd.5 for ; Tue, 14 Mar 2023 07:20:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678803655; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HM5lBYM5JHxhdR6wdijjwP/bSZzxLLcsQ1TOBnRb9Fc=; b=LEAS81uxiVMKQpQQ84/4wJKpJ6iTIYjIxjOkgaPDL0PNkMh6xahkQ/7m/PYUDHiCIa O5o78p6BoxqfLWarSYb7k9215yAmip/Cn1pxd2uZn8xSDrW3qGz60B79CnJ/wJVcPRZi 1siwuzoIwvJEAq3EmWlQJim1x3AqfW2Nm1iYqRP2bysU4mBiJbw8yWtxB2UPfBLpMC5Y Q2x44KzB/NCUlQa9ju0rOptsxH/EYLjkl7176Qj/kRDhMtPuxmyHS0ND9CzVMKbG3Pk3 zeDuwbO9fGeVhSdfqe+HD/UKsoQmxdJJDwCHZqBwkbmvtl6VYGWrDl+G3tj6ODS6BtJ6 D8/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678803655; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HM5lBYM5JHxhdR6wdijjwP/bSZzxLLcsQ1TOBnRb9Fc=; b=ZhQ0z/fdWp63H1ER2wzTURSrAEJ6aNTg2zroUV0j7Q06yptgpfLEOSr++KsCS2IXJb zZo9OKiIitfxw9mpXxt4oBbaVL+rwk89hsdBlE5LTql0+FnbWZZZ4JAVRmDDvLebksfD JcGGaj7hu3Y5v9vYQTMsK2OxAhTCpbLgZCRhD4ojyfpFKjmyxD3+n3usjn+HbNlR98vc hzvbBbnr3CF9v+YbgNIVnjVWbpnbFwmCX4JhdgFzhxrA7ASlgpzc0xt0dZ7hEMrYCjGq a1BzkjdiPxWfMjhVx7SLecE1D54/0mH9mtE/zGSUWg9s8dk7KCZPpD2+zaIsfMYUUk/g 5mvg== X-Gm-Message-State: AO0yUKVXOf9dP700yA5QFDUmh8bIykFHwVg65SHuCXVYeka524SXT4Rg XfDMzKpO6cKySPt2hBeYBUqTKIzptKOuabHr82PLuQ== X-Google-Smtp-Source: AK7set89mB0kceC4VPeI/2LlUSeixB/eMLYAitl4IXTF7Vxb1D9FMbjN2w80PjDD0H1Wi3DCLIwJGQ== X-Received: by 2002:a05:6402:383:b0:4ac:bd84:43d8 with SMTP id o3-20020a056402038300b004acbd8443d8mr36016013edv.8.1678803655613; Tue, 14 Mar 2023 07:20:55 -0700 (PDT) Received: from localhost.localdomain ([2409:8a55:316f:1390:203d:c9:a6dd:88c7]) by smtp.gmail.com with ESMTPSA id h1-20020a50c381000000b004c0c5864cc5sm1117832edf.25.2023.03.14.07.20.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 07:20:53 -0700 (PDT) From: "J.J. Martzki" To: dev@dpdk.org Cc: stephen@networkplumber.org, thomas@monjalon.net, konstantin.ananyev@huawei.com, "J.J. Martzki" , Konstantin Ananyev , Ruifeng Wang Subject: [PATCH v5] lib/bpf: Rename bpf function names to avoid potential conflict with libpcap Date: Tue, 14 Mar 2023 22:20:38 +0800 Message-Id: <20230314142038.23436-1-mars14850@gmail.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230312062021.7349-1-mars14850@gmail.com> References: <20230312062021.7349-1-mars14850@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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(-) diff --git a/lib/bpf/bpf.c b/lib/bpf/bpf.c index 1e1dd42a58..8a0254d8bb 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 #include -/* Workaround name conflicts with libpcap */ -#define bpf_validate(f, len) bpf_validate_libpcap(f, len) #include #include -#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..3e067c1ff4 100644 --- a/lib/bpf/bpf_impl.h +++ b/lib/bpf/bpf_impl.h @@ -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; diff --git a/lib/bpf/bpf_jit_arm64.c b/lib/bpf/bpf_jit_arm64.c index db79ff7385..f9ddafd7dc 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..a73b2006db 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..45ce9210da 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..119dc4d3aa 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)