🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by Michal Luczaj Tue, 01 Dec 2026 16:19
Re: [PATCH net-next v8 4/7] vsock: add a netlink command to assign the g2h device to a netns
#25360
Author: Michal Luczaj
Date: Tue, 01 Dec 2026 16:19
85 lines
11684 bytes
On 12/1/26 02:06, Bobby Eshleman wrote:
> +/* Reset @sk if it can no longer reach the g2h device, as an unplug of the
> + * device does (see virtio_vsock_reset_sock()).
> + */
> +static void vsock_g2h_reset_unreachable_sk(struct sock *sk)
> +{
> +	if (sk->sk_state == TCP_CLOSE || vsock_g2h_reachable_sk(vsock_sk(sk)))
> +		return;
> +
> +	sk->sk_state = TCP_CLOSE;
> +	sk->sk_err = ECONNRESET;
> +	sk_error_report(sk);
> +}

...

> +/* Move the g2h device to @net, which keeps @net alive until the device leaves
> + * again. Returns -ENODEV if no g2h transport is loaded, -EOPNOTSUPP if the
> + * loaded one cannot be moved, and -EADDRINUSE if a guest in @net already uses
> + * the device's CID.
> + */
> +static int vsock_g2h_net_assign(struct net *net, struct sk_buff *msg,
> +				struct genl_info *info)
> +{
> +	struct netlink_ext_ack *extack = info->extack;
> +	netns_tracker old_tracker;
> +	struct net *old;
> +	int ret;
> +
> +	mutex_lock(&vsock_register_mutex);
> +
> +	ret = -ENODEV;
> +	if (!transport_g2h) {
> +		NL_SET_ERR_MSG(extack, "no guest-to-host transport is loaded");
> +		goto unlock;
> +	}
> +
> +	ret = -EOPNOTSUPP;
> +	if (!vsock_net_assignable(transport_g2h)) {
> +		NL_SET_ERR_MSG(extack,
> +			       "the loaded guest-to-host transport does not support namespace assignment");
> +		goto unlock;
> +	}
> +
> +	if (transport_h2g && !transport_h2g->has_remote_cid) {
> +		NL_SET_ERR_MSG(extack,
> +			       "the loaded host-to-guest transport cannot check the device's CID");
> +		goto unlock;
> +	}
> +
> +	ret = -EADDRINUSE;
> +	if (transport_h2g &&
> +	    transport_h2g->has_remote_cid(net,
> +					  transport_g2h->get_local_cid())) {
> +		NL_SET_ERR_MSG(extack,
> +			       "a guest in the target namespace already uses the device's CID");
> +		goto unlock;
> +	}
> +
> +	ret = vsock_nl_dev_netns_fill(msg, info, net);
> +	if (ret)
> +		goto unlock;
> +
> +	ret = genlmsg_reply(msg, info);
> +	msg = NULL;
> +	if (ret)
> +		goto unlock;
> +
> +	old = vsock_g2h_net_swap(net, &old_tracker);
> +
> +	/* See vsock_maybe_set_connected() comment about synchronizing with
> +	 * connecting sockets.
> +	 */
> +	vsock_for_each_connected_socket(transport_g2h,
> +					vsock_g2h_reset_unreachable_sk);
> +

Are you sure a lockless (sk_lock-wise) reset is the right approach? I was
hoping we could "reuse" vsock_g2h_reset_unreachable() from v7 to finally
fix all those lockless transport resets. With this version, instead, we're
introducing more lockless socket state writes.

thanks,
Michal
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads