hvsock: fail the probe on non-HyperV machines
Differential Revision: https://reviews.freebsd.org/D25459
This commit is contained in:
parent
239aebee61
commit
625932c9aa
@ -74,6 +74,8 @@ SYSCTL_INT(_net_hvsock, OID_AUTO, hvs_dbg_level, CTLFLAG_RWTUN, &hvs_dbg_level,
|
|||||||
|
|
||||||
MALLOC_DEFINE(M_HVSOCK, "hyperv_socket", "hyperv socket control structures");
|
MALLOC_DEFINE(M_HVSOCK, "hyperv_socket", "hyperv socket control structures");
|
||||||
|
|
||||||
|
static int hvs_dom_probe(void);
|
||||||
|
|
||||||
/* The MTU is 16KB per host side's design */
|
/* The MTU is 16KB per host side's design */
|
||||||
#define HVSOCK_MTU_SIZE (1024 * 16)
|
#define HVSOCK_MTU_SIZE (1024 * 16)
|
||||||
#define HVSOCK_SEND_BUF_SZ (PAGE_SIZE - sizeof(struct vmpipe_proto_header))
|
#define HVSOCK_SEND_BUF_SZ (PAGE_SIZE - sizeof(struct vmpipe_proto_header))
|
||||||
@ -124,6 +126,7 @@ static struct protosw hv_socket_protosw[] = {
|
|||||||
static struct domain hv_socket_domain = {
|
static struct domain hv_socket_domain = {
|
||||||
.dom_family = AF_HYPERV,
|
.dom_family = AF_HYPERV,
|
||||||
.dom_name = "hyperv",
|
.dom_name = "hyperv",
|
||||||
|
.dom_probe = hvs_dom_probe,
|
||||||
.dom_protosw = hv_socket_protosw,
|
.dom_protosw = hv_socket_protosw,
|
||||||
.dom_protoswNPROTOSW = &hv_socket_protosw[nitems(hv_socket_protosw)]
|
.dom_protoswNPROTOSW = &hv_socket_protosw[nitems(hv_socket_protosw)]
|
||||||
};
|
};
|
||||||
@ -323,6 +326,16 @@ hvs_trans_unlock(void)
|
|||||||
sx_xunlock(&hvs_trans_socks_sx);
|
sx_xunlock(&hvs_trans_socks_sx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
hvs_dom_probe(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* Don't even give us a chance to attach on non-HyperV. */
|
||||||
|
if (vm_guest != VM_GUEST_HV)
|
||||||
|
return (ENXIO);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
hvs_trans_init(void)
|
hvs_trans_init(void)
|
||||||
{
|
{
|
||||||
@ -330,9 +343,6 @@ hvs_trans_init(void)
|
|||||||
if (!IS_DEFAULT_VNET(curvnet))
|
if (!IS_DEFAULT_VNET(curvnet))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (vm_guest != VM_GUEST_HV)
|
|
||||||
return;
|
|
||||||
|
|
||||||
HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
|
HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
|
||||||
"%s: HyperV Socket hvs_trans_init called\n", __func__);
|
"%s: HyperV Socket hvs_trans_init called\n", __func__);
|
||||||
|
|
||||||
@ -355,9 +365,6 @@ hvs_trans_attach(struct socket *so, int proto, struct thread *td)
|
|||||||
{
|
{
|
||||||
struct hvs_pcb *pcb = so2hvspcb(so);
|
struct hvs_pcb *pcb = so2hvspcb(so);
|
||||||
|
|
||||||
if (vm_guest != VM_GUEST_HV)
|
|
||||||
return (ESOCKTNOSUPPORT);
|
|
||||||
|
|
||||||
HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
|
HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
|
||||||
"%s: HyperV Socket hvs_trans_attach called\n", __func__);
|
"%s: HyperV Socket hvs_trans_attach called\n", __func__);
|
||||||
|
|
||||||
@ -384,9 +391,6 @@ hvs_trans_detach(struct socket *so)
|
|||||||
{
|
{
|
||||||
struct hvs_pcb *pcb;
|
struct hvs_pcb *pcb;
|
||||||
|
|
||||||
if (vm_guest != VM_GUEST_HV)
|
|
||||||
return;
|
|
||||||
|
|
||||||
HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
|
HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
|
||||||
"%s: HyperV Socket hvs_trans_detach called\n", __func__);
|
"%s: HyperV Socket hvs_trans_detach called\n", __func__);
|
||||||
|
|
||||||
@ -604,9 +608,6 @@ hvs_trans_disconnect(struct socket *so)
|
|||||||
{
|
{
|
||||||
struct hvs_pcb *pcb;
|
struct hvs_pcb *pcb;
|
||||||
|
|
||||||
if (vm_guest != VM_GUEST_HV)
|
|
||||||
return (ESOCKTNOSUPPORT);
|
|
||||||
|
|
||||||
HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
|
HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
|
||||||
"%s: HyperV Socket hvs_trans_disconnect called\n", __func__);
|
"%s: HyperV Socket hvs_trans_disconnect called\n", __func__);
|
||||||
|
|
||||||
@ -934,9 +935,6 @@ hvs_trans_close(struct socket *so)
|
|||||||
{
|
{
|
||||||
struct hvs_pcb *pcb;
|
struct hvs_pcb *pcb;
|
||||||
|
|
||||||
if (vm_guest != VM_GUEST_HV)
|
|
||||||
return;
|
|
||||||
|
|
||||||
HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
|
HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
|
||||||
"%s: HyperV Socket hvs_trans_close called\n", __func__);
|
"%s: HyperV Socket hvs_trans_close called\n", __func__);
|
||||||
|
|
||||||
@ -978,9 +976,6 @@ hvs_trans_abort(struct socket *so)
|
|||||||
{
|
{
|
||||||
struct hvs_pcb *pcb = so2hvspcb(so);
|
struct hvs_pcb *pcb = so2hvspcb(so);
|
||||||
|
|
||||||
if (vm_guest != VM_GUEST_HV)
|
|
||||||
return;
|
|
||||||
|
|
||||||
HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
|
HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
|
||||||
"%s: HyperV Socket hvs_trans_abort called\n", __func__);
|
"%s: HyperV Socket hvs_trans_abort called\n", __func__);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user