X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=vswitchd%2Fbridge.c;h=2c1142b2c8b22c9e79ad0360ce4bc306212acc7a;hb=22a86f18c4aa481b3b5e5fd6fa71bc74856a60bf;hp=5a2b25170d8a2019875ac3f94159a99034d8b164;hpb=a699f6143e09b1d63ea284b7d8180c74f27dea60;p=openvswitch diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 5a2b2517..2c1142b2 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -148,10 +148,10 @@ static struct ovsdb_idl *idl; /* Most recently processed IDL sequence number. */ static unsigned int idl_seqno; -/* Each time this timer expires, the bridge fetches systems and interface +/* Each time this timer expires, the bridge fetches interface and mirror * statistics and pushes them into the database. */ -#define STATS_INTERVAL (5 * 1000) /* In milliseconds. */ -static long long int stats_timer = LLONG_MIN; +#define IFACE_STATS_INTERVAL (5 * 1000) /* In milliseconds. */ +static long long int iface_stats_timer = LLONG_MIN; /* Stores the time after which rate limited statistics may be written to the * database. Only updated when changes to the database require rate limiting. @@ -220,6 +220,9 @@ static void port_configure_bond(struct port *, struct bond_settings *, uint32_t *bond_stable_ids); static bool port_is_synthetic(const struct port *); +static void reconfigure_system_stats(const struct ovsrec_open_vswitch *); +static void run_system_stats(void); + static void bridge_configure_mirrors(struct bridge *); static struct mirror *mirror_create(struct bridge *, const struct ovsrec_mirror *); @@ -456,6 +459,8 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg) iface_clear_db_record(if_cfg->cfg); } } + + reconfigure_system_stats(ovs_cfg); } static bool @@ -474,6 +479,11 @@ bridge_reconfigure_ofp(void) struct ofpp_garbage *garbage, *next; LIST_FOR_EACH_SAFE (garbage, next, list_node, &br->ofpp_garbage) { + /* It's a bit dangerous to call bridge_run_fast() here as ofproto's + * internal datastructures may not be consistent. Eventually, when + * port additions and deletions are cheaper, these calls should be + * removed. */ + bridge_run_fast(); ofproto_port_del(br->ofproto, garbage->ofp_port); list_remove(&garbage->list_node); free(garbage); @@ -482,6 +492,7 @@ bridge_reconfigure_ofp(void) if (time_msec() >= deadline) { return false; } + bridge_run_fast(); } } @@ -550,6 +561,8 @@ bridge_reconfigure_continue(const struct ovsrec_open_vswitch *ovs_cfg) * forked us to exit successfully. */ daemonize_complete(); reconfiguring = false; + + VLOG_INFO("%s (Open vSwitch) %s", program_name, VERSION); } return done; @@ -748,7 +761,10 @@ bridge_configure_datapath_id(struct bridge *br) memcpy(br->ea, ea, ETH_ADDR_LEN); dpid = bridge_pick_datapath_id(br, ea, hw_addr_iface); - ofproto_set_datapath_id(br->ofproto, dpid); + if (dpid != ofproto_get_datapath_id(br->ofproto)) { + VLOG_INFO("bridge %s: using datapath ID %016"PRIx64, br->name, dpid); + ofproto_set_datapath_id(br->ofproto, dpid); + } dpid_string = xasprintf("%016"PRIx64, dpid); ovsrec_bridge_set_datapath_id(br->cfg, dpid_string); @@ -1329,9 +1345,15 @@ iface_create(struct bridge *br, struct if_cfg *if_cfg, int ofp_port) hmap_remove(&br->if_cfg_todo, &if_cfg->hmap_node); free(if_cfg); - /* Do the bits that can fail up front. */ + /* Do the bits that can fail up front. + * + * It's a bit dangerous to call bridge_run_fast() here as ofproto's + * internal datastructures may not be consistent. Eventually, when port + * additions and deletions are cheaper, these calls should be removed. */ + bridge_run_fast(); assert(!iface_lookup(br, iface_cfg->name)); error = iface_do_create(br, iface_cfg, port_cfg, &ofp_port, &netdev); + bridge_run_fast(); if (error) { iface_clear_db_record(iface_cfg); return false; @@ -1855,19 +1877,36 @@ enable_system_stats(const struct ovsrec_open_vswitch *cfg) } static void -refresh_system_stats(const struct ovsrec_open_vswitch *cfg) +reconfigure_system_stats(const struct ovsrec_open_vswitch *cfg) { - struct ovsdb_datum datum; - struct shash stats; + bool enable = enable_system_stats(cfg); - shash_init(&stats); - if (enable_system_stats(cfg)) { - get_system_stats(&stats); + system_stats_enable(enable); + if (!enable) { + ovsrec_open_vswitch_set_statistics(cfg, NULL); } +} + +static void +run_system_stats(void) +{ + const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_first(idl); + struct smap *stats; - ovsdb_datum_from_shash(&datum, &stats); - ovsdb_idl_txn_write(&cfg->header_, &ovsrec_open_vswitch_col_statistics, - &datum); + stats = system_stats_run(); + if (stats && cfg) { + struct ovsdb_idl_txn *txn; + struct ovsdb_datum datum; + + txn = ovsdb_idl_txn_create(idl); + ovsdb_datum_from_smap(&datum, stats); + ovsdb_idl_txn_write(&cfg->header_, &ovsrec_open_vswitch_col_statistics, + &datum); + ovsdb_idl_txn_commit(txn); + ovsdb_idl_txn_destroy(txn); + + free(stats); + } } static inline const char * @@ -1979,6 +2018,8 @@ bridge_run(void) bool vlan_splinters_changed; struct bridge *br; + ovsrec_open_vswitch_init((struct ovsrec_open_vswitch *) &null_cfg); + /* (Re)configure if necessary. */ if (!reconfiguring) { ovsdb_idl_run(idl); @@ -2063,8 +2104,8 @@ bridge_run(void) reconf_txn = NULL; } - /* Refresh system and interface stats if necessary. */ - if (time_msec() >= stats_timer) { + /* Refresh interface and mirror stats if necessary. */ + if (time_msec() >= iface_stats_timer) { if (cfg) { struct ovsdb_idl_txn *txn; @@ -2087,15 +2128,16 @@ bridge_run(void) } } - refresh_system_stats(cfg); refresh_controller_status(); ovsdb_idl_txn_commit(txn); ovsdb_idl_txn_destroy(txn); /* XXX */ } - stats_timer = time_msec() + STATS_INTERVAL; + iface_stats_timer = time_msec() + IFACE_STATS_INTERVAL; } + run_system_stats(); + if (time_msec() >= db_limiter) { struct ovsdb_idl_txn *txn; @@ -2160,12 +2202,14 @@ bridge_wait(void) HMAP_FOR_EACH (br, node, &all_bridges) { ofproto_wait(br->ofproto); } - poll_timer_wait_until(stats_timer); + poll_timer_wait_until(iface_stats_timer); if (db_limiter > time_msec()) { poll_timer_wait_until(db_limiter); } } + + system_stats_wait(); } /* Adds some memory usage statistics for bridges into 'usage', for use with