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

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

From: Yonghong Song <hidden>
Date: 2021-04-23 18:54:08
Also in: bpf


On 4/23/21 11:13 AM, Andrii Nakryiko wrote:
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>
[...]
+
+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.
+	return 0;
+}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help