OSDN Git Service

bpf: Generalize bpf_sk_storage
authorKP Singh <kpsingh@google.com>
Tue, 25 Aug 2020 18:29:15 +0000 (20:29 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 25 Aug 2020 22:00:04 +0000 (15:00 -0700)
commitf836a56e84ffc9f1a1cd73f77e10404ca46a4616
treec8ecb11c7e153aa30411b1691ff434ea68530217
parent4cc9ce4e739961a7b9e6b2f3b27a72124d356373
bpf: Generalize bpf_sk_storage

Refactor the functionality in bpf_sk_storage.c so that concept of
storage linked to kernel objects can be extended to other objects like
inode, task_struct etc.

Each new local storage will still be a separate map and provide its own
set of helpers. This allows for future object specific extensions and
still share a lot of the underlying implementation.

This includes the changes suggested by Martin in:

  https://lore.kernel.org/bpf/20200725013047.4006241-1-kafai@fb.com/

adding new map operations to support bpf_local_storage maps:

* storages for different kernel objects to optionally have different
  memory charging strategy (map_local_storage_charge,
  map_local_storage_uncharge)
* Functionality to extract the storage pointer from a pointer to the
  owning object (map_owner_storage_ptr)

Co-developed-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: KP Singh <kpsingh@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200825182919.1118197-4-kpsingh@chromium.org
include/linux/bpf.h
include/net/bpf_sk_storage.h
include/uapi/linux/bpf.h
net/core/bpf_sk_storage.c
tools/include/uapi/linux/bpf.h