#include "openvswitch/ofp-print.h"
#include "openvswitch/ofp-util.h"
#include "openvswitch/ofpbuf.h"
+#include "openvswitch/uuid.h"
#include "openvswitch/vlog.h"
#include "ovs-lldp.h"
#include "ovs-rcu.h"
#include "unaligned.h"
#include "unixctl.h"
#include "util.h"
+#include "uuid.h"
#include "vlan-bitmap.h"
VLOG_DEFINE_THIS_MODULE(ofproto_dpif);
struct shash all_dpif_backers = SHASH_INITIALIZER(&all_dpif_backers);
/* All existing ofproto_dpif instances, indexed by ->up.name. */
-struct hmap all_ofproto_dpifs = HMAP_INITIALIZER(&all_ofproto_dpifs);
+static struct hmap all_ofproto_dpifs_by_name =
+ HMAP_INITIALIZER(&all_ofproto_dpifs_by_name);
+
+/* All existing ofproto_dpif instances, indexed by ->uuid. */
+static struct hmap all_ofproto_dpifs_by_uuid =
+ HMAP_INITIALIZER(&all_ofproto_dpifs_by_uuid);
static bool ofproto_use_tnl_push_pop = true;
static void ofproto_unixctl_init(void);
struct ofproto_dpif *ofproto;
sset_clear(names);
- HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+ HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_by_name_node,
+ &all_ofproto_dpifs_by_name) {
if (strcmp(type, ofproto->up.type)) {
continue;
}
{
struct ofproto_dpif *ofproto;
- HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+ HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_by_name_node,
+ &all_ofproto_dpifs_by_name) {
if (sset_contains(&ofproto->ports, name)) {
return ofproto;
}
simap_init(&tmp_backers);
simap_swap(&backer->tnl_backers, &tmp_backers);
- HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+ HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_by_name_node,
+ &all_ofproto_dpifs_by_name) {
struct ofport_dpif *iter;
if (backer != ofproto->backer) {
backer->need_revalidate = 0;
xlate_txn_start();
- HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+ HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_by_name_node,
+ &all_ofproto_dpifs_by_name) {
struct ofport_dpif *ofport;
struct ofbundle *bundle;
const char *devname;
sset_init(&devnames);
- HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+ HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_by_name_node,
+ &all_ofproto_dpifs_by_name) {
if (ofproto->backer == backer) {
struct ofport *ofport;
return;
}
- HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node,
- &all_ofproto_dpifs) {
+ HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_by_name_node,
+ &all_ofproto_dpifs_by_name) {
if (simap_contains(&ofproto->backer->tnl_backers, devname)) {
return;
}
{
struct ofproto_dpif *ofproto;
- HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+ HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_by_name_node,
+ &all_ofproto_dpifs_by_name) {
if (ofproto->backer == backer) {
sset_clear(&ofproto->port_poll_set);
ofproto->port_poll_errno = error;
}
}
- hmap_insert(&all_ofproto_dpifs, &ofproto->all_ofproto_dpifs_node,
+ hmap_insert(&all_ofproto_dpifs_by_name,
+ &ofproto->all_ofproto_dpifs_by_name_node,
hash_string(ofproto->up.name, 0));
+ hmap_insert(&all_ofproto_dpifs_by_uuid,
+ &ofproto->all_ofproto_dpifs_by_uuid_node,
+ uuid_hash(&ofproto->uuid));
memset(&ofproto->stats, 0, sizeof ofproto->stats);
ofproto_init_tables(ofproto_, N_TABLES);
* to the ofproto or anything in it. */
udpif_synchronize(ofproto->backer->udpif);
- hmap_remove(&all_ofproto_dpifs, &ofproto->all_ofproto_dpifs_node);
+ hmap_remove(&all_ofproto_dpifs_by_name,
+ &ofproto->all_ofproto_dpifs_by_name_node);
+ hmap_remove(&all_ofproto_dpifs_by_uuid,
+ &ofproto->all_ofproto_dpifs_by_uuid_node);
OFPROTO_FOR_EACH_TABLE (table, &ofproto->up) {
CLS_FOR_EACH (rule, up.cr, &table->cls) {
if (all_ofprotos) {
struct ofproto_dpif *o;
- HMAP_FOR_EACH (o, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+ HMAP_FOR_EACH (o, all_ofproto_dpifs_by_name_node,
+ &all_ofproto_dpifs_by_name) {
if (o != ofproto) {
struct mac_entry *e;
return;
}
- HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+ HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_by_name_node,
+ &all_ofproto_dpifs_by_name) {
struct ofport *peer_ofport;
struct ofport_dpif *peer;
char *peer_peer;
}
\f
struct ofproto_dpif *
-ofproto_dpif_lookup(const char *name)
+ofproto_dpif_lookup_by_name(const char *name)
{
struct ofproto_dpif *ofproto;
- HMAP_FOR_EACH_WITH_HASH (ofproto, all_ofproto_dpifs_node,
- hash_string(name, 0), &all_ofproto_dpifs) {
+ HMAP_FOR_EACH_WITH_HASH (ofproto, all_ofproto_dpifs_by_name_node,
+ hash_string(name, 0),
+ &all_ofproto_dpifs_by_name) {
if (!strcmp(ofproto->up.name, name)) {
return ofproto;
}
return NULL;
}
+struct ofproto_dpif *
+ofproto_dpif_lookup_by_uuid(const struct uuid *uuid)
+{
+ struct ofproto_dpif *ofproto;
+
+ HMAP_FOR_EACH_WITH_HASH (ofproto, all_ofproto_dpifs_by_uuid_node,
+ uuid_hash(uuid), &all_ofproto_dpifs_by_uuid) {
+ if (uuid_equals(&ofproto->uuid, uuid)) {
+ return ofproto;
+ }
+ }
+ return NULL;
+}
+
static void
ofproto_unixctl_fdb_flush(struct unixctl_conn *conn, int argc,
const char *argv[], void *aux OVS_UNUSED)
struct ofproto_dpif *ofproto;
if (argc > 1) {
- ofproto = ofproto_dpif_lookup(argv[1]);
+ ofproto = ofproto_dpif_lookup_by_name(argv[1]);
if (!ofproto) {
unixctl_command_reply_error(conn, "no such bridge");
return;
mac_learning_flush(ofproto->ml);
ovs_rwlock_unlock(&ofproto->ml->rwlock);
} else {
- HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+ HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_by_name_node,
+ &all_ofproto_dpifs_by_name) {
ovs_rwlock_wrlock(&ofproto->ml->rwlock);
mac_learning_flush(ofproto->ml);
ovs_rwlock_unlock(&ofproto->ml->rwlock);
struct ofproto_dpif *ofproto;
if (argc > 1) {
- ofproto = ofproto_dpif_lookup(argv[1]);
+ ofproto = ofproto_dpif_lookup_by_name(argv[1]);
if (!ofproto) {
unixctl_command_reply_error(conn, "no such bridge");
return;
}
mcast_snooping_mdb_flush(ofproto->ms);
} else {
- HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+ HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_by_name_node,
+ &all_ofproto_dpifs_by_name) {
if (!mcast_snooping_enabled(ofproto->ms)) {
continue;
}
const struct ofproto_dpif *ofproto;
const struct mac_entry *e;
- ofproto = ofproto_dpif_lookup(argv[1]);
+ ofproto = ofproto_dpif_lookup_by_name(argv[1]);
if (!ofproto) {
unixctl_command_reply_error(conn, "no such bridge");
return;
struct mcast_group_bundle *b;
struct mcast_mrouter_bundle *mrouter;
- ofproto = ofproto_dpif_lookup(argv[1]);
+ ofproto = ofproto_dpif_lookup_by_name(argv[1]);
if (!ofproto) {
unixctl_command_reply_error(conn, "no such bridge");
return;
{
const struct ofproto_dpif *ofproto;
- HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_node, &all_ofproto_dpifs) {
+ HMAP_FOR_EACH (ofproto, all_ofproto_dpifs_by_name_node,
+ &all_ofproto_dpifs_by_name) {
char *name = xasprintf("%s@%s", ofproto->up.type, ofproto->up.name);
shash_add_nocopy(ofproto_shash, name, ofproto);
}
struct dpif_flow f;
int error;
- ofproto = ofproto_dpif_lookup(argv[argc - 1]);
+ ofproto = ofproto_dpif_lookup_by_name(argv[argc - 1]);
if (!ofproto) {
unixctl_command_reply_error(conn, "no such bridge");
return;
{
struct ds ds = DS_EMPTY_INITIALIZER;
const char *br = argv[argc -1];
- struct ofproto_dpif *ofproto = ofproto_dpif_lookup(br);
+ struct ofproto_dpif *ofproto = ofproto_dpif_lookup_by_name(br);
if (!ofproto) {
unixctl_command_reply_error(conn, "no such bridge");
struct ds ds = DS_EMPTY_INITIALIZER;
const char *br = argv[1];
const char *name, *value;
- struct ofproto_dpif *ofproto = ofproto_dpif_lookup(br);
+ struct ofproto_dpif *ofproto = ofproto_dpif_lookup_by_name(br);
bool changed;
if (!ofproto) {