-/* Copyright (c) 2008, 2009, 2010 Nicira Networks
+/* Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
svec_init(&dpif_types);
dp_enumerate_types(&dpif_types);
for (i = 0; i < dpif_types.n; i++) {
- struct dpif *dpif;
- int retval;
size_t j;
dp_enumerate_names(dpif_types.names[i], &dpif_names);
- /* For each dpif... */
+ /* Delete each dpif whose name is not in 'bridge_names'. */
for (j = 0; j < dpif_names.n; j++) {
- retval = dpif_open(dpif_names.names[j], dpif_types.names[i], &dpif);
- if (!retval) {
- struct svec all_names;
- size_t k;
-
- /* ...check whether any of its names is in 'bridge_names'. */
- svec_init(&all_names);
- dpif_get_all_names(dpif, &all_names);
- for (k = 0; k < all_names.n; k++) {
- if (svec_contains(&bridge_names, all_names.names[k])) {
- goto found;
- }
+ if (!svec_contains(&bridge_names, dpif_names.names[j])) {
+ struct dpif *dpif;
+ int retval;
+
+ retval = dpif_open(dpif_names.names[j], dpif_types.names[i],
+ &dpif);
+ if (!retval) {
+ dpif_delete(dpif);
+ dpif_close(dpif);
}
-
- /* No. Delete the dpif. */
- dpif_delete(dpif);
-
- found:
- svec_destroy(&all_names);
- dpif_close(dpif);
}
}
}
* that port already belongs to a different datapath, so we must do all
* port deletions before any port additions. */
LIST_FOR_EACH (br, node, &all_bridges) {
- struct odp_port *dpif_ports;
- size_t n_dpif_ports;
+ struct dpif_port_dump dump;
struct shash want_ifaces;
+ struct dpif_port dpif_port;
- dpif_port_list(br->dpif, &dpif_ports, &n_dpif_ports);
bridge_get_all_ifaces(br, &want_ifaces);
- for (i = 0; i < n_dpif_ports; i++) {
- const struct odp_port *p = &dpif_ports[i];
- if (!shash_find(&want_ifaces, p->devname)
- && strcmp(p->devname, br->name)) {
- int retval = dpif_port_del(br->dpif, p->port);
+ DPIF_PORT_FOR_EACH (&dpif_port, &dump, br->dpif) {
+ if (!shash_find(&want_ifaces, dpif_port.name)
+ && strcmp(dpif_port.name, br->name)) {
+ int retval = dpif_port_del(br->dpif, dpif_port.port_no);
if (retval) {
VLOG_ERR("failed to remove %s interface from %s: %s",
- p->devname, dpif_name(br->dpif),
+ dpif_port.name, dpif_name(br->dpif),
strerror(retval));
}
}
}
shash_destroy(&want_ifaces);
- free(dpif_ports);
}
LIST_FOR_EACH (br, node, &all_bridges) {
- struct odp_port *dpif_ports;
- size_t n_dpif_ports;
struct shash cur_ifaces, want_ifaces;
+ struct dpif_port_dump dump;
+ struct dpif_port dpif_port;
/* Get the set of interfaces currently in this datapath. */
- dpif_port_list(br->dpif, &dpif_ports, &n_dpif_ports);
shash_init(&cur_ifaces);
- for (i = 0; i < n_dpif_ports; i++) {
- const char *name = dpif_ports[i].devname;
- shash_add_once(&cur_ifaces, name, &dpif_ports[i]);
+ DPIF_PORT_FOR_EACH (&dpif_port, &dump, br->dpif) {
+ struct dpif_port *port_info = xmalloc(sizeof *port_info);
+ dpif_port_clone(port_info, &dpif_port);
+ shash_add(&cur_ifaces, dpif_port.name, port_info);
}
/* Get the set of interfaces we want on this datapath. */
SHASH_FOR_EACH (node, &want_ifaces) {
const char *if_name = node->name;
struct iface *iface = node->data;
- struct odp_port *dpif_port = shash_find_data(&cur_ifaces, if_name);
- const char *type = iface ? iface->type : "internal";
+ struct dpif_port *dpif_port;
+ const char *type;
int error;
+ type = iface ? iface->type : "internal";
+ dpif_port = shash_find_data(&cur_ifaces, if_name);
+
/* If we have a port or a netdev already, and it's not the type we
* want, then delete the port (if any) and close the netdev (if
* any). */
|| (iface && iface->netdev
&& strcmp(type, netdev_get_type(iface->netdev)))) {
if (dpif_port) {
- error = ofproto_port_del(br->ofproto, dpif_port->port);
+ error = ofproto_port_del(br->ofproto, dpif_port->port_no);
if (error) {
continue;
}
shash_from_ovs_idl_map(iface->cfg->key_options,
iface->cfg->value_options,
iface->cfg->n_options, &args);
- netdev_reconfigure(iface->netdev, &args);
+ netdev_set_config(iface->netdev, &args);
shash_destroy(&args);
}
}
- free(dpif_ports);
- shash_destroy(&cur_ifaces);
shash_destroy(&want_ifaces);
+
+ SHASH_FOR_EACH (node, &cur_ifaces) {
+ struct dpif_port *port_info = node->data;
+ dpif_port_destroy(port_info);
+ free(port_info);
+ }
+ shash_destroy(&cur_ifaces);
}
sflow_bridge_number = 0;
LIST_FOR_EACH (br, node, &all_bridges) {
ofproto_get_ofproto_controller_info(br->ofproto, &info);
OVSREC_CONTROLLER_FOR_EACH(cfg, idl) {
- struct ofproto_controller_info *cinfo = shash_find_data(&info, cfg->target);
-
- ovsrec_controller_set_is_connected(cfg, cinfo->is_connected);
- ovsrec_controller_set_role(cfg, nx_role_to_str(cinfo->role));
- ovsrec_controller_set_status(cfg, (char **) cinfo->pairs.keys,
- (char **) cinfo->pairs.values,
- cinfo->pairs.n);
+ struct ofproto_controller_info *cinfo =
+ shash_find_data(&info, cfg->target);
+
+ if (cinfo) {
+ ovsrec_controller_set_is_connected(cfg, cinfo->is_connected);
+ ovsrec_controller_set_role(cfg, nx_role_to_str(cinfo->role));
+ ovsrec_controller_set_status(cfg, (char **) cinfo->pairs.keys,
+ (char **) cinfo->pairs.values,
+ cinfo->pairs.n);
+ } else {
+ ovsrec_controller_set_is_connected(cfg, false);
+ ovsrec_controller_set_role(cfg, NULL);
+ ovsrec_controller_set_status(cfg, NULL, NULL, 0);
+ }
}
ofproto_free_ofproto_controller_info(&info);
/* (Re)configure if necessary. */
database_changed = ovsdb_idl_run(idl);
cfg = ovsrec_open_vswitch_first(idl);
+#ifdef HAVE_OPENSSL
+ /* Re-configure SSL. We do this on every trip through the main loop,
+ * instead of just when the database changes, because the contents of the
+ * key and certificate files can change without the database changing.
+ *
+ * We do this before bridge_reconfigure() because that function might
+ * initiate SSL connections and thus requires SSL to be configured. */
+ if (cfg && cfg->ssl) {
+ const struct ovsrec_ssl *ssl = cfg->ssl;
+
+ stream_ssl_set_key_and_cert(ssl->private_key, ssl->certificate);
+ stream_ssl_set_ca_cert_file(ssl->ca_cert, ssl->bootstrap_ca_cert);
+ }
+#endif
if (database_changed || datapath_destroyed) {
if (cfg) {
struct ovsdb_idl_txn *txn = ovsdb_idl_txn_create(idl);
}
}
-#ifdef HAVE_OPENSSL
- /* Re-configure SSL. We do this on every trip through the main loop,
- * instead of just when the database changes, because the contents of the
- * key and certificate files can change without the database changing. */
- if (cfg && cfg->ssl) {
- const struct ovsrec_ssl *ssl = cfg->ssl;
-
- stream_ssl_set_key_and_cert(ssl->private_key, ssl->certificate);
- stream_ssl_set_ca_cert_file(ssl->ca_cert, ssl->bootstrap_ca_cert);
- }
-#endif
-
/* Refresh system and interface stats if necessary. */
if (time_msec() >= stats_timer) {
if (cfg) {
static void
bridge_fetch_dp_ifaces(struct bridge *br)
{
- struct odp_port *dpif_ports;
- size_t n_dpif_ports;
+ struct dpif_port_dump dump;
+ struct dpif_port dpif_port;
size_t i, j;
/* Reset all interface numbers. */
}
hmap_clear(&br->ifaces);
- dpif_port_list(br->dpif, &dpif_ports, &n_dpif_ports);
- for (i = 0; i < n_dpif_ports; i++) {
- struct odp_port *p = &dpif_ports[i];
- struct iface *iface = iface_lookup(br, p->devname);
+ DPIF_PORT_FOR_EACH (&dpif_port, &dump, br->dpif) {
+ struct iface *iface = iface_lookup(br, dpif_port.name);
if (iface) {
if (iface->dp_ifidx >= 0) {
VLOG_WARN("%s reported interface %s twice",
- dpif_name(br->dpif), p->devname);
- } else if (iface_from_dp_ifidx(br, p->port)) {
+ dpif_name(br->dpif), dpif_port.name);
+ } else if (iface_from_dp_ifidx(br, dpif_port.port_no)) {
VLOG_WARN("%s reported interface %"PRIu16" twice",
- dpif_name(br->dpif), p->port);
+ dpif_name(br->dpif), dpif_port.port_no);
} else {
- iface->dp_ifidx = p->port;
+ iface->dp_ifidx = dpif_port.port_no;
hmap_insert(&br->ifaces, &iface->dp_ifidx_node,
hash_int(iface->dp_ifidx, 0));
}
: -1));
}
}
- free(dpif_ports);
}
\f
/* Bridge packet processing functions. */
const struct dst *dst = &set.dsts[i];
if (dst->vlan != cur_vlan) {
if (dst->vlan == OFP_VLAN_NONE) {
- nl_msg_put_flag(actions, ODPAT_STRIP_VLAN);
+ nl_msg_put_flag(actions, ODP_ACTION_ATTR_STRIP_VLAN);
} else {
ovs_be16 tci;
tci = htons(dst->vlan & VLAN_VID_MASK);
tci |= flow->vlan_tci & htons(VLAN_PCP_MASK);
- nl_msg_put_be16(actions, ODPAT_SET_DL_TCI, tci);
+ nl_msg_put_be16(actions, ODP_ACTION_ATTR_SET_DL_TCI, tci);
}
cur_vlan = dst->vlan;
}
- nl_msg_put_u32(actions, ODPAT_OUTPUT, dst->dp_ifidx);
+ nl_msg_put_u32(actions, ODP_ACTION_ATTR_OUTPUT, dst->dp_ifidx);
}
dst_set_free(&set);
}
return;
}
NL_ATTR_FOR_EACH_UNSAFE (a, left, actions, actions_len) {
- if (nl_attr_type(a) == ODPAT_OUTPUT) {
+ if (nl_attr_type(a) == ODP_ACTION_ATTR_OUTPUT) {
struct port *out_port = port_from_dp_ifidx(br, nl_attr_get_u32(a));
if (out_port && out_port->n_ifaces >= 2 &&
out_port->bond_mode == BM_SLB) {