selftests: fix two small compilation errors
Subsystems (3)
cover selftests: fix two small compilation errors
Fix them separately in each patch.
Jason Xing (2):
bpf: changes_pkt_data: correct the 'main' error
bpf: sockopt_sk: fix 'undeclared' definition error
.../selftests/bpf/prog_tests/changes_pkt_data.c | 12 ++++++------ tools/testing/selftests/bpf/prog_tests/sockopt_sk.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)
Signature · 1 line
2.43.5
PATCH 1/2 bpf: changes_pkt_data: correct the 'main' error
When compiling the selftests, the following error is printed out:selftests/bpf/prog_tests/changes_pkt_data.c: In function ‘test_aux’:selftests/bpf/prog_tests/changes_pkt_data.c:22:27: error: ‘main’ is usually a function [-Werror=main]
struct changes_pkt_data *main = NULL;
^~~~Fix it by replacing with 'main_data'.
--- .../selftests/bpf/prog_tests/changes_pkt_data.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/bpf/prog_tests/changes_pkt_data.c +6 -6
@@ -19,7 +19,7 @@ static void test_aux(const char *main_prog_name,struct bpf_program *freplace_prog =NULL ;struct bpf_program *main_prog =NULL ;LIBBPF_OPTS (bpf_object_open_opts, opts); -struct changes_pkt_data *main =NULL ; +struct changes_pkt_data *main_data =NULL ;char log[16 *1024 ];int err;
@@ -27,14 +27,14 @@ static void test_aux(const char *main_prog_name, opts.kernel_log_size =sizeof (log);if (env.verbosity >=VERBOSE_SUPER ) opts.kernel_log_level =1 |2 |4 ; - main =changes_pkt_data__open_opts (&opts); -if (!ASSERT_OK_PTR (main,"changes_pkt_data__open" )) + main_data =changes_pkt_data__open_opts (&opts); +if (!ASSERT_OK_PTR (main_data,"changes_pkt_data__open" )) goto out; - main_prog =bpf_object__find_program_by_name (main->obj, main_prog_name); + main_prog =bpf_object__find_program_by_name (main_data->obj, main_prog_name);if (!ASSERT_OK_PTR (main_prog,"main_prog" )) goto out;bpf_program__set_autoload (main_prog, true); - err =changes_pkt_data__load (main); + err =changes_pkt_data__load (main_data);print_verifier_log (log);if (!ASSERT_OK (err,"changes_pkt_data__load" )) goto out;
@@ -60,7 +60,7 @@ static void test_aux(const char *main_prog_name, out:changes_pkt_data_freplace__destroy (freplace); -changes_pkt_data__destroy (main); +changes_pkt_data__destroy (main_data); }/* There are two global subprograms in both changes_pkt_data.skel.h:
Signature · 1 line
2.43.5
PATCH 2/2 bpf: sockopt_sk: fix 'undeclared' definition error
In reply to Jason XingError messages:selftests/bpf/prog_tests/sockopt_sk.c: In function ‘getsetsockopt’:selftests/bpf/prog_tests/sockopt_sk.c:22:31: error: field ‘zc’ has incomplete type
struct tcp_zerocopy_receive zc;
^~
selftests/bpf/prog_tests/sockopt_sk.c:169:32: error: ‘TCP_ZEROCOPY_RECEIVE’ undeclared (first use in this function)
err = getsockopt(fd, SOL_TCP, TCP_ZEROCOPY_RECEIVE, &buf, &optlen);
^~~~~~~~~~~~~~~~~~~~Fix it by introducing the right header.
--- tools/testing/selftests/bpf/prog_tests/sockopt_sk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +1 -1
@@ -2,7 +2,7 @@#include <test_progs.h> #include "cgroup_helpers.h" -#include <netinet/tcp.h> +#include <uapi/linux/tcp.h> #include <linux/netlink.h> #include "sockopt_sk.skel.h"
Signature · 1 line
2.43.5
Re: [PATCH bpf-next v1 2/2] bpf: sockopt_sk: fix 'undeclared' definition error
Hi,
Quoted 21 lines · Jason Xing
Error messages:
selftests/bpf/prog_tests/sockopt_sk.c: In function ‘getsetsockopt’:selftests/bpf/prog_tests/sockopt_sk.c:22:31: error: field ‘zc’ has incomplete typestruct tcp_zerocopy_receive zc; ^~ selftests/bpf/prog_tests/sockopt_sk.c:169:32: error: ‘TCP_ZEROCOPY_RECEIVE’ undeclared (first use in this function) err = getsockopt(fd, SOL_TCP, TCP_ZEROCOPY_RECEIVE, &buf, &optlen); ^~~~~~~~~~~~~~~~~~~~Fix it by introducing the right header.
Signed-off-by Jason Xing <[email protected]>--- tools/testing/selftests/bpf/prog_tests/sockopt_sk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +0
-0
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c line 5
Quoted 5 lines
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +1
-1@@ -2,7 +2,7 @@#include <test_progs.h> #include "cgroup_helpers.h" -#include <netinet/tcp.h> +#include <uapi/linux/tcp.h>
Should it be <linux/tcp.h> instead ? Directly including uapi header file in application seems weird.
Quoted 3 lines
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +0
-0#include <linux/netlink.h> #include "sockopt_sk.skel.h"
Re: [PATCH bpf-next v1 2/2] bpf: sockopt_sk: fix 'undeclared' definition error
Quoted 28 lines · Hou Tao
Hi,
Quoted 24 lines · Jason Xing
Error messages:
selftests/bpf/prog_tests/sockopt_sk.c: In function ‘getsetsockopt’:selftests/bpf/prog_tests/sockopt_sk.c:22:31: error: field ‘zc’ has incomplete typestruct tcp_zerocopy_receive zc; ^~ selftests/bpf/prog_tests/sockopt_sk.c:169:32: error: ‘TCP_ZEROCOPY_RECEIVE’ undeclared (first use in this function) err = getsockopt(fd, SOL_TCP, TCP_ZEROCOPY_RECEIVE, &buf, &optlen); ^~~~~~~~~~~~~~~~~~~~Fix it by introducing the right header.
Signed-off-by Jason Xing <[email protected]>--- tools/testing/selftests/bpf/prog_tests/sockopt_sk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +0
-0@@ -2,7 +2,7 @@#include <test_progs.h> #include "cgroup_helpers.h"
Quoted 4 lines
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c line 5
Quoted 2 lines
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +1
-1-#include <netinet/tcp.h> +#include <uapi/linux/tcp.h> Should it be <
linux/tcp.h> instead ?
I thought that too, but I altered my thoughts after reading this commit[1], totally without knowing why the tcp part should be changed. Should I change it back?
Quoted 2 lines
Directly including uapi header file
in application seems weird.
After greping the tools/testing/selftests/bpf, we see some similar usage like including a uapi header file.
[1]
commit a2f482c34a52176ae89d143979bbc9e7a72857c8
Author: Alexis Lothoré (eBPF Foundation) <[email protected]> Date: Wed Nov 20 08:43:21 2024 +0100
selftests/bpf: use the same udp and tcp headers in tests under test_progs
Trying to add udp-dedicated helpers in network_helpers involves including some udp header, which makes multiple test_progs tests build fail:
In file included from ./progs/test_cls_redirect.h:13,
from [...]/prog_tests/cls_redirect.c:15:
[...]/usr/include/linux/udp.h:23:8: error: redefinition of ‘struct udphdr’
23 | struct udphdr {
| ^~~~~~
In file included from ./network_helpers.h:17,
from [...]/prog_tests/cls_redirect.c:13:
[...]/usr/include/netinet/udp.h:55:8: note: originally defined here
55 | struct udphdr
| ^~~~~~
This error is due to struct udphdr being defined in both <linux/udp.h> and <netinet/udp.h>.
Use only <netinet/udp.h> in every test. While at it, perform the same for tcp.h. For some tests, the change needs to be done in the eBPF program part as well, because of some headers sharing between both sides.
Thanks,
Jason
Re: [PATCH bpf-next v1 2/2] bpf: sockopt_sk: fix 'undeclared' definition error
Hi,
Quoted 28 lines · Jason Xing
Quoted 27 lines · Hou Tao
Hi,
Quoted 24 lines · Jason Xing
Error messages:
selftests/bpf/prog_tests/sockopt_sk.c: In function ‘getsetsockopt’:selftests/bpf/prog_tests/sockopt_sk.c:22:31: error: field ‘zc’ has incomplete typestruct tcp_zerocopy_receive zc; ^~ selftests/bpf/prog_tests/sockopt_sk.c:169:32: error: ‘TCP_ZEROCOPY_RECEIVE’ undeclared (first use in this function) err = getsockopt(fd, SOL_TCP, TCP_ZEROCOPY_RECEIVE, &buf, &optlen); ^~~~~~~~~~~~~~~~~~~~Fix it by introducing the right header.
Signed-off-by Jason Xing <[email protected]>--- tools/testing/selftests/bpf/prog_tests/sockopt_sk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +0
-0@@ -2,7 +2,7 @@#include <test_progs.h> #include "cgroup_helpers.h"
Quoted 6 lines
Quoted 3 lines
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c line 5
Quoted 2 lines
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +1
-1-#include <netinet/tcp.h> +#include <uapi/linux/tcp.h> Should it be <
linux/tcp.h> instead ?I thought that too, but I altered my thoughts after reading this commit[1], totally without knowing why the tcp part should be changed. Should I change it back?
Thanks for pointing the commit to me. Under my local environment, it seems both netinet/tcp.h and linux/tcp define tcp_zerocopy_receive and tcphdr, and I think that is the reason why the commit changes tcp as well. For the following build error:
selftests/bpf/prog_tests/sockopt_sk.c:22:31: error: field ‘zc’ has incomplete type
struct tcp_zerocopy_receive zc;
I think maybe your local environment is a bit out-of-date. I prefer to keep it as-is.
Quoted 40 lines
Quoted 3 lines
Directly including uapi header file
in application seems weird.After greping the
tools/testing/selftests/bpf, we see some similar usage like including a uapi header file.[1]
commita2f482c34a52176ae89d143979bbc9e7a72857c8Author: Alexis Lothoré (eBPF Foundation) <[email protected]> Date: Wed Nov 20 08:43:21 2024 +0100selftests/bpf: use the same udp and tcp headers in tests under
test_progsTrying to add udp-dedicated helpers in
network_helpersinvolves including some udp header, which makes multipletest_progstests build fail:In file included from
./progs/test_cls_redirect.h:13,
from [...]/prog_tests/cls_redirect.c:15:
[...]/usr/include/linux/udp.h:23:8: error: redefinition of ‘struct udphdr’
23 | struct udphdr {
| ^~~~~~
In file included from ./network_helpers.h:17,
from [...]/prog_tests/cls_redirect.c:13:
[...]/usr/include/netinet/udp.h:55:8: note: originally defined here
55 | struct udphdr
| ^~~~~~This error is due to struct udphdr being defined in both <
linux/udp.h> and <netinet/udp.h>.Use only <
netinet/udp.h> in every test. While at it, perform the same fortcp.h. For some tests, the change needs to be done in the eBPF program part as well, because of some headers sharing between both sides.Thanks,
Jason.
Re: [PATCH bpf-next v1 2/2] bpf: sockopt_sk: fix 'undeclared' definition error
Quoted 44 lines · Hou Tao
Hi,
Quoted 28 lines · Jason Xing
Quoted 27 lines · Hou Tao
Hi,
Quoted 24 lines · Jason Xing
Error messages:
selftests/bpf/prog_tests/sockopt_sk.c: In function ‘getsetsockopt’:selftests/bpf/prog_tests/sockopt_sk.c:22:31: error: field ‘zc’ has incomplete typestruct tcp_zerocopy_receive zc; ^~ selftests/bpf/prog_tests/sockopt_sk.c:169:32: error: ‘TCP_ZEROCOPY_RECEIVE’ undeclared (first use in this function) err = getsockopt(fd, SOL_TCP, TCP_ZEROCOPY_RECEIVE, &buf, &optlen); ^~~~~~~~~~~~~~~~~~~~Fix it by introducing the right header.
Signed-off-by Jason Xing <[email protected]>--- tools/testing/selftests/bpf/prog_tests/sockopt_sk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +0
-0@@ -2,7 +2,7 @@#include <test_progs.h> #include "cgroup_helpers.h" Quoted 6 lines
Quoted 3 lines
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c line 5
Quoted 2 lines
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +1
-1-#include <netinet/tcp.h> +#include <uapi/linux/tcp.h> Should it be <
linux/tcp.h> instead ?I thought that too, but I altered my thoughts after reading this commit[1], totally without knowing why the tcp part should be changed. Should I change it back?
Thanks for pointing the commit to me. Under my local environment, it seems both
netinet/tcp.hand linux/tcp definetcp_zerocopy_receiveand tcphdr, and I think that is the reason why the commit changes tcp as well. For the following build error:
Quoted 6 lines
selftests/bpf/prog_tests/sockopt_sk.c:22:31: error: field ‘zc’ has incomplete type
structtcp_zerocopy_receivezc;I think maybe your local environment is a bit out-of-date. I prefer to keep it as-is.
Thanks for your review.
Right, but I believe many users can't manage to upgrade to the latest version for the whole system. The selftests are supposed to be compatible, I reckon. It's surely not bad to consider the compatibility after adjusting the header file.
Thanks,
Jason
Hi Jason,
cc bpf@vger
Quoted 31 lines · Jason Xing
Quoted 10 lines · On Thu, Feb 6, 2025 at 5:28 AM <[email protected]> wrote:
Dear patch submitter,
CI has tested the following submission:
Status: FAILURE Name: [bpf-next,v1,0/2] selftests: fix two small compilation errors Patchwork: https://patchwork.kernel.org/project/netdevbpf/list/?series=930276&state=* Matrix: https://github.com/kernel-patches/bpf/actions/runs/13165816880Failed jobs:
test_progs-aarch64-gcc: https://github.com/kernel-patches/bpf/actions/runs/13165816880/job/36746357575I'm afraid this has nothing to do with the series?
Traceback (most recent call last):
5288 File "/tmp/work/_actions/libbpf/ci/v3/run-vmtest/print_test_summary.py", line 85, in <module>
5289json_summary=json.load(f)
5290 ^^^^^^^^^^^^
5291 File "/usr/lib/python3.12/json/__init__.py", line 293, in load 5292 return loads(fp.read(),
5293 ^^^^^^^^^^^^^^^^
5294 File "/usr/lib/python3.12/json/__init__.py", line 346, in loads 5295 return_default_decoder.decode(s)
5296 ^^^^^^^^^^^^^^^^^^^^^^^^^^
5297 File "/usr/lib/python3.12/json/decoder.py", line 337, in decode 5298 obj, end =self.raw_decode(s, idx=_w(s, 0).end())
5299 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5300 File "/usr/lib/python3.12/json/decoder.py", line 355, inraw_decode5301 raiseJSONDecodeError("Expecting value", s, err.value)from None 5302json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 5303Error: Process completed with exit code 2
Quoted 1 line
Am I missing something?
If you expand the "test_progs" section right above that, you'll see:
Caught signal #11!
Stack trace:
./test_progs(crash_handler+0x34)[0xaaaad4e05bfc] linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0xffff85106850] ./test_progs(+0x45874)[0xaaaad4a25874] ./test_progs(htab_lookup_elem+0x3c)[0xaaaad4a258e4] ./test_progs(+0x45b74)[0xaaaad4a25b74] ./test_progs(+0x4646c)[0xaaaad4a2646c] ./test_progs(test_arena_htab+0x48)[0xaaaad4a264f4] ./test_progs(+0x426258)[0xaaaad4e06258] ./test_progs(main+0x694)[0xaaaad4e080a0] /lib/aarch64-linux-gnu/libc.so.6(+0x284c4)[0xffff84eb84c4]
/lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98)[0xffff84eb8598]
./test_progs(_start+0x30)[0xaaaad4a1faf0] /tmp/work/_actions/libbpf/ci/v3/run-vmtest/run-bpf-selftests.sh: line
26: 101 Segmentation fault ./${selftest} ${args} --json-summary "${json_file}"
The infra couldn't parse the stack as json (rightly so).
Thanks,
Daniel
Quoted 53 lines · Daniel Xu
Hi Jason,
cc bpf@vger
Quoted 31 lines · Jason Xing
Quoted 10 lines · On Thu, Feb 6, 2025 at 5:28 AM <[email protected]> wrote:
Dear patch submitter,
CI has tested the following submission:
Status: FAILURE Name: [bpf-next,v1,0/2] selftests: fix two small compilation errors Patchwork: https://patchwork.kernel.org/project/netdevbpf/list/?series=930276&state=* Matrix: https://github.com/kernel-patches/bpf/actions/runs/13165816880Failed jobs:
test_progs-aarch64-gcc: https://github.com/kernel-patches/bpf/actions/runs/13165816880/job/36746357575I'm afraid this has nothing to do with the series?
Traceback (most recent call last):
5288 File "/tmp/work/_actions/libbpf/ci/v3/run-vmtest/print_test_summary.py", line 85, in <module>
5289json_summary=json.load(f)
5290 ^^^^^^^^^^^^
5291 File "/usr/lib/python3.12/json/__init__.py", line 293, in load 5292 return loads(fp.read(),
5293 ^^^^^^^^^^^^^^^^
5294 File "/usr/lib/python3.12/json/__init__.py", line 346, in loads 5295 return_default_decoder.decode(s)
5296 ^^^^^^^^^^^^^^^^^^^^^^^^^^
5297 File "/usr/lib/python3.12/json/decoder.py", line 337, in decode 5298 obj, end =self.raw_decode(s, idx=_w(s, 0).end())
5299 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5300 File "/usr/lib/python3.12/json/decoder.py", line 355, inraw_decode5301 raiseJSONDecodeError("Expecting value", s, err.value)from None 5302json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 5303Error: Process completed with exit code 2Quoted 1 line
Am I missing something?
If you expand the "
test_progs" section right above that, you'll see:Caught signal #11! Stack trace: ./test_progs(crash_handler+0x34)[0xaaaad4e05bfc] linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0xffff85106850] ./test_progs(+0x45874)[0xaaaad4a25874] ./test_progs(htab_lookup_elem+0x3c)[0xaaaad4a258e4] ./test_progs(+0x45b74)[0xaaaad4a25b74] ./test_progs(+0x4646c)[0xaaaad4a2646c] ./test_progs(test_arena_htab+0x48)[0xaaaad4a264f4] ./test_progs(+0x426258)[0xaaaad4e06258] ./test_progs(main+0x694)[0xaaaad4e080a0] /lib/aarch64-linux-gnu/libc.so.6(+0x284c4)[0xffff84eb84c4]
Quoted 7 lines
/lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98)[0xffff84eb8598]
./test_progs(_start+0x30)[0xaaaad4a1faf0]/tmp/work/_actions/libbpf/ci/v3/run-vmtest/run-bpf-selftests.sh: line
26: 101 Segmentation fault ./${selftest} ${args} --json-summary
"${json_file}"The infra couldn't parse the stack as json (rightly so).
Thanks for the reply. I'm surprised that this error is related to this series, really? Could you point out why these two patches cause the segfault please?
Thanks,
Jason
Martin KaFai Lau
reviewerRe: [PATCH bpf-next v1 1/2] bpf: changes_pkt_data: correct the 'main' error
In reply to Jason XingQuoted 4 lines · Jason Xing
When compiling the selftests, the following error is printed out:
selftests/bpf/prog_tests/changes_pkt_data.c: In function ‘test_aux’:selftests/bpf/prog_tests/changes_pkt_data.c:22:27: error: ‘main’ is usually a function [-Werror=main]
structchanges_pkt_data*main = NULL;
The bpf CI has been testing this piece with different compilers. I also don't see it in my environment. How to reproduce it and which compiler?
Quoted 48 lines
Fix it by replacing with '
main_data'.Signed-off-by Jason Xing <[email protected]>--- .../selftests/bpf/prog_tests/changes_pkt_data.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)tools/testing/selftests/bpf/prog_tests/changes_pkt_data.c +6
-6@@ -19,7 +19,7 @@ static void test_aux(const char *main_prog_name,struct bpf_program *freplace_prog =NULL ;struct bpf_program *main_prog =NULL ;LIBBPF_OPTS (bpf_object_open_opts, opts); -struct changes_pkt_data *main =NULL ; +struct changes_pkt_data *main_data =NULL ;char log[16 *1024 ];int err;@@ -27,14 +27,14 @@ static void test_aux(const char *main_prog_name, opts.kernel_log_size =sizeof (log);if (env.verbosity >=VERBOSE_SUPER ) opts.kernel_log_level =1 |2 |4 ; - main =changes_pkt_data__open_opts (&opts); -if (!ASSERT_OK_PTR (main,"changes_pkt_data__open" )) + main_data =changes_pkt_data__open_opts (&opts); +if (!ASSERT_OK_PTR (main_data,"changes_pkt_data__open" )) goto out; - main_prog =bpf_object__find_program_by_name (main->obj, main_prog_name); + main_prog =bpf_object__find_program_by_name (main_data->obj, main_prog_name);if (!ASSERT_OK_PTR (main_prog,"main_prog" )) goto out;bpf_program__set_autoload (main_prog, true); - err =changes_pkt_data__load (main); + err =changes_pkt_data__load (main_data);print_verifier_log (log);if (!ASSERT_OK (err,"changes_pkt_data__load" )) goto out;@@ -60,7 +60,7 @@ static void test_aux(const char *main_prog_name, out:changes_pkt_data_freplace__destroy (freplace); -changes_pkt_data__destroy (main); +changes_pkt_data__destroy (main_data); }/* There are two global subprograms in both changes_pkt_data.skel.h:
Re: [PATCH bpf-next v1 1/2] bpf: changes_pkt_data: correct the 'main' error
Quoted 9 lines · Martin KaFai Lau
Quoted 4 lines · Jason Xing
When compiling the selftests, the following error is printed out:
selftests/bpf/prog_tests/changes_pkt_data.c: In function ‘test_aux’:selftests/bpf/prog_tests/changes_pkt_data.c:22:27: error: ‘main’ is usually a function [-Werror=main]
structchanges_pkt_data*main = NULL;The bpf CI has been testing this piece with different compilers. I also don't see it in my environment. How to reproduce it and which compiler?
The gcc version is "gcc version 8.5.0" which is an old one. Yep, there are some cases sometimes where bpf CI doesn't report because the compilation relies on the system environment? Sorry that I have no clue about this happening. One thing I know is that if using some old distros and cloud services, it's not hard to see this.
In this series, rename it to avoid error messages which could stop the local compilation.
Thanks,
Jason
Hi Maintainers from bpf,
Quoted 2 lines · Jason Xing
Fix them separately in each patch.
I'd like to know if it's possible to merge the series because it does harm to some old distro with only updating the kernel?
Thanks,
Jason
Quoted 12 lines
Jason Xing (2):
bpf:changes_pkt_data: correct the 'main' error
bpf:sockopt_sk: fix 'undeclared' definition error.../selftests/bpf/prog_tests/changes_pkt_data.c | 12 ++++++------ tools/testing/selftests/bpf/prog_tests/sockopt_sk.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)--
2.43.5
Martin KaFai Lau
reviewerRe: [PATCH bpf-next v1 2/2] bpf: sockopt_sk: fix 'undeclared' definition error
In reply to Jason XingQuoted 29 lines · Jason Xing
Quoted 28 lines · Hou Tao
Hi,
Quoted 24 lines · Jason Xing
Error messages:
selftests/bpf/prog_tests/sockopt_sk.c: In function ‘getsetsockopt’:selftests/bpf/prog_tests/sockopt_sk.c:22:31: error: field ‘zc’ has incomplete typestruct tcp_zerocopy_receive zc; ^~ selftests/bpf/prog_tests/sockopt_sk.c:169:32: error: ‘TCP_ZEROCOPY_RECEIVE’ undeclared (first use in this function) err = getsockopt(fd, SOL_TCP, TCP_ZEROCOPY_RECEIVE, &buf, &optlen); ^~~~~~~~~~~~~~~~~~~~Fix it by introducing the right header.
Signed-off-by Jason Xing <[email protected]>--- tools/testing/selftests/bpf/prog_tests/sockopt_sk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +0
-0@@ -2,7 +2,7 @@#include <test_progs.h> #include "cgroup_helpers.h"
Quoted 8 lines
Quoted 4 lines
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c line 5
Quoted 2 lines
tools/testing/selftests/bpf/prog_tests/sockopt_sk.c +1
-1-#include <netinet/tcp.h> +#include <uapi/linux/tcp.h> Should it be <
linux/tcp.h> instead ?I thought that too, but I altered my thoughts after reading this commit[1], totally without knowing why the tcp part should be changed. Should I change it back?
afaik, uapi/ or not does not make a difference.
Quoted 18 lines
Quoted 3 lines
Directly including uapi header file
in application seems weird.After greping the
tools/testing/selftests/bpf, we see some similar usage like including a uapi header file.[1]
commita2f482c34a52176ae89d143979bbc9e7a72857c8Author: Alexis Lothoré (eBPF Foundation) <[email protected]> Date: Wed Nov 20 08:43:21 2024 +0100selftests/bpf: use the same udp and tcp headers in tests under
test_progsTrying to add udp-dedicated helpers in
network_helpersinvolves including some udp header, which makes multipletest_progstests build fail:
Quoted 10 lines
In file included from
./progs/test_cls_redirect.h:13,
from [...]/prog_tests/cls_redirect.c:15:
[...]/usr/include/linux/udp.h:23:8: error: redefinition of ‘struct udphdr’
23 | struct udphdr {
| ^~~~~~
In file included from ./network_helpers.h:17,
from [...]/prog_tests/cls_redirect.c:13:
[...]/usr/include/netinet/udp.h:55:8: note: originally defined here
55 | struct udphdr
| ^~~~~~
e.g. this will happen to the tcphdr also when sockopt_sk.c starts including network_helpers.h.
Quoted 6 lines
This error is due to struct udphdr being defined in both <
linux/udp.h> and <netinet/udp.h>.Use only <
netinet/udp.h> in every test. While at it, perform the same fortcp.h. For some tests, the change needs to be done in the eBPF
This patch just undo exactly what this commit a2f482c34a52 tries to solve for tcp.h also, no?
pw-bot: cr
Quoted 5 lines
program part as well, because of some headers sharing between both sides.
Thanks,
Jason
Martin KaFai Lau
reviewerRe: [PATCH bpf-next v1 1/2] bpf: changes_pkt_data: correct the 'main' error
In reply to Jason XingQuoted 8 lines · Jason Xing
Quoted 7 lines · Martin KaFai Lau
Quoted 4 lines · Jason Xing
When compiling the selftests, the following error is printed out:
selftests/bpf/prog_tests/changes_pkt_data.c: In function ‘test_aux’:selftests/bpf/prog_tests/changes_pkt_data.c:22:27: error: ‘main’ is usually a function [-Werror=main]struct changes_pkt_data *main = NULL;
Quoted 4 lines
Quoted 2 lines
The bpf CI has been testing this piece with different compilers. I also don't see it in my environment. How to reproduce it and which compiler?
The gcc version is "gcc version 8.5.0" which is an old one. Yep, there
gcc 8.5 is old. I don't even know if it supports compiling the bpf prog in the bpf selftests. Please update the compiler.