mbox series

[bpf-next,0/3] bpf: expose bpf_{s,g}etsockopt helpers to bind{4,6} hooks

Message ID 20201202172516.3483656-1-sdf@google.com
Headers show
Series bpf: expose bpf_{s,g}etsockopt helpers to bind{4,6} hooks | expand

Message

Stanislav Fomichev Dec. 2, 2020, 5:25 p.m. UTC
This might be useful for the listener sockets to pre-populate
some options. Since those helpers require locked sockets,
I'm changing bind hooks to lock/unlock the sockets. This
should not cause any performance overhead because at this
point there shouldn't be any socket lock contention and the
locking/unlocking should be cheap.

Also, as part of the series, I convert test_sock_addr bpf
assembly into C (and preserve the narrow load tests) to
make it easier to extend with th bpf_setsockopt later on.

v2:
* remove version from bpf programs (Andrii Nakryiko)

Stanislav Fomichev (3):
  selftests/bpf: rewrite test_sock_addr bind bpf into C
  bpf: allow bpf_{s,g}etsockopt from cgroup bind{4,6} hooks
  selftests/bpf: extend bind{4,6} programs with a call to bpf_setsockopt

 include/linux/bpf-cgroup.h                    |  12 +-
 net/core/filter.c                             |   4 +
 net/ipv4/af_inet.c                            |   2 +-
 net/ipv6/af_inet6.c                           |   2 +-
 .../testing/selftests/bpf/progs/bind4_prog.c  | 102 +++++++++
 .../testing/selftests/bpf/progs/bind6_prog.c  | 119 +++++++++++
 tools/testing/selftests/bpf/test_sock_addr.c  | 196 ++----------------
 7 files changed, 245 insertions(+), 192 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/bind4_prog.c
 create mode 100644 tools/testing/selftests/bpf/progs/bind6_prog.c

Comments

Alexei Starovoitov Dec. 3, 2020, 6:32 p.m. UTC | #1
On Wed, Dec 02, 2020 at 09:25:13AM -0800, Stanislav Fomichev wrote:
> This might be useful for the listener sockets to pre-populate

> some options. Since those helpers require locked sockets,

> I'm changing bind hooks to lock/unlock the sockets. This

> should not cause any performance overhead because at this

> point there shouldn't be any socket lock contention and the

> locking/unlocking should be cheap.

> 

> Also, as part of the series, I convert test_sock_addr bpf

> assembly into C (and preserve the narrow load tests) to

> make it easier to extend with th bpf_setsockopt later on.

> 

> v2:

> * remove version from bpf programs (Andrii Nakryiko)


Applied, Thanks