Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 May 2020 09:17:07 +0000 (UTC)
From:      Wei Hu <whu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r361360 - head/sys/dev/hyperv/hvsock
Message-ID:  <202005220917.04M9H7oE028708@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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
  
  Reported by:	pho
  Sponsored by:	Microsoft

Modified:
  head/sys/dev/hyperv/hvsock/hv_sock.c

Modified: head/sys/dev/hyperv/hvsock/hv_sock.c
==============================================================================
--- head/sys/dev/hyperv/hvsock/hv_sock.c	Fri May 22 09:02:40 2020	(r361359)
+++ head/sys/dev/hyperv/hvsock/hv_sock.c	Fri May 22 09:17:07 2020	(r361360)
@@ -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__);
 
@@ -380,6 +383,9 @@ hvs_trans_detach(struct socket *so)
 {
 	struct hvs_pcb *pcb;
 
+	if (vm_guest != VM_GUEST_HV)
+		return;
+
 	HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
 	    "%s: HyperV Socket hvs_trans_detach called\n", __func__);
 
@@ -589,6 +595,9 @@ hvs_trans_disconnect(struct socket *so)
 {
 	struct hvs_pcb *pcb;
 
+	if (vm_guest != VM_GUEST_HV)
+		return (ESOCKTNOSUPPORT);
+
 	HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
 	    "%s: HyperV Socket hvs_trans_disconnect called\n", __func__);
 
@@ -916,6 +925,9 @@ hvs_trans_close(struct socket *so)
 {
 	struct hvs_pcb *pcb;
 
+	if (vm_guest != VM_GUEST_HV)
+		return;
+
 	HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
 	    "%s: HyperV Socket hvs_trans_close called\n", __func__);
 
@@ -956,6 +968,9 @@ void
 hvs_trans_abort(struct socket *so)
 {
 	struct hvs_pcb *pcb = so2hvspcb(so);
+
+	if (vm_guest != VM_GUEST_HV)
+		return;
 
 	HVSOCK_DBG(HVSOCK_DBG_VERBOSE,
 	    "%s: HyperV Socket hvs_trans_abort called\n", __func__);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005220917.04M9H7oE028708>