Commit f45f702a authored by Thomas Haller's avatar Thomas Haller

device: cleanup handling master/slave relationships in NMDevice

I found the handling of the master-device very confusing because it was
unclear who sets priv->master, and when it should be set.

Now:

- Setting priv->master (in a slave) always goes together with adding
  the master to priv->slaves (in the master). Previously, this was
  done at separate places, so it was not clear if master and slave
  always agree on their relationship -- in fact, they did not.

- There are now three basic functions which do the enslaving/releasing:
    (1) nm_device_master_add_slave()
    (2) nm_device_master_enslave_slave()
    (3) nm_device_master_release_one_slave()
  Step 3/release basically undoes the 1/add and 2/enslave steps.

- completing the enslaving/releasing is now done by
    (1) nm_device_slave_notify_enslave()
    (2) nm_device_slave_notify_release()
  These functions also emit signals like NM_DEVICE_MASTER.

- Derived classes no longer emit NM_DEVICE_SLAVES notification. Instead
  the notification is emited together with NM_DEVICE_MASTER, whenever a
  slaves changes state. Also, NM_DEVICE_SLAVES list now only exposes
  slaves that are actually @is_enslaved.
parent 9a8d9a0d
......@@ -408,7 +408,6 @@ enslave_slave (NMDevice *device,
} else
_LOGI (LOGD_BOND, "bond slave %s was enslaved", slave_iface);
g_object_notify (G_OBJECT (device), NM_DEVICE_SLAVES);
return TRUE;
}
......@@ -432,20 +431,16 @@ release_slave (NMDevice *device,
_LOGW (LOGD_BOND, "failed to release bond slave %s",
nm_device_get_ip_iface (slave));
}
} else {
_LOGI (LOGD_BOND, "bond slave %s was released",
nm_device_get_ip_iface (slave));
}
g_object_notify (G_OBJECT (device), NM_DEVICE_SLAVES);
if (configure) {
/* Kernel bonding code "closes" the slave when releasing it, (which clears
* IFF_UP), so we must bring it back up here to ensure carrier changes and
* other state is noticed by the now-released slave.
*/
if (!nm_device_bring_up (slave, TRUE, &no_firmware))
_LOGW (LOGD_BOND, "released bond slave could not be brought up.");
} else {
_LOGI (LOGD_BOND, "bond slave %s was released",
nm_device_get_ip_iface (slave));
}
}
......
......@@ -344,8 +344,6 @@ enslave_slave (NMDevice *device,
nm_device_get_ip_iface (slave));
}
g_object_notify (G_OBJECT (device), NM_DEVICE_SLAVES);
return TRUE;
}
......@@ -373,8 +371,6 @@ release_slave (NMDevice *device,
_LOGI (LOGD_BRIDGE, "bridge port %s was detached",
nm_device_get_ip_iface (slave));
}
g_object_notify (G_OBJECT (device), NM_DEVICE_SLAVES);
}
static gboolean
......
This diff is collapsed.
......@@ -637,8 +637,6 @@ enslave_slave (NMDevice *device,
} else
_LOGI (LOGD_TEAM, "team port %s was enslaved", slave_iface);
g_object_notify (G_OBJECT (device), NM_DEVICE_SLAVES);
return TRUE;
}
......@@ -659,12 +657,7 @@ release_slave (NMDevice *device,
_LOGI (LOGD_TEAM, "released team port %s", nm_device_get_ip_iface (slave));
else
_LOGW (LOGD_TEAM, "failed to release team port %s", nm_device_get_ip_iface (slave));
} else
_LOGI (LOGD_TEAM, "team port %s was released", nm_device_get_ip_iface (slave));
g_object_notify (G_OBJECT (device), NM_DEVICE_SLAVES);
if (configure) {
/* Kernel team code "closes" the port when releasing it, (which clears
* IFF_UP), so we must bring it back up here to ensure carrier changes and
* other state is noticed by the now-released port.
......@@ -672,7 +665,8 @@ release_slave (NMDevice *device,
if (!nm_device_bring_up (slave, TRUE, &no_firmware))
_LOGW (LOGD_TEAM, "released team port %s could not be brought up",
nm_device_get_ip_iface (slave));
}
} else
_LOGI (LOGD_TEAM, "team port %s was released", nm_device_get_ip_iface (slave));
}
static gboolean
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment