forked from kernel-patches/bpf
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests/bpf: add skmsg verdict tests
Add two normal skmsg verdict tests in sockmap_basic.c Signed-off-by: Liu Jian <liujian56@huawei.com>
- Loading branch information
Showing
2 changed files
with
96 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
25 changes: 25 additions & 0 deletions
25
tools/testing/selftests/bpf/progs/test_sockmap_msg_verdict.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,25 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
#include "vmlinux.h" | ||
#include <bpf/bpf_helpers.h> | ||
|
||
struct { | ||
__uint(type, BPF_MAP_TYPE_SOCKMAP); | ||
__uint(max_entries, 4); | ||
__type(key, int); | ||
__type(value, int); | ||
} sock_map SEC(".maps"); | ||
|
||
u64 skmsg_redir_flags = 0; | ||
u32 skmsg_redir_key = 0; | ||
|
||
SEC("sk_msg") | ||
int prog_skmsg_verdict(struct sk_msg_md *msg) | ||
{ | ||
u64 flags = skmsg_redir_flags; | ||
int key = skmsg_redir_key; | ||
|
||
bpf_msg_redirect_map(msg, &sock_map, key, flags); | ||
return SK_PASS; | ||
} | ||
|
||
char _license[] SEC("license") = "GPL"; |