From: Ben Pfaff Date: Sat, 3 Jan 2009 00:39:59 +0000 (-0800) Subject: vswitchd: Don't make and pass socketpair to secchan if we won't use it. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89c8ff6cdf4e0d3390d372767fd05c59f655aadf;p=openvswitch vswitchd: Don't make and pass socketpair to secchan if we won't use it. If there's a remote controller then secchan will talk to it, not to vswitchd, so there's no need to make a socketpair for communication in that case. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 447a8819..17c6dc88 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -553,19 +553,24 @@ start_secchan(struct bridge *br) br->secchan = NULL; } - /* Create socketpair for communicating with secchan subprocess. */ - if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sockets)) { - VLOG_ERR("%s: failed to create socket pair: %s", - br->name, strerror(errno)); - goto error; + if (!br->controller) { + /* Create socketpair for communicating with secchan subprocess. */ + if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sockets)) { + VLOG_ERR("%s: failed to create socket pair: %s", + br->name, strerror(errno)); + goto error; + } + set_nonblocking(sockets[0]); + set_nonblocking(sockets[1]); + + /* Connect to our end of the socketpair. */ + dp_name = xasprintf("fd:%d", sockets[0]); + rconn_connect(br->rconn, dp_name); + free(dp_name); + } else { + /* secchan will connect to the external controller, not to us, so there + * is nothing for us to do. */ } - set_nonblocking(sockets[0]); - set_nonblocking(sockets[1]); - - /* Connect to our end of the socketpair. */ - dp_name = xasprintf("fd:%d", sockets[0]); - rconn_connect(br->rconn, dp_name); - free(dp_name); /* Assemble command-line arguments. */ svec_init(&argv); @@ -598,9 +603,13 @@ start_secchan(struct bridge *br) svec_terminate(&argv); /* Start secchan. */ - retval = process_start(argv.names, &sockets[1], 1, &br->secchan); + if (!br->controller) { + retval = process_start(argv.names, &sockets[1], 1, &br->secchan); + close(sockets[1]); + } else { + retval = process_start(argv.names, NULL, 0, &br->secchan); + } svec_destroy(&argv); - close(sockets[1]); if (retval) { VLOG_ERR("%s: failed to start secchan for datapath nl:%d: %s", br->name, br->dp_idx, strerror(retval));