Commit 93d1c2da authored by Andrii Nakryiko's avatar Andrii Nakryiko
Browse files

Merge branch 'fix-number-of-arguments-in-test'

Cupertino Miranda says:

====================
Fix number of arguments in test

Hi everyone,

This is a new version based on comments.

Regards,
Cupertino

Changes from v1:
 - Comment with gcc-bpf replaced by bpf_gcc.
 - Used pragma GCC optimize to disable GCC optimization in test.

Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Yonghong Song <yonghong.song@linux.dev>
Cc: David Faust <david.faust@oracle.com>
Cc: Jose Marchesi <jose.marchesi@oracle.com>
Cc: Elena Zannoni <elena.zannoni@oracle.com>
====================

Link: https://lore.kernel.org/r/20240507122220.207820-1-cupertino.miranda@oracle.com


Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
parents 675b4e24 b2e086cb
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -81,11 +81,11 @@ TEST_INST_SUBDIRS += bpf_gcc
# The following tests contain C code that, although technically legal,
# triggers GCC warnings that cannot be disabled: declaration of
# anonymous struct types in function parameter lists.
progs/btf_dump_test_case_bitfields.c-CFLAGS := -Wno-error
progs/btf_dump_test_case_namespacing.c-CFLAGS := -Wno-error
progs/btf_dump_test_case_packing.c-CFLAGS := -Wno-error
progs/btf_dump_test_case_padding.c-CFLAGS := -Wno-error
progs/btf_dump_test_case_syntax.c-CFLAGS := -Wno-error
progs/btf_dump_test_case_bitfields.c-bpf_gcc-CFLAGS := -Wno-error
progs/btf_dump_test_case_namespacing.c-bpf_gcc-CFLAGS := -Wno-error
progs/btf_dump_test_case_packing.c-bpf_gcc-CFLAGS := -Wno-error
progs/btf_dump_test_case_padding.c-bpf_gcc-CFLAGS := -Wno-error
progs/btf_dump_test_case_syntax.c-bpf_gcc-CFLAGS := -Wno-error
endif

ifneq ($(CLANG_CPUV4),)
@@ -470,7 +470,7 @@ LINKED_BPF_SRCS := $(patsubst %.bpf.o,%.c,$(foreach skel,$(LINKED_SKELS),$($(ske
# $eval()) and pass control to DEFINE_TEST_RUNNER_RULES.
# Parameters:
# $1 - test runner base binary name (e.g., test_progs)
# $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, gcc-bpf, etc)
# $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, bpf_gcc, etc)
define DEFINE_TEST_RUNNER

TRUNNER_OUTPUT := $(OUTPUT)$(if $2,/)$2
@@ -498,7 +498,7 @@ endef
# Using TRUNNER_XXX variables, provided by callers of DEFINE_TEST_RUNNER and
# set up by DEFINE_TEST_RUNNER itself, create test runner build rules with:
# $1 - test runner base binary name (e.g., test_progs)
# $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, gcc-bpf, etc)
# $2 - test runner extra "flavor" (e.g., no_alu32, cpuv4, bpf_gcc, etc)
define DEFINE_TEST_RUNNER_RULES

ifeq ($($(TRUNNER_OUTPUT)-dir),)
@@ -521,7 +521,8 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o: \
		     | $(TRUNNER_OUTPUT) $$(BPFOBJ)
	$$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@,			\
					  $(TRUNNER_BPF_CFLAGS)         \
					  $$($$<-CFLAGS))
					  $$($$<-CFLAGS)		\
					  $$($$<-$2-CFLAGS))

$(TRUNNER_BPF_SKELS): %.skel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
	$$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
+21 −6
Original line number Diff line number Diff line
@@ -318,6 +318,14 @@ bool encap_v6(struct xdp_md *xdp, struct ctl_value *cval,
	return true;
}

#ifndef __clang__
#pragma GCC push_options
/* GCC optimization collapses functions and increases the number of arguments
 * beyond the compatible amount supported by BPF.
 */
#pragma GCC optimize("-fno-ipa-sra")
#endif

static __attribute__ ((noinline))
bool encap_v4(struct xdp_md *xdp, struct ctl_value *cval,
	      struct packet_description *pckt,
@@ -372,6 +380,10 @@ bool encap_v4(struct xdp_md *xdp, struct ctl_value *cval,
	return true;
}

#ifndef __clang__
#pragma GCC pop_options
#endif

static __attribute__ ((noinline))
int swap_mac_and_send(void *data, void *data_end)
{
@@ -588,12 +600,13 @@ static void connection_table_lookup(struct real_definition **real,
__attribute__ ((noinline))
static int process_l3_headers_v6(struct packet_description *pckt,
				 __u8 *protocol, __u64 off,
				 __u16 *pkt_bytes, void *data,
				 void *data_end)
				 __u16 *pkt_bytes, void *extra_args[2])
{
	struct ipv6hdr *ip6h;
	__u64 iph_len;
	int action;
	void *data = extra_args[0];
	void *data_end = extra_args[1];

	ip6h = data + off;
	if (ip6h + 1 > data_end)
@@ -619,11 +632,12 @@ static int process_l3_headers_v6(struct packet_description *pckt,
__attribute__ ((noinline))
static int process_l3_headers_v4(struct packet_description *pckt,
				 __u8 *protocol, __u64 off,
				 __u16 *pkt_bytes, void *data,
				 void *data_end)
				 __u16 *pkt_bytes, void *extra_args[2])
{
	struct iphdr *iph;
	int action;
	void *data = extra_args[0];
	void *data_end = extra_args[1];

	iph = data + off;
	if (iph + 1 > data_end)
@@ -666,13 +680,14 @@ static int process_packet(void *data, __u64 off, void *data_end,
	__u8 protocol;
	__u32 vip_num;
	int action;
	void *extra_args[2] = { data, data_end };

	if (is_ipv6)
		action = process_l3_headers_v6(&pckt, &protocol, off,
					       &pkt_bytes, data, data_end);
					       &pkt_bytes, extra_args);
	else
		action = process_l3_headers_v4(&pckt, &protocol, off,
					       &pkt_bytes, data, data_end);
					       &pkt_bytes, extra_args);
	if (action >= 0)
		return action;
	protocol = pckt.flow.proto;