summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-05-04 10:26:58 -0700
committerBen Pfaff <blp@nicira.com>2011-05-04 10:26:58 -0700
commitf8ddccd2852c10758854ac18c7d440cca68e3964 (patch)
tree776f087627293126ebbb594acf2fa82cba3009b7
parent2ac6beddbf6a85299c449939a2086126f1f47dbc (diff)
downloadopenvswitch-f8ddccd2852c10758854ac18c7d440cca68e3964.tar.gz
bond: New function bond_slave_set_netdev().
To be used by an upcoming change.
-rw-r--r--lib/bond.c39
-rw-r--r--lib/bond.h1
2 files changed, 31 insertions, 9 deletions
diff --git a/lib/bond.c b/lib/bond.c
index ed6ed89b8..208310841 100644
--- a/lib/bond.c
+++ b/lib/bond.c
@@ -330,6 +330,21 @@ bond_reconfigure(struct bond *bond, const struct bond_settings *s)
return revalidate;
}
+static void
+bond_slave_set_netdev__(struct bond *bond, struct bond_slave *slave,
+ struct netdev *netdev)
+{
+ if (slave->netdev != netdev) {
+ if (bond->monitor) {
+ if (slave->netdev) {
+ netdev_monitor_remove(bond->monitor, slave->netdev);
+ }
+ netdev_monitor_add(bond->monitor, netdev);
+ }
+ slave->netdev = netdev;
+ }
+}
+
/* Registers 'slave_' as a slave of 'bond'. The 'slave_' pointer is an
* arbitrary client-provided pointer that uniquely identifies a slave within a
* bond. If 'slave_' already exists within 'bond' then this function
@@ -369,20 +384,26 @@ bond_slave_register(struct bond *bond, void *slave_, uint16_t stb_id,
bond->bond_revalidate = true;
}
- if (slave->netdev != netdev) {
- if (bond->monitor) {
- if (slave->netdev) {
- netdev_monitor_remove(bond->monitor, slave->netdev);
- }
- netdev_monitor_add(bond->monitor, netdev);
- }
- slave->netdev = netdev;
- }
+ bond_slave_set_netdev__(bond, slave, netdev);
free(slave->name);
slave->name = xstrdup(netdev_get_name(netdev));
}
+/* Updates the network device to be used with 'slave_' to 'netdev'.
+ *
+ * This is useful if the caller closes and re-opens the network device
+ * registered with bond_slave_register() but doesn't need to change anything
+ * else. */
+void
+bond_slave_set_netdev(struct bond *bond, void *slave_, struct netdev *netdev)
+{
+ struct bond_slave *slave = bond_slave_lookup(bond, slave_);
+ if (slave) {
+ bond_slave_set_netdev__(bond, slave, netdev);
+ }
+}
+
/* Unregisters 'slave_' from 'bond'. If 'bond' does not contain such a slave
* then this function has no effect.
*
diff --git a/lib/bond.h b/lib/bond.h
index b2ab89cd8..8736f4cd4 100644
--- a/lib/bond.h
+++ b/lib/bond.h
@@ -75,6 +75,7 @@ void bond_destroy(struct bond *);
bool bond_reconfigure(struct bond *, const struct bond_settings *);
void bond_slave_register(struct bond *, void *slave_,
uint16_t stable_id, struct netdev *);
+void bond_slave_set_netdev(struct bond *, void *slave_, struct netdev *);
void bond_slave_unregister(struct bond *, const void *slave);
void bond_run(struct bond *, struct tag_set *, bool lacp_negotiated);