On 11/28/18 3:45 AM, Daniel Borkmann wrote:
On 11/28/2018 08:51 AM, Prashant Bhole wrote:
This patch adds tests to check whether bpf verifier prevents lookup
on queue/stack maps
Signed-off-by: Prashant Bhole
---
tools/testing/selftests/bpf/test_verifier.c | 52 +
1 fil
e, disable .pkt_access for the two.
Fixes: f1a2e44a3aec ("bpf: add queue and stack maps")
Signed-off-by: Daniel Borkmann
Acked-by: Alexei Starovoitov
Cc: Mauricio Vasquez B
Thanks for this as well.
Acked-by: Mauricio Vasquez B
lets wipe it there on error case, that is, empty stack/queue.
Fixes: f1a2e44a3aec ("bpf: add queue and stack maps")
Signed-off-by: Daniel Borkmann
Acked-by: Alexei Starovoitov
Cc: Mauricio Vasquez B
Thanks for the fix Daniel.
Acked-by: Mauricio Vasquez B
On 10/18/18 11:36 AM, Song Liu wrote:
On Thu, Oct 18, 2018 at 6:16 AM Mauricio Vasquez B
wrote:
test_maps:
Tests that queue/stack maps are behaving correctly even in corner cases
test_progs:
Tests new ebpf helpers
Signed-off-by: Mauricio Vasquez B
---
tools/lib/bpf/bpf.c
test_maps:
Tests that queue/stack maps are behaving correctly even in corner cases
test_progs:
Tests new ebpf helpers
Signed-off-by: Mauricio Vasquez B
---
tools/lib/bpf/bpf.c| 12 ++
tools/lib/bpf/bpf.h|2
tools/testing
ation for implementing queue/stack maps was to keep track
of a pool of elements, like network ports in a SNAT, however we forsee
other use cases, like for exampling saving last N kernel events in a map
and then analysing from userspace.
Signed-off-by: Mauricio Vasquez B
---
include/li
This commit adds the required logic to allow key being NULL
in case the key_size of the map is 0.
A new __bpf_copy_key function helper only copies the key from
userpsace when key_size != 0, otherwise it enforces that key must be
null.
Signed-off-by: Mauricio Vasquez B
Acked-by: Song Liu
In the following patches queue and stack maps (FIFO and LIFO
datastructures) will be implemented. In order to avoid confusion and
a possible name clash rename stack_map_ops to stack_trace_map_ops
Signed-off-by: Mauricio Vasquez B
Acked-by: Song Liu
---
include/linux/bpf_types.h |2
/stack maps
and it is still to implement in other kind of maps.
Signed-off-by: Mauricio Vasquez B
---
include/uapi/linux/bpf.h |1 +
kernel/bpf/syscall.c | 66 ++
2 files changed, 67 insertions(+)
diff --git a/include/uapi/linux/bpf.h b/include
Sync both files.
Signed-off-by: Mauricio Vasquez B
Acked-by: Song Liu
---
tools/include/uapi/linux/bpf.h | 30 +-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index f9187b41dff6
to be filled with a map value.
Signed-off-by: Mauricio Vasquez B
Acked-by: Song Liu
---
include/linux/bpf.h |1 +
kernel/bpf/verifier.c |9 ++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index e60fff48288b..0f8b863e0229
.
Signed-off-by: Mauricio Vasquez B
v2 -> v3:
- Remove "almost dead code" in syscall.c
- Remove unnecessary copy_from_user in bpf_map_lookup_and_delete_elem
- Rebase
v1 -> v2:
- Put ARG_PTR_TO_UNINIT_MAP_VALUE logic into a separated patch
- Fix missing __this_cpu_dec & pre
On 10/16/2018 06:20 PM, Alexei Starovoitov wrote:
On Tue, Oct 16, 2018 at 04:16:39PM -0500, Mauricio Vasquez wrote:
On 10/11/2018 06:51 PM, Alexei Starovoitov wrote:
On Wed, Oct 10, 2018 at 05:50:01PM -0500, Mauricio Vasquez wrote:
Does it make sense to you?
I reread the other patch, and
On 10/11/2018 06:51 PM, Alexei Starovoitov wrote:
On Wed, Oct 10, 2018 at 05:50:01PM -0500, Mauricio Vasquez wrote:
Does it make sense to you?
I reread the other patch, and found it does NOT use the following logic for
queue and stack:
rcu_read_lock();
ptr
On 10/10/2018 05:34 PM, Song Liu wrote:
On Wed, Oct 10, 2018 at 10:48 AM Mauricio Vasquez
wrote:
On 10/10/2018 11:48 AM, Song Liu wrote:
On Wed, Oct 10, 2018 at 7:06 AM Mauricio Vasquez B
wrote:
The following patch implements a bpf queue/stack maps that
provides the peek/pop/push
On 10/10/2018 11:48 AM, Song Liu wrote:
On Wed, Oct 10, 2018 at 7:06 AM Mauricio Vasquez B
wrote:
The following patch implements a bpf queue/stack maps that
provides the peek/pop/push functions. There is not a direct
relationship between those functions and the current maps
syscalls, hence
test_maps:
Tests that queue/stack maps are behaving correctly even in corner cases
test_progs:
Tests new ebpf helpers
Signed-off-by: Mauricio Vasquez B
---
tools/lib/bpf/bpf.c| 12 ++
tools/lib/bpf/bpf.h|1
tools/testing
Sync both files.
Signed-off-by: Mauricio Vasquez B
---
tools/include/uapi/linux/bpf.h | 30 +-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index f9187b41dff6..c8824d5364ff 100644
to be filled with a map value.
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf.h |1 +
kernel/bpf/verifier.c |9 ++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 5793f0c7fbb5..e37b4986bb45 100644
--- a
ation for implementing queue/stack maps was to keep track
of a pool of elements, like network ports in a SNAT, however we forsee
other use cases, like for exampling saving last N kernel events in a map
and then analysing from userspace.
Signed-off-by: Mauricio Vasquez B
---
include/li
/stack maps
and it is still to implement in other kind of maps.
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf.h |1 +
include/uapi/linux/bpf.h |1 +
kernel/bpf/syscall.c | 82 ++
3 files changed, 84 insertions(+)
diff --git a
This commit adds the required logic to allow key being NULL
in case the key_size of the map is 0.
A new __bpf_copy_key function helper only copies the key from
userpsace when key_size != 0, otherwise it enforces that key must be
null.
Signed-off-by: Mauricio Vasquez B
---
kernel/bpf/syscall.c
In the following patches queue and stack maps (FIFO and LIFO
datastructures) will be implemented. In order to avoid confusion and
a possible name clash rename stack_map_ops to stack_trace_map_ops
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf_types.h |2 +-
kernel/bpf/stackmap.c
.
Signed-off-by: Mauricio Vasquez B
v1 -> v2:
- Put ARG_PTR_TO_UNINIT_MAP_VALUE logic into a separated patch
- Fix missing __this_cpu_dec & preempt_enable calls in kernel/bpf/syscall.c
RFC v4 -> v1:
- Remove roundup to power of 2 in memory allocation
- Remove count and use a free slo
things a bit because lookup nor
lookup_and_delete have a flag argument.
I am asking because mixing stack with stack trace is still confusing
after this patch.
Thanks,
Song
On Mon, Oct 8, 2018 at 12:11 PM Mauricio Vasquez B
wrote:
In the following patches queue and stack maps (FIFO and LIFO
On 10/08/2018 08:36 PM, Song Liu wrote:
On Mon, Oct 8, 2018 at 12:12 PM Mauricio Vasquez B
wrote:
Queue/stack maps implement a FIFO/LIFO data storage for ebpf programs.
These maps support peek, pop and push operations that are exposed to eBPF
programs through the new bpf_map[peek/pop/push
On 10/08/2018 08:13 PM, Song Liu wrote:
On Mon, Oct 8, 2018 at 12:12 PM Mauricio Vasquez B
wrote:
The following patch implements a bpf queue/stack maps that
provides the peek/pop/push functions. There is not a direct
relationship between those functions and the current maps
syscalls, hence
test_maps:
Tests that queue/stack maps are behaving correctly even in corner cases
test_progs:
Tests new ebpf helpers
Signed-off-by: Mauricio Vasquez B
---
tools/lib/bpf/bpf.c| 12 ++
tools/lib/bpf/bpf.h|1
tools/testing
Sync both files.
Signed-off-by: Mauricio Vasquez B
---
tools/include/uapi/linux/bpf.h | 36
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index f9187b41dff6..bfa042273fad
This commit adds the required logic to allow key being NULL
in case the key_size of the map is 0.
A new __bpf_copy_key function helper only copies the key from
userpsace when key_size != 0, otherwise it enforces that key must be
null.
Signed-off-by: Mauricio Vasquez B
---
kernel/bpf/syscall.c
/stack maps
and it is still to implement in other kind of maps.
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf.h |1 +
include/uapi/linux/bpf.h |1 +
kernel/bpf/syscall.c | 81 ++
3 files changed, 83 insertions(+)
diff --git a
ation for implementing queue/stack maps was to keep track
of a pool of elements, like network ports in a SNAT, however we forsee
other use cases, like for exampling saving last N kernel events in a map
and then analysing from userspace.
Signed-off-by: Mauricio Vasquez B
---
include/li
.
Signed-off-by: Mauricio Vasquez B
RFC v4 -> v1:
- Remove roundup to power of 2 in memory allocation
- Remove count and use a free slot to check if queue/stack is empty
- Use if + assigment for wrapping indexes
- Fix some minor style issues
- Squash two patches together
RFC v3 ->
In the following patches queue and stack maps (FIFO and LIFO
datastructures) will be implemented. In order to avoid confusion and
a possible name clash rename stack_map_ops to stack_trace_map_ops
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf_types.h |2 +-
kernel/bpf/stackmap.c
On 10/04/2018 10:40 PM, Mauricio Vasquez wrote:
On 10/04/2018 06:57 PM, Alexei Starovoitov wrote:
On Thu, Oct 04, 2018 at 07:12:44PM +0200, Mauricio Vasquez B wrote:
Implement two new kind of maps that support the peek, push and pop
operations.
A use case for this is to keep track of a
Sync both files.
Signed-off-by: Mauricio Vasquez B
---
tools/include/uapi/linux/bpf.h | 36
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index f9187b41dff6..bfa042273fad
Restrict the use of peek, push and pop helpers only to queue and stack
maps.
Signed-off-by: Mauricio Vasquez B
---
kernel/bpf/verifier.c | 14 ++
1 file changed, 14 insertions(+)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 489667f93061..8b1f1b348782 100644
This commit adds the required logic to allow key being NULL
in case the key_size of the map is 0.
A new __bpf_copy_key function helper only copies the key from
userpsace when key_size != 0, otherwise it enforces that key must be
null.
Signed-off-by: Mauricio Vasquez B
---
kernel/bpf/syscall.c
Two types of tests are done:
- test_maps: only userspace api.
- test_progs: userspace api and ebpf helpers.
Signed-off-by: Mauricio Vasquez B
---
tools/lib/bpf/bpf.c| 12 ++
tools/lib/bpf/bpf.h|1
tools/testing/selftests/bpf
/stack maps
and it is still to implement in other kind of maps.
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf.h |1 +
include/uapi/linux/bpf.h |1 +
kernel/bpf/syscall.c | 82 ++
3 files changed, 84 insertions(+)
diff --git a
Implement two new kind of maps that support the peek, push and pop
operations.
A use case for this is to keep track of a pool of elements, like
network ports in a SNAT.
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf.h |7 +
include/linux/bpf_types.h |2
include
In the following patches queue and stack maps (FIFO and LIFO
datastructures) will be implemented. In order to avoid confusion and
a possible name clash rename stack_map_ops to stack_trace_map_ops
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf_types.h |2 +-
kernel/bpf/stackmap.c
: queue and stack.
Those maps provide to eBPF programs the peek, push and pop operations, and for
userspace applications a new bpf_map_lookup_and_delete_elem() is added.
Signed-off-by: Mauricio Vasquez B
v3 -> v4:
- Revert renaming of kernel/bpf/stackmap.c
- Remove restriction on value s
On 10/01/2018 07:26 PM, Alexei Starovoitov wrote:
On Mon, Oct 01, 2018 at 08:11:43AM -0500, Mauricio Vasquez wrote:
+BPF_CALL_3(bpf_map_pop_elem, struct bpf_map *, map, void *,
value, u32, size)
+{
+ void *ptr;
+
+ if (map->value_size != size)
+ return -EINVAL;
+
+ ptr =
On 09/19/2018 10:14 AM, Alexei Starovoitov wrote:
On Wed, Sep 19, 2018 at 04:51:41PM +0900, Prashant Bhole wrote:
Return ERR_PTR(-EOPNOTSUPP) from map_lookup_elem() methods of below
map types:
- BPF_MAP_TYPE_PROG_ARRAY
- BPF_MAP_TYPE_STACK_TRACE
- BPF_MAP_TYPE_XSKMAP
- BPF_MAP_TYPE_SOCKMAP/BP
On 09/18/2018 06:32 PM, Alexei Starovoitov wrote:
On Tue, Sep 18, 2018 at 06:53:07AM +0200, Mauricio Vasquez B wrote:
Two types of tests are done:
- test_maps: only userspace api.
- test_progs: userspace api and ebpf helpers.
Signed-off-by: Mauricio Vasquez B
---
kernel/bpf/helpers.c
On 09/18/2018 06:27 PM, Alexei Starovoitov wrote:
On Tue, Sep 18, 2018 at 06:52:51AM +0200, Mauricio Vasquez B wrote:
Implement two new kind of maps that support the peek, push and pop
operations.
A use case for this is to keep track of a pool of elements, like
network ports in a SNAT
On 09/18/2018 06:05 PM, Alexei Starovoitov wrote:
On Tue, Sep 18, 2018 at 06:52:34AM +0200, Mauricio Vasquez B wrote:
In the following patches queue and stack maps (FIFO and LIFO
datastructures) will be implemented. In order to avoid confusion and
a possible name clash rename stackmap.c to
Two types of tests are done:
- test_maps: only userspace api.
- test_progs: userspace api and ebpf helpers.
Signed-off-by: Mauricio Vasquez B
---
kernel/bpf/helpers.c |2
tools/lib/bpf/bpf.c| 12 ++
tools/lib/bpf/bpf.h
Restrict the use of peek, push and pop helpers only to queue and stack
maps.
Signed-off-by: Mauricio Vasquez B
---
kernel/bpf/verifier.c | 14 ++
1 file changed, 14 insertions(+)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index b9e005188f0e..1628ffe48e32 100644
Implement two new kind of maps that support the peek, push and pop
operations.
A use case for this is to keep track of a pool of elements, like
network ports in a SNAT.
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf.h |3
include/linux/bpf_types.h |2
include
Sync both files.
Signed-off-by: Mauricio Vasquez B
---
tools/include/uapi/linux/bpf.h | 31 ++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 66917a4eba27..c899386dcb2b 100644
maps: queue and stack.
Those maps provide to eBPF programs the peek, push and pop operations, and for
userspace applications a new bpf_map_lookup_and_delete_elem() is added.
Signed-off-by: Mauricio Vasquez B
v2 -> v3:
- Return elements by value instead that by reference
- Implement queue/st
In the following patches queue and stack maps (FIFO and LIFO
datastructures) will be implemented. In order to avoid confusion and
a possible name clash rename stackmap.c to stacktracemap.c and
stack_map_ops to stack_trace_map_ops
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf_types.h
This commit adds the required logic to allow key being NULL
in case the key_size of the map is 0.
A new __bpf_copy_key function helper only copies the key from
userpsace when key_size != 0, otherwise it enforces that key must be
null.
Signed-off-by: Mauricio Vasquez B
---
kernel/bpf/syscall.c
helper.
A pop operation is not added because it will too specific to
stack/queue maps, instead this new operation could be useful
for other maps as well.
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf.h |1 +
include/uapi/linux/bpf.h |1 +
kernel/bpf/syscall.c | 82
On 09/10/2018 08:04 PM, Alexei Starovoitov wrote:
On Fri, Sep 7, 2018 at 1:40 PM, Mauricio Vasquez
wrote:
I read the Joe's proposal and using that for this problem looks like a nice
solution.
I think a good trade-off for now would be to go ahead with a queue/stack map
without prealloc
On 09/06/2018 07:13 PM, Alexei Starovoitov wrote:
On Fri, Aug 31, 2018 at 11:25:48PM +0200, Mauricio Vasquez B wrote:
In some applications this is needed have a pool of free elements, like for
example the list of free L4 ports in a SNAT. None of the current maps allow
to do it as it is not
Sync both files.
Signed-off-by: Mauricio Vasquez B
---
tools/include/uapi/linux/bpf.h | 36
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 66917a4eba27..0a5b904ba42f
Two types of tests are done:
- test_maps: only userspace api.
- test_progs: userspace api and ebpf helpers.
Signed-off-by: Mauricio Vasquez B
---
tools/lib/bpf/bpf.c| 12 ++
tools/lib/bpf/bpf.h|1
tools/testing/selftests/bpf
Restrict the use of peek, push and pop helpers only to queue and stack
maps.
Signed-off-by: Mauricio Vasquez B
---
kernel/bpf/verifier.c | 14 ++
1 file changed, 14 insertions(+)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 5bd67feb2f07..9e177ff4a3b9 100644
maps: queue and stack.
Those maps provide to eBPF programs the peek, push and pop operations, and for
userspace applications a new bpf_map_lookup_and_delete_elem() is added.
Signed-off-by: Mauricio Vasquez B
---
I am sending this as an RFC because there is still an issue I am not sure how
to solve
Implement two new kind of maps that support the peek, push and pop
operations.
A use case for this is to keep track of a pool of elements, like
network ports in a SNAT.
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf.h |8 +
include/linux/bpf_types.h |2
include
On 08/09/2018 11:23 AM, Alexei Starovoitov wrote:
On Thu, Aug 09, 2018 at 09:51:49AM -0500, Mauricio Vasquez wrote:
Agree that existing ops are not the right alias, but deferring to user
space as inline function also doesn't really seem like a good fit, imho,
so I'd prefer rath
On 08/09/2018 04:02 AM, Daniel Borkmann wrote:
On 08/09/2018 06:48 AM, Alexei Starovoitov wrote:
On Wed, Aug 08, 2018 at 10:08:47PM -0500, Mauricio Vasquez wrote:
And how about adding three new helpers: push/pop/peek as well?
Reusing lookup/update is neat, but does lookup == pop
or does
On 08/07/2018 09:42 AM, Alexei Starovoitov wrote:
On Mon, Aug 06, 2018 at 03:58:30PM +0200, Mauricio Vasquez B wrote:
Bpf queue implements a LIFO/FIFO data containers for ebpf programs.
queue/stack datastructure would be a great addition.
It allows to push an element to the queue by using
On 08/07/2018 08:52 AM, Daniel Borkmann wrote:
On 08/06/2018 03:58 PM, Mauricio Vasquez B wrote:
Bpf queue implements a LIFO/FIFO data containers for ebpf programs.
It allows to push an element to the queue by using the update operation
and to pop an element from the queue by using the
On 08/07/2018 08:44 AM, Daniel Borkmann wrote:
On 08/06/2018 03:58 PM, Mauricio Vasquez B wrote:
The example is made by two parts, a eBPF program that consumes elements
from a FIFO queue and prints them in the screen and a user space
application that inserts new elements into the queue each
On 08/07/2018 08:40 AM, Daniel Borkmann wrote:
On 08/06/2018 03:58 PM, Mauricio Vasquez B wrote:
Bpf queue implements a LIFO/FIFO data containers for ebpf programs.
It allows to push an element to the queue by using the update operation
and to pop an element from the queue by using the
The example is made by two parts, a eBPF program that consumes elements
from a FIFO queue and prints them in the screen and a user space
application that inserts new elements into the queue each time this is
executed.
Signed-off-by: Mauricio Vasquez B
---
samples/bpf/.gitignore
Signed-off-by: Mauricio Vasquez B
---
tools/include/uapi/linux/bpf.h |5 ++
tools/testing/selftests/bpf/test_maps.c | 72 +++
2 files changed, 77 insertions(+)
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index
.
Signed-off-by: Mauricio Vasquez B
---
include/linux/bpf_types.h |1
include/uapi/linux/bpf.h |5 +
kernel/bpf/Makefile |2
kernel/bpf/queuemap.c | 287 +
kernel/bpf/syscall.c | 61 +++---
kernel/bpf/verifier.c
Bpf queue map is a new kind of map that provides a LIFO/FIFO queue
implementation.
In some applications, like a SNAT, it is necessary to keep track of
a pool of free elemenets, network ports in this case, then a queue
can be used for that purpose.
Signed-off-by: Mauricio Vasquez B
---
Mauricio
On 06/30/2018 06:20 PM, Daniel Borkmann wrote:
On 06/29/2018 02:48 PM, Mauricio Vasquez B wrote:
Decrement the number of elements in the map in case the allocation
of a new node fails.
Signed-off-by: Mauricio Vasquez B
Thanks for the fix, Mauricio!
Could you reply with a Fixes: tag in
Decrement the number of elements in the map in case the allocation
of a new node fails.
Signed-off-by: Mauricio Vasquez B
---
kernel/bpf/hashtab.c | 16 +++-
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
index 3ca2198
75 matches
Mail list logo