diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2017-11-24 04:35:55 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-11-24 04:35:55 +0000 |
commit | ff27a837e601b1f0331b4700c167107b38475e31 (patch) | |
tree | 4a56d9683737ec68d8f0e5615abfea118eec6426 /examples/bpf/bpf_tailcall.c | |
parent | ea40c76ce7c05071cd7e99acf04f099c55a402e0 (diff) | |
parent | ef18ea8cd8792986b2e68ae2d28c26094298d586 (diff) | |
download | platform_external_iproute2-ff27a837e601b1f0331b4700c167107b38475e31.tar.gz platform_external_iproute2-ff27a837e601b1f0331b4700c167107b38475e31.tar.bz2 platform_external_iproute2-ff27a837e601b1f0331b4700c167107b38475e31.zip |
Merge changes Id0db30f6,I117dcabd,If21f95e2,I42c1ebfa am: 550751fdb7
am: ef18ea8cd8
Change-Id: I53ed491ce401e09246263c69e91c1bbbb026fe8b
Diffstat (limited to 'examples/bpf/bpf_tailcall.c')
-rw-r--r-- | examples/bpf/bpf_tailcall.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/examples/bpf/bpf_tailcall.c b/examples/bpf/bpf_tailcall.c index 040790d0..1a30426c 100644 --- a/examples/bpf/bpf_tailcall.c +++ b/examples/bpf/bpf_tailcall.c @@ -26,20 +26,40 @@ * classifier behaviour. */ -BPF_PROG_ARRAY(jmp_tc, FOO, PIN_OBJECT_NS, MAX_JMP_SIZE); -BPF_PROG_ARRAY(jmp_ex, BAR, PIN_OBJECT_NS, 1); - -BPF_ARRAY4(map_sh, 0, PIN_OBJECT_NS, 1); +struct bpf_elf_map __section_maps jmp_tc = { + .type = BPF_MAP_TYPE_PROG_ARRAY, + .id = FOO, + .size_key = sizeof(uint32_t), + .size_value = sizeof(uint32_t), + .pinning = PIN_OBJECT_NS, + .max_elem = MAX_JMP_SIZE, +}; + +struct bpf_elf_map __section_maps jmp_ex = { + .type = BPF_MAP_TYPE_PROG_ARRAY, + .id = BAR, + .size_key = sizeof(uint32_t), + .size_value = sizeof(uint32_t), + .pinning = PIN_OBJECT_NS, + .max_elem = 1, +}; + +struct bpf_elf_map __section_maps map_sh = { + .type = BPF_MAP_TYPE_ARRAY, + .size_key = sizeof(uint32_t), + .size_value = sizeof(uint32_t), + .pinning = PIN_OBJECT_NS, + .max_elem = 1, +}; __section_tail(FOO, ENTRY_0) int cls_case1(struct __sk_buff *skb) { - char fmt[] = "case1: map-val: %d from:%u\n"; int key = 0, *val; val = map_lookup_elem(&map_sh, &key); if (val) - trace_printk(fmt, sizeof(fmt), *val, skb->cb[0]); + printt("case1: map-val: %d from:%u\n", *val, skb->cb[0]); skb->cb[0] = ENTRY_0; tail_call(skb, &jmp_ex, ENTRY_0); @@ -50,12 +70,11 @@ int cls_case1(struct __sk_buff *skb) __section_tail(FOO, ENTRY_1) int cls_case2(struct __sk_buff *skb) { - char fmt[] = "case2: map-val: %d from:%u\n"; int key = 0, *val; val = map_lookup_elem(&map_sh, &key); if (val) - trace_printk(fmt, sizeof(fmt), *val, skb->cb[0]); + printt("case2: map-val: %d from:%u\n", *val, skb->cb[0]); skb->cb[0] = ENTRY_1; tail_call(skb, &jmp_tc, ENTRY_0); @@ -66,12 +85,11 @@ int cls_case2(struct __sk_buff *skb) __section_tail(BAR, ENTRY_0) int cls_exit(struct __sk_buff *skb) { - char fmt[] = "exit: map-val: %d from:%u\n"; int key = 0, *val; val = map_lookup_elem(&map_sh, &key); if (val) - trace_printk(fmt, sizeof(fmt), *val, skb->cb[0]); + printt("exit: map-val: %d from:%u\n", *val, skb->cb[0]); /* Termination point. */ return BPF_H_DEFAULT; @@ -80,7 +98,6 @@ int cls_exit(struct __sk_buff *skb) __section_cls_entry int cls_entry(struct __sk_buff *skb) { - char fmt[] = "fallthrough\n"; int key = 0, *val; /* For transferring state, we can use skb->cb[0] ... skb->cb[4]. */ @@ -92,7 +109,7 @@ int cls_entry(struct __sk_buff *skb) tail_call(skb, &jmp_tc, skb->hash & (MAX_JMP_SIZE - 1)); } - trace_printk(fmt, sizeof(fmt)); + printt("fallthrough\n"); return BPF_H_DEFAULT; } |