summaryrefslogtreecommitdiff
path: root/samples/bpf/test_maps.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2016-09-26 15:47:03 -0400
committerThomas Gleixner <tglx@linutronix.de>2016-09-26 15:47:03 -0400
commit1e1b37273cf719545da50b76f214f983a710aaf4 (patch)
tree033f6062325ef7aaeefe8559bb409ab7d2be3c76 /samples/bpf/test_maps.c
parentc183a603e8d8a5a189729b77d0c623a3d5950e5f (diff)
parentc291b015158577be533dd5a959dfc09bab119eed (diff)
Merge branch 'x86/urgent' into x86/apic
Bring in the upstream modifications so we can fixup the silent merge conflict which is introduced by this merge. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'samples/bpf/test_maps.c')
-rw-r--r--samples/bpf/test_maps.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/samples/bpf/test_maps.c b/samples/bpf/test_maps.c
index 47bf0858f9e4..cce2b59751eb 100644
--- a/samples/bpf/test_maps.c
+++ b/samples/bpf/test_maps.c
@@ -68,7 +68,16 @@ static void test_hashmap_sanity(int i, void *data)
assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == -1 &&
errno == E2BIG);
+ /* update existing element, thought the map is full */
+ key = 1;
+ assert(bpf_update_elem(map_fd, &key, &value, BPF_EXIST) == 0);
+ key = 2;
+ assert(bpf_update_elem(map_fd, &key, &value, BPF_ANY) == 0);
+ key = 1;
+ assert(bpf_update_elem(map_fd, &key, &value, BPF_ANY) == 0);
+
/* check that key = 0 doesn't exist */
+ key = 0;
assert(bpf_delete_elem(map_fd, &key) == -1 && errno == ENOENT);
/* iterate over two elements */
@@ -413,10 +422,12 @@ static void do_work(int fn, void *data)
for (i = fn; i < MAP_SIZE; i += TASKS) {
key = value = i;
- if (do_update)
+ if (do_update) {
assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == 0);
- else
+ assert(bpf_update_elem(map_fd, &key, &value, BPF_EXIST) == 0);
+ } else {
assert(bpf_delete_elem(map_fd, &key) == 0);
+ }
}
}