bpf, selftests: test_maps generating unrecognized data section
authorJohn Fastabend <john.fastabend@gmail.com>
Thu, 1 Apr 2021 22:25:56 +0000 (15:25 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 2 Apr 2021 23:21:08 +0000 (01:21 +0200)
With a relatively recent clang master branch test_map skips a section,

 libbpf: elf: skipping unrecognized data section(5) .rodata.str1.1

the cause is some pointless strings from bpf_printks in the BPF program
loaded during testing. After just removing the prints to fix above error
Daniel points out the program is a bit pointless and could be simply the
empty program returning SK_PASS.

Here we do just that and return simply SK_PASS. This program is used with
test_maps selftests to test insert/remove of a program into the sockmap
and sockhash maps. Its not testing actual functionality of the TCP
sockmap programs, these are tested from test_sockmap. So we shouldn't
lose in test coverage and fix above warnings. This original test was
added before test_sockmap existed and has been copied around ever since,
clean it up now.

Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/161731595664.74613.1603087410166945302.stgit@john-XPS-13-9370
tools/testing/selftests/bpf/progs/sockmap_tcp_msg_prog.c

index fdb4bf4408fa782c6f0e91aafd500d9905b0e7f5..eeaf6e75c9a26e28b093578f396d47d7dbd9c7a9 100644 (file)
@@ -8,18 +8,6 @@ int _version SEC("version") = 1;
 SEC("sk_msg1")
 int bpf_prog1(struct sk_msg_md *msg)
 {
-       void *data_end = (void *)(long) msg->data_end;
-       void *data = (void *)(long) msg->data;
-
-       char *d;
-
-       if (data + 8 > data_end)
-               return SK_DROP;
-
-       bpf_printk("data length %i\n", (__u64)msg->data_end - (__u64)msg->data);
-       d = (char *)data;
-       bpf_printk("hello sendmsg hook %i %i\n", d[0], d[1]);
-
        return SK_PASS;
 }