DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
Cc: dev@dpdk.org
Subject: [dpdk-dev] ebpf issues with secondary process.
Date: Thu, 17 Oct 2019 21:19:52 -0700
Message-ID: <20191017211952.6ebf0312@hermes.lan> (raw)

Trying to use the existing BPF code in BPF for packet filter is possible.
But one road block is that capture wants to allow a secondary process to
insert a packet filter. The current code in bpf_load() won't work for that.
The BPF program needs to be in shared area to allow secondary process
to work.

Why does the code use mmap() as an allocator instead of rte_malloc?

Something like the diff below (untested). JIT would have the same problem
but you would have issues with the mprotect stuff with huge pages.

I also noticed that bpf code is not using rte_memcpy and it has unnecessary
casts to void *.

diff --git a/lib/librte_bpf/bpf.c b/lib/librte_bpf/bpf.c
index 7e1879ffa5b5..d6995bbf0ba9 100644
--- a/lib/librte_bpf/bpf.c
+++ b/lib/librte_bpf/bpf.c
@@ -22,7 +22,7 @@ rte_bpf_destroy(struct rte_bpf *bpf)
 	if (bpf != NULL) {
 		if (bpf->jit.func != NULL)
 			munmap(bpf->jit.func, bpf->jit.sz);
-		munmap(bpf, bpf->sz);
+		rte_free(bpf);
diff --git a/lib/librte_bpf/bpf_load.c b/lib/librte_bpf/bpf_load.c
index 2a3b901d74c3..9a8e438a8963 100644
--- a/lib/librte_bpf/bpf_load.c
+++ b/lib/librte_bpf/bpf_load.c
@@ -32,9 +32,8 @@ bpf_load(const struct rte_bpf_prm *prm)
 	bsz = sizeof(bpf[0]);
 	sz = insz + xsz + bsz;
-	buf = mmap(NULL, sz, PROT_READ | PROT_WRITE,
-	if (buf == MAP_FAILED)
+	buf = rte_malloc("bpf", sz, 0);
+	if (buf == NULL)
 		return NULL;
 	bpf = (void *)buf;


                 reply	other threads:[~2019-10-18  4:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:

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

  git send-email \
    --in-reply-to=20191017211952.6ebf0312@hermes.lan \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git