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

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.comSigned-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
parents 675b4e24 b2e086cb
...@@ -81,11 +81,11 @@ TEST_INST_SUBDIRS += bpf_gcc ...@@ -81,11 +81,11 @@ TEST_INST_SUBDIRS += bpf_gcc
# The following tests contain C code that, although technically legal, # The following tests contain C code that, although technically legal,
# triggers GCC warnings that cannot be disabled: declaration of # triggers GCC warnings that cannot be disabled: declaration of
# anonymous struct types in function parameter lists. # anonymous struct types in function parameter lists.
progs/btf_dump_test_case_bitfields.c-CFLAGS := -Wno-error progs/btf_dump_test_case_bitfields.c-bpf_gcc-CFLAGS := -Wno-error
progs/btf_dump_test_case_namespacing.c-CFLAGS := -Wno-error progs/btf_dump_test_case_namespacing.c-bpf_gcc-CFLAGS := -Wno-error
progs/btf_dump_test_case_packing.c-CFLAGS := -Wno-error progs/btf_dump_test_case_packing.c-bpf_gcc-CFLAGS := -Wno-error
progs/btf_dump_test_case_padding.c-CFLAGS := -Wno-error progs/btf_dump_test_case_padding.c-bpf_gcc-CFLAGS := -Wno-error
progs/btf_dump_test_case_syntax.c-CFLAGS := -Wno-error progs/btf_dump_test_case_syntax.c-bpf_gcc-CFLAGS := -Wno-error
endif endif
ifneq ($(CLANG_CPUV4),) ifneq ($(CLANG_CPUV4),)
...@@ -470,7 +470,7 @@ LINKED_BPF_SRCS := $(patsubst %.bpf.o,%.c,$(foreach skel,$(LINKED_SKELS),$($(ske ...@@ -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. # $eval()) and pass control to DEFINE_TEST_RUNNER_RULES.
# Parameters: # Parameters:
# $1 - test runner base binary name (e.g., test_progs) # $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 define DEFINE_TEST_RUNNER
TRUNNER_OUTPUT := $(OUTPUT)$(if $2,/)$2 TRUNNER_OUTPUT := $(OUTPUT)$(if $2,/)$2
...@@ -498,7 +498,7 @@ endef ...@@ -498,7 +498,7 @@ endef
# Using TRUNNER_XXX variables, provided by callers of DEFINE_TEST_RUNNER and # 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: # set up by DEFINE_TEST_RUNNER itself, create test runner build rules with:
# $1 - test runner base binary name (e.g., test_progs) # $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 define DEFINE_TEST_RUNNER_RULES
ifeq ($($(TRUNNER_OUTPUT)-dir),) ifeq ($($(TRUNNER_OUTPUT)-dir),)
...@@ -521,7 +521,8 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o: \ ...@@ -521,7 +521,8 @@ $(TRUNNER_BPF_OBJS): $(TRUNNER_OUTPUT)/%.bpf.o: \
| $(TRUNNER_OUTPUT) $$(BPFOBJ) | $(TRUNNER_OUTPUT) $$(BPFOBJ)
$$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \ $$(call $(TRUNNER_BPF_BUILD_RULE),$$<,$$@, \
$(TRUNNER_BPF_CFLAGS) \ $(TRUNNER_BPF_CFLAGS) \
$$($$<-CFLAGS)) $$($$<-CFLAGS) \
$$($$<-$2-CFLAGS))
$(TRUNNER_BPF_SKELS): %.skel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT) $(TRUNNER_BPF_SKELS): %.skel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
$$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@) $$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)
......
...@@ -318,6 +318,14 @@ bool encap_v6(struct xdp_md *xdp, struct ctl_value *cval, ...@@ -318,6 +318,14 @@ bool encap_v6(struct xdp_md *xdp, struct ctl_value *cval,
return true; 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)) static __attribute__ ((noinline))
bool encap_v4(struct xdp_md *xdp, struct ctl_value *cval, bool encap_v4(struct xdp_md *xdp, struct ctl_value *cval,
struct packet_description *pckt, struct packet_description *pckt,
...@@ -372,6 +380,10 @@ bool encap_v4(struct xdp_md *xdp, struct ctl_value *cval, ...@@ -372,6 +380,10 @@ bool encap_v4(struct xdp_md *xdp, struct ctl_value *cval,
return true; return true;
} }
#ifndef __clang__
#pragma GCC pop_options
#endif
static __attribute__ ((noinline)) static __attribute__ ((noinline))
int swap_mac_and_send(void *data, void *data_end) int swap_mac_and_send(void *data, void *data_end)
{ {
...@@ -588,12 +600,13 @@ static void connection_table_lookup(struct real_definition **real, ...@@ -588,12 +600,13 @@ static void connection_table_lookup(struct real_definition **real,
__attribute__ ((noinline)) __attribute__ ((noinline))
static int process_l3_headers_v6(struct packet_description *pckt, static int process_l3_headers_v6(struct packet_description *pckt,
__u8 *protocol, __u64 off, __u8 *protocol, __u64 off,
__u16 *pkt_bytes, void *data, __u16 *pkt_bytes, void *extra_args[2])
void *data_end)
{ {
struct ipv6hdr *ip6h; struct ipv6hdr *ip6h;
__u64 iph_len; __u64 iph_len;
int action; int action;
void *data = extra_args[0];
void *data_end = extra_args[1];
ip6h = data + off; ip6h = data + off;
if (ip6h + 1 > data_end) if (ip6h + 1 > data_end)
...@@ -619,11 +632,12 @@ static int process_l3_headers_v6(struct packet_description *pckt, ...@@ -619,11 +632,12 @@ static int process_l3_headers_v6(struct packet_description *pckt,
__attribute__ ((noinline)) __attribute__ ((noinline))
static int process_l3_headers_v4(struct packet_description *pckt, static int process_l3_headers_v4(struct packet_description *pckt,
__u8 *protocol, __u64 off, __u8 *protocol, __u64 off,
__u16 *pkt_bytes, void *data, __u16 *pkt_bytes, void *extra_args[2])
void *data_end)
{ {
struct iphdr *iph; struct iphdr *iph;
int action; int action;
void *data = extra_args[0];
void *data_end = extra_args[1];
iph = data + off; iph = data + off;
if (iph + 1 > data_end) if (iph + 1 > data_end)
...@@ -666,13 +680,14 @@ static int process_packet(void *data, __u64 off, void *data_end, ...@@ -666,13 +680,14 @@ static int process_packet(void *data, __u64 off, void *data_end,
__u8 protocol; __u8 protocol;
__u32 vip_num; __u32 vip_num;
int action; int action;
void *extra_args[2] = { data, data_end };
if (is_ipv6) if (is_ipv6)
action = process_l3_headers_v6(&pckt, &protocol, off, action = process_l3_headers_v6(&pckt, &protocol, off,
&pkt_bytes, data, data_end); &pkt_bytes, extra_args);
else else
action = process_l3_headers_v4(&pckt, &protocol, off, action = process_l3_headers_v4(&pckt, &protocol, off,
&pkt_bytes, data, data_end); &pkt_bytes, extra_args);
if (action >= 0) if (action >= 0)
return action; return action;
protocol = pckt.flow.proto; protocol = pckt.flow.proto;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment