diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2016-09-01 12:33:46 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2016-09-01 12:33:46 -0400 |
commit | 0cb7bf61b1e9f05027de58c80f9b46a714d24e35 (patch) | |
tree | 41fb55cf62d07b425122f9a8b96412c0d8eb99c5 /samples/bpf/test_maps.c | |
parent | aa877175e7a9982233ed8f10cb4bfddd78d82741 (diff) | |
parent | 3eab887a55424fc2c27553b7bfe32330df83f7b8 (diff) |
Merge branch 'linus' into smp/hotplug
Apply upstream changes to avoid conflicts with pending patches.
Diffstat (limited to 'samples/bpf/test_maps.c')
-rw-r--r-- | samples/bpf/test_maps.c | 15 |
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) | |||
68 | assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == -1 && | 68 | assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == -1 && |
69 | errno == E2BIG); | 69 | errno == E2BIG); |
70 | 70 | ||
71 | /* update existing element, thought the map is full */ | ||
72 | key = 1; | ||
73 | assert(bpf_update_elem(map_fd, &key, &value, BPF_EXIST) == 0); | ||
74 | key = 2; | ||
75 | assert(bpf_update_elem(map_fd, &key, &value, BPF_ANY) == 0); | ||
76 | key = 1; | ||
77 | assert(bpf_update_elem(map_fd, &key, &value, BPF_ANY) == 0); | ||
78 | |||
71 | /* check that key = 0 doesn't exist */ | 79 | /* check that key = 0 doesn't exist */ |
80 | key = 0; | ||
72 | assert(bpf_delete_elem(map_fd, &key) == -1 && errno == ENOENT); | 81 | assert(bpf_delete_elem(map_fd, &key) == -1 && errno == ENOENT); |
73 | 82 | ||
74 | /* iterate over two elements */ | 83 | /* iterate over two elements */ |
@@ -413,10 +422,12 @@ static void do_work(int fn, void *data) | |||
413 | 422 | ||
414 | for (i = fn; i < MAP_SIZE; i += TASKS) { | 423 | for (i = fn; i < MAP_SIZE; i += TASKS) { |
415 | key = value = i; | 424 | key = value = i; |
416 | if (do_update) | 425 | if (do_update) { |
417 | assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == 0); | 426 | assert(bpf_update_elem(map_fd, &key, &value, BPF_NOEXIST) == 0); |
418 | else | 427 | assert(bpf_update_elem(map_fd, &key, &value, BPF_EXIST) == 0); |
428 | } else { | ||
419 | assert(bpf_delete_elem(map_fd, &key) == 0); | 429 | assert(bpf_delete_elem(map_fd, &key) == 0); |
430 | } | ||
420 | } | 431 | } |
421 | } | 432 | } |
422 | 433 | ||