-
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.
selftests: bpf: test BPF_PROG_QUERY for progs attached to sockmap
Add test for querying progs attached to sockmap. we use an existing libbpf query interface to query prog cnt before and after progs attaching to sockmap and check whether the queried prog id is right. Signed-off-by: Di Zhu <zhudi2@huawei.com> Acked-by: Yonghong Song <yhs@fb.com> Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com> Link: https://lore.kernel.org/r/20220119014005.1209-2-zhudi2@huawei.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
- Loading branch information
Di Zhu
authored and
Alexei Starovoitov
committed
Jan 21, 2022
1 parent
748cd57
commit 820e6e2
Showing
2 changed files
with
90 additions
and
0 deletions.
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
24 changes: 24 additions & 0 deletions
24
tools/testing/selftests/bpf/progs/test_sockmap_progs_query.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,24 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
#include "vmlinux.h" | ||
#include <bpf/bpf_helpers.h> | ||
|
||
struct { | ||
__uint(type, BPF_MAP_TYPE_SOCKMAP); | ||
__uint(max_entries, 1); | ||
__type(key, __u32); | ||
__type(value, __u64); | ||
} sock_map SEC(".maps"); | ||
|
||
SEC("sk_skb") | ||
int prog_skb_verdict(struct __sk_buff *skb) | ||
{ | ||
return SK_PASS; | ||
} | ||
|
||
SEC("sk_msg") | ||
int prog_skmsg_verdict(struct sk_msg_md *msg) | ||
{ | ||
return SK_PASS; | ||
} | ||
|
||
char _license[] SEC("license") = "GPL"; |