Skip to content

Commit 93d1c2d

Browse files
committed
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 <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: Eduard Zingerman <[email protected]> Cc: Yonghong Song <[email protected]> Cc: David Faust <[email protected]> Cc: Jose Marchesi <[email protected]> Cc: Elena Zannoni <[email protected]> ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andrii Nakryiko <[email protected]>
2 parents 675b4e2 + b2e086c commit 93d1c2d

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

tools/testing/selftests/bpf/Makefile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ TEST_INST_SUBDIRS += bpf_gcc
8181
# The following tests contain C code that, although technically legal,
8282
# triggers GCC warnings that cannot be disabled: declaration of
8383
# anonymous struct types in function parameter lists.
84-
progs/btf_dump_test_case_bitfields.c-CFLAGS := -Wno-error
85-
progs/btf_dump_test_case_namespacing.c-CFLAGS := -Wno-error
86-
progs/btf_dump_test_case_packing.c-CFLAGS := -Wno-error
87-
progs/btf_dump_test_case_padding.c-CFLAGS := -Wno-error
88-
progs/btf_dump_test_case_syntax.c-CFLAGS := -Wno-error
84+
progs/btf_dump_test_case_bitfields.c-bpf_gcc-CFLAGS := -Wno-error
85+
progs/btf_dump_test_case_namespacing.c-bpf_gcc-CFLAGS := -Wno-error
86+
progs/btf_dump_test_case_packing.c-bpf_gcc-CFLAGS := -Wno-error
87+
progs/btf_dump_test_case_padding.c-bpf_gcc-CFLAGS := -Wno-error
88+
progs/btf_dump_test_case_syntax.c-bpf_gcc-CFLAGS := -Wno-error
8989
endif
9090

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

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

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

526527
$(TRUNNER_BPF_SKELS): %.skel.h: %.bpf.o $(BPFTOOL) | $(TRUNNER_OUTPUT)
527528
$$(call msg,GEN-SKEL,$(TRUNNER_BINARY),$$@)

tools/testing/selftests/bpf/progs/test_xdp_noinline.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,14 @@ bool encap_v6(struct xdp_md *xdp, struct ctl_value *cval,
318318
return true;
319319
}
320320

321+
#ifndef __clang__
322+
#pragma GCC push_options
323+
/* GCC optimization collapses functions and increases the number of arguments
324+
* beyond the compatible amount supported by BPF.
325+
*/
326+
#pragma GCC optimize("-fno-ipa-sra")
327+
#endif
328+
321329
static __attribute__ ((noinline))
322330
bool encap_v4(struct xdp_md *xdp, struct ctl_value *cval,
323331
struct packet_description *pckt,
@@ -372,6 +380,10 @@ bool encap_v4(struct xdp_md *xdp, struct ctl_value *cval,
372380
return true;
373381
}
374382

383+
#ifndef __clang__
384+
#pragma GCC pop_options
385+
#endif
386+
375387
static __attribute__ ((noinline))
376388
int swap_mac_and_send(void *data, void *data_end)
377389
{
@@ -588,12 +600,13 @@ static void connection_table_lookup(struct real_definition **real,
588600
__attribute__ ((noinline))
589601
static int process_l3_headers_v6(struct packet_description *pckt,
590602
__u8 *protocol, __u64 off,
591-
__u16 *pkt_bytes, void *data,
592-
void *data_end)
603+
__u16 *pkt_bytes, void *extra_args[2])
593604
{
594605
struct ipv6hdr *ip6h;
595606
__u64 iph_len;
596607
int action;
608+
void *data = extra_args[0];
609+
void *data_end = extra_args[1];
597610

598611
ip6h = data + off;
599612
if (ip6h + 1 > data_end)
@@ -619,11 +632,12 @@ static int process_l3_headers_v6(struct packet_description *pckt,
619632
__attribute__ ((noinline))
620633
static int process_l3_headers_v4(struct packet_description *pckt,
621634
__u8 *protocol, __u64 off,
622-
__u16 *pkt_bytes, void *data,
623-
void *data_end)
635+
__u16 *pkt_bytes, void *extra_args[2])
624636
{
625637
struct iphdr *iph;
626638
int action;
639+
void *data = extra_args[0];
640+
void *data_end = extra_args[1];
627641

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

670685
if (is_ipv6)
671686
action = process_l3_headers_v6(&pckt, &protocol, off,
672-
&pkt_bytes, data, data_end);
687+
&pkt_bytes, extra_args);
673688
else
674689
action = process_l3_headers_v4(&pckt, &protocol, off,
675-
&pkt_bytes, data, data_end);
690+
&pkt_bytes, extra_args);
676691
if (action >= 0)
677692
return action;
678693
protocol = pckt.flow.proto;

0 commit comments

Comments
 (0)