diff options
author | David S. Miller <davem@davemloft.net> | 2018-08-04 20:51:55 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-08-04 20:51:55 -0400 |
commit | 5dbfb6eca0b23751d9ab21989a07b5a22fa544fe (patch) | |
tree | f689b89e1dd9fd73701af44f5aba3e7c78509a10 /tools | |
parent | 5607016cd1bbec538050b495669c3c8c5a2cee80 (diff) | |
parent | 8c85cbdf371f9ddf256ecc5d9548b26ee8fcfe2f (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
Daniel Borkmann says:
====================
pull-request: bpf 2018-08-05
The following pull-request contains BPF updates for your *net* tree.
The main changes are:
1) Fix bpftool percpu_array dump by using correct roundup to next
multiple of 8 for the value size, from Yonghong.
2) Fix in AF_XDP's __xsk_rcv_zc() to not returning frames back to
allocator since driver will recycle frame anyway in case of an
error, from Jakub.
3) Fix up BPF test_lwt_seg6local test cases to final iproute2
syntax, from Mathieu.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/bpf/bpftool/map.c | 14 | ||||
-rwxr-xr-x | tools/testing/selftests/bpf/test_lwt_seg6local.sh | 6 |
2 files changed, 12 insertions, 8 deletions
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c index 097b1a5e046b..f74a8bcbda87 100644 --- a/tools/bpf/bpftool/map.c +++ b/tools/bpf/bpftool/map.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <assert.h> | 36 | #include <assert.h> |
37 | #include <errno.h> | 37 | #include <errno.h> |
38 | #include <fcntl.h> | 38 | #include <fcntl.h> |
39 | #include <linux/kernel.h> | ||
39 | #include <stdbool.h> | 40 | #include <stdbool.h> |
40 | #include <stdio.h> | 41 | #include <stdio.h> |
41 | #include <stdlib.h> | 42 | #include <stdlib.h> |
@@ -90,7 +91,8 @@ static bool map_is_map_of_progs(__u32 type) | |||
90 | static void *alloc_value(struct bpf_map_info *info) | 91 | static void *alloc_value(struct bpf_map_info *info) |
91 | { | 92 | { |
92 | if (map_is_per_cpu(info->type)) | 93 | if (map_is_per_cpu(info->type)) |
93 | return malloc(info->value_size * get_possible_cpus()); | 94 | return malloc(round_up(info->value_size, 8) * |
95 | get_possible_cpus()); | ||
94 | else | 96 | else |
95 | return malloc(info->value_size); | 97 | return malloc(info->value_size); |
96 | } | 98 | } |
@@ -161,9 +163,10 @@ static void print_entry_json(struct bpf_map_info *info, unsigned char *key, | |||
161 | jsonw_name(json_wtr, "value"); | 163 | jsonw_name(json_wtr, "value"); |
162 | print_hex_data_json(value, info->value_size); | 164 | print_hex_data_json(value, info->value_size); |
163 | } else { | 165 | } else { |
164 | unsigned int i, n; | 166 | unsigned int i, n, step; |
165 | 167 | ||
166 | n = get_possible_cpus(); | 168 | n = get_possible_cpus(); |
169 | step = round_up(info->value_size, 8); | ||
167 | 170 | ||
168 | jsonw_name(json_wtr, "key"); | 171 | jsonw_name(json_wtr, "key"); |
169 | print_hex_data_json(key, info->key_size); | 172 | print_hex_data_json(key, info->key_size); |
@@ -176,7 +179,7 @@ static void print_entry_json(struct bpf_map_info *info, unsigned char *key, | |||
176 | jsonw_int_field(json_wtr, "cpu", i); | 179 | jsonw_int_field(json_wtr, "cpu", i); |
177 | 180 | ||
178 | jsonw_name(json_wtr, "value"); | 181 | jsonw_name(json_wtr, "value"); |
179 | print_hex_data_json(value + i * info->value_size, | 182 | print_hex_data_json(value + i * step, |
180 | info->value_size); | 183 | info->value_size); |
181 | 184 | ||
182 | jsonw_end_object(json_wtr); | 185 | jsonw_end_object(json_wtr); |
@@ -207,9 +210,10 @@ static void print_entry_plain(struct bpf_map_info *info, unsigned char *key, | |||
207 | 210 | ||
208 | printf("\n"); | 211 | printf("\n"); |
209 | } else { | 212 | } else { |
210 | unsigned int i, n; | 213 | unsigned int i, n, step; |
211 | 214 | ||
212 | n = get_possible_cpus(); | 215 | n = get_possible_cpus(); |
216 | step = round_up(info->value_size, 8); | ||
213 | 217 | ||
214 | printf("key:\n"); | 218 | printf("key:\n"); |
215 | fprint_hex(stdout, key, info->key_size, " "); | 219 | fprint_hex(stdout, key, info->key_size, " "); |
@@ -217,7 +221,7 @@ static void print_entry_plain(struct bpf_map_info *info, unsigned char *key, | |||
217 | for (i = 0; i < n; i++) { | 221 | for (i = 0; i < n; i++) { |
218 | printf("value (CPU %02d):%c", | 222 | printf("value (CPU %02d):%c", |
219 | i, info->value_size > 16 ? '\n' : ' '); | 223 | i, info->value_size > 16 ? '\n' : ' '); |
220 | fprint_hex(stdout, value + i * info->value_size, | 224 | fprint_hex(stdout, value + i * step, |
221 | info->value_size, " "); | 225 | info->value_size, " "); |
222 | printf("\n"); | 226 | printf("\n"); |
223 | } | 227 | } |
diff --git a/tools/testing/selftests/bpf/test_lwt_seg6local.sh b/tools/testing/selftests/bpf/test_lwt_seg6local.sh index 270fa8f49573..785eabf2a593 100755 --- a/tools/testing/selftests/bpf/test_lwt_seg6local.sh +++ b/tools/testing/selftests/bpf/test_lwt_seg6local.sh | |||
@@ -115,14 +115,14 @@ ip netns exec ns2 ip -6 route add fb00::6 encap bpf in obj test_lwt_seg6local.o | |||
115 | ip netns exec ns2 ip -6 route add fd00::1 dev veth3 via fb00::43 scope link | 115 | ip netns exec ns2 ip -6 route add fd00::1 dev veth3 via fb00::43 scope link |
116 | 116 | ||
117 | ip netns exec ns3 ip -6 route add fc42::1 dev veth5 via fb00::65 | 117 | ip netns exec ns3 ip -6 route add fc42::1 dev veth5 via fb00::65 |
118 | ip netns exec ns3 ip -6 route add fd00::1 encap seg6local action End.BPF obj test_lwt_seg6local.o sec add_egr_x dev veth4 | 118 | ip netns exec ns3 ip -6 route add fd00::1 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec add_egr_x dev veth4 |
119 | 119 | ||
120 | ip netns exec ns4 ip -6 route add fd00::2 encap seg6local action End.BPF obj test_lwt_seg6local.o sec pop_egr dev veth6 | 120 | ip netns exec ns4 ip -6 route add fd00::2 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec pop_egr dev veth6 |
121 | ip netns exec ns4 ip -6 addr add fc42::1 dev lo | 121 | ip netns exec ns4 ip -6 addr add fc42::1 dev lo |
122 | ip netns exec ns4 ip -6 route add fd00::3 dev veth7 via fb00::87 | 122 | ip netns exec ns4 ip -6 route add fd00::3 dev veth7 via fb00::87 |
123 | 123 | ||
124 | ip netns exec ns5 ip -6 route add fd00::4 table 117 dev veth9 via fb00::109 | 124 | ip netns exec ns5 ip -6 route add fd00::4 table 117 dev veth9 via fb00::109 |
125 | ip netns exec ns5 ip -6 route add fd00::3 encap seg6local action End.BPF obj test_lwt_seg6local.o sec inspect_t dev veth8 | 125 | ip netns exec ns5 ip -6 route add fd00::3 encap seg6local action End.BPF endpoint obj test_lwt_seg6local.o sec inspect_t dev veth8 |
126 | 126 | ||
127 | ip netns exec ns6 ip -6 addr add fb00::6/16 dev lo | 127 | ip netns exec ns6 ip -6 addr add fb00::6/16 dev lo |
128 | ip netns exec ns6 ip -6 addr add fd00::4/16 dev lo | 128 | ip netns exec ns6 ip -6 addr add fd00::4/16 dev lo |