From: Oliver Kurth Date: Fri, 15 Sep 2017 18:22:59 +0000 (-0700) Subject: Extend AsyncSocket code to handle a "network unreachable" error on a Linux X-Git-Tag: stable-10.2.0~581 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=58c1585e5aa76dde81e578444bc769caa4cb00bd;p=thirdparty%2Fopen-vm-tools.git Extend AsyncSocket code to handle a "network unreachable" error on a Linux connect() system call. modified: lib/asyncsocket/asyncSocketInt.h, lib/asyncsocket/asyncWebSocket.c, lib/asyncsocket/asyncsocket.c, lib/include/asyncsocket.h, Changes to common header files; not applicable to open-vm-tools. Reorder the includes in services/plugins/dndcp/xutils/xutils.cc to build with Gtk+ 3.x at a later date. --- diff --git a/open-vm-tools/lib/asyncsocket/asyncSocketInt.h b/open-vm-tools/lib/asyncsocket/asyncSocketInt.h index 7567c72d5..e6015edf2 100644 --- a/open-vm-tools/lib/asyncsocket/asyncSocketInt.h +++ b/open-vm-tools/lib/asyncsocket/asyncSocketInt.h @@ -99,6 +99,7 @@ #define ASOCK_EADDRINUSE WSAEADDRINUSE #define ASOCK_ECONNECTING WSAEWOULDBLOCK #define ASOCK_EWOULDBLOCK WSAEWOULDBLOCK +#define ASOCK_ENETUNREACH WSAENETUNREACH #else #define ASOCK_LASTERROR() errno #define ASOCK_ENOTCONN ENOTCONN @@ -106,6 +107,7 @@ #define ASOCK_EADDRINUSE EADDRINUSE #define ASOCK_ECONNECTING EINPROGRESS #define ASOCK_EWOULDBLOCK EWOULDBLOCK +#define ASOCK_ENETUNREACH ENETUNREACH #endif #define WEBSOCKET_HTTP_BUFFER_SIZE 8192 @@ -473,6 +475,16 @@ AsyncSocket *AsyncSocketListenerCreate(const char *addrStr, Bool webSockUseSSL, const char *protocols[], int *outError); +AsyncSocket *AsyncSocketListenerCreateImpl(const char *addrStr, + unsigned int port, + int socketFamily, + AsyncSocketConnectFn connectFn, + void *clientData, + AsyncSocketPollParams *pollParams, + Bool isWebSock, + Bool webSockUseSSL, + const char *protocols[], + int *outError); AsyncSocketState AsyncSocketGetState(AsyncSocket *sock); int AsyncSocketGetGenericErrno(AsyncSocket *s); diff --git a/open-vm-tools/lib/asyncsocket/asyncsocket.c b/open-vm-tools/lib/asyncsocket/asyncsocket.c index afbaa35bd..1a7853180 100644 --- a/open-vm-tools/lib/asyncsocket/asyncsocket.c +++ b/open-vm-tools/lib/asyncsocket/asyncsocket.c @@ -418,6 +418,12 @@ AsyncSocket_MsgError(int asyncSockError) // IN case ASOCKERR_CONNECTSSL: result = MSGID(asyncsocket.connectssl) "Connection error: could not negotiate SSL"; break; + case ASOCKERR_NETUNREACH: + result = MSGID(asyncsocket.netunreach) "Network unreachable"; + break; + case ASOCKERR_ADDRUNRESV: + result = MSGID(asyncsocket.addrunresv) "Address unresolvable"; + break; } if (!result) { @@ -1986,7 +1992,13 @@ AsyncSocketConnectWithAsock(AsyncSocket *asock, sysErr = ASOCK_LASTERROR(); Log(ASOCKPREFIX "connect failed, error %d: %s\n", sysErr, Err_Errno2String(sysErr)); - error = ASOCKERR_CONNECT; + + /* + * If "network unreachable" error happens, explicitly propogate + * the error to trigger the reconnection if possible. + */ + error = (sysErr == ASOCK_ENETUNREACH) ? ASOCKERR_NETUNREACH : + ASOCKERR_CONNECT; goto errorHaveAsock; } } else { diff --git a/open-vm-tools/lib/include/asyncsocket.h b/open-vm-tools/lib/include/asyncsocket.h index 059379fed..07bf8a75a 100644 --- a/open-vm-tools/lib/include/asyncsocket.h +++ b/open-vm-tools/lib/include/asyncsocket.h @@ -70,6 +70,8 @@ #define ASOCKERR_BINDADDRINUSE 11 #define ASOCKERR_LISTEN 12 #define ASOCKERR_CONNECTSSL 13 +#define ASOCKERR_NETUNREACH 14 +#define ASOCKERR_ADDRUNRESV 15 /* @@ -242,6 +244,18 @@ AsyncSocket *AsyncSocket_ListenWebSocket(const char *addrStr, void *clientData, AsyncSocketPollParams *pollParams, int *outError); +/* + * Listen on port and fire callback with new asock + * NOTE - Do not use this API. + * Listens on 127.0.0.1:port and does not use SSL. + * This API will be deprecated soon. + */ +AsyncSocket *AsyncSocket_ListenWebSocketNoHttp(unsigned int port, + const char *protocols[], + AsyncSocketConnectFn connectFn, + void *clientData, + AsyncSocketPollParams *pollParams, + int *outError); #ifndef _WIN32 AsyncSocket *AsyncSocket_ListenWebSocketUDS(const char *pipeName, Bool useSSL, diff --git a/open-vm-tools/lib/include/vm_product_versions.h b/open-vm-tools/lib/include/vm_product_versions.h index 76cd8817a..214901438 100644 --- a/open-vm-tools/lib/include/vm_product_versions.h +++ b/open-vm-tools/lib/include/vm_product_versions.h @@ -39,7 +39,7 @@ #if defined(VMX86_VIEWCLIENT) #define PRODUCT_VERSION 4,1,0,PRODUCT_BUILD_NUMBER_NUMERIC #elif defined(VMX86_VMRC) /* check VMX86_VMRC before VMX86_DESKTOP */ - #define PRODUCT_VERSION 8,0,0,PRODUCT_BUILD_NUMBER_NUMERIC /* VMRC_VERSION_NUMBER below has to match this */ + #define PRODUCT_VERSION 8,1,0,PRODUCT_BUILD_NUMBER_NUMERIC /* VMRC_VERSION_NUMBER below has to match this */ #elif defined(VMX86_FLEX) /* check VMX86_FLEX before VMX86_DESKTOP */ #define PRODUCT_VERSION 8,0,0,PRODUCT_BUILD_NUMBER_NUMERIC /* FLEX_VERSION_NUMBER below has to match this */ #elif defined(VMX86_TOOLS) @@ -164,8 +164,8 @@ #define WORKSTATION_VERSION "e.x.p" #define PLAYER_VERSION_NUMBER "12.0.0" /* this version number should always match real Player version number */ #define PLAYER_VERSION "e.x.p" -#define VMRC_VERSION_NUMBER "8.0.0" /* this version number should always match real VMRC version number */ -#define VMRC_VERSION "8.0.0" +#define VMRC_VERSION_NUMBER "8.1.0" /* this version number should always match real VMRC version number */ +#define VMRC_VERSION "8.1.0" #define FLEX_CLIENT_VERSION_NUMBER "8.0.0" #define FLEX_CLIENT_VERSION "e.x.p" @@ -358,7 +358,7 @@ */ #define PRODUCT_MAC_DESKTOP_VERSION_STRING_FOR_LICENSE "8.0" #define PRODUCT_PLAYER_VERSION_STRING_FOR_LICENSE "12.0" -#define PRODUCT_VMRC_VERSION_STRING_FOR_LICENSE "8.0" +#define PRODUCT_VMRC_VERSION_STRING_FOR_LICENSE "8.1" #define PRODUCT_FLEX_VERSION_STRING_FOR_LICENSE "8.0" #if defined(VMX86_TOOLS) diff --git a/open-vm-tools/modules/shared/vmxnet/vmxnet3_defs.h b/open-vm-tools/modules/shared/vmxnet/vmxnet3_defs.h index 886006271..f6327c1de 100644 --- a/open-vm-tools/modules/shared/vmxnet/vmxnet3_defs.h +++ b/open-vm-tools/modules/shared/vmxnet/vmxnet3_defs.h @@ -136,7 +136,8 @@ typedef enum { VMXNET3_CMD_GET_DEV_EXTRA_INFO, VMXNET3_CMD_GET_CONF_INTR, VMXNET3_CMD_GET_ADAPTIVE_RING_INFO, - VMXNET3_CMD_GET_TXDATA_DESC_SIZE + VMXNET3_CMD_GET_TXDATA_DESC_SIZE, + VMXNET3_CMD_GET_COALESCE } Vmxnet3_Cmd; /* Adaptive Ring Info Flags */ @@ -615,11 +616,10 @@ enum vmxnet3_intr_type { #define VMXNET3_COAL_RBC_MAX_RATE 100000 enum Vmxnet3_CoalesceMode { - VMXNET3_COALESCE_DEFAULT = 0, - VMXNET3_COALESCE_DISABLED = 1, - VMXNET3_COALESCE_ADAPT = 2, - VMXNET3_COALESCE_STATIC = 3, - VMXNET3_COALESCE_RBC = 4 + VMXNET3_COALESCE_DISABLED = 0, + VMXNET3_COALESCE_ADAPT = 1, + VMXNET3_COALESCE_STATIC = 2, + VMXNET3_COALESCE_RBC = 3 }; typedef diff --git a/open-vm-tools/services/plugins/dndcp/xutils/xutils.cc b/open-vm-tools/services/plugins/dndcp/xutils/xutils.cc index 7915ecd9d..cc9d95c87 100644 --- a/open-vm-tools/services/plugins/dndcp/xutils/xutils.cc +++ b/open-vm-tools/services/plugins/dndcp/xutils/xutils.cc @@ -19,12 +19,13 @@ #include #include + +#include "xutils/xutils.hh" + #if GTK_MAJOR_VERSION == 3 #include #endif -#include "xutils/xutils.hh" - /* These must be after the gtkmm includes, as gtkmm is quite picky. */ #include #include