Thread (29 messages) 29 messages, 4 authors, 2021-04-23

Re: [PATCH v3 bpf-next 17/18] selftests/bpf: add map linking selftest

From: Andrii Nakryiko <hidden>
Date: 2021-04-23 21:39:49
Also in: bpf

On Fri, Apr 23, 2021 at 2:23 PM Alexei Starovoitov
[off-list ref] wrote:
On Fri, Apr 23, 2021 at 11:54 AM Yonghong Song [off-list ref] wrote:
quoted


On 4/23/21 11:13 AM, Andrii Nakryiko wrote:
quoted
Add selftest validating various aspects of statically linking BTF-defined map
definitions. Legacy map definitions do not support extern resolution between
object files. Some of the aspects validated:
   - correct resolution of extern maps against concrete map definitions;
   - extern maps can currently only specify map type and key/value size and/or
     type information;
   - weak concrete map definitions are resolved properly.

Static map definitions are not yet supported by libbpf, so they are not
explicitly tested, though manual testing showes that BPF linker handles them
properly.

Acked-by: Yonghong Song <redacted>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
[...]
quoted
+
+SEC("raw_tp/sys_exit")
+int BPF_PROG(handler_exit1)
+{
+     /* lookup values with key = 2, set in another file */
+     int key = 2, *val;
+     struct my_key key_struct = { .x = 2 };
+     struct my_value *value_struct;
+
+     value_struct = bpf_map_lookup_elem(&map1, &key_struct);
+     if (value_struct)
+             output_first1 = value_struct->x;
+
+     val = bpf_map_lookup_elem(&map2, &key);
+     if (val)
+             output_second1 = *val;
+
+     val = bpf_map_lookup_elem(&map_weak, &key);
+     if (val)
+             output_weak1 = *val;
+
There is an extra tab in the above line. There is no need for new
revision just for this. If no new revision is needed, maybe
the maintainer can help fix it.
Sorry. I applied without it. Pls fold the fix in some of the future patches.
Ok, no problem, I'll do it in v3 of statics support patch set.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help