aboutsummaryrefslogtreecommitdiff
path: root/lib/bond.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-05-18 14:01:13 -0700
committerBen Pfaff <blp@nicira.com>2011-05-18 14:01:13 -0700
commitb2fda3effc787f265b5ad5dfa967ac00627bd075 (patch)
tree5c0017aedd36c0d9088dcd67a79beb8ff69bd4f9 /lib/bond.c
parent827ab71c97f25b77c94a1158834cdad35df6806f (diff)
parent2e281761473ed67ecae00205f62180e9a21c9ade (diff)
Merge 'next' into 'master'.
I know already that this breaks the statsfixes that were implemented by the following commits: 827ab71c97f "ofproto: Datapath statistics accounted twice." 6f1435fc8f7 "ofproto: Resubmit statistics improperly account during..." These were already broken in a previous merge. I will work on a fix.
Diffstat (limited to 'lib/bond.c')
-rw-r--r--lib/bond.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/lib/bond.c b/lib/bond.c
index cf1d0571..9caa3f2e 100644
--- a/lib/bond.c
+++ b/lib/bond.c
@@ -337,6 +337,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
@@ -376,20 +391,26 @@ bond_slave_register(struct bond *bond, void *slave_, uint32_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.
*