From: Ben Pfaff Date: Mon, 28 Jun 2010 18:17:28 +0000 (-0700) Subject: Merge "master" into "wdp". X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=1d63b8177a6f493061942dabe718f7e060d5b859;p=sliver-openvswitch.git Merge "master" into "wdp". --- 1d63b8177a6f493061942dabe718f7e060d5b859 diff --cc vswitchd/bridge.c index 3c5d9f695,d4a08b92f..4d27049b3 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@@ -82,12 -82,10 +82,10 @@@ struct iface long long delay_expires; /* Time after which 'enabled' may change. */ /* These members are valid only after bridge_reconfigure() causes them to - * be initialized.*/ + * be initialized. */ - int dp_ifidx; /* Index within kernel datapath. */ + int xf_ifidx; /* Index within kernel datapath. */ struct netdev *netdev; /* Network device. */ bool enabled; /* May be chosen for flows? */ - - /* This member is only valid *during* bridge_reconfigure(). */ const struct ovsrec_interface *cfg; }; @@@ -260,87 -260,89 +260,89 @@@ static struct ofhooks bridge_ofhooks /* Public functions. */ - /* Adds the name of each interface used by a bridge, including local and - * internal ports, to 'svec'. */ + /* Initializes the bridge module, configuring it to obtain its configuration + * from an OVSDB server accessed over 'remote', which should be a string in a + * form acceptable to ovsdb_idl_create(). */ void - bridge_get_ifaces(struct svec *svec) + bridge_init(const char *remote) { - struct bridge *br, *next; - size_t i, j; + /* Create connection to database. */ + idl = ovsdb_idl_create(remote, &ovsrec_idl_class); - LIST_FOR_EACH_SAFE (br, next, struct bridge, node, &all_bridges) { - for (i = 0; i < br->n_ports; i++) { - struct port *port = br->ports[i]; - - for (j = 0; j < port->n_ifaces; j++) { - struct iface *iface = port->ifaces[j]; - if (iface->xf_ifidx < 0) { - VLOG_ERR("%s interface not in datapath %s, ignoring", - iface->name, xfif_name(br->xfif)); - } else { - if (iface->xf_ifidx != XFLOWP_LOCAL) { - svec_add(svec, iface->name); - } - } - } - } - } + /* Register unixctl commands. */ + unixctl_command_register("fdb/show", bridge_unixctl_fdb_show, NULL); + unixctl_command_register("bridge/dump-flows", bridge_unixctl_dump_flows, + NULL); + unixctl_command_register("bridge/reconnect", bridge_unixctl_reconnect, + NULL); + bond_init(); } - void - bridge_init(const struct ovsrec_open_vswitch *cfg) + /* Performs configuration that is only necessary once at ovs-vswitchd startup, + * but for which the ovs-vswitchd configuration 'cfg' is required. */ + static void + bridge_configure_once(const struct ovsrec_open_vswitch *cfg) { + static bool already_configured_once; struct svec bridge_names; - struct svec dpif_names, dpif_types; + struct svec xfif_names, xfif_types; size_t i; - unixctl_command_register("fdb/show", bridge_unixctl_fdb_show, NULL); + /* Only do this once per ovs-vswitchd run. */ + if (already_configured_once) { + return; + } + already_configured_once = true; + + iface_stats_timer = time_msec() + IFACE_STATS_INTERVAL; + /* Get all the configured bridges' names from 'cfg' into 'bridge_names'. */ svec_init(&bridge_names); for (i = 0; i < cfg->n_bridges; i++) { svec_add(&bridge_names, cfg->bridges[i]->name); } svec_sort(&bridge_names); - /* Iterate over all system dpifs and delete any of them that do not appear ++ /* Iterate over all system xfifs and delete any of them that do not appear + * in 'cfg'. */ - svec_init(&dpif_names); - svec_init(&dpif_types); - dp_enumerate_types(&dpif_types); - for (i = 0; i < dpif_types.n; i++) { - struct dpif *dpif; + svec_init(&xfif_names); + svec_init(&xfif_types); + xf_enumerate_types(&xfif_types); + for (i = 0; i < xfif_types.n; i++) { + struct xfif *xfif; int retval; size_t j; - dp_enumerate_names(dpif_types.names[i], &dpif_names); + xf_enumerate_names(xfif_types.names[i], &xfif_names); - /* For each dpif... */ - for (j = 0; j < dpif_names.n; j++) { - retval = dpif_open(dpif_names.names[j], dpif_types.names[i], &dpif); ++ /* For each xfif... */ + for (j = 0; j < xfif_names.n; j++) { + retval = xfif_open(xfif_names.names[j], xfif_types.names[i], &xfif); if (!retval) { struct svec all_names; size_t k; + /* ...check whether any of its names is in 'bridge_names'. */ svec_init(&all_names); - dpif_get_all_names(dpif, &all_names); + xfif_get_all_names(xfif, &all_names); for (k = 0; k < all_names.n; k++) { if (svec_contains(&bridge_names, all_names.names[k])) { goto found; } } + - /* No. Delete the dpif. */ - dpif_delete(dpif); ++ /* No. Delete the xfif. */ + xfif_delete(xfif); + found: svec_destroy(&all_names); - dpif_close(dpif); + xfif_close(xfif); } } } svec_destroy(&bridge_names); - svec_destroy(&dpif_names); - svec_destroy(&dpif_types); + svec_destroy(&xfif_names); + svec_destroy(&xfif_types); - - unixctl_command_register("bridge/dump-flows", bridge_unixctl_dump_flows, - NULL); - - bond_init(); - bridge_reconfigure(cfg); } #ifdef HAVE_OPENSSL diff --cc vswitchd/ovs-vswitchd.c index 69adc4475,e2473dcfe..92379f930 --- a/vswitchd/ovs-vswitchd.c +++ b/vswitchd/ovs-vswitchd.c @@@ -99,39 -91,15 +92,15 @@@ main(int argc, char *argv[] if (signal_poll(sighup)) { vlog_reopen_log_file(); } - if (inited && bridge_run()) { - need_reconfigure = true; - } - ovsdb_idl_run(idl); - if (idl_seqno != ovsdb_idl_get_seqno(idl)) { - idl_seqno = ovsdb_idl_get_seqno(idl); - need_reconfigure = true; - } - if (need_reconfigure) { - const struct ovsrec_open_vswitch *cfg; - - need_reconfigure = false; - cfg = ovsrec_open_vswitch_first(idl); - if (cfg) { - if (inited) { - bridge_reconfigure(cfg); - } else { - bridge_init(cfg); - inited = true; - } - } - } + bridge_run(); unixctl_server_run(unixctl); - dp_run(); + wdp_run(); netdev_run(); signal_wait(sighup); - if (inited) { - bridge_wait(); - } - ovsdb_idl_wait(idl); + bridge_wait(); unixctl_server_wait(unixctl); - dp_wait(); + wdp_wait(); netdev_wait(); poll_block(); }