X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=vswitchd%2Fbridge.c;h=9449879f897636ed6f48bda42bffdec11b782719;hb=fba6bd1d3f5891471daea8bf5da22303c2d889df;hp=fdd7c64064354e4da1b17a4db64e1ffeff8f7b1e;hpb=2c487bc808ba6a4a297523f2c6b78ca3e358073a;p=sliver-openvswitch.git diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index fdd7c6406..9449879f8 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -318,7 +318,7 @@ void bridge_init(const char *remote) { /* Create connection to database. */ - idl = ovsdb_idl_create(remote, &ovsrec_idl_class, true); + idl = ovsdb_idl_create(remote, &ovsrec_idl_class, true, true); idl_seqno = ovsdb_idl_get_seqno(idl); ovsdb_idl_set_lock(idl, "ovs_vswitchd"); ovsdb_idl_verify_write_only(idl); @@ -345,6 +345,7 @@ bridge_init(const char *remote) ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_link_speed); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_link_state); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_link_resets); + ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_mac_in_use); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_mtu); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_ofport); ovsdb_idl_omit_alert(idl, &ovsrec_interface_col_statistics); @@ -1698,6 +1699,7 @@ iface_refresh_status(struct iface *iface) int64_t bps; int mtu; int64_t mtu_64; + uint8_t mac[ETH_ADDR_LEN]; int error; if (iface_is_synthetic(iface)) { @@ -1721,8 +1723,7 @@ iface_refresh_status(struct iface *iface) netdev_features_is_full_duplex(current) ? "full" : "half"); ovsrec_interface_set_link_speed(iface->cfg, &bps, 1); - } - else { + } else { ovsrec_interface_set_duplex(iface->cfg, NULL); ovsrec_interface_set_link_speed(iface->cfg, NULL, 0); } @@ -1731,10 +1732,19 @@ iface_refresh_status(struct iface *iface) if (!error) { mtu_64 = mtu; ovsrec_interface_set_mtu(iface->cfg, &mtu_64, 1); - } - else { + } else { ovsrec_interface_set_mtu(iface->cfg, NULL, 0); } + + error = netdev_get_etheraddr(iface->netdev, mac); + if (!error) { + char mac_string[32]; + + sprintf(mac_string, ETH_ADDR_FMT, ETH_ADDR_ARGS(mac)); + ovsrec_interface_set_mac_in_use(iface->cfg, mac_string); + } else { + ovsrec_interface_set_mac_in_use(iface->cfg, NULL); + } } /* Writes 'iface''s CFM statistics to the database. 'iface' must not be @@ -1743,57 +1753,47 @@ static void iface_refresh_cfm_stats(struct iface *iface) { const struct ovsrec_interface *cfg = iface->cfg; - int fault, opup, error; - const uint64_t *rmps; - size_t n_rmps; - int health; - - fault = ofproto_port_get_cfm_fault(iface->port->bridge->ofproto, - iface->ofp_port); - if (fault >= 0) { + struct ofproto_cfm_status status; + + if (!ofproto_port_get_cfm_status(iface->port->bridge->ofproto, + iface->ofp_port, &status)) { + ovsrec_interface_set_cfm_fault(cfg, NULL, 0); + ovsrec_interface_set_cfm_fault_status(cfg, NULL, 0); + ovsrec_interface_set_cfm_remote_opstate(cfg, NULL); + ovsrec_interface_set_cfm_health(cfg, NULL, 0); + ovsrec_interface_set_cfm_remote_mpids(cfg, NULL, 0); + } else { const char *reasons[CFM_FAULT_N_REASONS]; - bool fault_bool = fault; + int64_t cfm_health = status.health; + bool faulted = status.faults != 0; size_t i, j; + ovsrec_interface_set_cfm_fault(cfg, &faulted, 1); + j = 0; for (i = 0; i < CFM_FAULT_N_REASONS; i++) { int reason = 1 << i; - if (fault & reason) { + if (status.faults & reason) { reasons[j++] = cfm_fault_reason_to_str(reason); } } - - ovsrec_interface_set_cfm_fault(cfg, &fault_bool, 1); ovsrec_interface_set_cfm_fault_status(cfg, (char **) reasons, j); - } else { - ovsrec_interface_set_cfm_fault(cfg, NULL, 0); - ovsrec_interface_set_cfm_fault_status(cfg, NULL, 0); - } - opup = ofproto_port_get_cfm_opup(iface->port->bridge->ofproto, - iface->ofp_port); - if (opup >= 0) { - ovsrec_interface_set_cfm_remote_opstate(cfg, opup ? "up" : "down"); - } else { - ovsrec_interface_set_cfm_remote_opstate(cfg, NULL); - } - - error = ofproto_port_get_cfm_remote_mpids(iface->port->bridge->ofproto, - iface->ofp_port, &rmps, &n_rmps); - if (error >= 0) { - ovsrec_interface_set_cfm_remote_mpids(cfg, (const int64_t *)rmps, - n_rmps); - } else { - ovsrec_interface_set_cfm_remote_mpids(cfg, NULL, 0); - } + if (status.remote_opstate >= 0) { + const char *remote_opstate = status.remote_opstate ? "up" : "down"; + ovsrec_interface_set_cfm_remote_opstate(cfg, remote_opstate); + } else { + ovsrec_interface_set_cfm_remote_opstate(cfg, NULL); + } - health = ofproto_port_get_cfm_health(iface->port->bridge->ofproto, - iface->ofp_port); - if (health >= 0) { - int64_t cfm_health = health; - ovsrec_interface_set_cfm_health(cfg, &cfm_health, 1); - } else { - ovsrec_interface_set_cfm_health(cfg, NULL, 0); + ovsrec_interface_set_cfm_remote_mpids(cfg, + (const int64_t *)status.rmps, + status.n_rmps); + if (cfm_health >= 0) { + ovsrec_interface_set_cfm_health(cfg, &cfm_health, 1); + } else { + ovsrec_interface_set_cfm_health(cfg, NULL, 0); + } } } @@ -1961,15 +1961,16 @@ run_system_stats(void) } static inline const char * -nx_role_to_str(enum nx_role role) +ofp12_controller_role_to_str(enum ofp12_controller_role role) { switch (role) { - case NX_ROLE_OTHER: + case OFPCR12_ROLE_EQUAL: return "other"; - case NX_ROLE_MASTER: + case OFPCR12_ROLE_MASTER: return "master"; - case NX_ROLE_SLAVE: + case OFPCR12_ROLE_SLAVE: return "slave"; + case OFPCR12_ROLE_NOCHANGE: default: return "*** INVALID ROLE ***"; } @@ -2005,7 +2006,8 @@ refresh_controller_status(void) } ovsrec_controller_set_is_connected(cfg, cinfo->is_connected); - ovsrec_controller_set_role(cfg, nx_role_to_str(cinfo->role)); + ovsrec_controller_set_role(cfg, ofp12_controller_role_to_str( + cinfo->role)); ovsrec_controller_set_status(cfg, &smap); smap_destroy(&smap); } else { @@ -3340,6 +3342,7 @@ iface_clear_db_record(const struct ovsrec_interface *if_cfg) ovsrec_interface_set_duplex(if_cfg, NULL); ovsrec_interface_set_link_speed(if_cfg, NULL, 0); ovsrec_interface_set_link_state(if_cfg, NULL); + ovsrec_interface_set_mac_in_use(if_cfg, NULL); ovsrec_interface_set_mtu(if_cfg, NULL, 0); ovsrec_interface_set_cfm_fault(if_cfg, NULL, 0); ovsrec_interface_set_cfm_fault_status(if_cfg, NULL, 0);