aboutsummaryrefslogtreecommitdiff
path: root/vswitchd
diff options
context:
space:
mode:
authorJustin Pettit <jpettit@nicira.com>2012-10-08 17:57:22 -0700
committerJustin Pettit <jpettit@nicira.com>2012-11-01 22:54:27 -0700
commitb0408fcacca150694d116d4ead3930757e545bbf (patch)
treecbaab13e5c29198ab26e972fcc185ecb5a5d405e /vswitchd
parent81816a5fe8ddd96a296fabc8ea8069e9a19a2631 (diff)
ofproto: Add initialization function.
A future commit will make all bridges of a particular dpif share a single backing datapath. In order to handle restart, the datapath will need to have some idea of what the initial state looks like. Otherwise, it won't know which ports belong to which bridges and orphaned ports may never be cleaned up. This commit introduces an initialization method to ofproto, which takes as an argument a high-level description of the bridges and ports. An ofproto provider can then use this information to initialize its state. Signed-off-by: Justin Pettit <jpettit@nicira.com>
Diffstat (limited to 'vswitchd')
-rw-r--r--vswitchd/bridge.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 8240d250..f7ed68a6 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -262,6 +262,48 @@ static void configure_splinter_port(struct port *);
static void add_vlan_splinter_ports(struct bridge *,
const unsigned long int *splinter_vlans,
struct shash *ports);
+
+static void
+bridge_init_ofproto(const struct ovsrec_open_vswitch *cfg)
+{
+ struct shash iface_hints;
+ static bool initialized = false;
+ int i;
+
+ if (initialized) {
+ return;
+ }
+
+ shash_init(&iface_hints);
+
+ for (i = 0; i < cfg->n_bridges; i++) {
+ const struct ovsrec_bridge *br_cfg = cfg->bridges[i];
+ int j;
+
+ for (j = 0; j < br_cfg->n_ports; j++) {
+ struct ovsrec_port *port_cfg = br_cfg->ports[j];
+ int k;
+
+ for (k = 0; k < port_cfg->n_interfaces; k++) {
+ struct ovsrec_interface *if_cfg = port_cfg->interfaces[k];
+ struct iface_hint *iface_hint;
+
+ iface_hint = xmalloc(sizeof *iface_hint);
+ iface_hint->br_name = br_cfg->name;
+ iface_hint->br_type = br_cfg->datapath_type;
+ iface_hint->ofp_port = if_cfg->n_ofport_request ?
+ *if_cfg->ofport_request : OFPP_NONE;
+
+ shash_add(&iface_hints, if_cfg->name, iface_hint);
+ }
+ }
+ }
+
+ ofproto_init(&iface_hints);
+
+ shash_destroy_free_data(&iface_hints);
+ initialized = true;
+}
/* Public functions. */
@@ -2076,6 +2118,12 @@ bridge_run(void)
}
cfg = ovsrec_open_vswitch_first(idl);
+ /* Initialize the ofproto library. This only needs to run once, but
+ * it must be done after the configuration is set. If the
+ * initialization has already occurred, bridge_init_ofproto()
+ * returns immediately. */
+ bridge_init_ofproto(cfg);
+
/* Let each bridge do the work that it needs to do. */
HMAP_FOR_EACH (br, node, &all_bridges) {
ofproto_run(br->ofproto);