-
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: Check inner map deletion
Add a test case to check whether an unsuccessful creation of an outer map of a BTF-defined map-in-map destroys the inner map. As bpf_object__create_map() is a static function, we cannot just call it from the test case and then check whether a map accessible via map->inner_map_fd has been closed. Instead, we iterate over all maps and check whether the map "$MAP_NAME.inner" does not exist. Signed-off-by: Martynas Pumputis <m@lambda.lt> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/20210719173838.423148-3-m@lambda.lt
- Loading branch information
Martynas Pumputis
authored and
Andrii Nakryiko
committed
Jul 19, 2021
1 parent
a21ab4c
commit 08f71a1
Showing
2 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
tools/testing/selftests/bpf/progs/test_map_in_map_invalid.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,26 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright (c) 2021 Isovalent, Inc. */ | ||
#include <linux/bpf.h> | ||
#include <bpf/bpf_helpers.h> | ||
|
||
struct inner { | ||
__uint(type, BPF_MAP_TYPE_ARRAY); | ||
__type(key, __u32); | ||
__type(value, int); | ||
__uint(max_entries, 4); | ||
}; | ||
|
||
struct { | ||
__uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS); | ||
__uint(max_entries, 0); /* This will make map creation to fail */ | ||
__uint(key_size, sizeof(__u32)); | ||
__array(values, struct inner); | ||
} mim SEC(".maps"); | ||
|
||
SEC("xdp") | ||
int xdp_noop0(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