* derivatives without specific, written prior permission.
*/
+#include <config.h>
#include <errno.h>
#include <getopt.h>
#include <limits.h>
+#include <signal.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "queue.h"
#include "util.h"
#include "rconn.h"
+#include "timeval.h"
#include "vconn.h"
#include "vconn-ssl.h"
#include "vlog-socket.h"
#define THIS_MODULE VLM_switch
#include "vlog.h"
+
+/* Strings to describe the manufacturer, hardware, and software. This data
+ * is queriable through the version stats message. */
+char mfr_desc[VERSION_STR_LEN] = "Nicira Networks";
+char hw_desc[VERSION_STR_LEN] = "Reference User-Space Switch";
+char sw_desc[VERSION_STR_LEN] = VERSION;
+
static void parse_options(int argc, char *argv[]);
static void usage(void) NO_RETURN;
set_program_name(argv[0]);
register_fault_handlers();
+ time_init();
vlog_init();
parse_options(argc, argv);
+ signal(SIGPIPE, SIG_IGN);
if (argc - optind != 1) {
fatal(0, "missing controller argument; use --help for usage");
}
- rconn = rconn_create(128, 60, max_backoff);
+ rconn = rconn_create(60, max_backoff);
error = rconn_connect(rconn, argv[optind]);
if (error == EAFNOSUPPORT) {
fatal(0, "no support for %s vconn", argv[optind]);
fatal(error, "could not listen for vlog connections");
}
+ die_if_already_running();
daemonize();
for (;;) {
parse_options(int argc, char *argv[])
{
enum {
- OPT_MAX_BACKOFF = UCHAR_MAX + 1
+ OPT_MAX_BACKOFF = UCHAR_MAX + 1,
+ OPT_MFR_DESC,
+ OPT_HW_DESC,
+ OPT_SW_DESC
};
static struct option long_options[] = {
{"listen", required_argument, 0, 'l'},
{"detach", no_argument, 0, 'D'},
{"pidfile", optional_argument, 0, 'P'},
+ {"force", no_argument, 0, 'f'},
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
+ {"mfr-desc", required_argument, 0, OPT_MFR_DESC},
+ {"hw-desc", required_argument, 0, OPT_HW_DESC},
+ {"sw-desc", required_argument, 0, OPT_SW_DESC},
VCONN_SSL_LONG_OPTIONS
{0, 0, 0, 0},
};
break;
case 'P':
- set_pidfile(optarg ? optarg : "switch.pid");
+ set_pidfile(optarg);
+ break;
+
+ case 'f':
+ ignore_existing_pidfile();
break;
case 'v':
}
break;
+ case OPT_MFR_DESC:
+ strncpy(mfr_desc, optarg, sizeof mfr_desc);
+ break;
+
+ case OPT_HW_DESC:
+ strncpy(hw_desc, optarg, sizeof hw_desc);
+ break;
+
+ case OPT_SW_DESC:
+ strncpy(sw_desc, optarg, sizeof sw_desc);
+ break;
+
case 'l':
if (listen_vconn_name) {
fatal(0, "-l or --listen may be only specified once");
"\nOther options:\n"
" -D, --detach run in background as daemon\n"
" -P, --pidfile[=FILE] create pidfile (default: %s/switch.pid)\n"
- " -v, --verbose=MODULE:FACILITY:LEVEL configure logging levels\n"
+ " -f, --force with -P, start even if already running\n"
+ " -v, --verbose=MODULE[:FACILITY[:LEVEL]] set logging levels\n"
" -v, --verbose set maximum verbosity level\n"
" -h, --help display this help message\n"
" -V, --version display version information\n",