* [PATCH net-next 0/2] vsock: fold acceptq accounting into core helpers
@ 2026-06-10 9:11 Raf Dickson
2026-06-10 9:11 ` [PATCH net-next 1/2] vsock: fold sk_acceptq_added() into vsock_enqueue_accept() Raf Dickson
2026-06-10 9:11 ` [PATCH net-next 2/2] vsock: fold sk_acceptq_removed() into vsock_remove_pending() Raf Dickson
0 siblings, 2 replies; 5+ messages in thread
From: Raf Dickson @ 2026-06-10 9:11 UTC (permalink / raw)
To: netdev, virtualization
Cc: pabeni, sgarzare, stefanha, bryan-bt.tan, vishnu.dasa,
bcm-kernel-feedback-list, Raf Dickson
These two patches follow up on commit c05fa14db43e
("vsock/vmci: fix sk_ack_backlog leak on failed handshake")
by folding sk_acceptq_added() and sk_acceptq_removed() into
vsock_enqueue_accept() and vsock_remove_pending() respectively,
as suggested by Paolo Abeni and Stefano Garzarella.
This makes the accounting automatic and prevents future callers
from forgetting it.
Raf Dickson (2):
vsock: fold sk_acceptq_added() into vsock_enqueue_accept()
vsock: fold sk_acceptq_removed() into vsock_remove_pending()
net/vmw_vsock/af_vsock.c | 4 ++--
net/vmw_vsock/hyperv_transport.c | 1 -
net/vmw_vsock/virtio_transport_common.c | 1 -
net/vmw_vsock/vmci_transport.c | 6 +-----
4 files changed, 3 insertions(+), 9 deletions(-)
--
2.54.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH net-next 1/2] vsock: fold sk_acceptq_added() into vsock_enqueue_accept() 2026-06-10 9:11 [PATCH net-next 0/2] vsock: fold acceptq accounting into core helpers Raf Dickson @ 2026-06-10 9:11 ` Raf Dickson 2026-06-10 23:12 ` Bobby Eshleman 2026-06-10 9:11 ` [PATCH net-next 2/2] vsock: fold sk_acceptq_removed() into vsock_remove_pending() Raf Dickson 1 sibling, 1 reply; 5+ messages in thread From: Raf Dickson @ 2026-06-10 9:11 UTC (permalink / raw) To: netdev, virtualization Cc: pabeni, sgarzare, stefanha, bryan-bt.tan, vishnu.dasa, bcm-kernel-feedback-list, Raf Dickson All three transports (vmci, virtio, hyperv) call sk_acceptq_added() immediately before vsock_enqueue_accept(). Move the call into vsock_enqueue_accept() itself so callers cannot forget it and the accounting is always consistent. Suggested-by: Paolo Abeni <pabeni@redhat.com> Suggested-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Raf Dickson <rafdog35@gmail.com> --- net/vmw_vsock/af_vsock.c | 1 + net/vmw_vsock/hyperv_transport.c | 1 - net/vmw_vsock/virtio_transport_common.c | 1 - net/vmw_vsock/vmci_transport.c | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 2ce1063d4a..73e6416ee9 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -507,6 +507,7 @@ void vsock_enqueue_accept(struct sock *listener, struct sock *connected) sock_hold(connected); sock_hold(listener); list_add_tail(&vconnected->accept_queue, &vlistener->accept_queue); + sk_acceptq_added(listener); } EXPORT_SYMBOL_GPL(vsock_enqueue_accept); diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c index b3394946b2..0de8148877 100644 --- a/net/vmw_vsock/hyperv_transport.c +++ b/net/vmw_vsock/hyperv_transport.c @@ -410,7 +410,6 @@ static void hvs_open_connection(struct vmbus_channel *chan) if (conn_from_host) { new->sk_state = TCP_ESTABLISHED; - sk_acceptq_added(sk); hvs_new->vm_srv_id = *if_type; hvs_new->host_srv_id = *if_instance; diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index b10666937c..4a39d48db9 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -1582,7 +1582,6 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb, return ret; } - sk_acceptq_added(sk); if (virtio_transport_space_update(child, skb)) child->sk_write_space(child); diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c index 91516488a7..4ce6660c11 100644 --- a/net/vmw_vsock/vmci_transport.c +++ b/net/vmw_vsock/vmci_transport.c @@ -1109,7 +1109,6 @@ static int vmci_transport_recv_listen(struct sock *sk, } vsock_add_pending(sk, pending); - sk_acceptq_added(sk); pending->sk_state = TCP_SYN_SENT; vmci_trans(vpending)->produce_size = -- 2.54.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 1/2] vsock: fold sk_acceptq_added() into vsock_enqueue_accept() 2026-06-10 9:11 ` [PATCH net-next 1/2] vsock: fold sk_acceptq_added() into vsock_enqueue_accept() Raf Dickson @ 2026-06-10 23:12 ` Bobby Eshleman 2026-06-11 1:43 ` Raf Dickson 0 siblings, 1 reply; 5+ messages in thread From: Bobby Eshleman @ 2026-06-10 23:12 UTC (permalink / raw) To: Raf Dickson Cc: netdev, virtualization, pabeni, sgarzare, stefanha, bryan-bt.tan, vishnu.dasa, bcm-kernel-feedback-list On Wed, Jun 10, 2026 at 09:11:20AM +0000, Raf Dickson wrote: > All three transports (vmci, virtio, hyperv) call sk_acceptq_added() > immediately before vsock_enqueue_accept(). Move the call into > vsock_enqueue_accept() itself so callers cannot forget it and the > accounting is always consistent. > > Suggested-by: Paolo Abeni <pabeni@redhat.com> > Suggested-by: Stefano Garzarella <sgarzare@redhat.com> > > Signed-off-by: Raf Dickson <rafdog35@gmail.com> > --- > net/vmw_vsock/af_vsock.c | 1 + > net/vmw_vsock/hyperv_transport.c | 1 - > net/vmw_vsock/virtio_transport_common.c | 1 - > net/vmw_vsock/vmci_transport.c | 1 - > 4 files changed, 1 insertion(+), 3 deletions(-) > > diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c > index 2ce1063d4a..73e6416ee9 100644 > --- a/net/vmw_vsock/af_vsock.c > +++ b/net/vmw_vsock/af_vsock.c > @@ -507,6 +507,7 @@ void vsock_enqueue_accept(struct sock *listener, struct sock *connected) > sock_hold(connected); > sock_hold(listener); > list_add_tail(&vconnected->accept_queue, &vlistener->accept_queue); > + sk_acceptq_added(listener); > } > EXPORT_SYMBOL_GPL(vsock_enqueue_accept); > > diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c > index b3394946b2..0de8148877 100644 > --- a/net/vmw_vsock/hyperv_transport.c > +++ b/net/vmw_vsock/hyperv_transport.c > @@ -410,7 +410,6 @@ static void hvs_open_connection(struct vmbus_channel *chan) > > if (conn_from_host) { > new->sk_state = TCP_ESTABLISHED; > - sk_acceptq_added(sk); > > hvs_new->vm_srv_id = *if_type; > hvs_new->host_srv_id = *if_instance; > diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c > index b10666937c..4a39d48db9 100644 > --- a/net/vmw_vsock/virtio_transport_common.c > +++ b/net/vmw_vsock/virtio_transport_common.c > @@ -1582,7 +1582,6 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb, > return ret; > } > > - sk_acceptq_added(sk); > if (virtio_transport_space_update(child, skb)) > child->sk_write_space(child); > > diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c > index 91516488a7..4ce6660c11 100644 > --- a/net/vmw_vsock/vmci_transport.c > +++ b/net/vmw_vsock/vmci_transport.c > @@ -1109,7 +1109,6 @@ static int vmci_transport_recv_listen(struct sock *sk, > } > > vsock_add_pending(sk, pending); > - sk_acceptq_added(sk); It looks like vmci might be an odd duck here, where sk_acceptq_added actually pairs with vsock_add_pending(), instead of vsock_enqueue_accept()... For example, if the pending work timer below fires, vsock_pending_work() will see vsock_is_pending() is true, and then hit sk_acceptq_removed() and underflow the zero backlog counter? Best, Bobby ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 1/2] vsock: fold sk_acceptq_added() into vsock_enqueue_accept() 2026-06-10 23:12 ` Bobby Eshleman @ 2026-06-11 1:43 ` Raf Dickson 0 siblings, 0 replies; 5+ messages in thread From: Raf Dickson @ 2026-06-11 1:43 UTC (permalink / raw) To: bobbyeshleman Cc: netdev, virtualization, pabeni, sgarzare, stefanha, bryan-bt.tan, vishnu.dasa, bcm-kernel-feedback-list On Wed, Jun 10, 2026 at 16:12:37 -0700, Bobby Eshleman wrote: > It looks like vmci might be an odd duck here, where sk_acceptq_added > actually pairs with vsock_add_pending(), instead of > vsock_enqueue_accept()... > > For example, if the pending work timer below fires, vsock_pending_work() > will see vsock_is_pending() is true, and then hit sk_acceptq_removed() > and underflow the zero backlog counter? You're right, thank you for catching that. In vmci sk_acceptq_added() pairs with vsock_add_pending(), not vsock_enqueue_accept(), so moving it would cause an underflow when the pending work timer fires without a successful connection. Patch 2/2 is unaffected. I'll send a v2 that keeps the vmci call site as-is and only folds the virtio and hyperv sites into vsock_enqueue_accept(). Raf ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next 2/2] vsock: fold sk_acceptq_removed() into vsock_remove_pending() 2026-06-10 9:11 [PATCH net-next 0/2] vsock: fold acceptq accounting into core helpers Raf Dickson 2026-06-10 9:11 ` [PATCH net-next 1/2] vsock: fold sk_acceptq_added() into vsock_enqueue_accept() Raf Dickson @ 2026-06-10 9:11 ` Raf Dickson 1 sibling, 0 replies; 5+ messages in thread From: Raf Dickson @ 2026-06-10 9:11 UTC (permalink / raw) To: netdev, virtualization Cc: pabeni, sgarzare, stefanha, bryan-bt.tan, vishnu.dasa, bcm-kernel-feedback-list, Raf Dickson Callers of vsock_remove_pending() must also call sk_acceptq_removed() to keep sk_ack_backlog consistent. Move the call into vsock_remove_pending() itself to make it automatic and prevent future callers from forgetting it. Suggested-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Raf Dickson <rafdog35@gmail.com> --- net/vmw_vsock/af_vsock.c | 3 +-- net/vmw_vsock/vmci_transport.c | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 73e6416ee9..b9772a0205 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -493,6 +493,7 @@ void vsock_remove_pending(struct sock *listener, struct sock *pending) list_del_init(&vpending->pending_links); sock_put(listener); sock_put(pending); + sk_acceptq_removed(listener); } EXPORT_SYMBOL_GPL(vsock_remove_pending); @@ -761,8 +762,6 @@ static void vsock_pending_work(struct work_struct *work) if (vsock_is_pending(sk)) { vsock_remove_pending(listener, sk); - - sk_acceptq_removed(listener); } else if (!vsk->rejected) { /* We are not on the pending list and accept() did not reject * us, so we must have been accepted by our user process. We diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c index 4ce6660c11..356bebca7c 100644 --- a/net/vmw_vsock/vmci_transport.c +++ b/net/vmw_vsock/vmci_transport.c @@ -980,11 +980,8 @@ static int vmci_transport_recv_listen(struct sock *sk, err = -EINVAL; } - if (err < 0) { + if (err < 0) vsock_remove_pending(sk, pending); - sk_acceptq_removed(sk); - } - release_sock(pending); vmci_transport_release_pending(pending); -- 2.54.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-11 1:43 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-06-10 9:11 [PATCH net-next 0/2] vsock: fold acceptq accounting into core helpers Raf Dickson 2026-06-10 9:11 ` [PATCH net-next 1/2] vsock: fold sk_acceptq_added() into vsock_enqueue_accept() Raf Dickson 2026-06-10 23:12 ` Bobby Eshleman 2026-06-11 1:43 ` Raf Dickson 2026-06-10 9:11 ` [PATCH net-next 2/2] vsock: fold sk_acceptq_removed() into vsock_remove_pending() Raf Dickson
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.