diff options
| author | Michael Biebl <biebl@debian.org> | 2024-08-09 18:57:15 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2024-08-09 18:57:15 +0200 |
| commit | e96d74409128c6a977e31f24fad9b267d2feb9a1 (patch) | |
| tree | 12dad71135c6c291de457568cb973208ea8a0024 /src/core/devices | |
| parent | 45a364c60a9d6d34e614c4f1f507c69336ad1e69 (diff) | |
New upstream version 1.48.8 upstream/1.48.8
Diffstat (limited to 'src/core/devices')
| -rw-r--r-- | src/core/devices/nm-device-bond.c | 58 | ||||
| -rw-r--r-- | src/core/devices/nm-device-bridge.c | 64 | ||||
| -rw-r--r-- | src/core/devices/nm-device-private.h | 7 | ||||
| -rw-r--r-- | src/core/devices/nm-device-vrf.c | 14 | ||||
| -rw-r--r-- | src/core/devices/nm-device.c | 800 | ||||
| -rw-r--r-- | src/core/devices/nm-device.h | 28 | ||||
| -rw-r--r-- | src/core/devices/ovs/nm-device-ovs-bridge.c | 2 | ||||
| -rw-r--r-- | src/core/devices/ovs/nm-device-ovs-interface.c | 14 | ||||
| -rw-r--r-- | src/core/devices/ovs/nm-device-ovs-port.c | 2 | ||||
| -rw-r--r-- | src/core/devices/team/nm-device-team.c | 63 | ||||
| -rw-r--r-- | src/core/devices/wifi/nm-device-wifi.c | 12 |
11 files changed, 546 insertions, 518 deletions
diff --git a/src/core/devices/nm-device-bond.c b/src/core/devices/nm-device-bond.c index 98670c8d..06a02d1a 100644 --- a/src/core/devices/nm-device-bond.c +++ b/src/core/devices/nm-device-bond.c @@ -121,7 +121,7 @@ _set_bond_attr(NMDevice *device, const char *attr, const char *value) /* kernel does not allow setting ad_actor_system to "00:00:00:00:00:00". We would thus * log an EINVAL error. Avoid that... at least, if the value is already "00:00:00:00:00:00". */ cur_val = - nm_platform_sysctl_master_get_option(nm_device_get_platform(device), ifindex, attr); + nm_platform_sysctl_controller_get_option(nm_device_get_platform(device), ifindex, attr); if (nm_streq0(cur_val, NM_BOND_AD_ACTOR_SYSTEM_DEFAULT)) return TRUE; @@ -129,8 +129,10 @@ _set_bond_attr(NMDevice *device, const char *attr, const char *value) * That will fail, and we will log a warning. There is nothing else to do. */ } - ret = - nm_platform_sysctl_master_set_option(nm_device_get_platform(device), ifindex, attr, value); + ret = nm_platform_sysctl_controller_set_option(nm_device_get_platform(device), + ifindex, + attr, + value); if (!ret) _LOGW(LOGD_PLATFORM, "failed to set bonding attribute '%s' to '%s'", attr, value); return ret; @@ -187,8 +189,9 @@ update_connection(NMDevice *device, NMConnection *connection) NM_SETTING_BOND_OPTION_BALANCE_SLB)) continue; - value = - nm_platform_sysctl_master_get_option(nm_device_get_platform(device), ifindex, option); + value = nm_platform_sysctl_controller_get_option(nm_device_get_platform(device), + ifindex, + option); if (value && _nm_setting_bond_get_option_type(s_bond, option) == NM_BOND_OPTION_TYPE_BOTH) { p = strchr(value, ' '); @@ -349,9 +352,10 @@ set_bond_arp_ip_targets(NMDevice *device, NMSettingBond *s_bond) gs_free char *cur_arp_ip_target = NULL; /* ARP targets: clear and initialize the list */ - cur_arp_ip_target = nm_platform_sysctl_master_get_option(nm_device_get_platform(device), - ifindex, - NM_SETTING_BOND_OPTION_ARP_IP_TARGET); + cur_arp_ip_target = + nm_platform_sysctl_controller_get_option(nm_device_get_platform(device), + ifindex, + NM_SETTING_BOND_OPTION_ARP_IP_TARGET); set_arp_targets( device, cur_arp_ip_target, @@ -659,7 +663,7 @@ commit_port_options(NMDevice *bond_device, NMDevice *port, NMSettingBondPort *s_ * one of those modes, don't try to set the priority explicitly to zero. */ prio_has = FALSE; } else if (nm_platform_kernel_support_get_full( - NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_BOND_SLAVE_PRIO, + NM_PLATFORM_KERNEL_SUPPORT_TYPE_IFLA_BOND_PORT_PRIO, FALSE) == NM_OPTION_BOOL_TRUE) { /* We can only detect support if we have it. We cannot detect lack of support if @@ -699,15 +703,15 @@ attach_port(NMDevice *device, NMDeviceBond *self = NM_DEVICE_BOND(device); NMSettingBondPort *s_port; - nm_device_master_check_slave_physical_port(device, port, LOGD_BOND); + nm_device_controller_check_port_physical_port(device, port, LOGD_BOND); if (configure) { gboolean success; nm_device_take_down(port, TRUE); - success = nm_platform_link_enslave(nm_device_get_platform(device), - nm_device_get_ip_ifindex(device), - nm_device_get_ip_ifindex(port)); + success = nm_platform_link_attach_port(nm_device_get_platform(device), + nm_device_get_ip_ifindex(device), + nm_device_get_ip_ifindex(port)); nm_device_bring_up(port); if (!success) { @@ -737,7 +741,7 @@ detach_port(NMDevice *device, NMDeviceBond *self = NM_DEVICE_BOND(device); gboolean success; gs_free char *address = NULL; - int ifindex_slave; + int ifindex_port; int ifindex; if (configure) { @@ -746,9 +750,9 @@ detach_port(NMDevice *device, configure = FALSE; } - ifindex_slave = nm_device_get_ip_ifindex(port); + ifindex_port = nm_device_get_ip_ifindex(port); - if (ifindex_slave <= 0) + if (ifindex_port <= 0) _LOGD(LOGD_BOND, "bond port %s is already detached", nm_device_get_ip_iface(port)); if (configure) { @@ -758,10 +762,10 @@ detach_port(NMDevice *device, address = g_strdup(nm_device_get_hw_address(device)); - if (ifindex_slave > 0) { - success = nm_platform_link_release(nm_device_get_platform(device), - nm_device_get_ip_ifindex(device), - ifindex_slave); + if (ifindex_port > 0) { + success = nm_platform_link_release_port(nm_device_get_platform(device), + nm_device_get_ip_ifindex(device), + ifindex_port); if (success) { _LOGI(LOGD_BOND, "detached bond port %s", nm_device_get_ip_iface(port)); @@ -773,7 +777,7 @@ detach_port(NMDevice *device, if ((applied = nm_device_get_applied_connection(device)) && ((s_wired = nm_connection_get_setting_wired(applied))) && ((cloned_mac = nm_setting_wired_get_cloned_mac_address(s_wired)))) { - /* When the last slave is released the bond MAC will be set to a random + /* When the last port is released the bond MAC will be set to a random * value by kernel; if we have set a cloned-mac-address, we need to * restore it to the previous value. */ nm_platform_process_events(nm_device_get_platform(device)); @@ -781,16 +785,16 @@ detach_port(NMDevice *device, nm_device_hw_addr_set(device, address, "restore", FALSE); } - /* Kernel bonding code "closes" the slave when releasing it, (which clears + /* Kernel bonding 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 slave. + * other state is noticed by the now-released port. */ - if (ifindex_slave > 0) { + if (ifindex_port > 0) { if (!nm_device_bring_up(port)) _LOGW(LOGD_BOND, "detached bond port could not be brought up."); } } else { - if (ifindex_slave > 0) { + if (ifindex_port > 0) { _LOGI(LOGD_BOND, "bond port %s was detached", nm_device_get_ip_iface(port)); } } @@ -962,8 +966,8 @@ nm_device_bond_class_init(NMDeviceBondClass *klass) device_class->get_generic_capabilities = get_generic_capabilities; device_class->complete_connection = complete_connection; - device_class->update_connection = update_connection; - device_class->master_update_slave_connection = controller_update_port_connection; + device_class->update_connection = update_connection; + device_class->controller_update_port_connection = controller_update_port_connection; device_class->create_and_realize = create_and_realize; device_class->act_stage1_prepare = act_stage1_prepare; diff --git a/src/core/devices/nm-device-bridge.c b/src/core/devices/nm-device-bridge.c index 82314f13..b256056d 100644 --- a/src/core/devices/nm-device-bridge.c +++ b/src/core/devices/nm-device-bridge.c @@ -311,7 +311,7 @@ typedef struct { #define OPTION_TYPE_TOFROM(to, fro) .to_sysfs = (to), .from_sysfs = (fro) -static const Option master_options[] = { +static const Option controller_options[] = { OPTION(NM_SETTING_BRIDGE_STP, /* this must stay as the first item */ "stp_state", OPTION_TYPE_BOOL(NM_BRIDGE_STP_DEF), ), @@ -487,12 +487,12 @@ update_connection(NMDevice *device, NMConnection *connection) gs_free char *stp = NULL; int stp_value; - option = master_options; + option = controller_options; nm_assert(nm_streq(option->sysname, "stp_state")); - stp = nm_platform_sysctl_master_get_option(nm_device_get_platform(device), - ifindex, - option->sysname); + stp = nm_platform_sysctl_controller_get_option(nm_device_get_platform(device), + ifindex, + option->sysname); stp_value = _nm_utils_ascii_str_to_int64(stp, 10, option->nm_min, option->nm_max, option->nm_default); g_object_set(s_bridge, option->name, stp_value, NULL); @@ -503,9 +503,9 @@ update_connection(NMDevice *device, NMConnection *connection) gs_free char *str = NULL; GParamSpec *pspec; - str = nm_platform_sysctl_master_get_option(nm_device_get_platform(device), - ifindex, - option->sysname); + str = nm_platform_sysctl_controller_get_option(nm_device_get_platform(device), + ifindex, + option->sysname); pspec = g_object_class_find_property(G_OBJECT_GET_CLASS(s_bridge), option->name); if (!stp_value && option->only_with_stp) @@ -575,22 +575,22 @@ out: } static gboolean -master_update_slave_connection(NMDevice *device, - NMDevice *slave, - NMConnection *connection, - GError **error) +controller_update_port_connection(NMDevice *device, + NMDevice *port, + NMConnection *connection, + GError **error) { NMSettingConnection *s_con; NMSettingBridgePort *s_port; - int ifindex_slave = nm_device_get_ifindex(slave); + int ifindex_port = nm_device_get_ifindex(port); NMConnection *applied_connection = nm_device_get_applied_connection(device); const NMPlatformLink *pllink; - g_return_val_if_fail(ifindex_slave > 0, FALSE); + g_return_val_if_fail(ifindex_port > 0, FALSE); s_con = nm_connection_get_setting_connection(connection); s_port = _nm_connection_ensure_setting(connection, NM_TYPE_SETTING_BRIDGE_PORT); - pllink = nm_platform_link_get(nm_device_get_platform(slave), ifindex_slave); + pllink = nm_platform_link_get(nm_device_get_platform(port), ifindex_port); if (pllink && pllink->port_kind == NM_PORT_KIND_BRIDGE) { g_object_set(s_port, @@ -917,19 +917,19 @@ attach_port(NMDevice *device, gpointer user_data) { NMDeviceBridge *self = NM_DEVICE_BRIDGE(device); - NMConnection *master_connection; + NMConnection *controller_connection; NMSettingBridge *s_bridge; NMSettingBridgePort *s_port; if (configure) { - if (!nm_platform_link_enslave(nm_device_get_platform(device), - nm_device_get_ip_ifindex(device), - nm_device_get_ip_ifindex(port))) + if (!nm_platform_link_attach_port(nm_device_get_platform(device), + nm_device_get_ip_ifindex(device), + nm_device_get_ip_ifindex(port))) return FALSE; - master_connection = nm_device_get_applied_connection(device); - nm_assert(master_connection); - s_bridge = nm_connection_get_setting_bridge(master_connection); + controller_connection = nm_device_get_applied_connection(device); + nm_assert(controller_connection); + s_bridge = nm_connection_get_setting_bridge(controller_connection); nm_assert(s_bridge); s_port = nm_connection_get_setting_bridge_port(connection); @@ -945,7 +945,7 @@ attach_port(NMDevice *device, plat_vlans = setting_vlans_to_platform(vlans); - /* Since the link was just enslaved, there are no existing VLANs + /* Since the link was just enportd, there are no existing VLANs * (except for the default one) and so there's no need to flush. */ if (plat_vlans @@ -976,7 +976,7 @@ detach_port(NMDevice *device, { NMDeviceBridge *self = NM_DEVICE_BRIDGE(device); gboolean success; - int ifindex_slave; + int ifindex_port; int ifindex; if (configure) { @@ -985,17 +985,17 @@ detach_port(NMDevice *device, configure = FALSE; } - ifindex_slave = nm_device_get_ip_ifindex(port); + ifindex_port = nm_device_get_ip_ifindex(port); - if (ifindex_slave <= 0) { + if (ifindex_port <= 0) { _LOGD(LOGD_TEAM, "bridge port %s is already detached", nm_device_get_ip_iface(port)); return TRUE; } if (configure) { - success = nm_platform_link_release(nm_device_get_platform(device), - nm_device_get_ip_ifindex(device), - ifindex_slave); + success = nm_platform_link_release_port(nm_device_get_platform(device), + nm_device_get_ip_ifindex(device), + ifindex_port); if (success) { _LOGI(LOGD_BRIDGE, "detached bridge port %s", nm_device_get_ip_iface(port)); @@ -1061,7 +1061,7 @@ create_and_realize(NMDevice *device, mtu = nm_setting_wired_get_mtu(s_wired); /* If mtu != 0, we set the MTU of the new bridge at creation time. However, kernel will still - * automatically adjust the MTU of the bridge based on the minimum of the slave's MTU. + * automatically adjust the MTU of the bridge based on the minimum of the port's MTU. * We don't want this automatism as the user asked for a fixed MTU. * * To workaround this behavior of kernel, we will later toggle the MTU twice. See @@ -1199,8 +1199,8 @@ nm_device_bridge_class_init(NMDeviceBridgeClass *klass) device_class->check_connection_available = check_connection_available; device_class->complete_connection = complete_connection; - device_class->update_connection = update_connection; - device_class->master_update_slave_connection = master_update_slave_connection; + device_class->update_connection = update_connection; + device_class->controller_update_port_connection = controller_update_port_connection; device_class->create_and_realize = create_and_realize; device_class->act_stage1_prepare_set_hwaddr_ethernet = TRUE; diff --git a/src/core/devices/nm-device-private.h b/src/core/devices/nm-device-private.h index 013bc7fd..3bf5925c 100644 --- a/src/core/devices/nm-device-private.h +++ b/src/core/devices/nm-device-private.h @@ -58,10 +58,11 @@ void nm_device_activate_schedule_stage3_ip_config(NMDevice *device, gboolean do_ void nm_device_recheck_available_connections(NMDevice *device); -void -nm_device_master_check_slave_physical_port(NMDevice *self, NMDevice *slave, NMLogDomain log_domain); +void nm_device_controller_check_port_physical_port(NMDevice *self, + NMDevice *port, + NMLogDomain log_domain); -void nm_device_master_release_slaves_all(NMDevice *self); +void nm_device_controller_release_ports_all(NMDevice *self); void nm_device_set_carrier(NMDevice *self, gboolean carrier); diff --git a/src/core/devices/nm-device-vrf.c b/src/core/devices/nm-device-vrf.c index 6c7adc6c..c3d31347 100644 --- a/src/core/devices/nm-device-vrf.c +++ b/src/core/devices/nm-device-vrf.c @@ -222,13 +222,13 @@ attach_port(NMDevice *device, gboolean success = TRUE; const char *port_iface = nm_device_get_ip_iface(port); - nm_device_master_check_slave_physical_port(device, port, LOGD_DEVICE); + nm_device_controller_check_port_physical_port(device, port, LOGD_DEVICE); if (configure) { nm_device_take_down(port, TRUE); - success = nm_platform_link_enslave(nm_device_get_platform(device), - nm_device_get_ip_ifindex(device), - nm_device_get_ip_ifindex(port)); + success = nm_platform_link_attach_port(nm_device_get_platform(device), + nm_device_get_ip_ifindex(device), + nm_device_get_ip_ifindex(port)); nm_device_bring_up(port); if (!success) @@ -267,9 +267,9 @@ detach_port(NMDevice *device, if (configure) { if (ifindex_port > 0) { - success = nm_platform_link_release(nm_device_get_platform(device), - nm_device_get_ip_ifindex(device), - ifindex_port); + success = nm_platform_link_release_port(nm_device_get_platform(device), + nm_device_get_ip_ifindex(device), + ifindex_port); if (success) { _LOGI(LOGD_DEVICE, "detached VRF port %s", nm_device_get_ip_iface(port)); diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index f3441508..725241d5 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -107,10 +107,10 @@ typedef void (*ActivationHandleFunc)(NMDevice *self); typedef enum { - RELEASE_SLAVE_TYPE_NO_CONFIG, - RELEASE_SLAVE_TYPE_CONFIG, - RELEASE_SLAVE_TYPE_CONFIG_FORCE, -} ReleaseSlaveType; + RELEASE_PORT_TYPE_NO_CONFIG, + RELEASE_PORT_TYPE_CONFIG, + RELEASE_PORT_TYPE_CONFIG_FORCE, +} ReleasePortType; typedef enum { CLEANUP_TYPE_KEEP, @@ -127,13 +127,13 @@ typedef enum _nm_packed { } AddrMethodState; typedef struct { - CList lst_slave; - NMDevice *slave; + CList lst_port; + NMDevice *port; GCancellable *cancellable; gulong watch_id; - bool slave_is_enslaved; + bool port_is_attached; bool configure; -} SlaveInfo; +} PortInfo; typedef struct { NMDevice *device; @@ -592,7 +592,7 @@ typedef struct _NMDevicePrivate { NMDeviceAutoconnectBlockedFlags autoconnect_blocked_flags : 5; - bool is_enslaved : 1; + bool is_attached : 1; bool device_link_changed_down : 1; @@ -710,13 +710,13 @@ typedef struct _NMDevicePrivate { NMPlatformLinkChangeFlags flags; } link_props_state; - /* controller interface for bridge/bond/team slave */ + /* controller interface for bridge/bond/team port */ NMDevice *controller; gulong controller_ready_id; int controller_ifindex; - /* slave management */ - CList slaves; /* list of SlaveInfo */ + /* port management */ + CList ports; /* list of PortInfo */ NMMetered metered; @@ -789,11 +789,11 @@ static void _dev_l3_cfg_commit(NMDevice *self, gboolean do_sync); static void _dev_l3_cfg_commit_type_reset(NMDevice *self); -static gboolean nm_device_master_add_slave(NMDevice *self, NMDevice *slave, gboolean configure); -static void nm_device_slave_notify_enslave(NMDevice *self, gboolean success); -static void nm_device_slave_notify_release(NMDevice *self, - NMDeviceStateReason reason, - ReleaseSlaveType release_type); +static gboolean nm_device_controller_add_port(NMDevice *self, NMDevice *port, gboolean configure); +static void nm_device_port_notify_attach_as_port(NMDevice *self, gboolean success); +static void nm_device_port_notify_release(NMDevice *self, + NMDeviceStateReason reason, + ReleasePortType release_type); static void _dev_ipll6_start(NMDevice *self); @@ -3834,9 +3834,9 @@ _dev_ip_state_check(NMDevice *self, int addr_family) if (priv->ip_data_x[IS_IPv4].state == NM_DEVICE_IP_STATE_PENDING && nm_active_connection_get_controller(NM_ACTIVE_CONNECTION(priv->act_request.obj)) - && !priv->is_enslaved) { + && !priv->is_attached) { /* Don't progress into IP_CHECK or SECONDARIES if we're waiting for the - * master to enslave us. */ + * controller to attach as port us. */ ip_state = NM_DEVICE_IP_STATE_PENDING; goto got_ip_state; } @@ -5683,9 +5683,9 @@ nm_device_get_route_metric(NMDevice *self, int addr_family) if (connection) { s_ip = nm_connection_get_setting_ip_config(connection, addr_family); - /* Slave interfaces don't have IP settings, but we may get here when + /* Port interfaces don't have IP settings, but we may get here when * external changes are made or when noticing IP changes when starting - * the slave connection. + * the port connection. */ if (s_ip) { route_metric = nm_setting_ip_config_get_route_metric(s_ip); @@ -6671,43 +6671,43 @@ nm_device_get_connectivity_state(NMDevice *self, int addr_family) /*****************************************************************************/ -static SlaveInfo * -find_slave_info(NMDevice *self, NMDevice *slave) +static PortInfo * +find_port_info(NMDevice *self, NMDevice *port) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - SlaveInfo *info; + PortInfo *info; - c_list_for_each_entry (info, &priv->slaves, lst_slave) { - if (info->slave == slave) + c_list_for_each_entry (info, &priv->ports, lst_port) { + if (info->port == port) return info; } return NULL; } static void -attach_port_done(NMDevice *self, NMDevice *slave, gboolean success) +attach_port_done(NMDevice *self, NMDevice *port, gboolean success) { - SlaveInfo *info; + PortInfo *info; - info = find_slave_info(self, slave); + info = find_port_info(self, port); if (!info) return; - info->slave_is_enslaved = success; + info->port_is_attached = success; - nm_device_slave_notify_enslave(info->slave, success); + nm_device_port_notify_attach_as_port(info->port, success); /* Ensure the device's hardware address is up-to-date; it often changes - * when slaves change. + * when ports change. */ nm_device_update_hw_address(self); - /* Since slave devices don't have their own IP configuration, + /* Since port devices don't have their own IP configuration, * set the MTU here. */ - _commit_mtu(slave); + _commit_mtu(port); - /* Restart IP configuration if we're waiting for slaves. Do this + /* Restart IP configuration if we're waiting for ports. Do this * after updating the hardware address as IP config may need the * new address. */ @@ -6718,181 +6718,181 @@ attach_port_done(NMDevice *self, NMDevice *slave, gboolean success) static void attach_port_cb(NMDevice *self, GError *error, gpointer user_data) { - NMDevice *slave = user_data; - SlaveInfo *info; + NMDevice *port = user_data; + PortInfo *info; if (nm_utils_error_is_cancelled(error)) return; - info = find_slave_info(self, slave); + info = find_port_info(self, port); if (!info) return; nm_clear_g_cancellable(&info->cancellable); - attach_port_done(self, slave, !error); + attach_port_done(self, port, !error); } /** - * nm_device_master_enslave_slave: - * @self: the master device - * @slave: the slave device to enslave - * @connection: (nullable): the slave device's connection + * nm_device_controller_attach_port: + * @self: the controller device + * @port: the port device to attach as port + * @connection: (nullable): the port device's connection * * If @self is capable of enslaving other devices (ie it's a bridge, bond, team, - * etc) then this function enslaves @slave. + * etc) then this function attach @port. */ static void -nm_device_master_enslave_slave(NMDevice *self, NMDevice *slave, NMConnection *connection) +nm_device_controller_attach_port(NMDevice *self, NMDevice *port, NMConnection *connection) { - SlaveInfo *info; - NMTernary success; - gboolean configure; + PortInfo *info; + NMTernary success; + gboolean configure; g_return_if_fail(self); - g_return_if_fail(slave); + g_return_if_fail(port); g_return_if_fail(NM_DEVICE_GET_CLASS(self)->attach_port); - info = find_slave_info(self, slave); + info = find_port_info(self, port); if (!info) return; - if (info->slave_is_enslaved) + if (info->port_is_attached) success = TRUE; else { configure = (info->configure && connection != NULL); if (configure) - g_return_if_fail(nm_device_get_state(slave) >= NM_DEVICE_STATE_DISCONNECTED); + g_return_if_fail(nm_device_get_state(port) >= NM_DEVICE_STATE_DISCONNECTED); nm_clear_g_cancellable(&info->cancellable); info->cancellable = g_cancellable_new(); success = NM_DEVICE_GET_CLASS(self)->attach_port(self, - slave, + port, connection, configure, info->cancellable, attach_port_cb, - slave); + port); if (success == NM_TERNARY_DEFAULT) return; } - attach_port_done(self, slave, success); + attach_port_done(self, port, success); } static void detach_port_cb(NMDevice *self, GError *error, gpointer user_data) { - nm_auto_unref_object NMDevice *slave = user_data; - NMDevicePrivate *port_priv = NM_DEVICE_GET_PRIVATE(slave); + nm_auto_unref_object NMDevice *port = user_data; + NMDevicePrivate *port_priv = NM_DEVICE_GET_PRIVATE(port); nm_assert(port_priv->port_detach_count > 0); if (--port_priv->port_detach_count == 0) { if (port_priv->state == NM_DEVICE_STATE_DEACTIVATING) { - deactivate_ready(slave, port_priv->port_detach_reason); + deactivate_ready(port, port_priv->port_detach_reason); } } } /** - * nm_device_master_release_slave: - * @self: the master device - * @slave: the slave device to release - * @configure: whether @self needs to actually release @slave - * @release_type: whether @self needs to actually release slave + * nm_device_controller_release_port: + * @self: the controller device + * @port: the port device to release + * @configure: whether @self needs to actually release @port + * @release_type: whether @self needs to actually release port * and whether that is forced. - * @reason: the state change reason for the @slave + * @reason: the state change reason for the @port * * If @self is capable of enslaving other devices (ie it's a bridge, bond, team, - * etc) then this function releases the previously enslaved @slave and/or - * updates the state of @self and @slave to reflect its release. + * etc) then this function releases the previously attached @port and/or + * updates the state of @self and @port to reflect its release. */ static void -nm_device_master_release_slave(NMDevice *self, - NMDevice *slave, - ReleaseSlaveType release_type, - NMDeviceStateReason reason) +nm_device_controller_release_port(NMDevice *self, + NMDevice *port, + ReleasePortType release_type, + NMDeviceStateReason reason) { NMDevicePrivate *priv; NMDevicePrivate *port_priv; - SlaveInfo *info; - gs_unref_object NMDevice *self_free = NULL; - gs_unref_object NMDevice *slave_free = NULL; + PortInfo *info; + gs_unref_object NMDevice *self_free = NULL; + gs_unref_object NMDevice *port_free = NULL; g_return_if_fail(NM_DEVICE(self)); - g_return_if_fail(NM_DEVICE(slave)); + g_return_if_fail(NM_DEVICE(port)); nm_assert(NM_IN_SET(release_type, - RELEASE_SLAVE_TYPE_NO_CONFIG, - RELEASE_SLAVE_TYPE_CONFIG, - RELEASE_SLAVE_TYPE_CONFIG_FORCE)); + RELEASE_PORT_TYPE_NO_CONFIG, + RELEASE_PORT_TYPE_CONFIG, + RELEASE_PORT_TYPE_CONFIG_FORCE)); g_return_if_fail(NM_DEVICE_GET_CLASS(self)->detach_port != NULL); - info = find_slave_info(self, slave); + info = find_port_info(self, port); _LOGT(LOGD_CORE, - "master: release one slave " NM_HASH_OBFUSCATE_PTR_FMT "/%s %s%s", - NM_HASH_OBFUSCATE_PTR(slave), - nm_device_get_iface(slave), - !info ? "(not registered)" : (info->slave_is_enslaved ? "(enslaved)" : "(not enslaved)"), - release_type == RELEASE_SLAVE_TYPE_CONFIG_FORCE + "controller: release one port " NM_HASH_OBFUSCATE_PTR_FMT "/%s %s%s", + NM_HASH_OBFUSCATE_PTR(port), + nm_device_get_iface(port), + !info ? "(not registered)" : (info->port_is_attached ? "(attached)" : "(not attached)"), + release_type == RELEASE_PORT_TYPE_CONFIG_FORCE ? " (force-configure)" - : (release_type == RELEASE_SLAVE_TYPE_CONFIG ? " (configure)" : "(no-config)")); + : (release_type == RELEASE_PORT_TYPE_CONFIG ? " (configure)" : "(no-config)")); if (!info) g_return_if_reached(); priv = NM_DEVICE_GET_PRIVATE(self); - port_priv = NM_DEVICE_GET_PRIVATE(slave); + port_priv = NM_DEVICE_GET_PRIVATE(port); g_return_if_fail(self == port_priv->controller); - nm_assert(slave == info->slave); + nm_assert(port == info->port); nm_clear_g_cancellable(&info->cancellable); /* first, let subclasses handle the release ... */ - if (info->slave_is_enslaved || nm_device_sys_iface_state_is_external(slave) - || release_type >= RELEASE_SLAVE_TYPE_CONFIG_FORCE) { + if (info->port_is_attached || nm_device_sys_iface_state_is_external(port) + || release_type >= RELEASE_PORT_TYPE_CONFIG_FORCE) { NMTernary ret; ret = NM_DEVICE_GET_CLASS(self)->detach_port(self, - slave, - release_type >= RELEASE_SLAVE_TYPE_CONFIG, + port, + release_type >= RELEASE_PORT_TYPE_CONFIG, NULL, detach_port_cb, - g_object_ref(slave)); + g_object_ref(port)); if (ret == NM_TERNARY_DEFAULT) { port_priv->port_detach_count++; port_priv->port_detach_reason = reason; } } - /* raise notifications about the release, including clearing is_enslaved. */ - nm_device_slave_notify_release(slave, reason, release_type); + /* raise notifications about the release, including clearing is_attached. */ + nm_device_port_notify_release(port, reason, release_type); /* keep both alive until the end of the function. * Transfers ownership from port_priv->controller. */ nm_assert(self == port_priv->controller); self_free = g_steal_pointer(&port_priv->controller); - nm_assert(slave == info->slave); - slave_free = g_steal_pointer(&info->slave); + nm_assert(port == info->port); + port_free = g_steal_pointer(&info->port); - c_list_unlink(&info->lst_slave); - g_signal_handler_disconnect(slave, info->watch_id); + c_list_unlink(&info->lst_port); + g_signal_handler_disconnect(port, info->watch_id); nm_g_slice_free(info); - if (c_list_is_empty(&priv->slaves)) { + if (c_list_is_empty(&priv->ports)) { _active_connection_set_state_flags_full(self, 0, - NM_ACTIVATION_STATE_FLAG_MASTER_HAS_SLAVES); + NM_ACTIVATION_STATE_FLAG_CONTROLLER_HAS_PORTS); } /* Ensure the device's hardware address is up-to-date; it often changes - * when slaves change. + * when ports change. */ nm_device_update_hw_address(self); - nm_device_set_unmanaged_by_flags(slave, - NM_UNMANAGED_IS_SLAVE, + nm_device_set_unmanaged_by_flags(port, + NM_UNMANAGED_IS_PORT, NM_UNMAN_FLAG_OP_FORGET, NM_DEVICE_STATE_REASON_REMOVED); } @@ -6922,7 +6922,7 @@ _dev_unmanaged_is_external_down(NMDevice *self, gboolean consider_can) /* Manage externally-created software interfaces only when they are IFF_UP */ if (priv->ifindex <= 0 || !priv->up - || !(!c_list_is_empty(&priv->slaves) + || !(!c_list_is_empty(&priv->ports) || nm_platform_link_can_assume(nm_device_get_platform(self), priv->ifindex))) return NM_UNMAN_FLAG_OP_SET_UNMANAGED; @@ -7017,8 +7017,8 @@ carrier_changed(NMDevice *self, gboolean carrier) return; } /* fall-through and change state of device */ - } else if (priv->is_enslaved && !carrier) { - /* Slaves don't deactivate when they lose carrier; for + } else if (priv->is_attached && !carrier) { + /* Ports don't deactivate when they lose carrier; for * bonds/teams in particular that would be actively * counterproductive. */ @@ -7162,65 +7162,65 @@ nm_device_set_carrier_from_platform(NMDevice *self) /*****************************************************************************/ static void -device_recheck_slave_status(NMDevice *self, const NMPlatformLink *plink) +device_recheck_port_status(NMDevice *self, const NMPlatformLink *plink) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMDevice *master; - nm_auto_nmpobj const NMPObject *plink_master_keep_alive = NULL; - const NMPlatformLink *plink_master; + NMDevice *controller; + nm_auto_nmpobj const NMPObject *plink_controller_keep_alive = NULL; + const NMPlatformLink *plink_controller; g_return_if_fail(plink); - if (plink->master > 0) { - master = nm_manager_get_device_by_ifindex(NM_MANAGER_GET, plink->master); - plink_master = nm_platform_link_get(nm_device_get_platform(self), plink->master); - plink_master_keep_alive = nmp_object_ref(NMP_OBJECT_UP_CAST(plink_master)); + if (plink->controller > 0) { + controller = nm_manager_get_device_by_ifindex(NM_MANAGER_GET, plink->controller); + plink_controller = nm_platform_link_get(nm_device_get_platform(self), plink->controller); + plink_controller_keep_alive = nmp_object_ref(NMP_OBJECT_UP_CAST(plink_controller)); } else { if (priv->controller_ifindex == 0) goto out; - master = NULL; - plink_master = NULL; + controller = NULL; + plink_controller = NULL; } - if (master == NULL && plink_master - && NM_IN_STRSET(plink_master->name, "ovs-system", "ovs-netdev") - && plink_master->type == NM_LINK_TYPE_OPENVSWITCH) { + if (controller == NULL && plink_controller + && NM_IN_STRSET(plink_controller->name, "ovs-system", "ovs-netdev") + && plink_controller->type == NM_LINK_TYPE_OPENVSWITCH) { _LOGD(LOGD_DEVICE, "the device claimed by openvswitch"); goto out; } - priv->controller_ifindex = plink->master; + priv->controller_ifindex = plink->controller; if (priv->controller) { - if (plink->master > 0 && plink->master == nm_device_get_ifindex(priv->controller)) { - /* call add-slave again. We expect @self already to be added to - * the master, but this also triggers a recheck-assume. */ - nm_device_master_add_slave(priv->controller, self, FALSE); + if (plink->controller > 0 && plink->controller == nm_device_get_ifindex(priv->controller)) { + /* call add-port again. We expect @self already to be added to + * the controller, but this also triggers a recheck-assume. */ + nm_device_controller_add_port(priv->controller, self, FALSE); goto out; } - nm_device_master_release_slave(priv->controller, - self, - RELEASE_SLAVE_TYPE_NO_CONFIG, - NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); + nm_device_controller_release_port(priv->controller, + self, + RELEASE_PORT_TYPE_NO_CONFIG, + NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); } - if (master) { - if (NM_DEVICE_GET_CLASS(master)->attach_port) { - nm_device_master_add_slave(master, self, FALSE); + if (controller) { + if (NM_DEVICE_GET_CLASS(controller)->attach_port) { + nm_device_controller_add_port(controller, self, FALSE); } else { _LOGD(LOGD_DEVICE, - "enslaved to non-master-type device %s; ignoring", - nm_device_get_iface(master)); + "attached to non-controller-type device %s; ignoring", + nm_device_get_iface(controller)); } goto out; } - if (plink->master) { + if (plink->controller) { _LOGD(LOGD_DEVICE, - "enslaved to unknown device %d (%s%s%s)", - plink->master, - NM_PRINT_FMT_QUOTED(plink_master, "\"", plink_master->name, "\"", "??")); + "attached to unknown device %d (%s%s%s)", + plink->controller, + NM_PRINT_FMT_QUOTED(plink_controller, "\"", plink_controller->name, "\"", "??")); if (!priv->ifindex_changed_id) { priv->ifindex_changed_id = g_signal_connect(nm_device_get_manager(self), NM_MANAGER_DEVICE_IFINDEX_CHANGED, @@ -7246,7 +7246,7 @@ device_ifindex_changed_cb(NMManager *manager, NMDevice *device_changed, NMDevice return; _LOGD(LOGD_DEVICE, - "master %s with ifindex %d appeared", + "controller %s with ifindex %d appeared", nm_device_get_iface(device_changed), nm_device_get_ifindex(device_changed)); if (!priv->device_link_changed_id) @@ -7436,7 +7436,7 @@ device_link_changed(gpointer user_data) _dev_unmanaged_check_external_down(self, FALSE, FALSE); - device_recheck_slave_status(self, pllink); + device_recheck_port_status(self, pllink); if (priv->up && (!was_up || seen_down)) { /* the link was down and just came up. That happens for example, while changing MTU. @@ -7988,7 +7988,7 @@ realize_start_notify(NMDevice *self, const NMPlatformLink *pllink) * Update the device from backing resource properties (like hardware * addresses, carrier states, driver/firmware info, etc). This function * should only change properties for this device, and should not perform - * any tasks that affect other interfaces (like master/slave or parent/child + * any tasks that affect other interfaces (like controller/port or parent/child * stuff). */ static void @@ -8140,7 +8140,7 @@ realize_start_setup(NMDevice *self, * @self: the #NMDevice * @plink: the #NMPlatformLink if backed by a kernel netdevice * - * Update the device's master/slave or parent/child relationships from + * Update the device's controller/port or parent/child relationships from * backing resource properties. After this function finishes, the device * is ready for network connectivity. */ @@ -8157,7 +8157,7 @@ nm_device_realize_finish(NMDevice *self, const NMPlatformLink *plink) g_return_if_fail(!priv->real); if (plink) - device_recheck_slave_status(self, plink); + device_recheck_port_status(self, plink); priv->real = TRUE; _notify(self, PROP_REAL); @@ -8317,7 +8317,7 @@ nm_device_unrealize(NMDevice *self, gboolean remove_resources, GError **error) nm_device_set_unmanaged_flags(self, NM_UNMANAGED_USER_UDEV | NM_UNMANAGED_USER_EXPLICIT - | NM_UNMANAGED_EXTERNAL_DOWN | NM_UNMANAGED_IS_SLAVE, + | NM_UNMANAGED_EXTERNAL_DOWN | NM_UNMANAGED_IS_PORT, NM_UNMAN_FLAG_OP_FORGET); nm_device_state_changed(self, @@ -8436,117 +8436,117 @@ nm_device_new_default_connection(NMDevice *self) } static void -slave_state_changed(NMDevice *slave, - NMDeviceState slave_new_state, - NMDeviceState slave_old_state, - NMDeviceStateReason reason, - NMDevice *self) +port_state_changed(NMDevice *port, + NMDeviceState port_new_state, + NMDeviceState port_old_state, + NMDeviceStateReason reason, + NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); gboolean release = FALSE; gboolean configure; _LOGD(LOGD_DEVICE, - "slave %s state change %d (%s) -> %d (%s)", - nm_device_get_iface(slave), - slave_old_state, - nm_device_state_to_string(slave_old_state), - slave_new_state, - nm_device_state_to_string(slave_new_state)); - - /* Don't try to enslave slaves until the master is ready */ + "port %s state change %d (%s) -> %d (%s)", + nm_device_get_iface(port), + port_old_state, + nm_device_state_to_string(port_old_state), + port_new_state, + nm_device_state_to_string(port_new_state)); + + /* Don't try to attach ports until the controller is ready */ if (priv->state < NM_DEVICE_STATE_CONFIG) return; - if (slave_new_state == NM_DEVICE_STATE_IP_CONFIG) - nm_device_master_enslave_slave(self, slave, nm_device_get_applied_connection(slave)); - else if (slave_new_state > NM_DEVICE_STATE_ACTIVATED) + if (port_new_state == NM_DEVICE_STATE_IP_CONFIG) + nm_device_controller_attach_port(self, port, nm_device_get_applied_connection(port)); + else if (port_new_state > NM_DEVICE_STATE_ACTIVATED) release = TRUE; - else if (slave_new_state <= NM_DEVICE_STATE_DISCONNECTED - && slave_old_state > NM_DEVICE_STATE_DISCONNECTED) { + else if (port_new_state <= NM_DEVICE_STATE_DISCONNECTED + && port_old_state > NM_DEVICE_STATE_DISCONNECTED) { /* Catch failures due to unavailable or unmanaged */ release = TRUE; } if (release) { configure = (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_MANAGED - && nm_device_sys_iface_state_get(slave) != NM_DEVICE_SYS_IFACE_STATE_EXTERNAL) - || nm_device_sys_iface_state_get(slave) == NM_DEVICE_SYS_IFACE_STATE_MANAGED; - - nm_device_master_release_slave(self, - slave, - configure ? RELEASE_SLAVE_TYPE_CONFIG - : RELEASE_SLAVE_TYPE_NO_CONFIG, - reason); + && nm_device_sys_iface_state_get(port) != NM_DEVICE_SYS_IFACE_STATE_EXTERNAL) + || nm_device_sys_iface_state_get(port) == NM_DEVICE_SYS_IFACE_STATE_MANAGED; + + nm_device_controller_release_port(self, + port, + configure ? RELEASE_PORT_TYPE_CONFIG + : RELEASE_PORT_TYPE_NO_CONFIG, + reason); /* Bridge/bond/team interfaces are left up until manually deactivated */ - if (c_list_is_empty(&priv->slaves) && priv->state == NM_DEVICE_STATE_ACTIVATED) - _LOGD(LOGD_DEVICE, "last slave removed; remaining activated"); + if (c_list_is_empty(&priv->ports) && priv->state == NM_DEVICE_STATE_ACTIVATED) + _LOGD(LOGD_DEVICE, "last port removed; remaining activated"); } } /** - * nm_device_master_add_slave: - * @self: the master device - * @slave: the slave device to enslave - * @configure: pass %TRUE if the slave should be configured by the master, or + * nm_device_controller_add_port: + * @self: the controller device + * @port: the port device to attach as port + * @configure: pass %TRUE if the port should be configured by the controller, or * %FALSE if it is already configured outside NetworkManager * * If @self is capable of enslaving other devices (ie it's a bridge, bond, team, - * etc) then this function adds @slave to the slave list for later enslavement. + * etc) then this function adds @port to the port list for later attachment as port. * - * Returns: %TRUE if the slave was enslaved. %FALSE means, the slave was already - * enslaved and nothing was done. + * Returns: %TRUE if the port was attached. %FALSE means, the port was already + * attached and nothing was done. */ static gboolean -nm_device_master_add_slave(NMDevice *self, NMDevice *slave, gboolean configure) +nm_device_controller_add_port(NMDevice *self, NMDevice *port, gboolean configure) { NMDevicePrivate *priv; NMDevicePrivate *port_priv; - SlaveInfo *info; + PortInfo *info; gboolean changed = 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(port), FALSE); g_return_val_if_fail(NM_DEVICE_GET_CLASS(self)->attach_port, FALSE); priv = NM_DEVICE_GET_PRIVATE(self); - port_priv = NM_DEVICE_GET_PRIVATE(slave); + port_priv = NM_DEVICE_GET_PRIVATE(port); - info = find_slave_info(self, slave); + info = find_port_info(self, port); _LOGT(LOGD_CORE, - "master: add one slave " NM_HASH_OBFUSCATE_PTR_FMT "/%s%s", - NM_HASH_OBFUSCATE_PTR(slave), - nm_device_get_iface(slave), + "controller: add one port " NM_HASH_OBFUSCATE_PTR_FMT "/%s%s", + NM_HASH_OBFUSCATE_PTR(port), + nm_device_get_iface(port), info ? " (already registered)" : ""); 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(port) >= NM_DEVICE_STATE_DISCONNECTED, FALSE); if (!info) { g_return_val_if_fail(!port_priv->controller, FALSE); - g_return_val_if_fail(!port_priv->is_enslaved, FALSE); + g_return_val_if_fail(!port_priv->is_attached, FALSE); - info = g_slice_new0(SlaveInfo); - info->slave = g_object_ref(slave); + info = g_slice_new0(PortInfo); + info->port = g_object_ref(port); info->configure = configure; info->watch_id = - g_signal_connect(slave, NM_DEVICE_STATE_CHANGED, G_CALLBACK(slave_state_changed), self); - c_list_link_tail(&priv->slaves, &info->lst_slave); + g_signal_connect(port, NM_DEVICE_STATE_CHANGED, G_CALLBACK(port_state_changed), self); + c_list_link_tail(&priv->ports, &info->lst_port); port_priv->controller = g_object_ref(self); - _active_connection_set_state_flags(self, NM_ACTIVATION_STATE_FLAG_MASTER_HAS_SLAVES); + _active_connection_set_state_flags(self, NM_ACTIVATION_STATE_FLAG_CONTROLLER_HAS_PORTS); /* no need to emit * - * _notify (slave, PROP_CONTROLLER); + * _notify (port, PROP_CONTROLLER); * - * because port_priv->is_enslaved is not true, thus the value + * because port_priv->is_attached is not true, thus the value * didn't change yet. */ - g_warn_if_fail(!NM_FLAGS_HAS(port_priv->unmanaged_mask, NM_UNMANAGED_IS_SLAVE)); - nm_device_set_unmanaged_by_flags(slave, - NM_UNMANAGED_IS_SLAVE, + g_warn_if_fail(!NM_FLAGS_HAS(port_priv->unmanaged_mask, NM_UNMANAGED_IS_PORT)); + nm_device_set_unmanaged_by_flags(port, + NM_UNMANAGED_IS_PORT, NM_UNMAN_FLAG_OP_SET_MANAGED, NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); changed = TRUE; @@ -8554,42 +8554,44 @@ nm_device_master_add_slave(NMDevice *self, NMDevice *slave, gboolean configure) g_return_val_if_fail(port_priv->controller == self, FALSE); nm_device_queue_recheck_assume(self); - nm_device_queue_recheck_assume(slave); + nm_device_queue_recheck_assume(port); return changed; } /** - * nm_device_master_check_slave_physical_port: - * @self: the master device - * @slave: a slave device + * nm_device_controller_check_port_physical_port: + * @self: the controller device + * @port: a port device * @log_domain: domain to log a warning in * - * Checks if @self already has a slave with the same #NMDevice:physical-port-id - * as @slave, and logs a warning if so. + * Checks if @self already has a port with the same #NMDevice:physical-port-id + * as @port, and logs a warning if so. */ void -nm_device_master_check_slave_physical_port(NMDevice *self, NMDevice *slave, NMLogDomain log_domain) +nm_device_controller_check_port_physical_port(NMDevice *self, + NMDevice *port, + NMLogDomain log_domain) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - const char *slave_physical_port_id, *existing_physical_port_id; - SlaveInfo *info; + const char *port_physical_port_id, *existing_physical_port_id; + PortInfo *info; - slave_physical_port_id = nm_device_get_physical_port_id(slave); - if (!slave_physical_port_id) + port_physical_port_id = nm_device_get_physical_port_id(port); + if (!port_physical_port_id) return; - c_list_for_each_entry (info, &priv->slaves, lst_slave) { - if (info->slave == slave) + c_list_for_each_entry (info, &priv->ports, lst_port) { + if (info->port == port) continue; - existing_physical_port_id = nm_device_get_physical_port_id(info->slave); - if (nm_streq0(slave_physical_port_id, existing_physical_port_id)) { + existing_physical_port_id = nm_device_get_physical_port_id(info->port); + if (nm_streq0(port_physical_port_id, existing_physical_port_id)) { _LOGW(log_domain, - "slave %s shares a physical port with existing slave %s", - nm_device_get_ip_iface(slave), - nm_device_get_ip_iface(info->slave)); - /* Since this function will get called for every slave, we only have + "port %s shares a physical port with existing port %s", + nm_device_get_ip_iface(port), + nm_device_get_ip_iface(info->port)); + /* Since this function will get called for every port, we only have * to warn about the first match we find; if there are other matches * later in the list, we will have already warned about them matching * @existing earlier. @@ -8600,14 +8602,14 @@ nm_device_master_check_slave_physical_port(NMDevice *self, NMDevice *slave, NMLo } void -nm_device_master_release_slaves_all(NMDevice *self) +nm_device_controller_release_ports_all(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDeviceStateReason reason; - SlaveInfo *info; - SlaveInfo *safe; + PortInfo *info; + PortInfo *safe; - /* Don't release the slaves if this connection doesn't belong to NM. */ + /* Don't release the ports if this connection doesn't belong to NM. */ if (nm_device_sys_iface_state_is_external(self)) return; @@ -8615,15 +8617,15 @@ nm_device_master_release_slaves_all(NMDevice *self) if (priv->state == NM_DEVICE_STATE_FAILED) reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED; - c_list_for_each_entry_safe (info, safe, &priv->slaves, lst_slave) { + c_list_for_each_entry_safe (info, safe, &priv->ports, lst_port) { if (priv->activation_state_preserve_external_ports - && nm_device_sys_iface_state_is_external(info->slave)) { + && nm_device_sys_iface_state_is_external(info->port)) { _LOGT(LOGD_DEVICE, - "master: preserve external port %s", - nm_device_get_iface(info->slave)); + "controller: preserve external port %s", + nm_device_get_iface(info->port)); continue; } - nm_device_master_release_slave(self, info->slave, RELEASE_SLAVE_TYPE_CONFIG, reason); + nm_device_controller_release_port(self, info->port, RELEASE_PORT_TYPE_CONFIG, reason); } /* We only need this flag for a short time. It served its purpose. Clear @@ -8663,7 +8665,7 @@ nm_device_get_controller(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - if (priv->is_enslaved) { + if (priv->is_attached) { g_return_val_if_fail(priv->controller, NULL); return priv->controller; } @@ -8671,15 +8673,15 @@ nm_device_get_controller(NMDevice *self) } /** - * nm_device_slave_notify_enslave: - * @self: the slave device + * nm_device_port_notify_attach: + * @self: the port device * @success: whether the enslaving operation succeeded * - * Notifies a slave that either it has been enslaved, or else its master tried - * to enslave it and failed. + * Notifies a port that either it has been attached, or else its controller tried + * to attach it as port and failed. */ static void -nm_device_slave_notify_enslave(NMDevice *self, gboolean success) +nm_device_port_notify_attach_as_port(NMDevice *self, gboolean success) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMConnection *connection = nm_device_get_applied_connection(self); @@ -8687,16 +8689,16 @@ nm_device_slave_notify_enslave(NMDevice *self, gboolean success) g_return_if_fail(priv->controller); - if (!priv->is_enslaved) { + if (!priv->is_attached) { if (success) { if (activating) { _LOGI(LOGD_DEVICE, - "Activation: connection '%s' enslaved, continuing activation", + "Activation: connection '%s' attached as port, continuing activation", nm_connection_get_id(connection)); } else - _LOGI(LOGD_DEVICE, "enslaved to %s", nm_device_get_iface(priv->controller)); + _LOGI(LOGD_DEVICE, "attached to %s", nm_device_get_iface(priv->controller)); - priv->is_enslaved = TRUE; + priv->is_attached = TRUE; _notify(priv->controller, PROP_CONTROLLER); @@ -8705,7 +8707,7 @@ nm_device_slave_notify_enslave(NMDevice *self, gboolean success) nm_gobject_notify_together(priv->controller, PROP_PORTS, PROP_SLAVES); } else if (activating) { _LOGW(LOGD_DEVICE, - "Activation: connection '%s' could not be enslaved", + "Activation: connection '%s' could not be attached as port", nm_connection_get_id(connection)); } } @@ -8724,56 +8726,58 @@ nm_device_slave_notify_enslave(NMDevice *self, gboolean success) } /** - * nm_device_slave_notify_release: - * @self: the slave device + * nm_device_port_notify_release: + * @self: the port device * @reason: the reason associated with the state change * - * Notifies a slave that it has been released, and why. + * Notifies a port that it has been released, and why. */ static void -nm_device_slave_notify_release(NMDevice *self, - NMDeviceStateReason reason, - ReleaseSlaveType release_type) +nm_device_port_notify_release(NMDevice *self, + NMDeviceStateReason reason, + ReleasePortType release_type) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMConnection *connection = nm_device_get_applied_connection(self); - const char *master_status; + const char *controller_status; g_return_if_fail(priv->controller); - if (!priv->is_enslaved && release_type == RELEASE_SLAVE_TYPE_NO_CONFIG) + if (!priv->is_attached && release_type == RELEASE_PORT_TYPE_NO_CONFIG) return; if (priv->state > NM_DEVICE_STATE_DISCONNECTED && priv->state <= NM_DEVICE_STATE_ACTIVATED) { switch (nm_device_state_reason_check(reason)) { case NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED: - master_status = "failed"; + controller_status = "failed"; break; case NM_DEVICE_STATE_REASON_USER_REQUESTED: - reason = NM_DEVICE_STATE_REASON_USER_REQUESTED; - master_status = "deactivated by user request"; + reason = NM_DEVICE_STATE_REASON_USER_REQUESTED; + controller_status = "deactivated by user request"; break; case NM_DEVICE_STATE_REASON_CONNECTION_REMOVED: - reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED; - master_status = "deactivated because master was removed"; + reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED; + controller_status = "deactivated because controller was removed"; break; default: - master_status = "deactivated"; + controller_status = "deactivated"; break; } _LOGD(LOGD_DEVICE, - "Activation: connection '%s' master %s", + "Activation: connection '%s' controller %s", nm_connection_get_id(connection), - master_status); + controller_status); /* Cancel any pending activation sources */ _cancel_activation(self); nm_device_queue_state(self, NM_DEVICE_STATE_DEACTIVATING, reason); } else - _LOGI(LOGD_DEVICE, "released from master device %s", nm_device_get_iface(priv->controller)); + _LOGI(LOGD_DEVICE, + "released from controller device %s", + nm_device_get_iface(priv->controller)); - priv->is_enslaved = FALSE; + priv->is_attached = FALSE; _notify(priv->controller, PROP_CONTROLLER); @@ -8788,7 +8792,7 @@ nm_device_slave_notify_release(NMDevice *self, * of the device (provided, it is still not cleared at this point). * * Called by the manager when the device was removed. Releases the device from - * the master in case it's enslaved. + * the controller in case it's attached as port. */ void nm_device_removed(NMDevice *self, gboolean unconfigure_ip_config) @@ -8803,12 +8807,12 @@ nm_device_removed(NMDevice *self, gboolean unconfigure_ip_config) priv = NM_DEVICE_GET_PRIVATE(self); if (priv->controller) { - /* this is called when something externally messes with the slave or during shut-down. - * Release the slave from master, but don't touch the device. */ - nm_device_master_release_slave(priv->controller, - self, - RELEASE_SLAVE_TYPE_NO_CONFIG, - NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); + /* this is called when something externally messes with the port or during shut-down. + * Release the port from controller, but don't touch the device. */ + nm_device_controller_release_port(priv->controller, + self, + RELEASE_PORT_TYPE_NO_CONFIG, + NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); } _dev_l3_register_l3cds(self, priv->l3cfg, FALSE, unconfigure_ip_config); @@ -8837,7 +8841,7 @@ is_available(NMDevice *self, NMDeviceCheckDevAvailableFlags flags) if (NM_FLAGS_HAS(flags, _NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER)) return TRUE; - /* master types are always available even without carrier. */ + /* controller types are always available even without carrier. */ if (nm_device_is_controller(self)) return TRUE; @@ -8877,7 +8881,7 @@ nm_device_is_available(NMDevice *self, NMDeviceCheckDevAvailableFlags flags) gboolean nm_device_ignore_carrier_by_default(NMDevice *self) { - /* master types ignore-carrier by default. */ + /* controller types ignore-carrier by default. */ return nm_device_is_controller(self); } @@ -9090,8 +9094,8 @@ device_has_config(NMDevice *self) if (!pllink) return FALSE; - if (pllink->master > 0) { - /* Master-slave relationship is also a configuration */ + if (pllink->controller > 0) { + /* Master-port relationship is also a configuration */ return TRUE; } @@ -9116,30 +9120,30 @@ device_has_config(NMDevice *self) } /** - * nm_device_master_update_slave_connection: - * @self: the master #NMDevice - * @slave: the slave #NMDevice - * @connection: the #NMConnection to update with the slave settings + * nm_device_controller_update_port_connection: + * @self: the controller #NMDevice + * @port: the port #NMDevice + * @connection: the #NMConnection to update with the port settings * @error: error description * - * Reads the slave configuration for @slave and updates @connection with those - * properties. This invokes a virtual function on the master device @self. + * Reads the port configuration for @port and updates @connection with those + * properties. This invokes a virtual function on the controller device @self. * * Returns: %TRUE if the configuration was read and @connection updated, * %FALSE on failure. */ gboolean -nm_device_master_update_slave_connection(NMDevice *self, - NMDevice *slave, - NMConnection *connection, - GError **error) +nm_device_controller_update_port_connection(NMDevice *self, + NMDevice *port, + NMConnection *connection, + GError **error) { NMDeviceClass *klass; gboolean success; g_return_val_if_fail(self, FALSE); g_return_val_if_fail(NM_IS_DEVICE(self), FALSE); - g_return_val_if_fail(slave, FALSE); + g_return_val_if_fail(port, FALSE); g_return_val_if_fail(connection, FALSE); g_return_val_if_fail(!error || !*error, FALSE); g_return_val_if_fail(nm_connection_get_setting_connection(connection), FALSE); @@ -9147,20 +9151,21 @@ nm_device_master_update_slave_connection(NMDevice *self, g_return_val_if_fail(nm_device_get_iface(self), FALSE); klass = NM_DEVICE_GET_CLASS(self); - if (klass->master_update_slave_connection) { - success = klass->master_update_slave_connection(self, slave, connection, error); + if (klass->controller_update_port_connection) { + success = klass->controller_update_port_connection(self, port, connection, error); g_return_val_if_fail(!error || (success && !*error) || *error, success); return success; } - g_set_error(error, - NM_DEVICE_ERROR, - NM_DEVICE_ERROR_FAILED, - "master device '%s' cannot update a slave connection for slave device '%s' (master " - "type not supported?)", - nm_device_get_iface(self), - nm_device_get_iface(slave)); + g_set_error( + error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_FAILED, + "controller device '%s' cannot update a port connection for port device '%s' (controller " + "type not supported?)", + nm_device_get_iface(self), + nm_device_get_iface(port)); return FALSE; } @@ -9196,7 +9201,7 @@ _get_maybe_ipv6_disabled(NMDevice *self) */ NMConnection * nm_device_generate_connection(NMDevice *self, - NMDevice *master, + NMDevice *controller, gboolean *out_maybe_later, GError **error) { @@ -9254,21 +9259,21 @@ nm_device_generate_connection(NMDevice *self, nm_connection_add_setting(connection, s_con); - /* If the device is a slave, update various slave settings */ - if (master) { - if (!nm_device_master_update_slave_connection(master, self, connection, &local)) { + /* If the device is a port, update various port settings */ + if (controller) { + if (!nm_device_controller_update_port_connection(controller, self, connection, &local)) { g_set_error(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, - "master device '%s' failed to update slave connection: %s", - nm_device_get_iface(master), + "controller device '%s' failed to update port connection: %s", + nm_device_get_iface(controller), local->message); g_error_free(local); NM_SET_OUT(out_maybe_later, TRUE); return NULL; } } else { - /* Only regular and master devices get IP configuration; slaves do not */ + /* Only regular and controller devices get IP configuration; ports do not */ s_ip4 = nm_utils_platform_capture_ip_setting(nm_device_get_platform(self), AF_INET, nm_device_get_ip_ifindex(self), @@ -9309,7 +9314,7 @@ nm_device_generate_connection(NMDevice *self, } /* Ignore the connection if it has no IP configuration, - * no slave configuration, and is not a master interface. + * no port configuration, and is not a controller interface. */ ip4_method = nm_utils_get_ip_config_method(connection, AF_INET); ip6_method = nm_utils_get_ip_config_method(connection, AF_INET6); @@ -9318,32 +9323,33 @@ nm_device_generate_connection(NMDevice *self, NM_SETTING_IP6_CONFIG_METHOD_IGNORE, NM_SETTING_IP6_CONFIG_METHOD_DISABLED) && !nm_setting_connection_get_controller(NM_SETTING_CONNECTION(s_con)) - && c_list_is_empty(&priv->slaves)) { + && c_list_is_empty(&priv->ports)) { NM_SET_OUT(out_maybe_later, TRUE); g_set_error_literal( error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, - "ignoring generated connection (no IP and not in master-slave relationship)"); + "ignoring generated connection (no IP and not in controller-port relationship)"); return NULL; } - /* Ignore any IPv6LL-only, not master connections without slaves, + /* Ignore any IPv6LL-only, not controller connections without ports, * unless they are in the assume-ipv6ll-only list. */ if (nm_streq0(ip4_method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) && nm_streq0(ip6_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) && !nm_setting_connection_get_controller(NM_SETTING_CONNECTION(s_con)) - && c_list_is_empty(&priv->slaves) + && c_list_is_empty(&priv->ports) && !nm_config_data_get_assume_ipv6ll_only(NM_CONFIG_GET_DATA, self)) { - _LOGD(LOGD_DEVICE, - "ignoring generated connection (IPv6LL-only and not in master-slave relationship)"); + _LOGD( + LOGD_DEVICE, + "ignoring generated connection (IPv6LL-only and not in controller-port relationship)"); NM_SET_OUT(out_maybe_later, TRUE); g_set_error_literal( error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, - "ignoring generated connection (IPv6LL-only and not in master-slave relationship)"); + "ignoring generated connection (IPv6LL-only and not in controller-port relationship)"); return NULL; } @@ -9594,28 +9600,28 @@ nm_device_check_connection_compatible(NMDevice *self, } gboolean -nm_device_check_slave_connection_compatible(NMDevice *self, NMConnection *slave) +nm_device_check_port_connection_compatible(NMDevice *self, NMConnection *port) { NMSettingConnection *s_con; - const char *connection_type, *slave_type; + const char *connection_type, *port_type; g_return_val_if_fail(NM_IS_DEVICE(self), FALSE); - g_return_val_if_fail(NM_IS_CONNECTION(slave), FALSE); + g_return_val_if_fail(NM_IS_CONNECTION(port), FALSE); if (!nm_device_is_controller(self)) return FALSE; - /* All masters should have connection type set */ + /* All controllers should have connection type set */ connection_type = NM_DEVICE_GET_CLASS(self)->connection_type_supported; g_return_val_if_fail(connection_type, FALSE); - s_con = nm_connection_get_setting_connection(slave); + s_con = nm_connection_get_setting_connection(port); g_assert(s_con); - slave_type = nm_setting_connection_get_port_type(s_con); - if (!slave_type) + port_type = nm_setting_connection_get_port_type(s_con); + if (!port_type) return FALSE; - return nm_streq(connection_type, slave_type); + return nm_streq(connection_type, port_type); } gboolean @@ -9905,35 +9911,37 @@ activation_source_invoke_or_schedule(NMDevice *self, ActivationHandleFunc func, /*****************************************************************************/ static void -master_ready(NMDevice *self, NMActiveConnection *active) +controller_ready(NMDevice *self, NMActiveConnection *active) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - NMActiveConnection *master_connection; - NMDevice *master; + NMActiveConnection *controller_connection; + NMDevice *controller; /* Notify a controller device that it has a new port */ nm_assert(nm_active_connection_get_controller_ready(active)); - master_connection = nm_active_connection_get_controller(active); + controller_connection = nm_active_connection_get_controller(active); - master = nm_active_connection_get_device(master_connection); + controller = nm_active_connection_get_device(controller_connection); - _LOGD(LOGD_DEVICE, "master connection ready; master device %s", nm_device_get_iface(master)); + _LOGD(LOGD_DEVICE, + "controller connection ready; controller device %s", + nm_device_get_iface(controller)); - if (priv->controller && priv->controller != master) - nm_device_master_release_slave(priv->controller, - self, - RELEASE_SLAVE_TYPE_NO_CONFIG, - NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); + if (priv->controller && priv->controller != controller) + nm_device_controller_release_port(priv->controller, + self, + RELEASE_PORT_TYPE_NO_CONFIG, + NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); - /* If the master didn't change, add-slave only rechecks whether to assume a connection. */ - nm_device_master_add_slave(master, - self, - !nm_device_sys_iface_state_is_external_or_assume(self)); + /* If the controller didn't change, add-port only rechecks whether to assume a connection. */ + nm_device_controller_add_port(controller, + self, + !nm_device_sys_iface_state_is_external_or_assume(self)); } static void -master_ready_cb(NMActiveConnection *active, GParamSpec *pspec, NMDevice *self) +controller_ready_cb(NMActiveConnection *active, GParamSpec *pspec, NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); @@ -10062,7 +10070,7 @@ activate_stage1_device_prepare(NMDevice *self) NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS; NMActiveConnection *active; - NMActiveConnection *master; + NMActiveConnection *controller; NMDeviceClass *klass; nm_assert((priv->ip_data_4.state == NM_DEVICE_IP_STATE_NONE) @@ -10183,16 +10191,16 @@ activate_stage1_device_prepare(NMDevice *self) } } - active = NM_ACTIVE_CONNECTION(priv->act_request.obj); - master = nm_active_connection_get_controller(active); - if (master) { - if (nm_active_connection_get_state(master) >= NM_ACTIVE_CONNECTION_STATE_DEACTIVATING) { - NMDevice *master_device = nm_active_connection_get_device(master); - NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED; + active = NM_ACTIVE_CONNECTION(priv->act_request.obj); + controller = nm_active_connection_get_controller(active); + if (controller) { + if (nm_active_connection_get_state(controller) >= NM_ACTIVE_CONNECTION_STATE_DEACTIVATING) { + NMDevice *controller_device = nm_active_connection_get_device(controller); + NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED; - _LOGD(LOGD_DEVICE, "master connection is deactivating"); + _LOGD(LOGD_DEVICE, "controller connection is deactivating"); - if (master_device && NM_DEVICE_GET_PRIVATE(master_device)->queued_act_request) { + if (controller_device && NM_DEVICE_GET_PRIVATE(controller_device)->queued_act_request) { /* if the controller is going to activate again, don't block this device */ failure_reason = NM_DEVICE_STATE_REASON_NONE; } @@ -10206,20 +10214,20 @@ activate_stage1_device_prepare(NMDevice *self) priv->controller_ready_id = g_signal_connect(active, "notify::" NM_ACTIVE_CONNECTION_INT_CONTROLLER_READY, - G_CALLBACK(master_ready_cb), + G_CALLBACK(controller_ready_cb), self); } return; } } nm_clear_g_signal_handler(priv->act_request.obj, &priv->controller_ready_id); - if (master) - master_ready(self, active); + if (controller) + controller_ready(self, active); else if (priv->controller) { - nm_device_master_release_slave(priv->controller, - self, - RELEASE_SLAVE_TYPE_CONFIG_FORCE, - NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); + nm_device_controller_release_port(priv->controller, + self, + RELEASE_PORT_TYPE_CONFIG_FORCE, + NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); } nm_device_activate_schedule_stage2_device_config(self, TRUE); @@ -10447,7 +10455,7 @@ activate_stage2_device_config(NMDevice *self) NMActStageReturn ret; NMSettingWired *s_wired; gboolean no_firmware = FALSE; - SlaveInfo *info; + PortInfo *info; NMTernary accept_all_mac_addresses; nm_device_state_changed(self, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE); @@ -10495,17 +10503,17 @@ activate_stage2_device_config(NMDevice *self) } } - /* If we have slaves that aren't yet enslaved, do that now */ - c_list_for_each_entry (info, &priv->slaves, lst_slave) { - NMDeviceState slave_state = nm_device_get_state(info->slave); + /* If we have ports that aren't yet attached, do that now */ + c_list_for_each_entry (info, &priv->ports, lst_port) { + NMDeviceState port_state = nm_device_get_state(info->port); - if (slave_state == NM_DEVICE_STATE_IP_CONFIG) - nm_device_master_enslave_slave(self, - info->slave, - nm_device_get_applied_connection(info->slave)); + if (port_state == NM_DEVICE_STATE_IP_CONFIG) + nm_device_controller_attach_port(self, + info->port, + nm_device_get_applied_connection(info->port)); else if (priv->act_request.obj && nm_device_sys_iface_state_is_external(self) - && slave_state <= NM_DEVICE_STATE_DISCONNECTED) - nm_device_queue_recheck_assume(info->slave); + && port_state <= NM_DEVICE_STATE_DISCONNECTED) + nm_device_queue_recheck_assume(info->port); } s_wired = nm_device_get_applied_setting(self, NM_TYPE_SETTING_WIRED); @@ -11451,7 +11459,7 @@ connection_requires_carrier(NMConnection *connection) gboolean ip4_used = FALSE; gboolean ip6_used = FALSE; - /* We can progress to IP_CONFIG now, so that we're enslaved. + /* We can progress to IP_CONFIG now, so that we're attached as port. * That may actually cause carrier to go up and thus continue activation. */ s_con = nm_connection_get_setting_connection(connection); if (nm_setting_connection_get_controller(s_con)) @@ -11490,17 +11498,17 @@ connection_requires_carrier(NMConnection *connection) } static gboolean -have_any_ready_slaves(NMDevice *self) +have_any_ready_ports(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - SlaveInfo *info; + PortInfo *info; - /* Any enslaved slave is "ready" in the generic case as it's + /* Any attached port is "ready" in the generic case as it's * at least >= NM_DEVICE_STATE_IP_CONFIG and has had Layer 2 * properties set up. */ - c_list_for_each_entry (info, &priv->slaves, lst_slave) { - if (NM_DEVICE_GET_PRIVATE(info->slave)->is_enslaved) + c_list_for_each_entry (info, &priv->ports, lst_port) { + if (NM_DEVICE_GET_PRIVATE(info->port)->is_attached) return TRUE; } return FALSE; @@ -11924,10 +11932,10 @@ _set_mtu(NMDevice *self, guint32 mtu) _notify(self, PROP_MTU); if (priv->controller) { - /* changing the MTU of a slave, might require the master to reset - * its MTU. Note that the master usually cannot set a MTU larger - * then the slave's. Hence, when the slave increases the MTU, - * master might want to retry setting the MTU. */ + /* changing the MTU of a port, might require the controller to reset + * its MTU. Note that the controller usually cannot set a MTU larger + * then the port's. Hence, when the port increases the MTU, + * controller might want to retry setting the MTU. */ nm_device_commit_mtu(priv->controller); } } @@ -12042,8 +12050,8 @@ _commit_mtu(NMDevice *self) /* the interface has IPv6 enabled. The MTU with IPv6 cannot be smaller * then 1280. * - * For slave-devices (that don't have @s_ip6 we) don't do this fixup because - * it's anyway an unsolved problem when the slave configures a conflicting + * For port-devices (that don't have @s_ip6 we) don't do this fixup because + * it's anyway an unsolved problem when the port configures a conflicting * MTU. */ mtu_desired = 1280; } @@ -12145,8 +12153,8 @@ _commit_mtu(NMDevice *self) "mtu: failure to set MTU. %s", NM_IS_DEVICE_VLAN(self) ? "Is the parent's MTU size large enough?" - : (!c_list_is_empty(&priv->slaves) - ? "Are the MTU sizes of the slaves large enough?" + : (!c_list_is_empty(&priv->ports) + ? "Are the MTU sizes of the ports large enough?" : "Did you configure the MTU correctly?")); } priv->carrier_wait_until_msec = @@ -12662,7 +12670,7 @@ _dev_addrgenmode6_set(NMDevice *self, guint8 addr_gen_mode) /*****************************************************************************/ static gboolean -ip_requires_slaves(NMDevice *self, int addr_family) +ip_requires_ports(NMDevice *self, int addr_family) { const char *method; @@ -12671,7 +12679,7 @@ ip_requires_slaves(NMDevice *self, int addr_family) if (NM_IS_IPv4(addr_family)) return nm_streq(method, NM_SETTING_IP4_CONFIG_METHOD_AUTO); - /* SLAAC, DHCP, and Link-Local depend on connectivity (and thus slaves) + /* SLAAC, DHCP, and Link-Local depend on connectivity (and thus ports) * to complete addressing. SLAAC and DHCP need a peer to provide a prefix. */ return NM_IN_STRSET(method, @@ -12716,11 +12724,11 @@ activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family, const priv->ip_data_x[IS_IPv4].wait_for_carrier = FALSE; } - if (nm_device_is_controller(self) && ip_requires_slaves(self, addr_family)) { - /* If the master has no ready slaves, and depends on slaves for + if (nm_device_is_controller(self) && ip_requires_ports(self, addr_family)) { + /* If the controller has no ready ports, and depends on ports for * a successful IP configuration attempt, then postpone IP addressing. */ - if (!have_any_ready_slaves(self)) { + if (!have_any_ready_ports(self)) { if (!priv->ip_data_x[IS_IPv4].wait_for_ports) { _LOGT_ip(addr_family, "waiting for ports"); priv->ip_data_x[IS_IPv4].wait_for_ports = TRUE; @@ -12766,10 +12774,10 @@ activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family, const if (priv->controller) { /* If a device only has an IPv6 link-local address, * we don't generate an assumed connection. Therefore, - * when a new slave connection (without IP configuration) + * when a new port connection (without IP configuration) * is activated on the device, the link-local address * remains configured. The IP configuration of an activated - * slave should not depend on the previous state. Flush + * port should not depend on the previous state. Flush * addresses and routes on activation. */ if (ip_ifindex > 0) { @@ -14289,7 +14297,7 @@ _device_activate(NMDevice *self, NMActRequest *req) g_return_if_fail(NM_IS_ACT_REQUEST(req)); nm_assert(nm_device_is_real(self)); - /* Ensure the activation request is still valid; the master may have + /* Ensure the activation request is still valid; the controller may have * already failed in which case activation of this device should not proceed. */ if (nm_active_connection_get_state(NM_ACTIVE_CONNECTION(req)) @@ -15078,7 +15086,7 @@ NM_UTILS_FLAGS2STR_DEFINE(nm_unmanaged_flags2str, NM_UTILS_FLAGS2STR(NM_UNMANAGED_USER_CONF, "user-conf"), NM_UTILS_FLAGS2STR(NM_UNMANAGED_USER_UDEV, "user-udev"), NM_UTILS_FLAGS2STR(NM_UNMANAGED_EXTERNAL_DOWN, "external-down"), - NM_UTILS_FLAGS2STR(NM_UNMANAGED_IS_SLAVE, "is-slave"), ); + NM_UTILS_FLAGS2STR(NM_UNMANAGED_IS_PORT, "is-port"), ); static const char * _unmanaged_flags2str(NMUnmanagedFlags flags, NMUnmanagedFlags mask, char *buf, gsize len) @@ -15209,8 +15217,8 @@ _get_managed_by_flags(NMUnmanagedFlags flags, flags &= ~(NM_UNMANAGED_BY_DEFAULT | NM_UNMANAGED_USER_UDEV | NM_UNMANAGED_EXTERNAL_DOWN); } - if (NM_FLAGS_HAS(mask, NM_UNMANAGED_IS_SLAVE) && !NM_FLAGS_HAS(flags, NM_UNMANAGED_IS_SLAVE)) { - /* for an enslaved device, by-default doesn't matter */ + if (NM_FLAGS_HAS(mask, NM_UNMANAGED_IS_PORT) && !NM_FLAGS_HAS(flags, NM_UNMANAGED_IS_PORT)) { + /* for an attached device, by-default doesn't matter */ flags &= ~NM_UNMANAGED_BY_DEFAULT; } @@ -15991,8 +15999,8 @@ check_connection_available(NMDevice *self, } if (nm_device_is_controller(self)) { - /* master types are always available even without carrier. - * Making connection non-available would un-enslave slaves which + /* controller types are always available even without carrier. + * Making connection non-available would de-attach ports which * is not desired. */ return TRUE; } @@ -16446,8 +16454,8 @@ nm_device_cleanup(NMDevice *self, NMDeviceStateReason reason, CleanupType cleanu ifindex = nm_device_get_ip_ifindex(self); if (cleanup_type == CLEANUP_TYPE_DECONFIGURE) { - /* master: release slaves */ - nm_device_master_release_slaves_all(self); + /* controller: release ports */ + nm_device_controller_release_ports_all(self); /* Take out any entries in the routing table and any IP address the device had. */ if (ifindex > 0) { @@ -16469,13 +16477,13 @@ nm_device_cleanup(NMDevice *self, NMDeviceStateReason reason, CleanupType cleanu if (ifindex > 0) nm_platform_ip4_dev_route_blacklist_set(nm_device_get_platform(self), ifindex, NULL); - /* slave: mark no longer enslaved */ + /* port: mark no longer attached */ if (priv->controller && priv->ifindex > 0 - && nm_platform_link_get_master(nm_device_get_platform(self), priv->ifindex) <= 0) { - nm_device_master_release_slave(priv->controller, - self, - RELEASE_SLAVE_TYPE_NO_CONFIG, - NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); + && nm_platform_link_get_controller(nm_device_get_platform(self), priv->ifindex) <= 0) { + nm_device_controller_release_port(priv->controller, + self, + RELEASE_PORT_TYPE_NO_CONFIG, + NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); } lldp_setup(self, NM_TERNARY_FALSE); @@ -16768,7 +16776,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, if (state < NM_DEVICE_STATE_UNAVAILABLE || (state >= NM_DEVICE_STATE_IP_CONFIG && state < NM_DEVICE_STATE_ACTIVATED)) { - /* preserve-external-ports is used by NMCheckpoint to activate a master + /* preserve-external-ports is used by NMCheckpoint to activate a controller * device, and preserve already attached ports. This means, this state is only * relevant during the deactivation and the following activation of the * right profile. Once we are sufficiently far in the activation of the @@ -16985,7 +16993,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, case NM_DEVICE_STATE_FAILED: /* Usually upon failure the activation chain is interrupted in * one of the stages; but in some cases the device fails for - * external events (as a failure of master connection) while + * external events (as a failure of controller connection) while * the activation sequence is running and so we need to ensure * that the chain is terminated here. */ @@ -16996,8 +17004,8 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, "Activation: failed for connection '%s'", sett_conn ? nm_settings_connection_get_id(sett_conn) : "<unknown>"); - /* Notify any slaves of the unexpected failure */ - nm_device_master_release_slaves_all(self); + /* Notify any ports of the unexpected failure */ + nm_device_controller_release_ports_all(self); /* If the connection doesn't yet have a timestamp, set it to zero so that * we can distinguish between connections we've tried to activate and have @@ -17221,7 +17229,7 @@ nm_device_get_state_reason(NMDevice *self) * @flag: whether to set or clear the the flag. * * This sets an internal flag to true, which does something specific. - * For non-master devices, it has no effect. For master devices, this + * For non-controller devices, it has no effect. For controller devices, this * will prevent to detach all external ports, until the next activation * completes. * @@ -18391,19 +18399,19 @@ static GVariant * _device_get_ports_variant(NMDevice *device) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(device); - SlaveInfo *info; + PortInfo *info; GVariantBuilder builder; gboolean any = FALSE; if (priv->ports_variant) return priv->ports_variant; - c_list_for_each_entry (info, &priv->slaves, lst_slave) { + c_list_for_each_entry (info, &priv->ports, lst_port) { const char *path; - if (!NM_DEVICE_GET_PRIVATE(info->slave)->is_enslaved) + if (!NM_DEVICE_GET_PRIVATE(info->port)->is_attached) continue; - path = nm_dbus_object_get_path(NM_DBUS_OBJECT(info->slave)); + path = nm_dbus_object_get_path(NM_DBUS_OBJECT(info->port)); if (!path) continue; if (!any) { @@ -18690,7 +18698,7 @@ nm_device_init(NMDevice *self) c_list_init(&self->devices_lst); c_list_init(&self->devcon_dev_lst_head); c_list_init(&self->policy_auto_activate_lst); - c_list_init(&priv->slaves); + c_list_init(&priv->ports); priv->ipdhcp_data_6.v6.mode = NM_NDISC_DHCP_LEVEL_NONE; @@ -18844,7 +18852,7 @@ dispose(GObject *object) _cleanup_generic_pre(self, CLEANUP_TYPE_KEEP); - nm_assert(c_list_is_empty(&priv->slaves)); + nm_assert(c_list_is_empty(&priv->ports)); /* Let the kernel manage IPv6LL again */ _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_EUI64); diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index ba45497c..37eda5c0 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -375,10 +375,10 @@ typedef struct _NMDeviceClass { /* Update the connection with currently configured L2 settings */ void (*update_connection)(NMDevice *device, NMConnection *connection); - gboolean (*master_update_slave_connection)(NMDevice *self, - NMDevice *slave, - NMConnection *connection, - GError **error); + gboolean (*controller_update_port_connection)(NMDevice *self, + NMDevice *port, + NMConnection *connection, + GError **error); /* Attachs a port asynchronously. Returns TRUE/FALSE on immediate * success/error; in such cases, the callback is not invoked. If the @@ -526,14 +526,14 @@ gboolean nm_device_is_available(NMDevice *dev, NMDeviceCheckDevAvailableFlags fl gboolean nm_device_has_carrier(NMDevice *dev); NMConnection *nm_device_generate_connection(NMDevice *self, - NMDevice *master, + NMDevice *controller, gboolean *out_maybe_later, GError **error); -gboolean nm_device_master_update_slave_connection(NMDevice *master, - NMDevice *slave, - NMConnection *connection, - GError **error); +gboolean nm_device_controller_update_port_connection(NMDevice *controller, + NMDevice *port, + NMConnection *connection, + GError **error); gboolean nm_device_can_auto_connect(NMDevice *self, NMSettingsConnection *sett_conn, char **specific_object); @@ -549,7 +549,7 @@ gboolean nm_device_check_connection_compatible(NMDevice *device, gboolean check_properties, GError **error); -gboolean nm_device_check_slave_connection_compatible(NMDevice *device, NMConnection *connection); +gboolean nm_device_check_port_connection_compatible(NMDevice *device, NMConnection *connection); gboolean nm_device_can_be_parent(NMDevice *device); gboolean nm_device_can_assume_connections(NMDevice *self); @@ -603,9 +603,9 @@ void nm_device_copy_ip6_dns_config(NMDevice *self, NMDevice *from_device); * them by default * @NM_UNMANAGED_USER_UDEV: %TRUE when unmanaged by user decision (via UDev rule) * @NM_UNMANAGED_EXTERNAL_DOWN: %TRUE when unmanaged because !IFF_UP and not created by NM - * @NM_UNMANAGED_IS_SLAVE: indicates that the device is enslaved. Note that - * setting the NM_UNMANAGED_IS_SLAVE to %TRUE makes no sense, this flag has only - * meaning to set a slave device as managed if the parent is managed too. + * @NM_UNMANAGED_IS_PORT: indicates that the device is attached as port. Note that + * setting the NM_UNMANAGED_IS_PORT to %TRUE makes no sense, this flag has only + * meaning to set a port device as managed if the parent is managed too. */ typedef enum { NM_UNMANAGED_NONE = 0, @@ -624,7 +624,7 @@ typedef enum { NM_UNMANAGED_USER_CONF = (1LL << 6), NM_UNMANAGED_USER_UDEV = (1LL << 7), NM_UNMANAGED_EXTERNAL_DOWN = (1LL << 8), - NM_UNMANAGED_IS_SLAVE = (1LL << 9), + NM_UNMANAGED_IS_PORT = (1LL << 9), NM_UNMANAGED_ALL = ((1LL << 10) - 1), } NMUnmanagedFlags; diff --git a/src/core/devices/ovs/nm-device-ovs-bridge.c b/src/core/devices/ovs/nm-device-ovs-bridge.c index 27d04003..09777669 100644 --- a/src/core/devices/ovs/nm-device-ovs-bridge.c +++ b/src/core/devices/ovs/nm-device-ovs-bridge.c @@ -49,7 +49,7 @@ create_and_realize(NMDevice *device, const NMPlatformLink **out_plink, GError **error) { - /* The actual backing resources will be created on enslavement by the port + /* The actual backing resources will be created on attachment by the port * when it can identify the port and the bridge. */ return TRUE; diff --git a/src/core/devices/ovs/nm-device-ovs-interface.c b/src/core/devices/ovs/nm-device-ovs-interface.c index c83451de..ac136be2 100644 --- a/src/core/devices/ovs/nm-device-ovs-interface.c +++ b/src/core/devices/ovs/nm-device-ovs-interface.c @@ -379,6 +379,7 @@ act_stage3_ip_config(NMDevice *device, int addr_family) { NMDeviceOvsInterface *self = NM_DEVICE_OVS_INTERFACE(device); NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self); + bool old_wait_link; /* * When the ovs-interface device enters stage3, it becomes eligible to be attached to @@ -432,6 +433,7 @@ act_stage3_ip_config(NMDevice *device, int addr_family) priv->wait_link.cloned_mac_evaluated = TRUE; } + old_wait_link = priv->wait_link.waiting; priv->wait_link.waiting = TRUE; if (check_waiting_for_link(device, addr_family == AF_INET ? "stage3-ipv4" : "stage3-ipv6")) { nm_device_devip_set_state(device, addr_family, NM_DEVICE_IP_STATE_PENDING, NULL); @@ -450,6 +452,18 @@ act_stage3_ip_config(NMDevice *device, int addr_family) nm_utils_addr_family_to_char(addr_family)); priv->wait_link.waiting = FALSE; + /* + * It is possible we detect the link is ready before link_changed event does. It could happen + * because another stage3_ip_config scheduled happened right after the link is ready. + * Therefore, if we learn on this function that we are not waiting for the link anymore, + * we schedule a sync. stage3_ip_config. Otherwise, it could happen that we proceed with + * IP configuration without the needed allocated resources like DHCP client. + */ + if (old_wait_link) { + nm_device_bring_up(device); + nm_device_activate_schedule_stage3_ip_config(device, TRUE); + return; + } nm_clear_g_source_inst(&priv->wait_link.tun_set_ifindex_idle_source); nm_clear_g_signal_handler(nm_device_get_platform(device), &priv->wait_link.tun_link_signal_id); diff --git a/src/core/devices/ovs/nm-device-ovs-port.c b/src/core/devices/ovs/nm-device-ovs-port.c index e1020280..2acafba2 100644 --- a/src/core/devices/ovs/nm-device-ovs-port.c +++ b/src/core/devices/ovs/nm-device-ovs-port.c @@ -48,7 +48,7 @@ create_and_realize(NMDevice *device, const NMPlatformLink **out_plink, GError **error) { - /* The port will be added to ovsdb when an interface is enslaved, + /* The port will be added to ovsdb when an interface is attached as port, * because there's no such thing like an empty port. */ return TRUE; diff --git a/src/core/devices/team/nm-device-team.c b/src/core/devices/team/nm-device-team.c index 1f70537f..0f420a7a 100644 --- a/src/core/devices/team/nm-device-team.c +++ b/src/core/devices/team/nm-device-team.c @@ -238,10 +238,10 @@ update_connection(NMDevice *device, NMConnection *connection) /*****************************************************************************/ static gboolean -master_update_slave_connection(NMDevice *device, - NMDevice *slave, - NMConnection *connection, - GError **error) +controller_update_port_connection(NMDevice *device, + NMDevice *port, + NMConnection *connection, + GError **error) { NMDeviceTeam *self = NM_DEVICE_TEAM(device); NMSettingTeamPort *s_port; @@ -251,23 +251,24 @@ master_update_slave_connection(NMDevice *device, struct teamdctl *tdc; const char *team_port_config = NULL; const char *iface = nm_device_get_iface(device); - const char *iface_slave = nm_device_get_iface(slave); + const char *iface_port = nm_device_get_iface(port); NMConnection *applied_connection = nm_device_get_applied_connection(device); tdc = _tdc_connect_new(self, iface, &connect_error); if (!tdc) { - g_set_error(error, - NM_DEVICE_ERROR, - NM_DEVICE_ERROR_FAILED, - "update slave connection for slave '%s' failed to connect to teamd for master " - "%s (%s)", - iface_slave, - iface, - connect_error->message); + g_set_error( + error, + NM_DEVICE_ERROR, + NM_DEVICE_ERROR_FAILED, + "update port connection for port '%s' failed to connect to teamd for controller " + "%s (%s)", + iface_port, + iface, + connect_error->message); return FALSE; } - err = teamdctl_port_config_get_raw_direct(tdc, iface_slave, (char **) &team_port_config); + err = teamdctl_port_config_get_raw_direct(tdc, iface_port, (char **) &team_port_config); port_config = g_strdup(team_port_config); teamdctl_disconnect(tdc); teamdctl_free(tdc); @@ -275,9 +276,9 @@ master_update_slave_connection(NMDevice *device, g_set_error(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_FAILED, - "update slave connection for slave '%s' failed to get configuration from teamd " - "master %s (err=%d)", - iface_slave, + "update port connection for port '%s' failed to get configuration from teamd " + "controller %s (err=%d)", + iface_port, iface, err); g_free(port_config); @@ -858,7 +859,7 @@ attach_port(NMDevice *device, const char *port_iface = nm_device_get_ip_iface(port); NMSettingTeamPort *s_team_port; - nm_device_master_check_slave_physical_port(device, port, LOGD_TEAM); + nm_device_controller_check_port_physical_port(device, port, LOGD_TEAM); if (configure) { nm_device_take_down(port, TRUE); @@ -881,9 +882,9 @@ attach_port(NMDevice *device, return FALSE; } } - success = nm_platform_link_enslave(nm_device_get_platform(device), - nm_device_get_ip_ifindex(device), - nm_device_get_ip_ifindex(port)); + success = nm_platform_link_attach_port(nm_device_get_platform(device), + nm_device_get_ip_ifindex(device), + nm_device_get_ip_ifindex(port)); nm_device_bring_up(port); if (!success) @@ -927,9 +928,9 @@ detach_port(NMDevice *device, if (ifindex_port <= 0) { _LOGD(LOGD_TEAM, "team port %s is already detached", port_iface); } else if (do_release) { - success = nm_platform_link_release(nm_device_get_platform(device), - nm_device_get_ip_ifindex(device), - ifindex_port); + success = nm_platform_link_release_port(nm_device_get_platform(device), + nm_device_get_ip_ifindex(device), + ifindex_port); if (success) _LOGI(LOGD_TEAM, "detached team port %s", port_iface); else @@ -974,7 +975,7 @@ create_and_realize(NMDevice *device, g_set_error(error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, - "Failed to create team master interface '%s' for '%s': %s", + "Failed to create team controller interface '%s' for '%s': %s", iface, nm_connection_get_id(connection), nm_strerror(r)); @@ -1127,12 +1128,12 @@ nm_device_team_class_init(NMDeviceTeamClass *klass) device_class->connection_type_check_compatible = NM_SETTING_TEAM_SETTING_NAME; device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES(NM_LINK_TYPE_TEAM); - device_class->is_controller = TRUE; - device_class->create_and_realize = create_and_realize; - device_class->get_generic_capabilities = get_generic_capabilities; - device_class->complete_connection = complete_connection; - device_class->update_connection = update_connection; - device_class->master_update_slave_connection = master_update_slave_connection; + device_class->is_controller = TRUE; + device_class->create_and_realize = create_and_realize; + device_class->get_generic_capabilities = get_generic_capabilities; + device_class->complete_connection = complete_connection; + device_class->update_connection = update_connection; + device_class->controller_update_port_connection = controller_update_port_connection; device_class->act_stage1_prepare_also_for_external_or_assume = TRUE; device_class->act_stage1_prepare = act_stage1_prepare; diff --git a/src/core/devices/wifi/nm-device-wifi.c b/src/core/devices/wifi/nm-device-wifi.c index 206113e4..f24b9733 100644 --- a/src/core/devices/wifi/nm-device-wifi.c +++ b/src/core/devices/wifi/nm-device-wifi.c @@ -3293,8 +3293,8 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) GError *error = NULL; guint timeout; NMActRequest *request; - NMActiveConnection *master_ac; - NMDevice *master; + NMActiveConnection *controller_ac; + NMDevice *controller; nm_clear_g_source(&priv->sup_timeout_id); nm_clear_g_source(&priv->link_timeout_id); @@ -3374,10 +3374,10 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) /* Tell the supplicant in which bridge the interface is */ if ((request = nm_device_get_act_request(device)) - && (master_ac = nm_active_connection_get_controller(NM_ACTIVE_CONNECTION(request))) - && (master = nm_active_connection_get_device(master_ac)) - && nm_device_get_device_type(master) == NM_DEVICE_TYPE_BRIDGE) { - nm_supplicant_interface_set_bridge(priv->sup_iface, nm_device_get_iface(master)); + && (controller_ac = nm_active_connection_get_controller(NM_ACTIVE_CONNECTION(request))) + && (controller = nm_active_connection_get_device(controller_ac)) + && nm_device_get_device_type(controller) == NM_DEVICE_TYPE_BRIDGE) { + nm_supplicant_interface_set_bridge(priv->sup_iface, nm_device_get_iface(controller)); } else nm_supplicant_interface_set_bridge(priv->sup_iface, NULL); |