summaryrefslogtreecommitdiff
path: root/tools/lib/bpf/xsk.h
diff options
context:
space:
mode:
authorMariusz Dudek <mariuszx.dudek@intel.com>2020-12-03 10:05:45 +0100
committerAlexei Starovoitov <ast@kernel.org>2020-12-03 10:37:59 -0800
commite459f49b4394e2630ea55d5ac7a49402686848fe (patch)
tree2820e6dedca6e7e9da5e5425d74b8460ea50bf05 /tools/lib/bpf/xsk.h
parent22e8ebe35a2e30ee19e02c41cacc99c2f896bc4b (diff)
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
Diffstat (limited to 'tools/lib/bpf/xsk.h')
-rw-r--r--tools/lib/bpf/xsk.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/lib/bpf/xsk.h b/tools/lib/bpf/xsk.h
index 5865e082ba0b..e9f121f5d129 100644
--- a/tools/lib/bpf/xsk.h
+++ b/tools/lib/bpf/xsk.h
@@ -204,6 +204,11 @@ struct xsk_umem_config {
__u32 flags;
};
+LIBBPF_API int xsk_setup_xdp_prog(int ifindex,
+ int *xsks_map_fd);
+LIBBPF_API int xsk_socket__update_xskmap(struct xsk_socket *xsk,
+ int xsks_map_fd);
+
/* Flags for the libbpf_flags field. */
#define XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD (1 << 0)