diff mbox series

[bpf-next,v2,5/5] selftests/bpf: add timeout map check in map_ptr tests

Message ID 20201214201118.148126-6-xiyou.wangcong@gmail.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series bpf: introduce timeout map | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/source_inline fail Was 0 now: 1
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 32 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Cong Wang Dec. 14, 2020, 8:11 p.m. UTC
From: Cong Wang <cong.wang@bytedance.com>

Similar to regular hashmap test.

Cc: Andrey Ignatov <rdna@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Dongdong Wang <wangdongdong.6@bytedance.com>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
---
 .../selftests/bpf/progs/map_ptr_kern.c        | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)

Comments

Andrey Ignatov Dec. 14, 2020, 8:41 p.m. UTC | #1
Cong Wang <xiyou.wangcong@gmail.com> [Mon, 2020-12-14 12:11 -0800]:
> From: Cong Wang <cong.wang@bytedance.com>
> 
> Similar to regular hashmap test.
> 
> Cc: Andrey Ignatov <rdna@fb.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Dongdong Wang <wangdongdong.6@bytedance.com>
> Signed-off-by: Cong Wang <cong.wang@bytedance.com>

Thanks.

Acked-by: Andrey Ignatov <rdna@fb.com>

> ---
>  .../selftests/bpf/progs/map_ptr_kern.c        | 20 +++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/progs/map_ptr_kern.c b/tools/testing/selftests/bpf/progs/map_ptr_kern.c
> index 34f9880a1903..f158b4f7e6c8 100644
> --- a/tools/testing/selftests/bpf/progs/map_ptr_kern.c
> +++ b/tools/testing/selftests/bpf/progs/map_ptr_kern.c
> @@ -648,6 +648,25 @@ static inline int check_ringbuf(void)
>  	return 1;
>  }
>  
> +struct {
> +	__uint(type, BPF_MAP_TYPE_TIMEOUT_HASH);
> +	__uint(max_entries, MAX_ENTRIES);
> +	__type(key, __u32);
> +	__type(value, __u32);
> +} m_timeout SEC(".maps");
> +
> +static inline int check_timeout_hash(void)
> +{
> +	struct bpf_htab *timeout_hash = (struct bpf_htab *)&m_timeout;
> +	struct bpf_map *map = (struct bpf_map *)&m_timeout;
> +
> +	VERIFY(check_default(&timeout_hash->map, map));
> +	VERIFY(timeout_hash->n_buckets == MAX_ENTRIES);
> +	VERIFY(timeout_hash->elem_size == 72);
> +
> +	return 1;
> +}
> +
>  SEC("cgroup_skb/egress")
>  int cg_skb(void *ctx)
>  {
> @@ -679,6 +698,7 @@ int cg_skb(void *ctx)
>  	VERIFY_TYPE(BPF_MAP_TYPE_SK_STORAGE, check_sk_storage);
>  	VERIFY_TYPE(BPF_MAP_TYPE_DEVMAP_HASH, check_devmap_hash);
>  	VERIFY_TYPE(BPF_MAP_TYPE_RINGBUF, check_ringbuf);
> +	VERIFY_TYPE(BPF_MAP_TYPE_TIMEOUT_HASH, check_timeout_hash);
>  
>  	return 1;
>  }
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/progs/map_ptr_kern.c b/tools/testing/selftests/bpf/progs/map_ptr_kern.c
index 34f9880a1903..f158b4f7e6c8 100644
--- a/tools/testing/selftests/bpf/progs/map_ptr_kern.c
+++ b/tools/testing/selftests/bpf/progs/map_ptr_kern.c
@@ -648,6 +648,25 @@  static inline int check_ringbuf(void)
 	return 1;
 }
 
+struct {
+	__uint(type, BPF_MAP_TYPE_TIMEOUT_HASH);
+	__uint(max_entries, MAX_ENTRIES);
+	__type(key, __u32);
+	__type(value, __u32);
+} m_timeout SEC(".maps");
+
+static inline int check_timeout_hash(void)
+{
+	struct bpf_htab *timeout_hash = (struct bpf_htab *)&m_timeout;
+	struct bpf_map *map = (struct bpf_map *)&m_timeout;
+
+	VERIFY(check_default(&timeout_hash->map, map));
+	VERIFY(timeout_hash->n_buckets == MAX_ENTRIES);
+	VERIFY(timeout_hash->elem_size == 72);
+
+	return 1;
+}
+
 SEC("cgroup_skb/egress")
 int cg_skb(void *ctx)
 {
@@ -679,6 +698,7 @@  int cg_skb(void *ctx)
 	VERIFY_TYPE(BPF_MAP_TYPE_SK_STORAGE, check_sk_storage);
 	VERIFY_TYPE(BPF_MAP_TYPE_DEVMAP_HASH, check_devmap_hash);
 	VERIFY_TYPE(BPF_MAP_TYPE_RINGBUF, check_ringbuf);
+	VERIFY_TYPE(BPF_MAP_TYPE_TIMEOUT_HASH, check_timeout_hash);
 
 	return 1;
 }