]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Test unhashing kTLS socket after removing from map
authorJakub Sitnicki <jakub@cloudflare.com>
Mon, 17 Feb 2020 12:15:30 +0000 (12:15 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 19 Feb 2020 15:54:05 +0000 (16:54 +0100)
commit5a82f4c8cc07599c213476256b95771f1f26e9a9
tree20be453de9bbad27e82af5f26490e642ccda7437
parent2de504e29a667c2f632b8a41725b962720fa0bad
selftests/bpf: Test unhashing kTLS socket after removing from map

When a TCP socket gets inserted into a sockmap, its sk_prot callbacks get
replaced with tcp_bpf callbacks built from regular tcp callbacks. If TLS
gets enabled on the same socket, sk_prot callbacks get replaced once again,
this time with kTLS callbacks built from tcp_bpf callbacks.

Now, we allow removing a socket from a sockmap that has kTLS enabled. After
removal, socket remains with kTLS configured. This is where things things
get tricky.

Since the socket has a set of sk_prot callbacks that are a mix of kTLS and
tcp_bpf callbacks, we need to restore just the tcp_bpf callbacks to the
original ones. At the moment, it comes down to the the unhash operation.

We had a regression recently because tcp_bpf callbacks were not cleared in
this particular scenario of removing a kTLS socket from a sockmap. It got
fixed in commit 103a0c2d6537 ("bpf: Sockmap/tls, during free we may call
tcp_bpf_unhash() in loop").

Add a test that triggers the regression so that we don't reintroduce it in
the future.

Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20200217121530.754315-4-jakub@cloudflare.com
tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c [new file with mode: 0644]