datapath: Clean up code in vport_get_stats().
[openvswitch] / vswitchd / bridge.c
index 18e4ef2401ca8b397dc8fad7dfc37dbbe7ef0072..d505b533c9ecc8e774962740454fa61c7758dfcc 100644 (file)
@@ -317,6 +317,17 @@ bridge_init(const char *remote)
     bond_init();
 }
 
+void
+bridge_exit(void)
+{
+    struct bridge *br, *next_br;
+
+    LIST_FOR_EACH_SAFE (br, next_br, node, &all_bridges) {
+        bridge_destroy(br);
+    }
+    ovsdb_idl_destroy(idl);
+}
+
 /* Performs configuration that is only necessary once at ovs-vswitchd startup,
  * but for which the ovs-vswitchd configuration 'cfg' is required. */
 static void
@@ -384,30 +395,6 @@ bridge_configure_once(const struct ovsrec_open_vswitch *cfg)
     svec_destroy(&dpif_types);
 }
 
-/* Initializes 'options' and fills it with the options for 'if_cfg'. Merges
- * keys from "options" and "other_config", preferring "options" keys over
- * "other_config" keys. */
-static void
-iface_get_options(const struct ovsrec_interface *if_cfg, struct shash *options)
-{
-    size_t i;
-
-    shash_from_ovs_idl_map(if_cfg->key_options, if_cfg->value_options,
-                           if_cfg->n_options, options);
-
-    for (i = 0; i < if_cfg->n_other_config; i++) {
-        char *key = if_cfg->key_other_config[i];
-        char *value = if_cfg->value_other_config[i];
-
-        if (!shash_find_data(options, key)) {
-            shash_add(options, key, value);
-        } else {
-            VLOG_WARN("%s: ignoring \"other_config\" key %s that conflicts "
-                      "with \"options\" key %s", if_cfg->name, key, key);
-        }
-    }
-}
-
 /* Callback for iterate_and_prune_ifaces(). */
 static bool
 check_iface(struct bridge *br, struct iface *iface, void *aux OVS_UNUSED)
@@ -684,7 +671,9 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
 
                 shash_init(&args);
                 if (iface) {
-                    iface_get_options(iface->cfg, &args);
+                    shash_from_ovs_idl_map(iface->cfg->key_options, 
+                                           iface->cfg->value_options,
+                                           iface->cfg->n_options, &args);
                 }
                 error = netdev_open(&options, &netdev);
                 shash_destroy(&args);
@@ -722,7 +711,9 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
                 struct shash args;
 
                 shash_init(&args);
-                iface_get_options(iface->cfg, &args);
+                shash_from_ovs_idl_map(iface->cfg->key_options, 
+                                       iface->cfg->value_options,
+                                       iface->cfg->n_options, &args);
                 netdev_reconfigure(iface->netdev, &args);
                 shash_destroy(&args);
             }
@@ -1110,6 +1101,14 @@ dpid_from_hash(const void *data, size_t n)
     return eth_addr_to_uint64(hash);
 }
 
+static void
+iface_refresh_tunnel_egress(struct iface *iface)
+{
+    const char *name = netdev_get_tnl_iface(iface->netdev);
+
+    ovsrec_interface_set_tunnel_egress_iface(iface->cfg, name);
+}
+
 static void
 iface_refresh_cfm_stats(struct iface *iface)
 {
@@ -1319,6 +1318,7 @@ bridge_run(void)
                         struct iface *iface = port->ifaces[j];
                         iface_refresh_stats(iface);
                         iface_refresh_cfm_stats(iface);
+                        iface_refresh_tunnel_egress(iface);
                     }
                 }
             }