Skip to content

gh-92658: AF_HYPERV is only supported on Windows #93192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1582,7 +1582,7 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
}
#endif /* HAVE_SOCKADDR_ALG */

#ifdef AF_HYPERV
#ifdef HAVE_AF_HYPERV
case AF_HYPERV:
{
SOCKADDR_HV *a = (SOCKADDR_HV *) addr;
Expand Down Expand Up @@ -2407,7 +2407,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
return 1;
}
#endif /* HAVE_SOCKADDR_ALG */
#ifdef AF_HYPERV
#ifdef HAVE_AF_HYPERV
case AF_HYPERV:
{
switch (s->sock_proto) {
Expand Down Expand Up @@ -2476,7 +2476,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
return 0;
}
}
#endif /* AF_HYPERV */
#endif /* HAVE_AF_HYPERV */

/* More cases here... */

Expand Down Expand Up @@ -2626,13 +2626,13 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
return 1;
}
#endif /* HAVE_SOCKADDR_ALG */
#ifdef AF_HYPERV
#ifdef HAVE_AF_HYPERV
case AF_HYPERV:
{
*len_ret = sizeof (SOCKADDR_HV);
return 1;
}
#endif /* AF_HYPERV */
#endif /* HAVE_AF_HYPERV */

/* More cases here... */

Expand Down Expand Up @@ -7460,7 +7460,7 @@ PyInit__socket(void)
/* Linux LLC */
PyModule_AddIntMacro(m, AF_LLC);
#endif
#ifdef AF_HYPERV
#ifdef HAVE_AF_HYPERV
/* Hyper-V sockets */
PyModule_AddIntMacro(m, AF_HYPERV);

Expand All @@ -7481,7 +7481,7 @@ PyInit__socket(void)
PyModule_AddStringConstant(m, "HV_GUID_CHILDREN", "90DB8B89-0D35-4F79-8CE9-49EA0AC8B7CD");
PyModule_AddStringConstant(m, "HV_GUID_LOOPBACK", "E0E16197-DD56-4A10-9195-5EE7A155A838");
PyModule_AddStringConstant(m, "HV_GUID_PARENT", "A42E7CDA-D03F-480C-9CC2-A4DE20ABB878");
#endif /* AF_HYPERV */
#endif /* HAVE_AF_HYPERV */

#ifdef USE_BLUETOOTH
PyModule_AddIntMacro(m, AF_BLUETOOTH);
Expand Down
7 changes: 6 additions & 1 deletion Modules/socketmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ typedef int SOCKET_T;
#define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLongLong(fd)
#endif

// AF_HYPERV is only supported on Windows
#if defined(AF_HYPERV) && defined(MS_WINDOWS)
# define HAVE_AF_HYPERV
#endif

/* Socket address */
typedef union sock_addr {
struct sockaddr_in in;
Expand Down Expand Up @@ -297,7 +302,7 @@ typedef union sock_addr {
#ifdef HAVE_LINUX_TIPC_H
struct sockaddr_tipc tipc;
#endif
#ifdef AF_HYPERV
#ifdef HAVE_AF_HYPERV
SOCKADDR_HV hv;
#endif
} sock_addr_t;
Expand Down