Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147176838
D25062.id77873.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D25062.id77873.diff
View Options
Index: sys/dev/hyperv/hvsock/hv_sock.c
===================================================================
--- sys/dev/hyperv/hvsock/hv_sock.c
+++ sys/dev/hyperv/hvsock/hv_sock.c
@@ -74,6 +74,8 @@
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 */
#define HVSOCK_MTU_SIZE (1024 * 16)
#define HVSOCK_SEND_BUF_SZ (PAGE_SIZE - sizeof(struct vmpipe_proto_header))
@@ -124,6 +126,7 @@
static struct domain hv_socket_domain = {
.dom_family = AF_HYPERV,
.dom_name = "hyperv",
+ .dom_probe = hvs_dom_probe,
.dom_protosw = hv_socket_protosw,
.dom_protoswNPROTOSW = &hv_socket_protosw[nitems(hv_socket_protosw)]
};
@@ -322,6 +325,16 @@
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
hvs_trans_init(void)
{
@@ -329,9 +342,6 @@
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__);
@@ -354,9 +364,6 @@
{
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__);
@@ -383,9 +390,6 @@
{
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__);
@@ -595,9 +599,6 @@
{
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__);
@@ -925,9 +926,6 @@
{
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__);
@@ -969,9 +967,6 @@
{
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__);
Index: sys/kern/uipc_domain.c
===================================================================
--- sys/kern/uipc_domain.c
+++ sys/kern/uipc_domain.c
@@ -172,7 +172,11 @@
{
struct domain *dp = arg;
struct protosw *pr;
+ int flags;
+ flags = atomic_load_acq_int(&dp->dom_flags);
+ if ((flags & DOMF_SUPPORTED) == 0)
+ return;
if (dp->dom_init)
(*dp->dom_init)();
for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
@@ -200,6 +204,8 @@
{
struct domain *dp = arg;
+ if ((atomic_load_acq_int(&dp->dom_flags) & DOMF_SUPPORTED) == 0)
+ return;
if (dp->dom_destroy)
(*dp->dom_destroy)();
}
@@ -216,6 +222,9 @@
struct domain *dp;
dp = (struct domain *)data;
+ if (dp->dom_probe != NULL && (*dp->dom_probe)() != 0)
+ return;
+ atomic_set_rel_int(&dp->dom_flags, DOMF_SUPPORTED);
mtx_lock(&dom_mtx);
dp->dom_next = domains;
domains = dp;
Index: sys/sys/domain.h
===================================================================
--- sys/sys/domain.h
+++ sys/sys/domain.h
@@ -50,8 +50,10 @@
struct domain {
int dom_family; /* AF_xxx */
char *dom_name;
+ int dom_flags;
void (*dom_init) /* initialize domain data structures */
(void);
+ int (*dom_probe)(void); /* check for support (optional) */
void (*dom_destroy) /* cleanup structures / state */
(void);
int (*dom_externalize) /* externalize access rights */
@@ -70,6 +72,9 @@
/* af-dependent data on ifnet */
};
+/* dom_flags */
+#define DOMF_SUPPORTED 0x0001 /* System supports this domain. */
+
#ifdef _KERNEL
extern int domain_init_status;
extern struct domain *domains;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 9, 9:09 PM (11 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29457682
Default Alt Text
D25062.id77873.diff (3 KB)
Attached To
Mode
D25062: domain: give domains a chance to probe for availability
Attached
Detach File
Event Timeline
Log In to Comment