Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
* where we can't otherwise provide revalidation feedback to the client.
* That's only unixctl commands now; I hope no other cases will arise. */
struct tag_set unixctl_tags;
* where we can't otherwise provide revalidation feedback to the client.
* That's only unixctl commands now; I hope no other cases will arise. */
struct tag_set unixctl_tags;
};
static struct hmap all_bonds = HMAP_INITIALIZER(&all_bonds);
};
static struct hmap all_bonds = HMAP_INITIALIZER(&all_bonds);
hmap_init(&bond->slaves);
bond->no_slaves_tag = tag_create_random();
bond->next_fake_iface_update = LLONG_MAX;
hmap_init(&bond->slaves);
bond->no_slaves_tag = tag_create_random();
bond->next_fake_iface_update = LLONG_MAX;
bond_reconfigure(bond, s);
bond_reconfigure(bond, s);
+struct bond *
+bond_ref(const struct bond *bond_)
+{
+ struct bond *bond = CONST_CAST(struct bond *, bond_);
+
+ ovs_assert(bond->ref_cnt > 0);
+ bond->ref_cnt++;
+ return bond;
+}
+
-bond_destroy(struct bond *bond)
+bond_unref(struct bond *bond)
{
struct bond_slave *slave, *next_slave;
{
struct bond_slave *slave, *next_slave;
+ ovs_assert(bond->ref_cnt > 0);
+ if (--bond->ref_cnt) {
+ return;
+ }
+
hmap_remove(&all_bonds, &bond->hmap_node);
HMAP_FOR_EACH_SAFE (slave, next_slave, hmap_node, &bond->slaves) {
hmap_remove(&all_bonds, &bond->hmap_node);
HMAP_FOR_EACH_SAFE (slave, next_slave, hmap_node, &bond->slaves) {
/* Basics. */
struct bond *bond_create(const struct bond_settings *);
/* Basics. */
struct bond *bond_create(const struct bond_settings *);
-void bond_destroy(struct bond *);
+void bond_unref(struct bond *);
+struct bond *bond_ref(const struct bond *);
bool bond_reconfigure(struct bond *, const struct bond_settings *);
void bond_slave_register(struct bond *, void *slave_, struct netdev *);
bool bond_reconfigure(struct bond *, const struct bond_settings *);
void bond_slave_register(struct bond *, void *slave_, struct netdev *);
free(bundle->name);
free(bundle->trunks);
lacp_unref(bundle->lacp);
free(bundle->name);
free(bundle->trunks);
lacp_unref(bundle->lacp);
- bond_destroy(bundle->bond);
+ bond_unref(bundle->bond);
bond_slave_register(bundle->bond, port, port->up.netdev);
}
} else {
bond_slave_register(bundle->bond, port, port->up.netdev);
}
} else {
- bond_destroy(bundle->bond);
+ bond_unref(bundle->bond);
if (list_is_empty(&bundle->ports)) {
bundle_destroy(bundle);
} else if (list_is_short(&bundle->ports)) {
if (list_is_empty(&bundle->ports)) {
bundle_destroy(bundle);
} else if (list_is_short(&bundle->ports)) {
- bond_destroy(bundle->bond);
+ bond_unref(bundle->bond);