svn commit: r361275 - in head/sys: conf dev/hyperv/hvsock dev/hyperv/include dev/hyperv/vmbus modules/hyperv modules/hyperv/hvsock sys

Kyle Evans kevans at freebsd.org
Fri May 22 16:12:35 UTC 2020


On Wed, May 20, 2020 at 6:04 AM Wei Hu <whu at freebsd.org> wrote:
>
> Author: whu
> Date: Wed May 20 11:03:59 2020
> New Revision: 361275
> URL: https://svnweb.freebsd.org/changeset/base/361275
>
> Log:
>   HyperV socket implementation for FreeBSD
>
>   This change adds Hyper-V socket feature in FreeBSD. New socket address
>   family AF_HYPERV and its kernel support are added.
>
> [... snip ...]
> +void
> +hvs_trans_init(void)
> +{
> +       /* Skip initialization of globals for non-default instances. */
> +       if (!IS_DEFAULT_VNET(curvnet))
> +               return;
> +
> +       if (vm_guest != VM_GUEST_HV)
> +               return;
> +
> +       HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
> +           "%s: HyperV Socket hvs_trans_init called\n", __func__);
> +
> +       /* Initialize Globals */
> +       previous_auto_bound_port = MAX_PORT;
> +       sx_init(&hvs_trans_socks_sx, "hvs_trans_sock_sx");
> +       mtx_init(&hvs_trans_socks_mtx,
> +           "hvs_trans_socks_mtx", NULL, MTX_DEF);
> +       LIST_INIT(&hvs_trans_bound_socks);
> +       LIST_INIT(&hvs_trans_connected_socks);
> +}
> +

I have a suspicion that all of these should really be per-vnet for
correct semantics with VIMAGE, with the IS_DEFAULT_VNET check earlier
dropped completely. I haven't read around the rest all that much, but
this would at least seem to prevent port re-use by a different vnet,
which is perhaps "good enough" but I think this is something that
should be fixed in the mid-term.

Thanks,

Kyle Evans


More information about the svn-src-all mailing list