All of lore.kernel.org
 help / color / mirror / Atom feed
From: Konstantin Ananyev <konstantin.ananyev@intel.com>
To: dev@dpdk.org
Cc: stephen@networkplumber.org,
	Konstantin Ananyev <konstantin.ananyev@intel.com>
Subject: [dpdk-dev] [PATCH] bpf: fix convert API can be undefined
Date: Mon,  1 Nov 2021 14:52:46 +0000	[thread overview]
Message-ID: <20211101145246.23465-1-konstantin.ananyev@intel.com> (raw)

rte_bpf_convert() implementation depends on libpcap.
Right now it is defined only when this library is installed and
RTE_PORT_PCAP is defined.
Fix that by providing for such case stub rte_bpf_convert()
implementation that will always return an error.
Also move stub for another function (rte_bpf_elf_load) into
the same place (bpf_stub.c).

Fixes: 2eccf6afbea9 ("bpf: add function to convert classic BPF to DPDK BPF")

Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
---
 lib/bpf/bpf_load.c  | 18 ------------------
 lib/bpf/bpf_stub.c  | 45 +++++++++++++++++++++++++++++++++++++++++++++
 lib/bpf/meson.build |  1 +
 lib/bpf/rte_bpf.h   |  4 ----
 4 files changed, 46 insertions(+), 22 deletions(-)
 create mode 100644 lib/bpf/bpf_stub.c

diff --git a/lib/bpf/bpf_load.c b/lib/bpf/bpf_load.c
index 2a3b901d74..272f2ba11b 100644
--- a/lib/bpf/bpf_load.c
+++ b/lib/bpf/bpf_load.c
@@ -130,21 +130,3 @@ rte_bpf_load(const struct rte_bpf_prm *prm)
 
 	return bpf;
 }
-
-#ifndef RTE_LIBRTE_BPF_ELF
-struct rte_bpf *
-rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname,
-	const char *sname)
-{
-	if (prm == NULL || fname == NULL || sname == NULL) {
-		rte_errno = EINVAL;
-		return NULL;
-	}
-
-	RTE_BPF_LOG(ERR, "%s() is not supported with current config\n"
-		"rebuild with libelf installed\n",
-		__func__);
-	rte_errno = ENOTSUP;
-	return NULL;
-}
-#endif
diff --git a/lib/bpf/bpf_stub.c b/lib/bpf/bpf_stub.c
new file mode 100644
index 0000000000..caec00f42f
--- /dev/null
+++ b/lib/bpf/bpf_stub.c
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018-2021 Intel Corporation
+ */
+
+#include "bpf_impl.h"
+#include <rte_errno.h>
+
+/**
+ * Contains stubs for unimplemented public API functions
+ */
+
+#ifndef RTE_LIBRTE_BPF_ELF
+struct rte_bpf *
+rte_bpf_elf_load(const struct rte_bpf_prm *prm, const char *fname,
+	const char *sname)
+{
+	if (prm == NULL || fname == NULL || sname == NULL) {
+		rte_errno = EINVAL;
+		return NULL;
+	}
+
+	RTE_BPF_LOG(ERR, "%s() is not supported with current config\n"
+		"rebuild with libelf installed\n",
+		__func__);
+	rte_errno = ENOTSUP;
+	return NULL;
+}
+#endif
+
+#ifndef RTE_PORT_PCAP
+struct rte_bpf_prm *
+rte_bpf_convert(const struct bpf_program *prog)
+{
+	if (prog == NULL) {
+		rte_errno = EINVAL;
+		return NULL;
+	}
+
+	RTE_BPF_LOG(ERR, "%s() is not supported with current config\n"
+		"rebuild with libpcap installed\n",
+		__func__);
+	rte_errno = ENOTSUP;
+	return NULL;
+}
+#endif
diff --git a/lib/bpf/meson.build b/lib/bpf/meson.build
index 33b506f3ac..0ec067957b 100644
--- a/lib/bpf/meson.build
+++ b/lib/bpf/meson.build
@@ -12,6 +12,7 @@ sources = files('bpf.c',
         'bpf_exec.c',
         'bpf_load.c',
         'bpf_pkt.c',
+        'bpf_stub.c',
         'bpf_validate.c')
 
 if arch_subdir == 'x86' and dpdk_conf.get('RTE_ARCH_64')
diff --git a/lib/bpf/rte_bpf.h b/lib/bpf/rte_bpf.h
index 0d0a84b130..5ec1f8abbb 100644
--- a/lib/bpf/rte_bpf.h
+++ b/lib/bpf/rte_bpf.h
@@ -212,8 +212,6 @@ __rte_experimental
 void
 rte_bpf_dump(FILE *f, const struct ebpf_insn *buf, uint32_t len);
 
-#ifdef RTE_PORT_PCAP
-
 struct bpf_program;
 
 /**
@@ -235,8 +233,6 @@ __rte_experimental
 struct rte_bpf_prm *
 rte_bpf_convert(const struct bpf_program *prog);
 
-#endif
-
 #ifdef __cplusplus
 }
 #endif
-- 
2.25.1


             reply	other threads:[~2021-11-01 15:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 14:52 Konstantin Ananyev [this message]
2021-11-01 16:10 ` [dpdk-dev] [PATCH v2 0/2] few bpf library fixes Konstantin Ananyev
2021-11-01 16:10   ` [dpdk-dev] [PATCH v2 1/2] bpf: fix doxygen comments Konstantin Ananyev
2021-11-01 16:10   ` [dpdk-dev] [PATCH v2 2/2] bpf: fix convert API can be undefined Konstantin Ananyev
2021-11-01 17:05     ` Stephen Hemminger
2021-11-02 10:54       ` Ananyev, Konstantin
2021-11-02 15:05         ` Stephen Hemminger
2021-11-03 10:54           ` Ananyev, Konstantin
2021-11-02 15:27     ` Stephen Hemminger
2021-11-03 11:17   ` [dpdk-dev] [PATCH v3 0/2] few bpf library fixes Konstantin Ananyev
2021-11-03 11:17     ` [dpdk-dev] [PATCH v3 1/2] bpf: fix doxygen comments Konstantin Ananyev
2021-11-03 11:17     ` [dpdk-dev] [PATCH v3 2/2] bpf: fix convert API can be undefined Konstantin Ananyev
2021-11-04 19:00     ` [dpdk-dev] [PATCH v3 0/2] few bpf library fixes Thomas Monjalon
2021-11-01 16:15 ` [dpdk-dev] [PATCH] bpf: fix convert API can be undefined Stephen Hemminger

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=20211101145246.23465-1-konstantin.ananyev@intel.com \
    --to=konstantin.ananyev@intel.com \
    --cc=dev@dpdk.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.