From: Michal Luczaj <hidden> Date: 2024-10-13 16:27:23
Series consists of few fixes for issues uncovered while working on a BPF
sockmap/sockhash redirection selftest.
The last patch is more of a RFC clean up attempt. Patch claims that there's
no functional change, but effectively it removes (never touched?) reference
to sock_map_unhash().
Signed-off-by: Michal Luczaj <redacted>
---
Changes in v2:
- Patch 2/4: Send a credit update [Stefano]
- Collect Reviewed-by
- Link to v1: https://lore.kernel.org/r/20241009-vsock-fixes-for-redir-v1-0-e455416f6d78@rbox.co
---
Michal Luczaj (4):
bpf, sockmap: SK_DROP on attempted redirects of unsupported af_vsock
vsock: Update rx_bytes on read_skb()
vsock: Update msg_count on read_skb()
bpf, vsock: Drop static vsock_bpf_prot initialization
include/net/sock.h | 5 +++++
net/core/sock_map.c | 8 ++++++++
net/vmw_vsock/virtio_transport_common.c | 14 ++++++++++++--
net/vmw_vsock/vsock_bpf.c | 8 --------
4 files changed, 25 insertions(+), 10 deletions(-)
---
base-commit: afeb2b51a761c9c52be5639eb40460462083f222
change-id: 20241009-vsock-fixes-for-redir-86707e1e8c04
Best regards,
--
Michal Luczaj [off-list ref]
From: Michal Luczaj <hidden> Date: 2024-10-13 16:27:19
Don't mislead the callers of bpf_{sk,msg}_redirect_{map,hash}(): make sure
to immediately and visibly fail the forwarding of unsupported af_vsock
packets.
Fixes: 634f1a7110b4 ("vsock: support sockmap")
Signed-off-by: Michal Luczaj <redacted>
---
include/net/sock.h | 5 +++++
net/core/sock_map.c | 8 ++++++++
2 files changed, 13 insertions(+)
From: Michal Luczaj <hidden> Date: 2024-10-13 16:27:22
vsock_bpf_prot is set up at runtime. Remove the superfluous init.
No functional change intended.
Fixes: 634f1a7110b4 ("vsock: support sockmap")
Signed-off-by: Michal Luczaj <redacted>
---
net/vmw_vsock/vsock_bpf.c | 8 --------
1 file changed, 8 deletions(-)
@@ -114,14 +114,6 @@ static int vsock_bpf_recvmsg(struct sock *sk, struct msghdr *msg,returncopied;}-/* Copy of original proto with updated sock_map methods */-staticstructprotovsock_bpf_prot={-.close=sock_map_close,-.recvmsg=vsock_bpf_recvmsg,-.sock_is_readable=sk_msg_is_readable,-.unhash=sock_map_unhash,-};-staticvoidvsock_bpf_rebuild_protos(structproto*prot,conststructproto*base){*prot=*base;
From: Michal Luczaj <hidden> Date: 2024-10-13 16:27:25
Make sure virtio_transport_inc_rx_pkt() and virtio_transport_dec_rx_pkt()
calls are balanced (i.e. virtio_vsock_sock::rx_bytes doesn't lie) after
vsock_transport::read_skb().
While here, also inform the peer that we've freed up space and it has more
credit.
Failing to update rx_bytes after packet is dequeued leads to a warning on
SOCK_STREAM recv():
[ 233.396654] rx_queue is empty, but rx_bytes is non-zero
[ 233.396702] WARNING: CPU: 11 PID: 40601 at net/vmw_vsock/virtio_transport_common.c:589
Fixes: 634f1a7110b4 ("vsock: support sockmap")
Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Michal Luczaj <redacted>
---
net/vmw_vsock/virtio_transport_common.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
On Sun, Oct 13, 2024 at 06:26:40PM +0200, Michal Luczaj wrote:
Make sure virtio_transport_inc_rx_pkt() and virtio_transport_dec_rx_pkt()
calls are balanced (i.e. virtio_vsock_sock::rx_bytes doesn't lie) after
vsock_transport::read_skb().
While here, also inform the peer that we've freed up space and it has more
credit.
Failing to update rx_bytes after packet is dequeued leads to a warning on
SOCK_STREAM recv():
[ 233.396654] rx_queue is empty, but rx_bytes is non-zero
[ 233.396702] WARNING: CPU: 11 PID: 40601 at net/vmw_vsock/virtio_transport_common.c:589
Fixes: 634f1a7110b4 ("vsock: support sockmap")
Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Michal Luczaj <redacted>
---
net/vmw_vsock/virtio_transport_common.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
Thanks for fixing this!
LGTM:
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
On Sun, Oct 13, 2024 at 06:26:38PM +0200, Michal Luczaj wrote:
Series consists of few fixes for issues uncovered while working on a BPF
sockmap/sockhash redirection selftest.
The last patch is more of a RFC clean up attempt. Patch claims that there's
no functional change, but effectively it removes (never touched?) reference
to sock_map_unhash().
Signed-off-by: Michal Luczaj <redacted>
---
Changes in v2:
- Patch 2/4: Send a credit update [Stefano]
- Collect Reviewed-by
- Link to v1: https://lore.kernel.org/r/20241009-vsock-fixes-for-redir-v1-0-e455416f6d78@rbox.co
For the virtio-vsock point of view, the series LGTM and I reviewed patch
2 and 3. I don't know BPF enough for the rest but I can't see anything
wrong.
Thanks,
Stefano
---
Michal Luczaj (4):
bpf, sockmap: SK_DROP on attempted redirects of unsupported af_vsock
vsock: Update rx_bytes on read_skb()
vsock: Update msg_count on read_skb()
bpf, vsock: Drop static vsock_bpf_prot initialization
include/net/sock.h | 5 +++++
net/core/sock_map.c | 8 ++++++++
net/vmw_vsock/virtio_transport_common.c | 14 ++++++++++++--
net/vmw_vsock/vsock_bpf.c | 8 --------
4 files changed, 25 insertions(+), 10 deletions(-)
---
base-commit: afeb2b51a761c9c52be5639eb40460462083f222
change-id: 20241009-vsock-fixes-for-redir-86707e1e8c04
Best regards,
--
Michal Luczaj [off-list ref]
From: John Fastabend <john.fastabend@gmail.com> Date: 2024-10-16 18:25:42
Michal Luczaj wrote:
Series consists of few fixes for issues uncovered while working on a BPF
sockmap/sockhash redirection selftest.
The last patch is more of a RFC clean up attempt. Patch claims that there's
no functional change, but effectively it removes (never touched?) reference
to sock_map_unhash().
Signed-off-by: Michal Luczaj <redacted>
---
For the series LGTM, ack.
Acked-by: John Fastabend <john.fastabend@gmail.com>
Hello:
This series was applied to bpf/bpf.git (master)
by Daniel Borkmann [off-list ref]:
On Sun, 13 Oct 2024 18:26:38 +0200 you wrote:
Series consists of few fixes for issues uncovered while working on a BPF
sockmap/sockhash redirection selftest.
The last patch is more of a RFC clean up attempt. Patch claims that there's
no functional change, but effectively it removes (never touched?) reference
to sock_map_unhash().
[...]