mbox series

[RFC,0/4] eBPF RSS through QMP support.

Message ID 20230330001522.120774-1-andrew@daynix.com
Headers show
Series eBPF RSS through QMP support. | expand

Message

Andrew Melnichenko March 30, 2023, 12:15 a.m. UTC
This series of patches provides the ability to retrieve eBPF program
through qmp, so management application may load bpf blob with proper capabilities.
Now, virtio-net devices can accept eBPF programs and maps through properties
as external file descriptors. Access to the eBPF map is direct through mmap()
call, so it should not require additional capabilities to bpf* calls.
eBPF file descriptors can be passed to QEMU from parent process or by unix
socket with sendfd() qmp command.

Overall, the basic scenario of using the helper looks like this:
 * Libvirt checks for ebpf_fds property.
 * Libvirt requests eBPF blob through QMP.
 * Libvirt loads blob for virtio-net.
 * Libvirt launches the QEMU with eBPF fds passed.
 
Andrew Melnychenko (4):
  ebpf: Added eBPF initialization by fds and map update.
  virtio-net: Added property to load eBPF RSS with fds.
  ebpf: Added declaration/initialization routines.
  qmp: Added new command to retrieve eBPF blob.

 ebpf/ebpf.c                    |  48 +++++++++++++
 ebpf/ebpf.h                    |  25 +++++++
 ebpf/ebpf_rss-stub.c           |   6 ++
 ebpf/ebpf_rss.c                | 124 +++++++++++++++++++++++++++------
 ebpf/ebpf_rss.h                |  10 +++
 ebpf/meson.build               |   1 +
 hw/net/virtio-net.c            |  77 ++++++++++++++++++--
 include/hw/virtio/virtio-net.h |   1 +
 monitor/qmp-cmds.c             |  17 +++++
 qapi/misc.json                 |  25 +++++++
 10 files changed, 307 insertions(+), 27 deletions(-)
 create mode 100644 ebpf/ebpf.c
 create mode 100644 ebpf/ebpf.h

Comments

Jason Wang March 30, 2023, 6:57 a.m. UTC | #1
On Thu, Mar 30, 2023 at 8:33 AM Andrew Melnychenko <andrew@daynix.com> wrote:
>
> This series of patches provides the ability to retrieve eBPF program
> through qmp, so management application may load bpf blob with proper capabilities.
> Now, virtio-net devices can accept eBPF programs and maps through properties
> as external file descriptors. Access to the eBPF map is direct through mmap()
> call, so it should not require additional capabilities to bpf* calls.
> eBPF file descriptors can be passed to QEMU from parent process or by unix
> socket with sendfd() qmp command.
>
> Overall, the basic scenario of using the helper looks like this:
>  * Libvirt checks for ebpf_fds property.
>  * Libvirt requests eBPF blob through QMP.
>  * Libvirt loads blob for virtio-net.
>  * Libvirt launches the QEMU with eBPF fds passed.

Is there a libvirt side draft that can be used as a reference?

Thanks

>
> Andrew Melnychenko (4):
>   ebpf: Added eBPF initialization by fds and map update.
>   virtio-net: Added property to load eBPF RSS with fds.
>   ebpf: Added declaration/initialization routines.
>   qmp: Added new command to retrieve eBPF blob.
>
>  ebpf/ebpf.c                    |  48 +++++++++++++
>  ebpf/ebpf.h                    |  25 +++++++
>  ebpf/ebpf_rss-stub.c           |   6 ++
>  ebpf/ebpf_rss.c                | 124 +++++++++++++++++++++++++++------
>  ebpf/ebpf_rss.h                |  10 +++
>  ebpf/meson.build               |   1 +
>  hw/net/virtio-net.c            |  77 ++++++++++++++++++--
>  include/hw/virtio/virtio-net.h |   1 +
>  monitor/qmp-cmds.c             |  17 +++++
>  qapi/misc.json                 |  25 +++++++
>  10 files changed, 307 insertions(+), 27 deletions(-)
>  create mode 100644 ebpf/ebpf.c
>  create mode 100644 ebpf/ebpf.h
>
> --
> 2.39.1
>
Andrew Melnichenko March 30, 2023, 10:48 a.m. UTC | #2
On Thu, Mar 30, 2023 at 9:57 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Thu, Mar 30, 2023 at 8:33 AM Andrew Melnychenko <andrew@daynix.com> wrote:
> >
> > This series of patches provides the ability to retrieve eBPF program
> > through qmp, so management application may load bpf blob with proper capabilities.
> > Now, virtio-net devices can accept eBPF programs and maps through properties
> > as external file descriptors. Access to the eBPF map is direct through mmap()
> > call, so it should not require additional capabilities to bpf* calls.
> > eBPF file descriptors can be passed to QEMU from parent process or by unix
> > socket with sendfd() qmp command.
> >
> > Overall, the basic scenario of using the helper looks like this:
> >  * Libvirt checks for ebpf_fds property.
> >  * Libvirt requests eBPF blob through QMP.
> >  * Libvirt loads blob for virtio-net.
> >  * Libvirt launches the QEMU with eBPF fds passed.
>
> Is there a libvirt side draft that can be used as a reference?
>
> Thanks
>

I'm working on it. This is why it's RFC.
I have a small script that checks that eBPF retrieved through QMP can be loaded.
Also, please check the eBPF blob declaration/initialization routine
and qmp commands.
So, this API should be implemented once and right.

> >
> > Andrew Melnychenko (4):
> >   ebpf: Added eBPF initialization by fds and map update.
> >   virtio-net: Added property to load eBPF RSS with fds.
> >   ebpf: Added declaration/initialization routines.
> >   qmp: Added new command to retrieve eBPF blob.
> >
> >  ebpf/ebpf.c                    |  48 +++++++++++++
> >  ebpf/ebpf.h                    |  25 +++++++
> >  ebpf/ebpf_rss-stub.c           |   6 ++
> >  ebpf/ebpf_rss.c                | 124 +++++++++++++++++++++++++++------
> >  ebpf/ebpf_rss.h                |  10 +++
> >  ebpf/meson.build               |   1 +
> >  hw/net/virtio-net.c            |  77 ++++++++++++++++++--
> >  include/hw/virtio/virtio-net.h |   1 +
> >  monitor/qmp-cmds.c             |  17 +++++
> >  qapi/misc.json                 |  25 +++++++
> >  10 files changed, 307 insertions(+), 27 deletions(-)
> >  create mode 100644 ebpf/ebpf.c
> >  create mode 100644 ebpf/ebpf.h
> >
> > --
> > 2.39.1
> >
>