mbox series

[bpf-next,v3,00/12] bpf: sockmap, sockhash: support storing UDP sockets

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

Message

Lorenz Bauer March 4, 2020, 10:13 a.m. UTC
Thanks to Jakub's suggestion I was able to eliminate sk_psock_hooks!
Now TCP and UDP only need to export a single function get_proto,
which is called from the sockmap code. This reduced the amount of
boilerplate a bit. The downside is that the IPv6 proto rebuild is
copied and pasted from TCP, but I think I can live with that.

Changes since v2:
- Remove sk_psock_hooks based on Jakub's idea
- Fix reference to tcp_bpf_clone in commit message
- Add inet_csk_has_ulp helper

Changes since v1:
- Check newsk->sk_prot in tcp_bpf_clone
- Fix compilation with BPF_STREAM_PARSER disabled
- Use spin_lock_init instead of static initializer
- Elaborate on TCPF_SYN_RECV
- Cosmetic changes to TEST macros, and more tests
- Add Jakub and me as maintainers

Jakub Sitnicki (2):
  bpf: add sockmap hooks for UDP sockets
  bpf: sockmap: add UDP support

Lorenz Bauer (10):
  bpf: sockmap: only check ULP for TCP sockets
  skmsg: update saved hooks only once
  bpf: tcp: move assertions into tcp_bpf_get_proto
  bpf: tcp: guard declarations with CONFIG_NET_SOCK_MSG
  bpf: sockmap: move generic sockmap hooks from BPF TCP
  bpf: sockmap: simplify sock_map_init_proto
  selftests: bpf: don't listen() on UDP sockets
  selftests: bpf: add tests for UDP sockets in sockmap
  selftests: bpf: enable UDP sockmap reuseport tests
  bpf, doc: update maintainers for L7 BPF

 MAINTAINERS                                   |   3 +
 include/linux/bpf.h                           |   4 +-
 include/linux/skmsg.h                         |  56 ++---
 include/net/tcp.h                             |  20 +-
 include/net/udp.h                             |   5 +
 net/core/sock_map.c                           | 158 +++++++++++---
 net/ipv4/Makefile                             |   1 +
 net/ipv4/tcp_bpf.c                            | 114 ++--------
 net/ipv4/udp_bpf.c                            |  53 +++++
 .../bpf/prog_tests/select_reuseport.c         |   6 -
 .../selftests/bpf/prog_tests/sockmap_listen.c | 204 +++++++++++++-----
 11 files changed, 399 insertions(+), 225 deletions(-)
 create mode 100644 net/ipv4/udp_bpf.c

Comments

Jakub Sitnicki March 5, 2020, 12:59 p.m. UTC | #1
On Wed, Mar 04, 2020 at 11:13 AM CET, Lorenz Bauer wrote:
> Thanks to Jakub's suggestion I was able to eliminate sk_psock_hooks!
> Now TCP and UDP only need to export a single function get_proto,
> which is called from the sockmap code. This reduced the amount of
> boilerplate a bit. The downside is that the IPv6 proto rebuild is
> copied and pasted from TCP, but I think I can live with that.

This turned out nicely, IMHO. Thanks for reworking it.

-jkbs

[...]
John Fastabend March 6, 2020, 3:45 p.m. UTC | #2
Lorenz Bauer wrote:
> Thanks to Jakub's suggestion I was able to eliminate sk_psock_hooks!
> Now TCP and UDP only need to export a single function get_proto,
> which is called from the sockmap code. This reduced the amount of
> boilerplate a bit. The downside is that the IPv6 proto rebuild is
> copied and pasted from TCP, but I think I can live with that.
> 
> Changes since v2:
> - Remove sk_psock_hooks based on Jakub's idea
> - Fix reference to tcp_bpf_clone in commit message
> - Add inet_csk_has_ulp helper
> 
> Changes since v1:
> - Check newsk->sk_prot in tcp_bpf_clone
> - Fix compilation with BPF_STREAM_PARSER disabled
> - Use spin_lock_init instead of static initializer
> - Elaborate on TCPF_SYN_RECV
> - Cosmetic changes to TEST macros, and more tests
> - Add Jakub and me as maintainers
> 
> Jakub Sitnicki (2):
>   bpf: add sockmap hooks for UDP sockets
>   bpf: sockmap: add UDP support
> 
> Lorenz Bauer (10):
>   bpf: sockmap: only check ULP for TCP sockets
>   skmsg: update saved hooks only once
>   bpf: tcp: move assertions into tcp_bpf_get_proto
>   bpf: tcp: guard declarations with CONFIG_NET_SOCK_MSG
>   bpf: sockmap: move generic sockmap hooks from BPF TCP
>   bpf: sockmap: simplify sock_map_init_proto
>   selftests: bpf: don't listen() on UDP sockets
>   selftests: bpf: add tests for UDP sockets in sockmap
>   selftests: bpf: enable UDP sockmap reuseport tests
>   bpf, doc: update maintainers for L7 BPF
> 
>  MAINTAINERS                                   |   3 +
>  include/linux/bpf.h                           |   4 +-
>  include/linux/skmsg.h                         |  56 ++---
>  include/net/tcp.h                             |  20 +-
>  include/net/udp.h                             |   5 +
>  net/core/sock_map.c                           | 158 +++++++++++---
>  net/ipv4/Makefile                             |   1 +
>  net/ipv4/tcp_bpf.c                            | 114 ++--------
>  net/ipv4/udp_bpf.c                            |  53 +++++
>  .../bpf/prog_tests/select_reuseport.c         |   6 -
>  .../selftests/bpf/prog_tests/sockmap_listen.c | 204 +++++++++++++-----
>  11 files changed, 399 insertions(+), 225 deletions(-)
>  create mode 100644 net/ipv4/udp_bpf.c
> 
> -- 
> 2.20.1
> 

Nice series thanks for doing this. I'll drop it into some Cilium CI just
to be sure everything on the sockmap/ktls side is still working but
looks good to me.

I'll try to add send bpf hooks here shortly as well so we get the sendmsg
bpf progs running here as well.

Thanks,
John