Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 May 2020 10:51:22 -0500
From:      Kyle Evans <kevans@freebsd.org>
To:        Wei Hu <whu@freebsd.org>
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>,  svn-src-head <svn-src-head@freebsd.org>
Subject:   Re: svn commit: r361360 - head/sys/dev/hyperv/hvsock
Message-ID:  <CACNAnaFGeHXOJUr2mCAYt7pP0bo49p%2BM0w_W0QfNthj-vX0tPQ@mail.gmail.com>
In-Reply-To: <202005220917.04M9H7oE028708@repo.freebsd.org>
References:  <202005220917.04M9H7oE028708@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, May 22, 2020 at 4:17 AM Wei Hu <whu@freebsd.org> wrote:
>
> Author: whu
> Date: Fri May 22 09:17:07 2020
> New Revision: 361360
> URL: https://svnweb.freebsd.org/changeset/base/361360
>
> Log:
>   Socket AF_HYPERV should return failure when it is not running on HyperV
>
> [... snip ...]
> @@ -354,6 +354,9 @@ hvs_trans_attach(struct socket *so, int proto, struct
>  {
>         struct hvs_pcb *pcb = so2hvspcb(so);
>
> +       if (vm_guest != VM_GUEST_HV)
> +               return (ESOCKTNOSUPPORT);
> +
>         HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
>             "%s: HyperV Socket hvs_trans_attach called\n", __func__);
>

This one may be OK, but none of these other methods should be able to
be invoked if the attach failed. See this comment at around
^/sys/kern/uipc_socket.c#50:

50 * pru_detach() disassociates protocol layer state from an attached socket,
51 * and will be called exactly once for sockets in which pru_attach() has
52 * been successfully called.  If pru_attach() returned an error,
53 * pru_detach() will not be called.  Socket layer private.

That said, I wonder if VNET_DOMAIN_SET provides the correct semantics
here at all. You can't fail domain_init, but I don't think there's any
value in this domain actually getting registered on non-HyperV guests,
a fact which presumably won't change at runtime.

I have some concerns about how hvsock works out with vnets, but I'll
drop those on the initial commit thread.

Thanks,

Kyle Evans



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACNAnaFGeHXOJUr2mCAYt7pP0bo49p%2BM0w_W0QfNthj-vX0tPQ>