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 0E40741DEB; Sun, 5 Mar 2023 18:31:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9DB1C40EF0; Sun, 5 Mar 2023 18:31:21 +0100 (CET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id A21D940EE5 for ; Sun, 5 Mar 2023 18:31:20 +0100 (CET) Received: by mail-pl1-f169.google.com with SMTP id p6so7849925plf.0 for ; Sun, 05 Mar 2023 09:31:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; t=1678037480; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=VpPTmpbdJfOhfRYLE6pYO4lIwiGIZJjhFcE39DRb+8s=; b=geai+fcsfO7rjbwg2vyqcMMFk97D5MJu8Ggwa/CnnmUcHYXe/FxJjtsbu6VTStlCNB bUvbmSrk1zzis50Y0lUD5FkEcRFn0F1f3SKIbWQ7ihso6Vl7lnh+TiS5P3dSCJPzqWiO NGwh96MLYdiGswtnsDUfHaOW9wflwmXFu/vwcSii+cRVAsEEOTAlJKvC/lsH7AG0AbzW rDWAKB+RF5uMahd9v6PoCU/hmSusYdfszjeo+8zKTXgGYyZ12N259dvWRhmrYdpqRu98 nO2a17hNF4bQnkjlgGsHBtqAq2gsB7pwNhIonvbBozfqAD+TQFn3ESUNIqpWS4VjOCBW 5sTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678037480; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VpPTmpbdJfOhfRYLE6pYO4lIwiGIZJjhFcE39DRb+8s=; b=ajfL00UDKuo7X2gt7ayVCBxv5GqYfDjTERWa4VgT3QMzwh8Tf+vfBB3Wks1zW0Fl1h X6KdtikHpx45Wx8MW/VRVzAo/1jeg9h0YIrmI3P5WIOklA68pf2p404X05YaMmeTtNhT vqJpIv/3h3TY/3FLgPuhNApuO8nrlTgN6NRG36Mu1ALdCvE3HYG4WWaFs8IB1WbMzCtq AiHG0GgKLTTpYOEvLAnpWws6DoISI3ORcSE7CszfppqYlXLImaPxcLJfehiD+SmqHyZT 9FwVGiOeYH/OS95MxwNcZZ87gob1FhbiwVYLcEu+VszySyMDnGeIdQjxg0RZHdE4VHa5 r1ug== X-Gm-Message-State: AO0yUKWmmtGv3n9R/VknhtnLtoenLUik25esH7MYmUKnDMPqAG17vRZm HQF12kd4GFo4NoSapAtBtkkvAA== X-Google-Smtp-Source: AK7set8Fc9N+aNB1t2ZtI4vZ6liYNaXaRe0taOWbxuMLiP8/eUkFr97o40RL02S7SMVaHodgkh+K8A== X-Received: by 2002:a17:902:c1cd:b0:19e:32da:e458 with SMTP id c13-20020a170902c1cd00b0019e32dae458mr6956294plc.63.1678037479628; Sun, 05 Mar 2023 09:31:19 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id kf3-20020a17090305c300b0019c8ef78d52sm4998378plb.21.2023.03.05.09.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Mar 2023 09:31:19 -0800 (PST) Date: Sun, 5 Mar 2023 09:31:17 -0800 From: Stephen Hemminger To: Martzki Cc: dev@dpdk.org, Konstantin Ananyev Subject: Re: [PATCH] lib/bpf: Rename 'bpf_validate' to avoid potential conflict with libpcap Message-ID: <20230305093117.1f31f2e3@hermes.local> In-Reply-To: <20230305091655.05306280@hermes.local> References: <20230303135655.78749-1-mars14850@gmail.com> <20230305091655.05306280@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Sun, 5 Mar 2023 09:16:55 -0800 Stephen Hemminger wrote: > On Fri, 3 Mar 2023 21:56:54 +0800 > Martzki 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 > > > > 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 > > Let's change all the function names here to rte_bpf_XXX. Something like this diff --git a/lib/bpf/bpf.c b/lib/bpf/bpf.c index 1e1dd42a589f..f218a8f2b049 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 9563274c9c6b..d441be66634f 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 b4d8e87c6dfb..7fca2db9bef6 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 *); +extern int rte_bpf_jit_arm64(struct rte_bpf *); extern int rte_bpf_logtype; diff --git a/lib/bpf/bpf_jit_x86.c b/lib/bpf/bpf_jit_x86.c index c1a30e038660..182004ac7d6c 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 1e17df6ce0ab..2c4bca358603 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 61cbb42216b8..2d3d899966b9 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;