-
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.
selftest/bpf: extend the offload test with map checks
Check map device information is reported correctly, and perform basic map operations. Check device destruction gets rid of the maps and map allocation failure path by telling netdevsim to reject map offload via DebugFS. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
- Loading branch information
Jakub Kicinski
authored and
Daniel Borkmann
committed
Jan 18, 2018
1 parent
395cacb
commit 7fedbb7
Showing
3 changed files
with
218 additions
and
25 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
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,34 @@ | ||
/* SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) */ | ||
#include <linux/bpf.h> | ||
#include "bpf_helpers.h" | ||
|
||
struct bpf_map_def SEC("maps") htab = { | ||
.type = BPF_MAP_TYPE_HASH, | ||
.key_size = sizeof(__u32), | ||
.value_size = sizeof(long), | ||
.max_entries = 2, | ||
}; | ||
|
||
struct bpf_map_def SEC("maps") array = { | ||
.type = BPF_MAP_TYPE_ARRAY, | ||
.key_size = sizeof(__u32), | ||
.value_size = sizeof(long), | ||
.max_entries = 2, | ||
}; | ||
|
||
/* Sample program which should always load for testing control paths. */ | ||
SEC(".text") int func() | ||
{ | ||
__u64 key64 = 0; | ||
__u32 key = 0; | ||
long *value; | ||
|
||
value = bpf_map_lookup_elem(&htab, &key); | ||
if (!value) | ||
return 1; | ||
value = bpf_map_lookup_elem(&array, &key64); | ||
if (!value) | ||
return 1; | ||
|
||
return 0; | ||
} |
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