BPF List
 help / color / mirror / Atom feed
* [PATCH bpf 0/2] Check timer_off for map_in_map only when map value has timer
@ 2022-11-26 10:53 Hengqi Chen
  2022-11-26 10:53 ` [PATCH bpf 1/2] bpf: Check timer_off for map_in_map only when map value have timer Hengqi Chen
  2022-11-26 10:53 ` [PATCH bpf 2/2] selftests/bpf: Update map_in_map using map without BTF key/value info Hengqi Chen
  0 siblings, 2 replies; 12+ messages in thread
From: Hengqi Chen @ 2022-11-26 10:53 UTC (permalink / raw)
  To: bpf; +Cc: ast, daniel, andrii, martin.lau, song, yhs, toke, hengqi.chen

The timer_off value could be -EINVAL or -ENOENT when map value of
inner map is struct and contains no bpf_timer.

The EINVAL case happens when the map is created without BTF key/value
info, map->timer_off is set to -EINVAL in map_create(). For example:

    map_fd = bpf_map_create(BPF_MAP_TYPE_LRU_HASH, NULL, 4, 4, 1, NULL);

The ENOENT case happens when the map is created with BTF key/value
info (e.g. from BPF skeleton), map->timer_off is set to -ENOENT as
what btf_find_timer() returns. For example, map created from BPF skeleton:

    struct inner_key {
    	__u32 x;
    };

    struct inner_value {
    	__u32 y;
    };

    struct inner {
    	__uint(type, BPF_MAP_TYPE_LRU_HASH);
    	__uint(max_entries, 1);
    	__type(key, struct inner_key);
    	__type(value, struct inner_value);
    } inner SEC(".maps");

    struct {
    	__uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
    	__uint(max_entries, 1);
    	__type(key, __u32);
    	__array(values, struct inner);
    } outer SEC(".maps");

Since timer_off is different, the map_in_map outer in the above case
can NOT be updated using map_fd in the first case. This patch tries
to fix such restriction.

Hengqi Chen (2):
  bpf: Check timer_off for map_in_map only when map value have timer
  selftests/bpf: Update map_in_map using map without BTF key/value info

 kernel/bpf/map_in_map.c                       |  9 ++++++-
 .../selftests/bpf/prog_tests/btf_map_in_map.c | 27 +++++++++++++++++++
 .../selftests/bpf/progs/test_btf_map_in_map.c | 22 +++++++++++++++
 3 files changed, 57 insertions(+), 1 deletion(-)

--
2.34.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-11-29  6:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-26 10:53 [PATCH bpf 0/2] Check timer_off for map_in_map only when map value has timer Hengqi Chen
2022-11-26 10:53 ` [PATCH bpf 1/2] bpf: Check timer_off for map_in_map only when map value have timer Hengqi Chen
2022-11-27  3:21   ` Yonghong Song
2022-11-28  2:16     ` Hengqi Chen
2022-11-28  0:44   ` Alexei Starovoitov
2022-11-28  2:42     ` Hengqi Chen
2022-11-28  2:49       ` Alexei Starovoitov
2022-11-28  3:07         ` Hengqi Chen
2022-11-28  3:14           ` Alexei Starovoitov
2022-11-28  4:11             ` Hengqi Chen
2022-11-29  6:12       ` Andrii Nakryiko
2022-11-26 10:53 ` [PATCH bpf 2/2] selftests/bpf: Update map_in_map using map without BTF key/value info Hengqi Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox