From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: mariusz.dudek@gmail.com
Cc: "Magnus Karlsson" <magnus.karlsson@intel.com>,
"Björn Töpel" <bjorn.topel@intel.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
Networking <netdev@vger.kernel.org>,
"Jonathan Lemon" <jonathan.lemon@gmail.com>,
bpf <bpf@vger.kernel.org>,
"Mariusz Dudek" <mariuszx.dudek@intel.com>
Subject: Re: [PATCH bpf-next 1/2] libbpf: separate XDP program load with xsk socket creation
Date: Wed, 4 Nov 2020 13:07:24 -0800 [thread overview]
Message-ID: <CAEf4BzZMJV+Ko07DjXD-VxpX9dWtDhd_eGENiTSTHA5uiVLWLw@mail.gmail.com> (raw)
In-Reply-To: <20201104094626.3406-2-mariuszx.dudek@intel.com>
On Wed, Nov 4, 2020 at 1:47 AM <mariusz.dudek@gmail.com> wrote:
>
> From: Mariusz Dudek <mariuszx.dudek@intel.com>
>
> 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 - prepares bpf program if given and
> loads it on a selected network interface or loads the built in
> XDP program, if no XDP program is supplied. It can also return
> xsks_map_fd which is needed by unprivileged process to update
> xsks_map with AF_XDP socket "fd"
>
> - xsk_update_xskmap - inserts an AF_XDP socket into an xskmap
> for a particular xsk_socket
>
Your commit message seems to be heavily shifted right...
> Signed-off-by: Mariusz Dudek <mariuszx.dudek@intel.com>
> ---
> tools/lib/bpf/libbpf.map | 2 +
> tools/lib/bpf/xsk.c | 157 ++++++++++++++++++++++++++++++++-------
> tools/lib/bpf/xsk.h | 13 ++++
> 3 files changed, 146 insertions(+), 26 deletions(-)
>
[...]
> diff --git a/tools/lib/bpf/xsk.h b/tools/lib/bpf/xsk.h
> index 1069c46364ff..c42b91935d3c 100644
> --- a/tools/lib/bpf/xsk.h
> +++ b/tools/lib/bpf/xsk.h
> @@ -201,6 +201,19 @@ struct xsk_umem_config {
> __u32 flags;
> };
>
> +struct bpf_prog_cfg {
> + struct bpf_insn *prog;
> + const char *license;
> + size_t insns_cnt;
> + int xsks_map_fd;
> +};
This config will have problems with backward/forward compatibility.
Please check how xxx_opts are done and use them for extensible options
structs.
> +
> +LIBBPF_API int xsk_setup_xdp_prog(int ifindex,
> + struct bpf_prog_cfg *cfg,
> + int *xsks_map_fd);
> +LIBBPF_API int xsk_update_xskmap(struct xsk_socket *xsk,
> + int xsks_map_fd);
this should be called xsk_socket__update_map? BTW, what's xskmap? Is
that a special BPF map type?
> +
> /* Flags for the libbpf_flags field. */
> #define XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD (1 << 0)
>
> --
> 2.20.1
>
next prev parent reply other threads:[~2020-11-04 21:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-04 9:46 [PATCH bpf-next 0/2] libbpf: add support for privileged/unprivileged control separation mariusz.dudek
2020-11-04 9:46 ` [PATCH bpf-next 1/2] libbpf: separate XDP program load with xsk socket creation mariusz.dudek
2020-11-04 21:07 ` Andrii Nakryiko [this message]
2020-11-05 13:58 ` Mariusz Dudek
2020-11-04 9:46 ` [PATCH bpf-next 2/2] samples/bpf: sample application for eBPF load and socket creation split mariusz.dudek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAEf4BzZMJV+Ko07DjXD-VxpX9dWtDhd_eGENiTSTHA5uiVLWLw@mail.gmail.com \
--to=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@intel.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jonathan.lemon@gmail.com \
--cc=magnus.karlsson@intel.com \
--cc=mariusz.dudek@gmail.com \
--cc=mariuszx.dudek@intel.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).