device: rename {enslave,release}_slave() to {attach,detach}_port()
Rename the enslave_slave() and release_slave() device methods to attach_port() and detach_port().
This commit is contained in:
@@ -425,7 +425,7 @@ commit_port_options(NMDevice *bond_device, NMDevice *port, NMSettingBondPort *s_
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
enslave_slave(NMDevice *device, NMDevice *port, NMConnection *connection, gboolean configure)
|
attach_port(NMDevice *device, NMDevice *port, NMConnection *connection, gboolean configure)
|
||||||
{
|
{
|
||||||
NMDeviceBond *self = NM_DEVICE_BOND(device);
|
NMDeviceBond *self = NM_DEVICE_BOND(device);
|
||||||
NMSettingBondPort *s_port;
|
NMSettingBondPort *s_port;
|
||||||
@@ -442,7 +442,7 @@ enslave_slave(NMDevice *device, NMDevice *port, NMConnection *connection, gboole
|
|||||||
nm_device_bring_up(port, TRUE, NULL);
|
nm_device_bring_up(port, TRUE, NULL);
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
_LOGI(LOGD_BOND, "assigning bond port %s: failed", nm_device_get_ip_iface(port));
|
_LOGI(LOGD_BOND, "attaching bond port %s: failed", nm_device_get_ip_iface(port));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -450,15 +450,15 @@ enslave_slave(NMDevice *device, NMDevice *port, NMConnection *connection, gboole
|
|||||||
|
|
||||||
commit_port_options(device, port, s_port);
|
commit_port_options(device, port, s_port);
|
||||||
|
|
||||||
_LOGI(LOGD_BOND, "assigned bond port %s", nm_device_get_ip_iface(port));
|
_LOGI(LOGD_BOND, "attached bond port %s", nm_device_get_ip_iface(port));
|
||||||
} else
|
} else
|
||||||
_LOGI(LOGD_BOND, "bond port %s was assigned", nm_device_get_ip_iface(port));
|
_LOGI(LOGD_BOND, "bond port %s was attached", nm_device_get_ip_iface(port));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
detach_port(NMDevice *device, NMDevice *port, gboolean configure)
|
||||||
{
|
{
|
||||||
NMDeviceBond *self = NM_DEVICE_BOND(device);
|
NMDeviceBond *self = NM_DEVICE_BOND(device);
|
||||||
gboolean success;
|
gboolean success;
|
||||||
@@ -472,10 +472,10 @@ release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
|||||||
configure = FALSE;
|
configure = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifindex_slave = nm_device_get_ip_ifindex(slave);
|
ifindex_slave = nm_device_get_ip_ifindex(port);
|
||||||
|
|
||||||
if (ifindex_slave <= 0)
|
if (ifindex_slave <= 0)
|
||||||
_LOGD(LOGD_BOND, "bond slave %s is already released", nm_device_get_ip_iface(slave));
|
_LOGD(LOGD_BOND, "bond port %s is already detached", nm_device_get_ip_iface(port));
|
||||||
|
|
||||||
if (configure) {
|
if (configure) {
|
||||||
NMConnection *applied;
|
NMConnection *applied;
|
||||||
@@ -490,9 +490,9 @@ release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
|||||||
ifindex_slave);
|
ifindex_slave);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
_LOGI(LOGD_BOND, "released bond slave %s", nm_device_get_ip_iface(slave));
|
_LOGI(LOGD_BOND, "detached bond port %s", nm_device_get_ip_iface(port));
|
||||||
} else {
|
} else {
|
||||||
_LOGW(LOGD_BOND, "failed to release bond slave %s", nm_device_get_ip_iface(slave));
|
_LOGW(LOGD_BOND, "failed to detach bond port %s", nm_device_get_ip_iface(port));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,12 +512,12 @@ release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
|||||||
* other state is noticed by the now-released slave.
|
* other state is noticed by the now-released slave.
|
||||||
*/
|
*/
|
||||||
if (ifindex_slave > 0) {
|
if (ifindex_slave > 0) {
|
||||||
if (!nm_device_bring_up(slave, TRUE, NULL))
|
if (!nm_device_bring_up(port, TRUE, NULL))
|
||||||
_LOGW(LOGD_BOND, "released bond slave could not be brought up.");
|
_LOGW(LOGD_BOND, "detached bond port could not be brought up.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ifindex_slave > 0) {
|
if (ifindex_slave > 0) {
|
||||||
_LOGI(LOGD_BOND, "bond slave %s was released", nm_device_get_ip_iface(slave));
|
_LOGI(LOGD_BOND, "bond port %s was detached", nm_device_get_ip_iface(port));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -663,8 +663,8 @@ nm_device_bond_class_init(NMDeviceBondClass *klass)
|
|||||||
device_class->create_and_realize = create_and_realize;
|
device_class->create_and_realize = create_and_realize;
|
||||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||||
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
||||||
device_class->enslave_slave = enslave_slave;
|
device_class->attach_port = attach_port;
|
||||||
device_class->release_slave = release_slave;
|
device_class->detach_port = detach_port;
|
||||||
device_class->can_reapply_change = can_reapply_change;
|
device_class->can_reapply_change = can_reapply_change;
|
||||||
device_class->reapply_connection = reapply_connection;
|
device_class->reapply_connection = reapply_connection;
|
||||||
}
|
}
|
||||||
|
@@ -975,7 +975,7 @@ deactivate(NMDevice *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure)
|
attach_port(NMDevice *device, NMDevice *port, NMConnection *connection, gboolean configure)
|
||||||
{
|
{
|
||||||
NMDeviceBridge *self = NM_DEVICE_BRIDGE(device);
|
NMDeviceBridge *self = NM_DEVICE_BRIDGE(device);
|
||||||
NMConnection *master_connection;
|
NMConnection *master_connection;
|
||||||
@@ -985,7 +985,7 @@ enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gbool
|
|||||||
if (configure) {
|
if (configure) {
|
||||||
if (!nm_platform_link_enslave(nm_device_get_platform(device),
|
if (!nm_platform_link_enslave(nm_device_get_platform(device),
|
||||||
nm_device_get_ip_ifindex(device),
|
nm_device_get_ip_ifindex(device),
|
||||||
nm_device_get_ip_ifindex(slave)))
|
nm_device_get_ip_ifindex(port)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
master_connection = nm_device_get_applied_connection(device);
|
master_connection = nm_device_get_applied_connection(device);
|
||||||
@@ -1009,25 +1009,25 @@ enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gbool
|
|||||||
* (except for the default one) and so there's no need to flush. */
|
* (except for the default one) and so there's no need to flush. */
|
||||||
|
|
||||||
if (plat_vlans
|
if (plat_vlans
|
||||||
&& !nm_platform_link_set_bridge_vlans(nm_device_get_platform(slave),
|
&& !nm_platform_link_set_bridge_vlans(nm_device_get_platform(port),
|
||||||
nm_device_get_ifindex(slave),
|
nm_device_get_ifindex(port),
|
||||||
TRUE,
|
TRUE,
|
||||||
plat_vlans))
|
plat_vlans))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
commit_slave_options(slave, s_port);
|
commit_slave_options(port, s_port);
|
||||||
|
|
||||||
_LOGI(LOGD_BRIDGE, "attached bridge port %s", nm_device_get_ip_iface(slave));
|
_LOGI(LOGD_BRIDGE, "attached bridge port %s", nm_device_get_ip_iface(port));
|
||||||
} else {
|
} else {
|
||||||
_LOGI(LOGD_BRIDGE, "bridge port %s was attached", nm_device_get_ip_iface(slave));
|
_LOGI(LOGD_BRIDGE, "bridge port %s was attached", nm_device_get_ip_iface(port));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
detach_port(NMDevice *device, NMDevice *port, gboolean configure)
|
||||||
{
|
{
|
||||||
NMDeviceBridge *self = NM_DEVICE_BRIDGE(device);
|
NMDeviceBridge *self = NM_DEVICE_BRIDGE(device);
|
||||||
gboolean success;
|
gboolean success;
|
||||||
@@ -1040,10 +1040,10 @@ release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
|||||||
configure = FALSE;
|
configure = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifindex_slave = nm_device_get_ip_ifindex(slave);
|
ifindex_slave = nm_device_get_ip_ifindex(port);
|
||||||
|
|
||||||
if (ifindex_slave <= 0) {
|
if (ifindex_slave <= 0) {
|
||||||
_LOGD(LOGD_TEAM, "bond slave %s is already released", nm_device_get_ip_iface(slave));
|
_LOGD(LOGD_TEAM, "bridge port %s is already detached", nm_device_get_ip_iface(port));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1053,12 +1053,12 @@ release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
|||||||
ifindex_slave);
|
ifindex_slave);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
_LOGI(LOGD_BRIDGE, "detached bridge port %s", nm_device_get_ip_iface(slave));
|
_LOGI(LOGD_BRIDGE, "detached bridge port %s", nm_device_get_ip_iface(port));
|
||||||
} else {
|
} else {
|
||||||
_LOGW(LOGD_BRIDGE, "failed to detach bridge port %s", nm_device_get_ip_iface(slave));
|
_LOGW(LOGD_BRIDGE, "failed to detach bridge port %s", nm_device_get_ip_iface(port));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_LOGI(LOGD_BRIDGE, "bridge port %s was detached", nm_device_get_ip_iface(slave));
|
_LOGI(LOGD_BRIDGE, "bridge port %s was detached", nm_device_get_ip_iface(port));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1182,8 +1182,8 @@ nm_device_bridge_class_init(NMDeviceBridgeClass *klass)
|
|||||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||||
device_class->act_stage2_config = act_stage2_config;
|
device_class->act_stage2_config = act_stage2_config;
|
||||||
device_class->deactivate = deactivate;
|
device_class->deactivate = deactivate;
|
||||||
device_class->enslave_slave = enslave_slave;
|
device_class->attach_port = attach_port;
|
||||||
device_class->release_slave = release_slave;
|
device_class->detach_port = detach_port;
|
||||||
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -207,37 +207,37 @@ update_connection(NMDevice *device, NMConnection *connection)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure)
|
attach_port(NMDevice *device, NMDevice *port, NMConnection *connection, gboolean configure)
|
||||||
{
|
{
|
||||||
NMDeviceVrf *self = NM_DEVICE_VRF(device);
|
NMDeviceVrf *self = NM_DEVICE_VRF(device);
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
const char *slave_iface = nm_device_get_ip_iface(slave);
|
const char *port_iface = nm_device_get_ip_iface(port);
|
||||||
|
|
||||||
nm_device_master_check_slave_physical_port(device, slave, LOGD_DEVICE);
|
nm_device_master_check_slave_physical_port(device, port, LOGD_DEVICE);
|
||||||
|
|
||||||
if (configure) {
|
if (configure) {
|
||||||
nm_device_take_down(slave, TRUE);
|
nm_device_take_down(port, TRUE);
|
||||||
success = nm_platform_link_enslave(nm_device_get_platform(device),
|
success = nm_platform_link_enslave(nm_device_get_platform(device),
|
||||||
nm_device_get_ip_ifindex(device),
|
nm_device_get_ip_ifindex(device),
|
||||||
nm_device_get_ip_ifindex(slave));
|
nm_device_get_ip_ifindex(port));
|
||||||
nm_device_bring_up(slave, TRUE, NULL);
|
nm_device_bring_up(port, TRUE, NULL);
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
_LOGI(LOGD_DEVICE, "enslaved VRF slave %s", slave_iface);
|
_LOGI(LOGD_DEVICE, "attached VRF port %s", port_iface);
|
||||||
} else
|
} else
|
||||||
_LOGI(LOGD_BOND, "VRF slave %s was enslaved", slave_iface);
|
_LOGI(LOGD_BOND, "VRF port %s was attached", port_iface);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
detach_port(NMDevice *device, NMDevice *port, gboolean configure)
|
||||||
{
|
{
|
||||||
NMDeviceVrf *self = NM_DEVICE_VRF(device);
|
NMDeviceVrf *self = NM_DEVICE_VRF(device);
|
||||||
gboolean success;
|
gboolean success;
|
||||||
int ifindex_slave;
|
int ifindex_port;
|
||||||
int ifindex;
|
int ifindex;
|
||||||
|
|
||||||
if (configure) {
|
if (configure) {
|
||||||
@@ -246,26 +246,26 @@ release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
|||||||
configure = FALSE;
|
configure = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifindex_slave = nm_device_get_ip_ifindex(slave);
|
ifindex_port = nm_device_get_ip_ifindex(port);
|
||||||
|
|
||||||
if (ifindex_slave <= 0)
|
if (ifindex_port <= 0)
|
||||||
_LOGD(LOGD_DEVICE, "VRF slave %s is already released", nm_device_get_ip_iface(slave));
|
_LOGD(LOGD_DEVICE, "VRF port %s is already detached", nm_device_get_ip_iface(port));
|
||||||
|
|
||||||
if (configure) {
|
if (configure) {
|
||||||
if (ifindex_slave > 0) {
|
if (ifindex_port > 0) {
|
||||||
success = nm_platform_link_release(nm_device_get_platform(device),
|
success = nm_platform_link_release(nm_device_get_platform(device),
|
||||||
nm_device_get_ip_ifindex(device),
|
nm_device_get_ip_ifindex(device),
|
||||||
ifindex_slave);
|
ifindex_port);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
_LOGI(LOGD_DEVICE, "released VRF slave %s", nm_device_get_ip_iface(slave));
|
_LOGI(LOGD_DEVICE, "detached VRF port %s", nm_device_get_ip_iface(port));
|
||||||
} else {
|
} else {
|
||||||
_LOGW(LOGD_DEVICE, "failed to release VRF slave %s", nm_device_get_ip_iface(slave));
|
_LOGW(LOGD_DEVICE, "failed to detach VRF port %s", nm_device_get_ip_iface(port));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ifindex_slave > 0) {
|
if (ifindex_port > 0) {
|
||||||
_LOGI(LOGD_DEVICE, "VRF slave %s was released", nm_device_get_ip_iface(slave));
|
_LOGI(LOGD_DEVICE, "VRF port %s was detached", nm_device_get_ip_iface(port));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,8 +316,8 @@ nm_device_vrf_class_init(NMDeviceVrfClass *klass)
|
|||||||
device_class->is_master = TRUE;
|
device_class->is_master = TRUE;
|
||||||
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES(NM_LINK_TYPE_VRF);
|
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES(NM_LINK_TYPE_VRF);
|
||||||
|
|
||||||
device_class->enslave_slave = enslave_slave;
|
device_class->attach_port = attach_port;
|
||||||
device_class->release_slave = release_slave;
|
device_class->detach_port = detach_port;
|
||||||
device_class->link_changed = link_changed;
|
device_class->link_changed = link_changed;
|
||||||
device_class->unrealize_notify = unrealize_notify;
|
device_class->unrealize_notify = unrealize_notify;
|
||||||
device_class->create_and_realize = create_and_realize;
|
device_class->create_and_realize = create_and_realize;
|
||||||
|
@@ -5948,7 +5948,7 @@ nm_device_master_enslave_slave(NMDevice *self, NMDevice *slave, NMConnection *co
|
|||||||
|
|
||||||
g_return_val_if_fail(self != NULL, FALSE);
|
g_return_val_if_fail(self != NULL, FALSE);
|
||||||
g_return_val_if_fail(slave != NULL, FALSE);
|
g_return_val_if_fail(slave != NULL, FALSE);
|
||||||
g_return_val_if_fail(NM_DEVICE_GET_CLASS(self)->enslave_slave != NULL, FALSE);
|
g_return_val_if_fail(NM_DEVICE_GET_CLASS(self)->attach_port != NULL, FALSE);
|
||||||
|
|
||||||
info = find_slave_info(self, slave);
|
info = find_slave_info(self, slave);
|
||||||
if (!info)
|
if (!info)
|
||||||
@@ -5961,7 +5961,7 @@ nm_device_master_enslave_slave(NMDevice *self, NMDevice *slave, NMConnection *co
|
|||||||
if (configure)
|
if (configure)
|
||||||
g_return_val_if_fail(nm_device_get_state(slave) >= NM_DEVICE_STATE_DISCONNECTED, FALSE);
|
g_return_val_if_fail(nm_device_get_state(slave) >= NM_DEVICE_STATE_DISCONNECTED, FALSE);
|
||||||
|
|
||||||
success = NM_DEVICE_GET_CLASS(self)->enslave_slave(self, slave, connection, configure);
|
success = NM_DEVICE_GET_CLASS(self)->attach_port(self, slave, connection, configure);
|
||||||
info->slave_is_enslaved = success;
|
info->slave_is_enslaved = success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6017,7 +6017,7 @@ nm_device_master_release_slave(NMDevice *self,
|
|||||||
RELEASE_SLAVE_TYPE_NO_CONFIG,
|
RELEASE_SLAVE_TYPE_NO_CONFIG,
|
||||||
RELEASE_SLAVE_TYPE_CONFIG,
|
RELEASE_SLAVE_TYPE_CONFIG,
|
||||||
RELEASE_SLAVE_TYPE_CONFIG_FORCE));
|
RELEASE_SLAVE_TYPE_CONFIG_FORCE));
|
||||||
g_return_if_fail(NM_DEVICE_GET_CLASS(self)->release_slave != NULL);
|
g_return_if_fail(NM_DEVICE_GET_CLASS(self)->detach_port != NULL);
|
||||||
|
|
||||||
info = find_slave_info(self, slave);
|
info = find_slave_info(self, slave);
|
||||||
|
|
||||||
@@ -6042,7 +6042,7 @@ nm_device_master_release_slave(NMDevice *self,
|
|||||||
/* first, let subclasses handle the release ... */
|
/* first, let subclasses handle the release ... */
|
||||||
if (info->slave_is_enslaved || nm_device_sys_iface_state_is_external(slave)
|
if (info->slave_is_enslaved || nm_device_sys_iface_state_is_external(slave)
|
||||||
|| release_type >= RELEASE_SLAVE_TYPE_CONFIG_FORCE)
|
|| release_type >= RELEASE_SLAVE_TYPE_CONFIG_FORCE)
|
||||||
NM_DEVICE_GET_CLASS(self)->release_slave(self,
|
NM_DEVICE_GET_CLASS(self)->detach_port(self,
|
||||||
slave,
|
slave,
|
||||||
release_type >= RELEASE_SLAVE_TYPE_CONFIG);
|
release_type >= RELEASE_SLAVE_TYPE_CONFIG);
|
||||||
|
|
||||||
@@ -6385,7 +6385,7 @@ device_recheck_slave_status(NMDevice *self, const NMPlatformLink *plink)
|
|||||||
NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED);
|
NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (master && NM_DEVICE_GET_CLASS(master)->enslave_slave) {
|
if (master && NM_DEVICE_GET_CLASS(master)->attach_port) {
|
||||||
nm_device_master_add_slave(master, self, FALSE);
|
nm_device_master_add_slave(master, self, FALSE);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -7609,7 +7609,7 @@ nm_device_master_add_slave(NMDevice *self, NMDevice *slave, gboolean configure)
|
|||||||
|
|
||||||
g_return_val_if_fail(NM_IS_DEVICE(self), FALSE);
|
g_return_val_if_fail(NM_IS_DEVICE(self), FALSE);
|
||||||
g_return_val_if_fail(NM_IS_DEVICE(slave), FALSE);
|
g_return_val_if_fail(NM_IS_DEVICE(slave), FALSE);
|
||||||
g_return_val_if_fail(NM_DEVICE_GET_CLASS(self)->enslave_slave != NULL, FALSE);
|
g_return_val_if_fail(NM_DEVICE_GET_CLASS(self)->attach_port != NULL, FALSE);
|
||||||
|
|
||||||
priv = NM_DEVICE_GET_PRIVATE(self);
|
priv = NM_DEVICE_GET_PRIVATE(self);
|
||||||
slave_priv = NM_DEVICE_GET_PRIVATE(slave);
|
slave_priv = NM_DEVICE_GET_PRIVATE(slave);
|
||||||
|
@@ -373,12 +373,12 @@ typedef struct _NMDeviceClass {
|
|||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
gboolean (*enslave_slave)(NMDevice *self,
|
gboolean (*attach_port)(NMDevice *self,
|
||||||
NMDevice *slave,
|
NMDevice *port,
|
||||||
NMConnection *connection,
|
NMConnection *connection,
|
||||||
gboolean configure);
|
gboolean configure);
|
||||||
|
|
||||||
void (*release_slave)(NMDevice *self, NMDevice *slave, gboolean configure);
|
void (*detach_port)(NMDevice *self, NMDevice *port, gboolean configure);
|
||||||
|
|
||||||
void (*parent_changed_notify)(NMDevice *self,
|
void (*parent_changed_notify)(NMDevice *self,
|
||||||
int old_ifindex,
|
int old_ifindex,
|
||||||
|
@@ -79,19 +79,19 @@ act_stage3_ip_config(NMDevice *device, int addr_family)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure)
|
attach_port(NMDevice *device, NMDevice *port, NMConnection *connection, gboolean configure)
|
||||||
{
|
{
|
||||||
if (!configure)
|
if (!configure)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
if (!NM_IS_DEVICE_OVS_PORT(slave))
|
if (!NM_IS_DEVICE_OVS_PORT(port))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
detach_port(NMDevice *device, NMDevice *port, gboolean configure)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -159,8 +159,8 @@ nm_device_ovs_bridge_class_init(NMDeviceOvsBridgeClass *klass)
|
|||||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||||
device_class->act_stage3_ip_config = act_stage3_ip_config;
|
device_class->act_stage3_ip_config = act_stage3_ip_config;
|
||||||
device_class->ready_for_ip_config = ready_for_ip_config;
|
device_class->ready_for_ip_config = ready_for_ip_config;
|
||||||
device_class->enslave_slave = enslave_slave;
|
device_class->attach_port = attach_port;
|
||||||
device_class->release_slave = release_slave;
|
device_class->detach_port = detach_port;
|
||||||
device_class->can_reapply_change_ovs_external_ids = TRUE;
|
device_class->can_reapply_change_ovs_external_ids = TRUE;
|
||||||
device_class->reapply_connection = nm_device_ovs_reapply_connection;
|
device_class->reapply_connection = nm_device_ovs_reapply_connection;
|
||||||
}
|
}
|
||||||
|
@@ -116,7 +116,7 @@ set_mtu_cb(GError *error, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure)
|
attach_port(NMDevice *device, NMDevice *port, NMConnection *connection, gboolean configure)
|
||||||
{
|
{
|
||||||
NMDeviceOvsPort *self = NM_DEVICE_OVS_PORT(device);
|
NMDeviceOvsPort *self = NM_DEVICE_OVS_PORT(device);
|
||||||
NMActiveConnection *ac_port = NULL;
|
NMActiveConnection *ac_port = NULL;
|
||||||
@@ -131,39 +131,39 @@ enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gbool
|
|||||||
ac_bridge = nm_active_connection_get_master(ac_port);
|
ac_bridge = nm_active_connection_get_master(ac_port);
|
||||||
if (!ac_bridge) {
|
if (!ac_bridge) {
|
||||||
_LOGW(LOGD_DEVICE,
|
_LOGW(LOGD_DEVICE,
|
||||||
"can't enslave %s: bridge active-connection not found",
|
"can't attach %s: bridge active-connection not found",
|
||||||
nm_device_get_iface(slave));
|
nm_device_get_iface(port));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bridge_device = nm_active_connection_get_device(ac_bridge);
|
bridge_device = nm_active_connection_get_device(ac_bridge);
|
||||||
if (!bridge_device) {
|
if (!bridge_device) {
|
||||||
_LOGW(LOGD_DEVICE, "can't enslave %s: bridge device not found", nm_device_get_iface(slave));
|
_LOGW(LOGD_DEVICE, "can't attach %s: bridge device not found", nm_device_get_iface(port));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nm_ovsdb_add_interface(nm_ovsdb_get(),
|
nm_ovsdb_add_interface(nm_ovsdb_get(),
|
||||||
nm_active_connection_get_applied_connection(ac_bridge),
|
nm_active_connection_get_applied_connection(ac_bridge),
|
||||||
nm_device_get_applied_connection(device),
|
nm_device_get_applied_connection(device),
|
||||||
nm_device_get_applied_connection(slave),
|
nm_device_get_applied_connection(port),
|
||||||
bridge_device,
|
bridge_device,
|
||||||
slave,
|
port,
|
||||||
add_iface_cb,
|
add_iface_cb,
|
||||||
g_object_ref(slave));
|
g_object_ref(port));
|
||||||
|
|
||||||
/* DPDK ports does not have a link after the devbind, so the MTU must be
|
/* DPDK ports does not have a link after the devbind, so the MTU must be
|
||||||
* set on ovsdb after adding the interface. */
|
* set on ovsdb after adding the interface. */
|
||||||
if (NM_IS_DEVICE_OVS_INTERFACE(slave) && _ovs_interface_is_dpdk(slave)) {
|
if (NM_IS_DEVICE_OVS_INTERFACE(port) && _ovs_interface_is_dpdk(port)) {
|
||||||
s_wired = nm_device_get_applied_setting(slave, NM_TYPE_SETTING_WIRED);
|
s_wired = nm_device_get_applied_setting(port, NM_TYPE_SETTING_WIRED);
|
||||||
|
|
||||||
if (!s_wired || !nm_setting_wired_get_mtu(s_wired))
|
if (!s_wired || !nm_setting_wired_get_mtu(s_wired))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
nm_ovsdb_set_interface_mtu(nm_ovsdb_get(),
|
nm_ovsdb_set_interface_mtu(nm_ovsdb_get(),
|
||||||
nm_device_get_ip_iface(slave),
|
nm_device_get_ip_iface(port),
|
||||||
nm_setting_wired_get_mtu(s_wired),
|
nm_setting_wired_get_mtu(s_wired),
|
||||||
set_mtu_cb,
|
set_mtu_cb,
|
||||||
g_object_ref(slave));
|
g_object_ref(port));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -186,31 +186,31 @@ del_iface_cb(GError *error, gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
detach_port(NMDevice *device, NMDevice *port, gboolean configure)
|
||||||
{
|
{
|
||||||
NMDeviceOvsPort *self = NM_DEVICE_OVS_PORT(device);
|
NMDeviceOvsPort *self = NM_DEVICE_OVS_PORT(device);
|
||||||
bool slave_not_managed = !NM_IN_SET(nm_device_sys_iface_state_get(slave),
|
bool port_not_managed = !NM_IN_SET(nm_device_sys_iface_state_get(port),
|
||||||
NM_DEVICE_SYS_IFACE_STATE_MANAGED,
|
NM_DEVICE_SYS_IFACE_STATE_MANAGED,
|
||||||
NM_DEVICE_SYS_IFACE_STATE_ASSUME);
|
NM_DEVICE_SYS_IFACE_STATE_ASSUME);
|
||||||
|
|
||||||
_LOGI(LOGD_DEVICE, "releasing ovs interface %s", nm_device_get_ip_iface(slave));
|
_LOGI(LOGD_DEVICE, "detaching ovs interface %s", nm_device_get_ip_iface(port));
|
||||||
|
|
||||||
/* Even if the an interface's device has gone away (e.g. externally
|
/* Even if the an interface's device has gone away (e.g. externally
|
||||||
* removed and thus we're called with configure=FALSE), we still need
|
* removed and thus we're called with configure=FALSE), we still need
|
||||||
* to make sure its OVSDB entry is gone.
|
* to make sure its OVSDB entry is gone.
|
||||||
*/
|
*/
|
||||||
if (configure || slave_not_managed) {
|
if (configure || port_not_managed) {
|
||||||
nm_ovsdb_del_interface(nm_ovsdb_get(),
|
nm_ovsdb_del_interface(nm_ovsdb_get(),
|
||||||
nm_device_get_iface(slave),
|
nm_device_get_iface(port),
|
||||||
del_iface_cb,
|
del_iface_cb,
|
||||||
g_object_ref(slave));
|
g_object_ref(port));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configure) {
|
if (configure) {
|
||||||
/* Open VSwitch is going to delete this one. We must ignore what happens
|
/* Open VSwitch is going to delete this one. We must ignore what happens
|
||||||
* next with the interface. */
|
* next with the interface. */
|
||||||
if (NM_IS_DEVICE_OVS_INTERFACE(slave))
|
if (NM_IS_DEVICE_OVS_INTERFACE(port))
|
||||||
nm_device_update_from_platform_link(slave, NULL);
|
nm_device_update_from_platform_link(port, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,8 +245,8 @@ nm_device_ovs_port_class_init(NMDeviceOvsPortClass *klass)
|
|||||||
device_class->get_generic_capabilities = get_generic_capabilities;
|
device_class->get_generic_capabilities = get_generic_capabilities;
|
||||||
device_class->act_stage3_ip_config = act_stage3_ip_config;
|
device_class->act_stage3_ip_config = act_stage3_ip_config;
|
||||||
device_class->ready_for_ip_config = ready_for_ip_config;
|
device_class->ready_for_ip_config = ready_for_ip_config;
|
||||||
device_class->enslave_slave = enslave_slave;
|
device_class->attach_port = attach_port;
|
||||||
device_class->release_slave = release_slave;
|
device_class->detach_port = detach_port;
|
||||||
device_class->can_reapply_change_ovs_external_ids = TRUE;
|
device_class->can_reapply_change_ovs_external_ids = TRUE;
|
||||||
device_class->reapply_connection = nm_device_ovs_reapply_connection;
|
device_class->reapply_connection = nm_device_ovs_reapply_connection;
|
||||||
}
|
}
|
||||||
|
@@ -791,18 +791,18 @@ deactivate(NMDevice *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gboolean configure)
|
attach_port(NMDevice *device, NMDevice *port, NMConnection *connection, gboolean configure)
|
||||||
{
|
{
|
||||||
NMDeviceTeam *self = NM_DEVICE_TEAM(device);
|
NMDeviceTeam *self = NM_DEVICE_TEAM(device);
|
||||||
NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self);
|
NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self);
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
const char *slave_iface = nm_device_get_ip_iface(slave);
|
const char *port_iface = nm_device_get_ip_iface(port);
|
||||||
NMSettingTeamPort *s_team_port;
|
NMSettingTeamPort *s_team_port;
|
||||||
|
|
||||||
nm_device_master_check_slave_physical_port(device, slave, LOGD_TEAM);
|
nm_device_master_check_slave_physical_port(device, port, LOGD_TEAM);
|
||||||
|
|
||||||
if (configure) {
|
if (configure) {
|
||||||
nm_device_take_down(slave, TRUE);
|
nm_device_take_down(port, TRUE);
|
||||||
|
|
||||||
s_team_port = nm_connection_get_setting_team_port(connection);
|
s_team_port = nm_connection_get_setting_team_port(connection);
|
||||||
if (s_team_port) {
|
if (s_team_port) {
|
||||||
@@ -811,19 +811,19 @@ enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gbool
|
|||||||
if (config) {
|
if (config) {
|
||||||
if (!priv->tdc) {
|
if (!priv->tdc) {
|
||||||
_LOGW(LOGD_TEAM,
|
_LOGW(LOGD_TEAM,
|
||||||
"enslaved team port %s config not changed, not connected to teamd",
|
"attached team port %s config not changed, not connected to teamd",
|
||||||
slave_iface);
|
port_iface);
|
||||||
} else {
|
} else {
|
||||||
gs_free char *sanitized_config = NULL;
|
gs_free char *sanitized_config = NULL;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
sanitized_config = g_strdup(config);
|
sanitized_config = g_strdup(config);
|
||||||
g_strdelimit(sanitized_config, "\r\n", ' ');
|
g_strdelimit(sanitized_config, "\r\n", ' ');
|
||||||
err = teamdctl_port_config_update_raw(priv->tdc, slave_iface, sanitized_config);
|
err = teamdctl_port_config_update_raw(priv->tdc, port_iface, sanitized_config);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
_LOGE(LOGD_TEAM,
|
_LOGE(LOGD_TEAM,
|
||||||
"failed to update config for port %s (err=%d)",
|
"failed to update config for port %s (err=%d)",
|
||||||
slave_iface,
|
port_iface,
|
||||||
err);
|
err);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -832,8 +832,8 @@ enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gbool
|
|||||||
}
|
}
|
||||||
success = nm_platform_link_enslave(nm_device_get_platform(device),
|
success = nm_platform_link_enslave(nm_device_get_platform(device),
|
||||||
nm_device_get_ip_ifindex(device),
|
nm_device_get_ip_ifindex(device),
|
||||||
nm_device_get_ip_ifindex(slave));
|
nm_device_get_ip_ifindex(port));
|
||||||
nm_device_bring_up(slave, TRUE, NULL);
|
nm_device_bring_up(port, TRUE, NULL);
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -841,21 +841,21 @@ enslave_slave(NMDevice *device, NMDevice *slave, NMConnection *connection, gbool
|
|||||||
nm_clear_g_source(&priv->teamd_read_timeout);
|
nm_clear_g_source(&priv->teamd_read_timeout);
|
||||||
priv->teamd_read_timeout = g_timeout_add_seconds(5, teamd_read_timeout_cb, self);
|
priv->teamd_read_timeout = g_timeout_add_seconds(5, teamd_read_timeout_cb, self);
|
||||||
|
|
||||||
_LOGI(LOGD_TEAM, "enslaved team port %s", slave_iface);
|
_LOGI(LOGD_TEAM, "attached team port %s", port_iface);
|
||||||
} else
|
} else
|
||||||
_LOGI(LOGD_TEAM, "team port %s was enslaved", slave_iface);
|
_LOGI(LOGD_TEAM, "team port %s was attached", port_iface);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
detach_port(NMDevice *device, NMDevice *port, gboolean configure)
|
||||||
{
|
{
|
||||||
NMDeviceTeam *self = NM_DEVICE_TEAM(device);
|
NMDeviceTeam *self = NM_DEVICE_TEAM(device);
|
||||||
NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self);
|
NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE(self);
|
||||||
gboolean do_release, success;
|
gboolean do_release, success;
|
||||||
NMSettingTeamPort *s_port;
|
NMSettingTeamPort *s_port;
|
||||||
int ifindex_slave;
|
int ifindex_port;
|
||||||
int ifindex;
|
int ifindex;
|
||||||
|
|
||||||
do_release = configure;
|
do_release = configure;
|
||||||
@@ -865,39 +865,39 @@ release_slave(NMDevice *device, NMDevice *slave, gboolean configure)
|
|||||||
do_release = FALSE;
|
do_release = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifindex_slave = nm_device_get_ip_ifindex(slave);
|
ifindex_port = nm_device_get_ip_ifindex(port);
|
||||||
|
|
||||||
if (ifindex_slave <= 0) {
|
if (ifindex_port <= 0) {
|
||||||
_LOGD(LOGD_TEAM, "team port %s is already released", nm_device_get_ip_iface(slave));
|
_LOGD(LOGD_TEAM, "team port %s is already detached", nm_device_get_ip_iface(port));
|
||||||
} else if (do_release) {
|
} else if (do_release) {
|
||||||
success = nm_platform_link_release(nm_device_get_platform(device),
|
success = nm_platform_link_release(nm_device_get_platform(device),
|
||||||
nm_device_get_ip_ifindex(device),
|
nm_device_get_ip_ifindex(device),
|
||||||
ifindex_slave);
|
ifindex_port);
|
||||||
if (success)
|
if (success)
|
||||||
_LOGI(LOGD_TEAM, "released team port %s", nm_device_get_ip_iface(slave));
|
_LOGI(LOGD_TEAM, "detached team port %s", nm_device_get_ip_iface(port));
|
||||||
else
|
else
|
||||||
_LOGW(LOGD_TEAM, "failed to release team port %s", nm_device_get_ip_iface(slave));
|
_LOGW(LOGD_TEAM, "failed to detach team port %s", nm_device_get_ip_iface(port));
|
||||||
|
|
||||||
/* Kernel team code "closes" the port when releasing it, (which clears
|
/* 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
|
* IFF_UP), so we must bring it back up here to ensure carrier changes and
|
||||||
* other state is noticed by the now-released port.
|
* other state is noticed by the now-released port.
|
||||||
*/
|
*/
|
||||||
if (!nm_device_bring_up(slave, TRUE, NULL)) {
|
if (!nm_device_bring_up(port, TRUE, NULL)) {
|
||||||
_LOGW(LOGD_TEAM,
|
_LOGW(LOGD_TEAM,
|
||||||
"released team port %s could not be brought up",
|
"detached team port %s could not be brought up",
|
||||||
nm_device_get_ip_iface(slave));
|
nm_device_get_ip_iface(port));
|
||||||
}
|
}
|
||||||
|
|
||||||
nm_clear_g_source(&priv->teamd_read_timeout);
|
nm_clear_g_source(&priv->teamd_read_timeout);
|
||||||
priv->teamd_read_timeout = g_timeout_add_seconds(5, teamd_read_timeout_cb, self);
|
priv->teamd_read_timeout = g_timeout_add_seconds(5, teamd_read_timeout_cb, self);
|
||||||
} else
|
} else
|
||||||
_LOGI(LOGD_TEAM, "team port %s was released", nm_device_get_ip_iface(slave));
|
_LOGI(LOGD_TEAM, "team port %s was detached", nm_device_get_ip_iface(port));
|
||||||
|
|
||||||
/* Delete any port configuration we previously set */
|
/* Delete any port configuration we previously set */
|
||||||
if (configure && priv->tdc
|
if (configure && priv->tdc
|
||||||
&& (s_port = nm_device_get_applied_setting(slave, NM_TYPE_SETTING_TEAM_PORT))
|
&& (s_port = nm_device_get_applied_setting(port, NM_TYPE_SETTING_TEAM_PORT))
|
||||||
&& (nm_setting_team_port_get_config(s_port)))
|
&& (nm_setting_team_port_get_config(s_port)))
|
||||||
teamdctl_port_config_update_raw(priv->tdc, nm_device_get_ip_iface(slave), "{}");
|
teamdctl_port_config_update_raw(priv->tdc, nm_device_get_ip_iface(port), "{}");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -1064,8 +1064,8 @@ nm_device_team_class_init(NMDeviceTeamClass *klass)
|
|||||||
device_class->act_stage1_prepare = act_stage1_prepare;
|
device_class->act_stage1_prepare = act_stage1_prepare;
|
||||||
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
||||||
device_class->deactivate = deactivate;
|
device_class->deactivate = deactivate;
|
||||||
device_class->enslave_slave = enslave_slave;
|
device_class->attach_port = attach_port;
|
||||||
device_class->release_slave = release_slave;
|
device_class->detach_port = detach_port;
|
||||||
|
|
||||||
obj_properties[PROP_CONFIG] = g_param_spec_string(NM_DEVICE_TEAM_CONFIG,
|
obj_properties[PROP_CONFIG] = g_param_spec_string(NM_DEVICE_TEAM_CONFIG,
|
||||||
"",
|
"",
|
||||||
|
Reference in New Issue
Block a user