lib: Move vlog.h to <openvswitch/vlog.h>
[cascardo/ovs.git] / vswitchd / bridge.c
index 2918f04..4d84732 100644 (file)
@@ -60,7 +60,7 @@
 #include "vlandev.h"
 #include "lib/vswitch-idl.h"
 #include "xenserver.h"
-#include "vlog.h"
+#include "openvswitch/vlog.h"
 #include "sflow_api.h"
 #include "vlan-bitmap.h"
 #include "packets.h"
@@ -74,7 +74,7 @@ struct iface {
      *
      * They are immutable: they never change between iface_create() and
      * iface_destroy(). */
-    struct list port_elem;      /* Element in struct port's "ifaces" list. */
+    struct ovs_list port_elem;  /* Element in struct port's "ifaces" list. */
     struct hmap_node name_node; /* In struct bridge's "iface_by_name" hmap. */
     struct hmap_node ofp_port_node; /* In struct bridge's "ifaces" hmap. */
     struct port *port;          /* Containing port. */
@@ -105,7 +105,7 @@ struct port {
 
     /* An ordinary bridge port has 1 interface.
      * A bridge port for bonding has at least 2 interfaces. */
-    struct list ifaces;         /* List of "struct iface"s. */
+    struct ovs_list ifaces;    /* List of "struct iface"s. */
 };
 
 struct bridge {
@@ -381,6 +381,7 @@ bridge_init(const char *remote)
     ovsdb_idl_omit(idl, &ovsrec_open_vswitch_col_system_version);
 
     ovsdb_idl_omit_alert(idl, &ovsrec_bridge_col_datapath_id);
+    ovsdb_idl_omit_alert(idl, &ovsrec_bridge_col_datapath_version);
     ovsdb_idl_omit_alert(idl, &ovsrec_bridge_col_status);
     ovsdb_idl_omit_alert(idl, &ovsrec_bridge_col_rstp_status);
     ovsdb_idl_omit_alert(idl, &ovsrec_bridge_col_stp_enable);
@@ -595,6 +596,9 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
                          ovs_strerror(error));
                 shash_destroy(&br->wanted_ports);
                 bridge_destroy(br);
+            } else {
+                /* Trigger storing datapath version. */
+                seq_change(connectivity_seq_get());
             }
         }
     }
@@ -1394,6 +1398,16 @@ port_configure_rstp(const struct ofproto *ofproto, struct port *port,
         port_s->priority = RSTP_DEFAULT_PORT_PRIORITY;
     }
 
+    config_str = smap_get(&port->cfg->other_config, "rstp-admin-p2p-mac");
+    if (config_str) {
+        port_s->admin_p2p_mac_state = strtoul(config_str, NULL, 0);
+    } else {
+        port_s->admin_p2p_mac_state = RSTP_ADMIN_P2P_MAC_FORCE_TRUE;
+    }
+
+    port_s->admin_port_state = smap_get_bool(&port->cfg->other_config,
+                                             "rstp-admin-port-state", true);
+
     port_s->admin_edge_port = smap_get_bool(&port->cfg->other_config,
                                             "rstp-port-admin-edge", false);
     port_s->auto_edge = smap_get_bool(&port->cfg->other_config,
@@ -2319,6 +2333,19 @@ iface_refresh_stats(struct iface *iface)
 #undef IFACE_STATS
 }
 
+static void
+br_refresh_datapath_info(struct bridge *br)
+{
+    const char *version;
+
+    version = (br->ofproto && br->ofproto->ofproto_class->get_datapath_version
+               ? br->ofproto->ofproto_class->get_datapath_version(br->ofproto)
+               : NULL);
+
+    ovsrec_bridge_set_datapath_version(br->cfg,
+                                       version ? version : "<unknown>");
+}
+
 static void
 br_refresh_stp_status(struct bridge *br)
 {
@@ -2439,7 +2466,7 @@ br_refresh_rstp_status(struct bridge *br)
     }
     smap_add_format(&smap, "rstp_bridge_id", RSTP_ID_FMT,
                     RSTP_ID_ARGS(status.bridge_id));
-    smap_add_format(&smap, "rstp_root_path_cost", "%d",
+    smap_add_format(&smap, "rstp_root_path_cost", "%"PRIu32,
                     status.root_path_cost);
     smap_add_format(&smap, "rstp_root_id", RSTP_ID_FMT,
                     RSTP_ID_ARGS(status.root_id));
@@ -2492,6 +2519,12 @@ port_refresh_rstp_status(struct port *port)
                     rstp_port_role_name(status.role));
     smap_add_format(&smap, "rstp_port_state", "%s",
                     rstp_state_name(status.state));
+    smap_add_format(&smap, "rstp_designated_bridge_id", RSTP_ID_FMT,
+                    RSTP_ID_ARGS(status.designated_bridge_id));
+    smap_add_format(&smap, "rstp_designated_port_id", RSTP_PORT_ID_FMT,
+                    status.designated_port_id);
+    smap_add_format(&smap, "rstp_designated_path_cost", "%"PRIu32,
+                    status.designated_path_cost);
 
     ovsrec_port_set_rstp_status(port->cfg, &smap);
     smap_destroy(&smap);
@@ -2510,7 +2543,7 @@ port_refresh_rstp_status(struct port *port)
 static void
 port_refresh_bond_status(struct port *port, bool force_update)
 {
-    uint8_t mac[6];
+    uint8_t mac[ETH_ADDR_LEN];
 
     /* Return if port is not a bond */
     if (list_is_singleton(&port->ifaces)) {
@@ -2695,6 +2728,7 @@ run_status_update(void)
 
                 br_refresh_stp_status(br);
                 br_refresh_rstp_status(br);
+                br_refresh_datapath_info(br);
                 HMAP_FOR_EACH (port, hmap_node, &br->ports) {
                     struct iface *iface;
 
@@ -2734,6 +2768,12 @@ run_status_update(void)
 static void
 status_update_wait(void)
 {
+    /* This prevents the process from constantly waking up on
+     * connectivity seq, when there is no connection to ovsdb. */
+    if (!ovsdb_idl_has_lock(idl)) {
+        return;
+    }
+
     /* If the 'status_txn' is non-null (transaction incomplete), waits for the
      * transaction to complete.  If the status update to database needs to be
      * run again (transaction fails), registers a timeout in
@@ -2796,9 +2836,6 @@ bridge_run(void)
          * with the current situation of multiple ovs-vswitchd daemons,
          * disable system stats collection. */
         system_stats_enable(false);
-        /* This prevents the process from constantly waking up on
-         * connectivity seq. */
-        connectivity_seqno = seq_read(connectivity_seq_get());
         return;
     } else if (!ovsdb_idl_has_lock(idl)) {
         return;