]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Separate XDP program load with xsk socket creation
authorMariusz Dudek <mariuszx.dudek@intel.com>
Thu, 3 Dec 2020 09:05:45 +0000 (10:05 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 3 Dec 2020 18:37:59 +0000 (10:37 -0800)
commita79a33af7fa48503bfdf4fe8d92353976b993184
tree2820e6dedca6e7e9da5e5425d74b8460ea50bf05
parentab74c392687dd299e60cba8000bf16cfd5c7e850
libbpf: Separate XDP program load with xsk socket creation

Add support for separation of eBPF program load and xsk socket
creation.

This is needed for use-case when you want to privide as little
privileges as possible to the data plane application that will
handle xsk socket creation and incoming traffic.

With this patch the data entity container can be run with only
CAP_NET_RAW capability to fulfill its purpose of creating xsk
socket and handling packages. In case your umem is larger or
equal process limit for MEMLOCK you need either increase the
limit or CAP_IPC_LOCK capability.

To resolve privileges issue two APIs are introduced:

- xsk_setup_xdp_prog - loads the built in XDP program. It can
also return xsks_map_fd which is needed by unprivileged process
to update xsks_map with AF_XDP socket "fd"

- xsk_socket__update_xskmap - inserts an AF_XDP socket into an xskmap
for a particular xsk_socket

Signed-off-by: Mariusz Dudek <mariuszx.dudek@intel.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/bpf/20201203090546.11976-2-mariuszx.dudek@intel.com
tools/lib/bpf/libbpf.map
tools/lib/bpf/xsk.c
tools/lib/bpf/xsk.h