Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sockmap: Fix reading with splice(2) #7158

Closed

Conversation

kernel-patches-daemon-bpf[bot]
Copy link

Pull request for series with
subject: sockmap: Fix reading with splice(2)
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=859429

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 0720887
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=859429
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 7015843
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=859429
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: b24862b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=859429
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 08ac454
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=859429
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: f85af9d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=859429
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 2ebb87f
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=859429
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: bb678f0
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=859429
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 98b303c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=859429
version: 1

The TCP BPF code will need to override splice_read(), so add it to prot.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@datadoghq.com>
If a socket is added to a sockmap with a verdict program which returns
SK_PASS, splice(2) is not able to read from the socket.

The verdict code removes skbs from the receive queue, checks them using
the bpf program, and then re-queues them onto a separate queue
(psock->ingress_msg).  The sockmap code modifies the TCP recvmsg hook to
check this second queue also so that works. But the splice_read hooks is
not modified and the default tcp_read_splice() only reads the normal
receive queue so it never sees the skbs which have been re-queued.

Fix it by using copy_splice_read() when replacing the proto for the
sockmap.  This could eventually be replaced with a more efficient custom
version.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@datadoghq.com>
If any tests failed, exit the program with a non-zero
error code.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@datadoghq.com>
Add an option to always return SK_PASS in the verdict callback
instead of redirecting the skb.  This allows testing cases
which are not covered by the test program as of now.

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@datadoghq.com>
Add a test mode which uses splice(2) to do a read from the
socket.  Can be run with something like the below:

 ./test_sockmap -t splice --txmsg_omit_skb_parser --txmsg_pass_skb

Signed-off-by: Vincent Whitchurch <vincent.whitchurch@datadoghq.com>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 4ff5747
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=859429
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=859429 expired. Closing PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant