aboutsummaryrefslogtreecommitdiffstats
path: root/samples/bpf
diff options
context:
space:
mode:
Diffstat (limited to 'samples/bpf')
-rw-r--r--samples/bpf/bpf_helpers.h4
-rw-r--r--samples/bpf/test_cgrp2_tc_kern.c2
-rw-r--r--samples/bpf/test_maps.c15
3 files changed, 16 insertions, 5 deletions
diff --git a/samples/bpf/bpf_helpers.h b/samples/bpf/bpf_helpers.h
index 217c8d507f2e..7927a090fa0d 100644
--- a/samples/bpf/bpf_helpers.h
+++ b/samples/bpf/bpf_helpers.h
@@ -72,8 +72,8 @@ static int (*bpf_l3_csum_replace)(void *ctx, int off, int from, int to, int flag
72 (void *) BPF_FUNC_l3_csum_replace; 72 (void *) BPF_FUNC_l3_csum_replace;
73static int (*bpf_l4_csum_replace)(void *ctx, int off, int from, int to, int flags) = 73static int (*bpf_l4_csum_replace)(void *ctx, int off, int from, int to, int flags) =
74 (void *) BPF_FUNC_l4_csum_replace; 74 (void *) BPF_FUNC_l4_csum_replace;
75static int (*bpf_skb_in_cgroup)(void *ctx, void *map, int index) = 75static int (*bpf_skb_under_cgroup)(void *ctx, void *map, int index) =
76 (void *) BPF_FUNC_skb_in_cgroup; 76 (void *) BPF_FUNC_skb_under_cgroup;
77 77
78#if defined(__x86_64__) 78#if defined(__x86_64__)
79 79
diff --git a/samples/bpf/test_cgrp2_tc_kern.c b/samples/bpf/test_cgrp2_tc_kern.c
index 2732c37c8d5b..10ff73404e3a 100644
--- a/samples/bpf/test_cgrp2_tc_kern.c
+++ b/samples/bpf/test_cgrp2_tc_kern.c
@@ -57,7 +57,7 @@ int handle_egress(struct __sk_buff *skb)
57 bpf_trace_printk(dont_care_msg, sizeof(dont_care_msg), 57 bpf_trace_printk(dont_care_msg, sizeof(dont_care_msg),
58 eth->h_proto, ip6h->nexthdr); 58 eth->h_proto, ip6h->nexthdr);
59 return TC_ACT_OK; 59 return TC_ACT_OK;
60 } else if (bpf_skb_in_cgroup(skb, &test_cgrp2_array_pin, 0) != 1) { 60 } else if (bpf_skb_under_cgroup(skb, &test_cgrp2_array_pin, 0) != 1) {
61 bpf_trace_printk(pass_msg, sizeof(pass_msg)); 61 bpf_trace_printk(pass_msg, sizeof(pass_msg));
62 return TC_ACT_OK; 62 return TC_ACT_OK;
63 } else { 63 } else {
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