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
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
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
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
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
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
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
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
49 matches
Mail list logo