-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bpf: selftests: add CPUMAP/DEVMAP selftests for xdp frags
Verify compatibility checks attaching a XDP frags program to a CPUMAP/DEVMAP Acked-by: Toke Hoiland-Jorgensen <toke@redhat.com> Acked-by: John Fastabend <john.fastabend@gmail.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://lore.kernel.org/r/d94b4d35adc1e42c9ca5004e6b2cdfd75992304d.1642758637.git.lorenzo@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
- Loading branch information
Lorenzo Bianconi
authored and
Alexei Starovoitov
committed
Jan 21, 2022
1 parent
6db28e2
commit 0c5e118
Showing
6 changed files
with
185 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tools/testing/selftests/bpf/progs/test_xdp_with_cpumap_frags_helpers.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include <linux/bpf.h> | ||
#include <bpf/bpf_helpers.h> | ||
|
||
#define IFINDEX_LO 1 | ||
|
||
struct { | ||
__uint(type, BPF_MAP_TYPE_CPUMAP); | ||
__uint(key_size, sizeof(__u32)); | ||
__uint(value_size, sizeof(struct bpf_cpumap_val)); | ||
__uint(max_entries, 4); | ||
} cpu_map SEC(".maps"); | ||
|
||
SEC("xdp_cpumap/dummy_cm") | ||
int xdp_dummy_cm(struct xdp_md *ctx) | ||
{ | ||
return XDP_PASS; | ||
} | ||
|
||
SEC("xdp.frags/cpumap") | ||
int xdp_dummy_cm_frags(struct xdp_md *ctx) | ||
{ | ||
return XDP_PASS; | ||
} | ||
|
||
char _license[] SEC("license") = "GPL"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tools/testing/selftests/bpf/progs/test_xdp_with_devmap_frags_helpers.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
#include <linux/bpf.h> | ||
#include <bpf/bpf_helpers.h> | ||
|
||
struct { | ||
__uint(type, BPF_MAP_TYPE_DEVMAP); | ||
__uint(key_size, sizeof(__u32)); | ||
__uint(value_size, sizeof(struct bpf_devmap_val)); | ||
__uint(max_entries, 4); | ||
} dm_ports SEC(".maps"); | ||
|
||
/* valid program on DEVMAP entry via SEC name; | ||
* has access to egress and ingress ifindex | ||
*/ | ||
SEC("xdp_devmap/map_prog") | ||
int xdp_dummy_dm(struct xdp_md *ctx) | ||
{ | ||
return XDP_PASS; | ||
} | ||
|
||
SEC("xdp.frags/devmap") | ||
int xdp_dummy_dm_frags(struct xdp_md *ctx) | ||
{ | ||
return XDP_PASS; | ||
} | ||
|
||
char _license[] SEC("license") = "GPL"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters