bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests: Make sure all 'skel' variables are declared static
@ 2020-09-29 12:30 Toke Høiland-Jørgensen
  2020-09-29 18:46 ` Alexei Starovoitov
  2020-09-29 18:50 ` patchwork-bot+bpf
  0 siblings, 2 replies; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-09-29 12:30 UTC (permalink / raw)
  To: daniel, ast
  Cc: Toke Høiland-Jørgensen, bpf, netdev, Martin KaFai Lau

If programs in prog_tests using skeletons declare the 'skel' variable as
global but not static, that will lead to linker errors on the final link of
the prog_tests binary due to duplicate symbols. Fix a few instances of this.

Fixes: b18c1f0aa477 ("bpf: selftest: Adapt sock_fields test to use skel and global variables")
Fixes: 9a856cae2217 ("bpf: selftest: Add test_btf_skc_cls_ingress")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 tools/testing/selftests/bpf/prog_tests/btf_skc_cls_ingress.c | 2 +-
 tools/testing/selftests/bpf/prog_tests/sock_fields.c         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/btf_skc_cls_ingress.c b/tools/testing/selftests/bpf/prog_tests/btf_skc_cls_ingress.c
index 4ce0e8a25bc5..86ccf37e26b3 100644
--- a/tools/testing/selftests/bpf/prog_tests/btf_skc_cls_ingress.c
+++ b/tools/testing/selftests/bpf/prog_tests/btf_skc_cls_ingress.c
@@ -16,7 +16,7 @@
 #include "test_progs.h"
 #include "test_btf_skc_cls_ingress.skel.h"
 
-struct test_btf_skc_cls_ingress *skel;
+static struct test_btf_skc_cls_ingress *skel;
 struct sockaddr_in6 srv_sa6;
 static __u32 duration;
 
diff --git a/tools/testing/selftests/bpf/prog_tests/sock_fields.c b/tools/testing/selftests/bpf/prog_tests/sock_fields.c
index 66e83b8fc69d..af87118e748e 100644
--- a/tools/testing/selftests/bpf/prog_tests/sock_fields.c
+++ b/tools/testing/selftests/bpf/prog_tests/sock_fields.c
@@ -36,7 +36,7 @@ struct bpf_spinlock_cnt {
 
 static struct sockaddr_in6 srv_sa6, cli_sa6;
 static int sk_pkt_out_cnt10_fd;
-struct test_sock_fields *skel;
+static struct test_sock_fields *skel;
 static int sk_pkt_out_cnt_fd;
 static __u64 parent_cg_id;
 static __u64 child_cg_id;
-- 
2.28.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] selftests: Make sure all 'skel' variables are declared static
  2020-09-29 12:30 [PATCH bpf-next] selftests: Make sure all 'skel' variables are declared static Toke Høiland-Jørgensen
@ 2020-09-29 18:46 ` Alexei Starovoitov
  2020-09-29 20:59   ` Toke Høiland-Jørgensen
  2020-09-29 18:50 ` patchwork-bot+bpf
  1 sibling, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2020-09-29 18:46 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Daniel Borkmann, Alexei Starovoitov, bpf, Network Development,
	Martin KaFai Lau

On Tue, Sep 29, 2020 at 5:32 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>
> If programs in prog_tests using skeletons declare the 'skel' variable as
> global but not static, that will lead to linker errors on the final link of
> the prog_tests binary due to duplicate symbols. Fix a few instances of this.
>
> Fixes: b18c1f0aa477 ("bpf: selftest: Adapt sock_fields test to use skel and global variables")
> Fixes: 9a856cae2217 ("bpf: selftest: Add test_btf_skc_cls_ingress")
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>

Thanks for the fix. Applied.
I wonder why we don't see it with different gcc and clang versions.
What linker do you use?
And what kind of error do you see?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] selftests: Make sure all 'skel' variables are declared static
  2020-09-29 12:30 [PATCH bpf-next] selftests: Make sure all 'skel' variables are declared static Toke Høiland-Jørgensen
  2020-09-29 18:46 ` Alexei Starovoitov
@ 2020-09-29 18:50 ` patchwork-bot+bpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+bpf @ 2020-09-29 18:50 UTC (permalink / raw)
  To: =?utf-8?b?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2VuIDx0b2tlQHJlZGhhdC5jb20+?=; +Cc: bpf

Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

On Tue, 29 Sep 2020 14:30:26 +0200 you wrote:
> If programs in prog_tests using skeletons declare the 'skel' variable as
> global but not static, that will lead to linker errors on the final link of
> the prog_tests binary due to duplicate symbols. Fix a few instances of this.
> 
> Fixes: b18c1f0aa477 ("bpf: selftest: Adapt sock_fields test to use skel and global variables")
> Fixes: 9a856cae2217 ("bpf: selftest: Add test_btf_skc_cls_ingress")
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
> 
> [...]

Here is the summary with links:
  - [bpf-next] selftests: Make sure all 'skel' variables are declared static
    https://git.kernel.org/bpf/bpf-next/c/f970cbcdcdb5

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next] selftests: Make sure all 'skel' variables are declared static
  2020-09-29 18:46 ` Alexei Starovoitov
@ 2020-09-29 20:59   ` Toke Høiland-Jørgensen
  0 siblings, 0 replies; 4+ messages in thread
From: Toke Høiland-Jørgensen @ 2020-09-29 20:59 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Daniel Borkmann, Alexei Starovoitov, bpf, Network Development,
	Martin KaFai Lau

Alexei Starovoitov <alexei.starovoitov@gmail.com> writes:

> On Tue, Sep 29, 2020 at 5:32 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>>
>> If programs in prog_tests using skeletons declare the 'skel' variable as
>> global but not static, that will lead to linker errors on the final link of
>> the prog_tests binary due to duplicate symbols. Fix a few instances of this.
>>
>> Fixes: b18c1f0aa477 ("bpf: selftest: Adapt sock_fields test to use skel and global variables")
>> Fixes: 9a856cae2217 ("bpf: selftest: Add test_btf_skc_cls_ingress")
>> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
>
> Thanks for the fix. Applied.

You're welcome! And thanks :)

> I wonder why we don't see it with different gcc and clang versions.

Yeah, I was wondering about that as well, actually...

> What linker do you use?
> And what kind of error do you see?

  BINARY   test_progs
/usr/bin/ld: /home/build/linux/tools/testing/selftests/bpf/sock_fields.test.o:/home/build/linux/tools/testing/selftests/bpf/prog_tests/sock_fields.c:39: multiple definition of `skel'; /home/build/linux/tools/testing/selftests/bpf/btf_skc_cls_ingress.test.o:/home/build/linux/tools/testing/selftests/bpf/prog_tests/btf_skc_cls_ingress.c:19: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:397: /home/build/linux/tools/testing/selftests/bpf/test_progs] Error 1

$  ld --version
GNU ld (GNU Binutils) 2.35

$ gcc --version
gcc (GCC) 10.2.0

-Toke


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-29 20:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 12:30 [PATCH bpf-next] selftests: Make sure all 'skel' variables are declared static Toke Høiland-Jørgensen
2020-09-29 18:46 ` Alexei Starovoitov
2020-09-29 20:59   ` Toke Høiland-Jørgensen
2020-09-29 18:50 ` patchwork-bot+bpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).