forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
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 a test case for loading BPF_SK_SKB_VERDICT
This adds a test case to ensure BPF_SK_SKB_VERDICT and BPF_SK_STREAM_VERDICT will never be attached at the same time. Signed-off-by: Cong Wang <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
- Loading branch information
Cong Wang
authored and
Alexei Starovoitov
committed
Apr 1, 2021
1 parent
d6378af
commit 8d7cb74
Showing
2 changed files
with
58 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
18 changes: 18 additions & 0 deletions
18
tools/testing/selftests/bpf/progs/test_sockmap_skb_verdict_attach.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,18 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
#include "vmlinux.h" | ||
#include <bpf/bpf_helpers.h> | ||
|
||
struct { | ||
__uint(type, BPF_MAP_TYPE_SOCKMAP); | ||
__uint(max_entries, 2); | ||
__type(key, __u32); | ||
__type(value, __u64); | ||
} sock_map SEC(".maps"); | ||
|
||
SEC("sk_skb/skb_verdict") | ||
int prog_skb_verdict(struct __sk_buff *skb) | ||
{ | ||
return SK_DROP; | ||
} | ||
|
||
char _license[] SEC("license") = "GPL"; |