mbox series

[bpf-next,0/7] bpf: sockmap, sockhash: support storing UDP sockets

Message ID 20200225135636.5768-1-lmb@cloudflare.com
Headers show
Series bpf: sockmap, sockhash: support storing UDP sockets | expand

Message

Lorenz Bauer Feb. 25, 2020, 1:56 p.m. UTC
This series adds support for storing UDP sockets in sockmap and sockhash. This
allows using these maps in reuseport programs on UDP sockets, instead of
reuseport sockarrays. We want to use this in our work for BPF based
socket dispatch.

The first two patches make the sockmap code more generic: anything related to
ULP must only be called on TCP sockets, and some of the tcp_bpf hooks can be
re-used for UDP.

The third patch introduces a new struct psock_hooks, which encapsulates some
fiddly state handling required to support IPv6-as-a-module. I'm not
particularly fond of it, and would be happy for suggestions on how to make
it less obtrusive.

The fourth patch adds udp_bpf modeled on tcp_bpf, using struct psock_hooks,
and relaxes sockmap update checks.

The final patches enable tests.

Lorenz Bauer (7):
  bpf: sockmap: only check ULP for TCP sockets
  bpf: sockmap: move generic sockmap hooks from BPF TCP
  skmsg: introduce sk_psock_hooks
  bpf: sockmap: allow UDP sockets
  selftests: bpf: don't listen() on UDP sockets
  selftests: bpf: add tests for UDP sockets in sockmap
  selftests: bpf: enable UDP sockmap reuseport tests

 MAINTAINERS                                   |   1 +
 include/linux/bpf.h                           |   4 +-
 include/linux/skmsg.h                         |  72 ++++----
 include/linux/udp.h                           |   4 +
 include/net/tcp.h                             |   1 -
 net/core/skmsg.c                              |  52 ++++++
 net/core/sock_map.c                           | 155 +++++++++++-----
 net/ipv4/Makefile                             |   1 +
 net/ipv4/tcp_bpf.c                            | 169 ++++--------------
 net/ipv4/udp_bpf.c                            |  53 ++++++
 .../bpf/prog_tests/select_reuseport.c         |   7 -
 .../selftests/bpf/prog_tests/sockmap_listen.c | 139 ++++++++------
 12 files changed, 381 insertions(+), 277 deletions(-)
 create mode 100644 net/ipv4/udp_bpf.c