ESX supports unix sockets, but they don't manifest themselves in file system like they do on Linux. Instead of using stat to check if a unix socket exist, this patch simply tries to open it instead.
Signed-off-by: Ethan Jackson <et...@nicira.com> --- lib/stream-unix.c | 1 - utilities/ovs-ofctl.c | 40 +++++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/stream-unix.c b/lib/stream-unix.c index 4feefdf..d5534b2 100644 --- a/lib/stream-unix.c +++ b/lib/stream-unix.c @@ -48,7 +48,6 @@ unix_open(const char *name, char *suffix, struct stream **streamp, fd = make_unix_socket(SOCK_STREAM, true, NULL, connect_path); if (fd < 0) { - VLOG_WARN("%s: connection failed (%s)", connect_path, strerror(-fd)); return -fd; } diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 08c3aa9..363c0a3 100644 --- a/utilities/ovs-ofctl.c +++ b/utilities/ovs-ofctl.c @@ -52,6 +52,7 @@ #include "poll-loop.h" #include "random.h" #include "stream-ssl.h" +#include "socket-util.h" #include "timeval.h" #include "unixctl.h" #include "util.h" @@ -332,14 +333,20 @@ run(int retval, const char *message, ...) /* Generic commands. */ -static void +static int open_vconn_socket(const char *name, struct vconn **vconnp) { char *vconn_name = xasprintf("unix:%s", name); - VLOG_DBG("connecting to %s", vconn_name); - run(vconn_open_block(vconn_name, 0, vconnp), - "connecting to %s", vconn_name); + int error; + + error = vconn_open(vconn_name, 0, vconnp, DSCP_DEFAULT); + if (error && error != ENOENT) { + ovs_fatal(0, "%s: failed to open socket (%s)", name, + strerror(error)); + } free(vconn_name); + + return error; } static enum ofputil_protocol @@ -350,7 +357,7 @@ open_vconn__(const char *name, const char *default_suffix, enum ofputil_protocol protocol; char *bridge_path; int ofp_version; - struct stat s; + int error; bridge_path = xasprintf("%s/%s.%s", ovs_rundir(), name, default_suffix); @@ -362,16 +369,12 @@ open_vconn__(const char *name, const char *default_suffix, if (strchr(name, ':')) { run(vconn_open_block(name, 0, vconnp), "connecting to %s", name); - } else if (!stat(name, &s) && S_ISSOCK(s.st_mode)) { - open_vconn_socket(name, vconnp); - } else if (!stat(bridge_path, &s) && S_ISSOCK(s.st_mode)) { - open_vconn_socket(bridge_path, vconnp); - } else if (!stat(socket_name, &s)) { - if (!S_ISSOCK(s.st_mode)) { - ovs_fatal(0, "cannot connect to %s: %s is not a socket", - name, socket_name); - } - open_vconn_socket(socket_name, vconnp); + } else if (!open_vconn_socket(name, vconnp)) { + /* Fall Through. */ + } else if (!open_vconn_socket(bridge_path, vconnp)) { + /* Fall Through. */ + } else if (!open_vconn_socket(socket_name, vconnp)) { + /* Fall Through. */ } else { ovs_fatal(0, "%s is not a bridge or a socket", name); } @@ -379,6 +382,13 @@ open_vconn__(const char *name, const char *default_suffix, free(bridge_path); free(socket_name); + VLOG_DBG("connecting to %s", vconn_get_name(*vconnp)); + error = vconn_connect_block(*vconnp); + if (error) { + ovs_fatal(0, "%s: failed to connect to socket (%s)", name, + strerror(error)); + } + ofp_version = vconn_get_version(*vconnp); protocol = ofputil_protocol_from_ofp_version(ofp_version); if (!protocol) { -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev