Skip to content

Commit 271b3e8

Browse files
committed
tests: runtime: Use nf_tables_newtable for module tests
nft_trans_alloc_gfp() is a static function that's called from multiple locations. This means it can be partially inlined - inlined in some places but not others. This makes the tests unreliable between different kernel and compiler verisons. Switch to nf_tables_newtable() which is used as a callback. The compiler is forced to not inline this.
1 parent ff64bae commit 271b3e8

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tests/runtime/btf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ REQUIRES_FEATURE btf
3030
WILL_FAIL
3131

3232
NAME kernel_module_attach
33-
RUN {{BPFTRACE}} -e 'fentry:nft_trans_alloc_gfp { printf("hit\n"); exit(); }'
33+
RUN {{BPFTRACE}} -e 'fentry:nf_tables_newtable { printf("hit\n"); exit(); }'
3434
AFTER nft add table bpftrace
3535
EXPECT hit
3636
REQUIRES_FEATURE fentry
@@ -39,7 +39,7 @@ REQUIRES nft --help
3939
CLEANUP nft delete table bpftrace
4040

4141
NAME kernel_module_attach_wildcard
42-
RUN {{BPFTRACE}} -e 'fentry:nf_table*:nft_trans_alloc_gfp { printf("hit\n"); exit(); }'
42+
RUN {{BPFTRACE}} -e 'fentry:nf_table*:nf_tables_newtable { printf("hit\n"); exit(); }'
4343
AFTER nft add table bpftrace
4444
EXPECT hit
4545
REQUIRES_FEATURE fentry
@@ -48,7 +48,7 @@ REQUIRES nft --help
4848
CLEANUP nft delete table bpftrace
4949

5050
NAME kernel_module_args
51-
RUN {{BPFTRACE}} -e 'fentry:nft_trans_alloc_gfp { printf("size: %d\n", args.size); exit(); }'
51+
RUN {{BPFTRACE}} -e 'fentry:nf_tables_newtable { printf("size: %d\n", args.size); exit(); }'
5252
AFTER nft add table bpftrace
5353
EXPECT_REGEX size: [0-9]+
5454
REQUIRES_FEATURE fentry
@@ -57,7 +57,7 @@ REQUIRES nft --help
5757
CLEANUP nft delete table bpftrace
5858

5959
NAME kernel_module_types
60-
RUN {{BPFTRACE}} -e 'fentry:nft_trans_alloc_gfp { printf("portid: %d\n", args.ctx->portid); exit(); }'
60+
RUN {{BPFTRACE}} -e 'fentry:nf_tables_newtable { printf("portid: %d\n", args.ctx->portid); exit(); }'
6161
AFTER nft add table bpftrace
6262
EXPECT_REGEX portid: [0-9]+
6363
REQUIRES_FEATURE fentry

tests/runtime/probe

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,17 @@ EXPECT_REGEX progs: [1-9][0-9]+
179179
REQUIRES bpftool
180180

181181
NAME kprobe_offset_module
182-
RUN {{BPFTRACE}} -e 'kprobe:nft_trans_alloc_gfp+0x5 { printf("hit\n"); exit(); }'
182+
RUN {{BPFTRACE}} -e 'kprobe:nf_tables_newtable+0x5 { printf("hit\n"); exit(); }'
183183
AFTER nft add table bpftrace
184184
EXPECT hit
185185
ARCH x86_64
186186
REQUIRES lsmod | grep '^nf_tables'
187187
REQUIRES nft --help
188188
CLEANUP nft delete table bpftrace
189189

190-
# Local entry point to nft_trans_alloc_gfp is located at offset of 8 bytes in ppc64 and aarch64.
190+
# Local entry point to nf_tables_newtable is located at offset of 8 bytes in ppc64 and aarch64.
191191
NAME kprobe_offset_module
192-
RUN {{BPFTRACE}} -e 'kprobe:nft_trans_alloc_gfp+0x8 { printf("hit\n"); exit(); }'
192+
RUN {{BPFTRACE}} -e 'kprobe:nf_tables_newtable+0x8 { printf("hit\n"); exit(); }'
193193
AFTER nft add table bpftrace
194194
EXPECT hit
195195
ARCH ppc64|ppc64le|aarch64

0 commit comments

Comments
 (0)