X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=utilities%2Fovs-openflowd.c;h=486eae288e9e56ab3cd2d9823d18cb9d546b8dd4;hb=a4b2e516ffd0aa466f2d0182c89a91ce5d23d9a4;hp=d0b90a092ac0ef2da2717b3fcafb6c19e69a315d;hpb=f8bfdc308beedddd5127201201da278f830df21b;p=openvswitch diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c index d0b90a09..486eae28 100644 --- a/utilities/ovs-openflowd.c +++ b/utilities/ovs-openflowd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,6 +82,8 @@ struct ofsettings { struct svec netflow; /* NetFlow targets. */ }; +static unixctl_cb_func ovs_openflowd_exit; + static void parse_options(int argc, char *argv[], struct ofsettings *); static void usage(void) NO_RETURN; @@ -94,6 +96,7 @@ main(int argc, char *argv[]) int error; struct dpif *dpif; struct netflow_options nf_options; + bool exiting; proctitle_init(argc, argv); set_program_name(argv[0]); @@ -109,6 +112,8 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } + unixctl_command_register("exit", ovs_openflowd_exit, &exiting); + VLOG_INFO("Open vSwitch version %s", VERSION BUILDNR); VLOG_INFO("OpenFlow protocol version 0x%02x", OFP_VERSION); @@ -123,10 +128,19 @@ main(int argc, char *argv[]) size_t i; SVEC_FOR_EACH (i, port, &s.ports) { - error = dpif_port_add(dpif, port, 0, NULL); + struct netdev *netdev; + + error = netdev_open_default(port, &netdev); + if (error) { + ovs_fatal(error, "%s: failed to open network device", port); + } + + error = dpif_port_add(dpif, netdev, NULL); if (error) { ovs_fatal(error, "failed to add %s as a port", port); } + + netdev_close(netdev); } } @@ -156,7 +170,8 @@ main(int argc, char *argv[]) daemonize_complete(); - while (s.run_forever || ofproto_is_alive(ofproto)) { + exiting = false; + while (!exiting && (s.run_forever || ofproto_is_alive(ofproto))) { error = ofproto_run(ofproto); if (error) { ovs_fatal(error, "unrecoverable datapath error"); @@ -169,6 +184,9 @@ main(int argc, char *argv[]) unixctl_server_wait(unixctl); dp_wait(); netdev_wait(); + if (exiting) { + poll_immediate_wake(); + } poll_block(); } @@ -176,6 +194,15 @@ main(int argc, char *argv[]) return 0; } + +static void +ovs_openflowd_exit(struct unixctl_conn *conn, const char *args OVS_UNUSED, + void *exiting_) +{ + bool *exiting = exiting_; + *exiting = true; + unixctl_command_reply(conn, 200, NULL); +} /* User interface. */ @@ -207,7 +234,8 @@ parse_options(int argc, char *argv[], struct ofsettings *s) OPT_UNIXCTL, OPT_ENABLE_DUMMY, VLOG_OPTION_ENUMS, - LEAK_CHECKER_OPTION_ENUMS + LEAK_CHECKER_OPTION_ENUMS, + DAEMON_OPTION_ENUMS }; static struct option long_options[] = { {"datapath-id", required_argument, 0, OPT_DATAPATH_ID},