X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=vswitchd%2Fovs-vswitchd.c;h=359e3ab1a5ce75683815796eb6bacd9a603e7209;hb=4cb3fde7c9224ca4f939852c5e7987fc5112d680;hp=d591e951e6aa4b475ad7130e9e231a93b6d933ff;hpb=b2fda3effc787f265b5ad5dfa967ac00627bd075;p=openvswitch diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c index d591e951..359e3ab1 100644 --- a/vswitchd/ovs-vswitchd.c +++ b/vswitchd/ovs-vswitchd.c @@ -30,9 +30,11 @@ #include "command-line.h" #include "compiler.h" #include "daemon.h" +#include "dirs.h" #include "dummy.h" #include "leak-checker.h" #include "netdev.h" +#include "openflow/openflow.h" #include "ovsdb-idl.h" #include "poll-loop.h" #include "process.h" @@ -52,7 +54,7 @@ VLOG_DEFINE_THIS_MODULE(vswitchd); static unixctl_cb_func ovs_vswitchd_exit; -static const char *parse_options(int argc, char *argv[]); +static char *parse_options(int argc, char *argv[]); static void usage(void) NO_RETURN; int @@ -60,7 +62,7 @@ main(int argc, char *argv[]) { struct unixctl_server *unixctl; struct signal *sighup; - const char *remote; + char *remote; bool exiting; int retval; @@ -79,9 +81,11 @@ main(int argc, char *argv[]) if (retval) { exit(EXIT_FAILURE); } - unixctl_command_register("exit", ovs_vswitchd_exit, &exiting); + unixctl_command_register("exit", "", ovs_vswitchd_exit, &exiting); bridge_init(remote); + free(remote); + exiting = false; while (!exiting) { if (signal_poll(sighup)) { @@ -102,11 +106,12 @@ main(int argc, char *argv[]) } bridge_exit(); unixctl_server_destroy(unixctl); + signal_unregister(sighup); return 0; } -static const char * +static char * parse_options(int argc, char *argv[]) { enum { @@ -142,12 +147,11 @@ parse_options(int argc, char *argv[]) } switch (c) { - case 'H': case 'h': usage(); case 'V': - OVS_PRINT_VERSION(OFP_VERSION, OFP_VERSION); + ovs_print_version(OFP_VERSION, OFP_VERSION); exit(EXIT_SUCCESS); case OPT_MLOCKALL: @@ -189,21 +193,27 @@ parse_options(int argc, char *argv[]) argc -= optind; argv += optind; - if (argc != 1) { - VLOG_FATAL("database socket is only non-option argument; " + switch (argc) { + case 0: + return xasprintf("unix:%s/db.sock", ovs_rundir()); + + case 1: + return xstrdup(argv[0]); + + default: + VLOG_FATAL("at most one non-option argument accepted; " "use --help for usage"); } - - return argv[0]; } static void usage(void) { printf("%s: Open vSwitch daemon\n" - "usage: %s [OPTIONS] DATABASE\n" - "where DATABASE is a socket on which ovsdb-server is listening.\n", - program_name, program_name); + "usage: %s [OPTIONS] [DATABASE]\n" + "where DATABASE is a socket on which ovsdb-server is listening\n" + " (default: \"unix:%s/db.sock\").\n", + program_name, program_name, ovs_rundir()); stream_usage("DATABASE", true, false, true); daemon_usage(); vlog_usage();