core: rename sys-iface-state to managed-type internally

The previous name was not very self explanatory. Managed type indicates
a bit better what the meaning is.
This commit is contained in:
Íñigo Huguet
2024-08-27 10:26:50 +02:00
committed by Fernando Fernandez Mancera
parent b2930f5361
commit 573c48d034
16 changed files with 176 additions and 179 deletions

View File

@@ -304,8 +304,8 @@ Note that the unmanaged flags are tracked via two variables
practice a tri-state variable with possible values TRUE (unmanaged), practice a tri-state variable with possible values TRUE (unmanaged),
FALSE (managed) and UNSET. FALSE (managed) and UNSET.
External devices and sys-iface-state External devices and managed-type
------------------------------------ ---------------------------------
Even if a device is managed, that doesn't mean that NetworkManager is Even if a device is managed, that doesn't mean that NetworkManager is
actively configuring it. When a device is created externally (for actively configuring it. When a device is created externally (for
@@ -314,7 +314,7 @@ creates a in-memory connection representing the configuration
parameters on the interface such as IP addresses, routes, DNS, etc.; parameters on the interface such as IP addresses, routes, DNS, etc.;
the connection appears as active but NetworkManager doesn't actually the connection appears as active but NetworkManager doesn't actually
touch the interface. The external status is tracked in the touch the interface. The external status is tracked in the
`sys-iface-state` member, which can have the following values: `managed-type` member, which can have the following values:
- EXTERNAL: the interface is not touched by NM. - EXTERNAL: the interface is not touched by NM.
- ASSUME: this value is deprecated; it used to mean that NM should manage the device without fully reconfiguring it. Now, the interface is either managed on external. - ASSUME: this value is deprecated; it used to mean that NM should manage the device without fully reconfiguring it. Now, the interface is either managed on external.

View File

@@ -608,12 +608,12 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason)
s_bond = nm_connection_get_setting_bond(connection); s_bond = nm_connection_get_setting_bond(connection);
g_return_val_if_fail(s_bond, NM_ACT_STAGE_RETURN_FAILURE); g_return_val_if_fail(s_bond, NM_ACT_STAGE_RETURN_FAILURE);
if (nm_device_sys_iface_state_is_external(device)) if (nm_device_managed_type_is_external(device))
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
_balance_slb_setup(self, connection); _balance_slb_setup(self, connection);
if (nm_device_sys_iface_state_is_external_or_assume(device)) if (nm_device_managed_type_is_external_or_assume(device))
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
_platform_lnk_bond_init_from_setting(s_bond, &props); _platform_lnk_bond_init_from_setting(s_bond, &props);

View File

@@ -1049,7 +1049,7 @@ attach_port(NMDevice *device,
nm_assert(s_bridge); nm_assert(s_bridge);
s_port = nm_connection_get_setting_bridge_port(connection); s_port = nm_connection_get_setting_bridge_port(connection);
if (!nm_device_sys_iface_state_is_external(device)) if (!nm_device_managed_type_is_external(device))
bridge_set_vlan_options(device, s_bridge, FALSE); bridge_set_vlan_options(device, s_bridge, FALSE);
if (nm_setting_bridge_get_vlan_filtering(s_bridge)) { if (nm_setting_bridge_get_vlan_filtering(s_bridge)) {

View File

@@ -988,8 +988,8 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason)
NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device); NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device);
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self);
if (nm_device_sys_iface_state_is_external_or_assume(device)) { if (nm_device_managed_type_is_external_or_assume(device)) {
if (!priv->ethtool_prev_set && !nm_device_sys_iface_state_is_external(device)) { if (!priv->ethtool_prev_set && !nm_device_managed_type_is_external(device)) {
NMSettingWired *s_wired; NMSettingWired *s_wired;
/* During restart of NetworkManager service we forget the original auto /* During restart of NetworkManager service we forget the original auto

View File

@@ -152,14 +152,13 @@ NM_UTILS_LOOKUP_STR_DEFINE(nm_device_mtu_source_to_string,
NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_MTU_SOURCE_CONNECTION, NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_MTU_SOURCE_CONNECTION,
"connection"), ); "connection"), );
NM_UTILS_LOOKUP_STR_DEFINE(nm_device_sys_iface_state_to_string, NM_UTILS_LOOKUP_STR_DEFINE(nm_device_managed_type_to_string,
NMDeviceSysIfaceState, NMDeviceManagedType,
NM_UTILS_LOOKUP_DEFAULT_NM_ASSERT("unknown"), NM_UTILS_LOOKUP_DEFAULT_NM_ASSERT("unknown"),
NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, "external"), NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_MANAGED_TYPE_EXTERNAL, "external"),
NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_SYS_IFACE_STATE_ASSUME, "assume"), NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_MANAGED_TYPE_ASSUME, "assume"),
NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_SYS_IFACE_STATE_MANAGED, "managed"), NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_MANAGED_TYPE_MANAGED, "managed"),
NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_SYS_IFACE_STATE_REMOVED, NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_MANAGED_TYPE_REMOVED, "removed"), );
"removed"), );
NM_UTILS_LOOKUP_STR_DEFINE(nm_device_ip_state_to_string, NM_UTILS_LOOKUP_STR_DEFINE(nm_device_ip_state_to_string,
NMDeviceIPState, NMDeviceIPState,

View File

@@ -57,19 +57,19 @@ const char *nm_device_mtu_source_to_string(NMDeviceMtuSource mtu_source);
/*****************************************************************************/ /*****************************************************************************/
typedef enum _nm_packed { typedef enum _nm_packed {
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, NM_DEVICE_MANAGED_TYPE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_ASSUME, NM_DEVICE_MANAGED_TYPE_ASSUME,
NM_DEVICE_SYS_IFACE_STATE_MANAGED, NM_DEVICE_MANAGED_TYPE_MANAGED,
/* the REMOVED state applies when the device is manually set to unmanaged /* the REMOVED state applies when the device is manually set to unmanaged
* or the link was externally removed. In both cases, we move the device * or the link was externally removed. In both cases, we move the device
* to UNMANAGED state, without touching the link -- be it, because the link * to UNMANAGED state, without touching the link -- be it, because the link
* is already gone or because we want to release it (give it up). * is already gone or because we want to release it (give it up).
*/ */
NM_DEVICE_SYS_IFACE_STATE_REMOVED, NM_DEVICE_MANAGED_TYPE_REMOVED,
} NMDeviceSysIfaceState; } NMDeviceManagedType;
const char *nm_device_sys_iface_state_to_string(NMDeviceSysIfaceState sys_iface_state); const char *nm_device_managed_type_to_string(NMDeviceManagedType managed_type);
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -72,7 +72,7 @@ parent_hwaddr_maybe_changed(NMDevice *parent, GParamSpec *pspec, gpointer user_d
const char *new_mac; const char *new_mac;
/* Never touch assumed devices */ /* Never touch assumed devices */
if (nm_device_sys_iface_state_is_external_or_assume(device)) if (nm_device_managed_type_is_external_or_assume(device))
return; return;
connection = nm_device_get_applied_connection(device); connection = nm_device_get_applied_connection(device);

View File

@@ -1586,26 +1586,25 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason)
{ {
NMDeviceWireGuard *self = NM_DEVICE_WIREGUARD(device); NMDeviceWireGuard *self = NM_DEVICE_WIREGUARD(device);
NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self);
NMDeviceSysIfaceState sys_iface_state; NMDeviceManagedType managed_type;
NMDeviceStateReason failure_reason; NMDeviceStateReason failure_reason;
NMActStageReturn ret; NMActStageReturn ret;
sys_iface_state = nm_device_sys_iface_state_get(device); managed_type = nm_device_managed_type_get(device);
if (sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_EXTERNAL) { if (managed_type == NM_DEVICE_MANAGED_TYPE_EXTERNAL) {
NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_NONE); NM_SET_OUT(out_failure_reason, NM_DEVICE_STATE_REASON_NONE);
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
} }
ret = ret = link_config(NM_DEVICE_WIREGUARD(device),
link_config(NM_DEVICE_WIREGUARD(device),
"configure", "configure",
(sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_ASSUME) ? LINK_CONFIG_MODE_ASSUME (managed_type == NM_DEVICE_MANAGED_TYPE_ASSUME) ? LINK_CONFIG_MODE_ASSUME
: LINK_CONFIG_MODE_FULL, : LINK_CONFIG_MODE_FULL,
&failure_reason); &failure_reason);
if (ret == NM_ACT_STAGE_RETURN_FAILURE) { if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
if (sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_ASSUME) { if (managed_type == NM_DEVICE_MANAGED_TYPE_ASSUME) {
/* this never fails. */ /* this never fails. */
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
} }

View File

@@ -571,11 +571,11 @@ typedef struct _NMDevicePrivate {
}; };
union { union {
const NMDeviceSysIfaceState sys_iface_state; const NMDeviceManagedType managed_type;
NMDeviceSysIfaceState sys_iface_state_; NMDeviceManagedType managed_type_;
}; };
NMDeviceSysIfaceState sys_iface_state_before_sleep; NMDeviceManagedType managed_type_before_sleep;
bool carrier : 1; bool carrier : 1;
bool ignore_carrier : 1; bool ignore_carrier : 1;
@@ -3357,47 +3357,47 @@ nm_device_create_l3_config_data_from_connection(NMDevice *self, NMConnection *co
/*****************************************************************************/ /*****************************************************************************/
NMDeviceSysIfaceState NMDeviceManagedType
nm_device_sys_iface_state_get(NMDevice *self) nm_device_managed_type_get(NMDevice *self)
{ {
g_return_val_if_fail(NM_IS_DEVICE(self), NM_DEVICE_SYS_IFACE_STATE_EXTERNAL); g_return_val_if_fail(NM_IS_DEVICE(self), NM_DEVICE_MANAGED_TYPE_EXTERNAL);
return NM_DEVICE_GET_PRIVATE(self)->sys_iface_state; return NM_DEVICE_GET_PRIVATE(self)->managed_type;
} }
gboolean gboolean
nm_device_sys_iface_state_is_external(NMDevice *self) nm_device_managed_type_is_external(NMDevice *self)
{ {
return NM_IN_SET(nm_device_sys_iface_state_get(self), NM_DEVICE_SYS_IFACE_STATE_EXTERNAL); return NM_IN_SET(nm_device_managed_type_get(self), NM_DEVICE_MANAGED_TYPE_EXTERNAL);
} }
gboolean gboolean
nm_device_sys_iface_state_is_external_or_assume(NMDevice *self) nm_device_managed_type_is_external_or_assume(NMDevice *self)
{ {
return NM_IN_SET(nm_device_sys_iface_state_get(self), return NM_IN_SET(nm_device_managed_type_get(self),
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, NM_DEVICE_MANAGED_TYPE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_ASSUME); NM_DEVICE_MANAGED_TYPE_ASSUME);
} }
void void
nm_device_sys_iface_state_set(NMDevice *self, NMDeviceSysIfaceState sys_iface_state) nm_device_managed_type_set(NMDevice *self, NMDeviceManagedType managed_type)
{ {
NMDevicePrivate *priv; NMDevicePrivate *priv;
g_return_if_fail(NM_IS_DEVICE(self)); g_return_if_fail(NM_IS_DEVICE(self));
g_return_if_fail(NM_IN_SET(sys_iface_state, g_return_if_fail(NM_IN_SET(managed_type,
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, NM_DEVICE_MANAGED_TYPE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_ASSUME, NM_DEVICE_MANAGED_TYPE_ASSUME,
NM_DEVICE_SYS_IFACE_STATE_MANAGED, NM_DEVICE_MANAGED_TYPE_MANAGED,
NM_DEVICE_SYS_IFACE_STATE_REMOVED)); NM_DEVICE_MANAGED_TYPE_REMOVED));
priv = NM_DEVICE_GET_PRIVATE(self); priv = NM_DEVICE_GET_PRIVATE(self);
if (priv->sys_iface_state != sys_iface_state) { if (priv->managed_type != managed_type) {
_LOGT(LOGD_DEVICE, _LOGT(LOGD_DEVICE,
"managed-type: %s -> %s", "managed-type: %s -> %s",
nm_device_sys_iface_state_to_string(priv->sys_iface_state), nm_device_managed_type_to_string(priv->managed_type),
nm_device_sys_iface_state_to_string(sys_iface_state)); nm_device_managed_type_to_string(managed_type));
priv->sys_iface_state_ = sys_iface_state; priv->managed_type_ = managed_type;
_dev_l3_cfg_commit_type_reset(self); _dev_l3_cfg_commit_type_reset(self);
nm_device_l3cfg_commit(self, NM_L3_CFG_COMMIT_TYPE_AUTO, FALSE); nm_device_l3cfg_commit(self, NM_L3_CFG_COMMIT_TYPE_AUTO, FALSE);
} }
@@ -3406,7 +3406,7 @@ nm_device_sys_iface_state_set(NMDevice *self, NMDeviceSysIfaceState sys_iface_st
* *
* If you change this, make sure that all callers are fine with such actions. */ * If you change this, make sure that all callers are fine with such actions. */
nm_assert(priv->sys_iface_state == sys_iface_state); nm_assert(priv->managed_type == managed_type);
} }
void void
@@ -3414,15 +3414,15 @@ nm_device_notify_sleeping(NMDevice *self)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
priv->sys_iface_state_before_sleep = priv->sys_iface_state; priv->managed_type_before_sleep = priv->managed_type;
} }
NMDeviceSysIfaceState NMDeviceManagedType
nm_device_get_sys_iface_state_before_sleep(NMDevice *self) nm_device_get_managed_type_before_sleep(NMDevice *self)
{ {
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self);
return priv->sys_iface_state_before_sleep; return priv->managed_type_before_sleep;
} }
static void static void
@@ -3820,7 +3820,7 @@ _dev_ip_state_check(NMDevice *self, int addr_family)
goto got_ip_state; goto got_ip_state;
} }
if (nm_device_sys_iface_state_is_external(self)) { if (nm_device_managed_type_is_external(self)) {
ip_state = NM_DEVICE_IP_STATE_READY; ip_state = NM_DEVICE_IP_STATE_READY;
goto got_ip_state; goto got_ip_state;
} }
@@ -4005,7 +4005,7 @@ got_ip_state:
/* If both IP states failed, or one failed and the other is disabled /* If both IP states failed, or one failed and the other is disabled
* then it's a failure. may-fail does not mean that both families may * then it's a failure. may-fail does not mean that both families may
* fail, instead it means that at least one family must succeed. */ * fail, instead it means that at least one family must succeed. */
if (nm_device_sys_iface_state_is_external_or_assume(self)) { if (nm_device_managed_type_is_external_or_assume(self)) {
_dev_ip_state_set_state(self, AF_INET, NM_DEVICE_IP_STATE_READY, "assumed"); _dev_ip_state_set_state(self, AF_INET, NM_DEVICE_IP_STATE_READY, "assumed");
_dev_ip_state_set_state(self, AF_INET6, NM_DEVICE_IP_STATE_READY, "assumed"); _dev_ip_state_set_state(self, AF_INET6, NM_DEVICE_IP_STATE_READY, "assumed");
combinedip_state = NM_DEVICE_IP_STATE_READY; combinedip_state = NM_DEVICE_IP_STATE_READY;
@@ -4458,7 +4458,7 @@ _dev_l3_register_l3cds(NMDevice *self,
if (!l3cfg) if (!l3cfg)
return FALSE; return FALSE;
is_external = nm_device_sys_iface_state_is_external(self); is_external = nm_device_managed_type_is_external(self);
changed = FALSE; changed = FALSE;
for (i = 0; i < (int) G_N_ELEMENTS(priv->l3cds); i++) { for (i = 0; i < (int) G_N_ELEMENTS(priv->l3cds); i++) {
@@ -4530,7 +4530,7 @@ update_external_connection(NMDevice *self)
/* Update external connections with configuration from platform */ /* Update external connections with configuration from platform */
if (!nm_device_sys_iface_state_is_external(self)) if (!nm_device_managed_type_is_external(self))
return; return;
settings_connection = nm_device_get_settings_connection(self); settings_connection = nm_device_get_settings_connection(self);
@@ -4726,17 +4726,17 @@ _dev_l3_cfg_commit_type_reset(NMDevice *self)
if (!priv->l3cfg) if (!priv->l3cfg)
return; return;
switch (priv->sys_iface_state) { switch (priv->managed_type) {
case NM_DEVICE_SYS_IFACE_STATE_EXTERNAL: case NM_DEVICE_MANAGED_TYPE_EXTERNAL:
case NM_DEVICE_SYS_IFACE_STATE_REMOVED: case NM_DEVICE_MANAGED_TYPE_REMOVED:
commit_type = NM_L3_CFG_COMMIT_TYPE_NONE; commit_type = NM_L3_CFG_COMMIT_TYPE_NONE;
goto do_set; goto do_set;
case NM_DEVICE_SYS_IFACE_STATE_ASSUME: case NM_DEVICE_MANAGED_TYPE_ASSUME:
/* TODO: NM_DEVICE_SYS_IFACE_STATE_ASSUME, will be dropped from the code. /* TODO: NM_DEVICE_MANAGED_TYPE_ASSUME, will be dropped from the code.
* Meanwhile, the commit type must be updated. */ * Meanwhile, the commit type must be updated. */
commit_type = NM_L3_CFG_COMMIT_TYPE_UPDATE; commit_type = NM_L3_CFG_COMMIT_TYPE_UPDATE;
goto do_set; goto do_set;
case NM_DEVICE_SYS_IFACE_STATE_MANAGED: case NM_DEVICE_MANAGED_TYPE_MANAGED:
commit_type = NM_L3_CFG_COMMIT_TYPE_UPDATE; commit_type = NM_L3_CFG_COMMIT_TYPE_UPDATE;
goto do_set; goto do_set;
} }
@@ -6365,7 +6365,7 @@ concheck_update_state(NMDevice *self,
_notify(self, IS_IPv4 ? PROP_IP4_CONNECTIVITY : PROP_IP6_CONNECTIVITY); _notify(self, IS_IPv4 ? PROP_IP4_CONNECTIVITY : PROP_IP6_CONNECTIVITY);
if (priv->state == NM_DEVICE_STATE_ACTIVATED && !nm_device_sys_iface_state_is_external(self)) if (priv->state == NM_DEVICE_STATE_ACTIVATED && !nm_device_managed_type_is_external(self))
_dev_l3_register_l3cds(self, priv->l3cfg, TRUE, NM_TERNARY_DEFAULT); _dev_l3_register_l3cds(self, priv->l3cfg, TRUE, NM_TERNARY_DEFAULT);
} }
@@ -6850,7 +6850,7 @@ nm_device_controller_release_port(NMDevice *self,
nm_clear_g_cancellable(&info->cancellable); nm_clear_g_cancellable(&info->cancellable);
/* first, let subclasses handle the release ... */ /* first, let subclasses handle the release ... */
if (info->port_is_attached || nm_device_sys_iface_state_is_external(port) if (info->port_is_attached || nm_device_managed_type_is_external(port)
|| release_type >= RELEASE_PORT_TYPE_CONFIG_FORCE) { || release_type >= RELEASE_PORT_TYPE_CONFIG_FORCE) {
NMTernary ret; NMTernary ret;
@@ -7286,7 +7286,7 @@ device_update_interface_flags(NMDevice *self, const NMPlatformLink *plink)
/* /*
* Returns the reason for managing a device. The suffix "external" indicates * Returns the reason for managing a device. The suffix "external" indicates
* that the reason mainly depends on whether we want to make the device * that the reason mainly depends on whether we want to make the device
* sys-iface-state=external or not. * managed_type=external or not.
*/ */
NMDeviceStateReason NMDeviceStateReason
nm_device_get_manage_reason_external(NMDevice *self) nm_device_get_manage_reason_external(NMDevice *self)
@@ -7294,14 +7294,14 @@ nm_device_get_manage_reason_external(NMDevice *self)
NMDeviceStateReason reason; NMDeviceStateReason reason;
/* By default we return reason NOW_MANAGED, which makes the device fully /* By default we return reason NOW_MANAGED, which makes the device fully
* managed by NM (sys-iface-state=managed). */ * managed by NM (managed_type=managed). */
reason = NM_DEVICE_STATE_REASON_NOW_MANAGED; reason = NM_DEVICE_STATE_REASON_NOW_MANAGED;
/* If the device is an external-down candidate but no longer has the flag /* If the device is an external-down candidate but no longer has the flag
* set, then the device is an externally created interface that previously * set, then the device is an externally created interface that previously
* had no addresses or no controller and now has. * had no addresses or no controller and now has.
* We need to set CONNECTION_ASSUMED as the reason, so that the device * We need to set CONNECTION_ASSUMED as the reason, so that the device
* is managed but is not touched by NM (sys-iface-state=external). */ * is managed but is not touched by NM (managed_type=external). */
if (nm_device_get_unmanaged_mask(self, NM_UNMANAGED_EXTERNAL_DOWN) if (nm_device_get_unmanaged_mask(self, NM_UNMANAGED_EXTERNAL_DOWN)
&& !nm_device_get_unmanaged_flags(self, NM_UNMANAGED_EXTERNAL_DOWN)) { && !nm_device_get_unmanaged_flags(self, NM_UNMANAGED_EXTERNAL_DOWN)) {
/* user-udev overwrites external-down, so we only assume the device /* user-udev overwrites external-down, so we only assume the device
@@ -7449,7 +7449,7 @@ device_link_changed(gpointer user_data)
* NMVpnConnection should become like a regular device, akin to NMDevicePpp). * NMVpnConnection should become like a regular device, akin to NMDevicePpp).
*/ */
if (priv->state >= NM_DEVICE_STATE_IP_CONFIG && priv->state <= NM_DEVICE_STATE_ACTIVATED if (priv->state >= NM_DEVICE_STATE_IP_CONFIG && priv->state <= NM_DEVICE_STATE_ACTIVATED
&& !nm_device_sys_iface_state_is_external(self)) && !nm_device_managed_type_is_external(self))
nm_device_l3cfg_commit(self, NM_L3_CFG_COMMIT_TYPE_REAPPLY, FALSE); nm_device_l3cfg_commit(self, NM_L3_CFG_COMMIT_TYPE_REAPPLY, FALSE);
/* If the device is active without a carrier (probably because it is /* If the device is active without a carrier (probably because it is
@@ -8041,7 +8041,7 @@ realize_start_setup(NMDevice *self,
_assume_state_set(self, assume_state_guess_assume, assume_state_connection_uuid); _assume_state_set(self, assume_state_guess_assume, assume_state_connection_uuid);
nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_EXTERNAL); nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_EXTERNAL);
if (plink) if (plink)
nm_device_update_from_platform_link(self, plink); nm_device_update_from_platform_link(self, plink);
@@ -8469,9 +8469,9 @@ port_state_changed(NMDevice *port,
} }
if (release) { if (release) {
configure = (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_MANAGED configure = (priv->managed_type == NM_DEVICE_MANAGED_TYPE_MANAGED
&& nm_device_sys_iface_state_get(port) != NM_DEVICE_SYS_IFACE_STATE_EXTERNAL) && nm_device_managed_type_get(port) != NM_DEVICE_MANAGED_TYPE_EXTERNAL)
|| nm_device_sys_iface_state_get(port) == NM_DEVICE_SYS_IFACE_STATE_MANAGED; || nm_device_managed_type_get(port) == NM_DEVICE_MANAGED_TYPE_MANAGED;
nm_device_controller_release_port(self, nm_device_controller_release_port(self,
port, port,
@@ -8610,7 +8610,7 @@ nm_device_controller_release_ports_all(NMDevice *self)
PortInfo *safe; PortInfo *safe;
/* Don't release the ports 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)) if (nm_device_managed_type_is_external(self))
return; return;
reason = priv->state_reason; reason = priv->state_reason;
@@ -8619,7 +8619,7 @@ nm_device_controller_release_ports_all(NMDevice *self)
c_list_for_each_entry_safe (info, safe, &priv->ports, lst_port) { c_list_for_each_entry_safe (info, safe, &priv->ports, lst_port) {
if (priv->activation_state_preserve_external_ports if (priv->activation_state_preserve_external_ports
&& nm_device_sys_iface_state_is_external(info->port)) { && nm_device_managed_type_is_external(info->port)) {
_LOGT(LOGD_DEVICE, _LOGT(LOGD_DEVICE,
"controller: preserve external port %s", "controller: preserve external port %s",
nm_device_get_iface(info->port)); nm_device_get_iface(info->port));
@@ -8821,9 +8821,9 @@ nm_device_removed(NMDevice *self, gboolean unconfigure_ip_config)
* commit type NONE, that doesn't emit a l3cd-changed. Do it manually, * commit type NONE, that doesn't emit a l3cd-changed. Do it manually,
* to ensure that entries are removed from the DNS manager. */ * to ensure that entries are removed from the DNS manager. */
if (priv->l3cfg if (priv->l3cfg
&& NM_IN_SET(priv->sys_iface_state, && NM_IN_SET(priv->managed_type,
NM_DEVICE_SYS_IFACE_STATE_REMOVED, NM_DEVICE_MANAGED_TYPE_REMOVED,
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL)) { NM_DEVICE_MANAGED_TYPE_EXTERNAL)) {
l3cd_old = nm_l3cfg_get_combined_l3cd(priv->l3cfg, TRUE); l3cd_old = nm_l3cfg_get_combined_l3cd(priv->l3cfg, TRUE);
if (l3cd_old) if (l3cd_old)
g_signal_emit(self, signals[L3CD_CHANGED], 0, l3cd_old, NULL); g_signal_emit(self, signals[L3CD_CHANGED], 0, l3cd_old, NULL);
@@ -9937,7 +9937,7 @@ controller_ready(NMDevice *self, NMActiveConnection *active)
/* If the controller didn't change, add-port only rechecks whether to assume a connection. */ /* If the controller didn't change, add-port only rechecks whether to assume a connection. */
nm_device_controller_add_port(controller, nm_device_controller_add_port(controller,
self, self,
!nm_device_sys_iface_state_is_external_or_assume(self)); !nm_device_managed_type_is_external_or_assume(self));
} }
static void static void
@@ -10093,7 +10093,7 @@ activate_stage1_device_prepare(NMDevice *self)
if (priv->stage1_sriov_state != NM_DEVICE_STAGE_STATE_COMPLETED) { if (priv->stage1_sriov_state != NM_DEVICE_STAGE_STATE_COMPLETED) {
NMSettingSriov *s_sriov = NULL; NMSettingSriov *s_sriov = NULL;
if (nm_device_sys_iface_state_is_external_or_assume(self)) { if (nm_device_managed_type_is_external_or_assume(self)) {
/* pass */ /* pass */
} else if (priv->stage1_sriov_state == NM_DEVICE_STAGE_STATE_PENDING) { } else if (priv->stage1_sriov_state == NM_DEVICE_STAGE_STATE_PENDING) {
return; return;
@@ -10163,7 +10163,7 @@ activate_stage1_device_prepare(NMDevice *self)
klass = NM_DEVICE_GET_CLASS(self); klass = NM_DEVICE_GET_CLASS(self);
if (klass->act_stage1_prepare_set_hwaddr_ethernet if (klass->act_stage1_prepare_set_hwaddr_ethernet
&& !nm_device_sys_iface_state_is_external_or_assume(self)) { && !nm_device_managed_type_is_external_or_assume(self)) {
if (!nm_device_hw_addr_set_cloned(self, nm_device_get_applied_connection(self), FALSE)) { if (!nm_device_hw_addr_set_cloned(self, nm_device_get_applied_connection(self), FALSE)) {
nm_device_state_changed(self, nm_device_state_changed(self,
NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_FAILED,
@@ -10173,7 +10173,7 @@ activate_stage1_device_prepare(NMDevice *self)
} }
if (klass->act_stage1_prepare_also_for_external_or_assume if (klass->act_stage1_prepare_also_for_external_or_assume
|| !nm_device_sys_iface_state_is_external_or_assume(self)) { || !nm_device_managed_type_is_external_or_assume(self)) {
nm_assert(!klass->act_stage1_prepare_also_for_external_or_assume nm_assert(!klass->act_stage1_prepare_also_for_external_or_assume
|| klass->act_stage1_prepare); || klass->act_stage1_prepare);
if (klass->act_stage1_prepare) { if (klass->act_stage1_prepare) {
@@ -10460,12 +10460,12 @@ activate_stage2_device_config(NMDevice *self)
nm_device_state_changed(self, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE); nm_device_state_changed(self, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE);
if (!nm_device_sys_iface_state_is_external(self)) { if (!nm_device_managed_type_is_external(self)) {
_ethtool_state_set(self); _ethtool_state_set(self);
nm_device_link_properties_set(self, FALSE); nm_device_link_properties_set(self, FALSE);
} }
if (!nm_device_sys_iface_state_is_external(self)) { if (!nm_device_managed_type_is_external(self)) {
if (!priv->tc_committed && !tc_commit(self)) { if (!priv->tc_committed && !tc_commit(self)) {
_LOGW(LOGD_DEVICE, "failed applying traffic control rules"); _LOGW(LOGD_DEVICE, "failed applying traffic control rules");
nm_device_state_changed(self, nm_device_state_changed(self,
@@ -10478,7 +10478,7 @@ activate_stage2_device_config(NMDevice *self)
_routing_rules_sync(self, NM_TERNARY_TRUE); _routing_rules_sync(self, NM_TERNARY_TRUE);
if (!nm_device_sys_iface_state_is_external_or_assume(self)) { if (!nm_device_managed_type_is_external_or_assume(self)) {
if (!nm_device_bring_up_full(self, FALSE, TRUE, &no_firmware)) { if (!nm_device_bring_up_full(self, FALSE, TRUE, &no_firmware)) {
nm_device_state_changed(self, nm_device_state_changed(self,
NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_FAILED,
@@ -10490,7 +10490,7 @@ activate_stage2_device_config(NMDevice *self)
klass = NM_DEVICE_GET_CLASS(self); klass = NM_DEVICE_GET_CLASS(self);
if (klass->act_stage2_config_also_for_external_or_assume if (klass->act_stage2_config_also_for_external_or_assume
|| !nm_device_sys_iface_state_is_external_or_assume(self)) { || !nm_device_managed_type_is_external_or_assume(self)) {
NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE; NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE;
ret = klass->act_stage2_config(self, &failure_reason); ret = klass->act_stage2_config(self, &failure_reason);
@@ -10511,7 +10511,7 @@ activate_stage2_device_config(NMDevice *self)
nm_device_controller_attach_port(self, nm_device_controller_attach_port(self,
info->port, info->port,
nm_device_get_applied_connection(info->port)); nm_device_get_applied_connection(info->port));
else if (priv->act_request.obj && nm_device_sys_iface_state_is_external(self) else if (priv->act_request.obj && nm_device_managed_type_is_external(self)
&& port_state <= NM_DEVICE_STATE_DISCONNECTED) && port_state <= NM_DEVICE_STATE_DISCONNECTED)
nm_device_queue_recheck_assume(info->port); nm_device_queue_recheck_assume(info->port);
} }
@@ -11136,7 +11136,7 @@ _dev_ipdhcpx_start(NMDevice *self, int addr_family)
return; return;
} }
if (nm_device_sys_iface_state_is_external(self)) { if (nm_device_managed_type_is_external(self)) {
fail_reason = nm_assert_unreachable_val("cannot run DHCP on external interface"); fail_reason = nm_assert_unreachable_val("cannot run DHCP on external interface");
goto out_fail; goto out_fail;
} }
@@ -11745,7 +11745,7 @@ _dev_ipll6_start(NMDevice *self)
connection = nm_device_get_applied_connection(self); connection = nm_device_get_applied_connection(self);
assume = nm_device_sys_iface_state_is_external_or_assume(self); assume = nm_device_managed_type_is_external_or_assume(self);
if (_prop_get_ipv6_addr_gen_mode(self) == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) { if (_prop_get_ipv6_addr_gen_mode(self) == NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY) {
NMUtilsStableType stable_type; NMUtilsStableType stable_type;
@@ -11977,7 +11977,7 @@ _commit_mtu(NMDevice *self)
if (ifindex <= 0) if (ifindex <= 0)
return; return;
if (!nm_device_get_applied_connection(self) || nm_device_sys_iface_state_is_external(self)) { if (!nm_device_get_applied_connection(self) || nm_device_managed_type_is_external(self)) {
/* we don't tamper with the MTU of disconnected and external devices. */ /* we don't tamper with the MTU of disconnected and external devices. */
return; return;
} }
@@ -12703,7 +12703,7 @@ activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family, const
NMConnection *connection; NMConnection *connection;
int ip_ifindex; int ip_ifindex;
if (nm_device_sys_iface_state_is_external(self)) if (nm_device_managed_type_is_external(self))
goto out; goto out;
connection = nm_device_get_applied_connection(self); connection = nm_device_get_applied_connection(self);
@@ -12940,7 +12940,7 @@ activate_stage3_ip_config(NMDevice *self)
/* Add the interface to the specified firewall zone */ /* Add the interface to the specified firewall zone */
switch (priv->fw_state) { switch (priv->fw_state) {
case FIREWALL_STATE_UNMANAGED: case FIREWALL_STATE_UNMANAGED:
if (nm_device_sys_iface_state_is_external(self)) { if (nm_device_managed_type_is_external(self)) {
/* fake success */ /* fake success */
priv->fw_state = FIREWALL_STATE_INITIALIZED; priv->fw_state = FIREWALL_STATE_INITIALIZED;
} else if (ifindex > 0) { } else if (ifindex > 0) {
@@ -12970,7 +12970,7 @@ activate_stage3_ip_config(NMDevice *self)
ipv6_method = nm_device_get_effective_ip_config_method(self, AF_INET6); ipv6_method = nm_device_get_effective_ip_config_method(self, AF_INET6);
if (!g_file_test("/proc/sys/net/ipv6", G_FILE_TEST_IS_DIR)) { if (!g_file_test("/proc/sys/net/ipv6", G_FILE_TEST_IS_DIR)) {
_NMLOG_ip((nm_device_sys_iface_state_is_external(self) _NMLOG_ip((nm_device_managed_type_is_external(self)
|| NM_IN_STRSET(ipv6_method, || NM_IN_STRSET(ipv6_method,
NM_SETTING_IP6_CONFIG_METHOD_AUTO, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
NM_SETTING_IP6_CONFIG_METHOD_DISABLED, NM_SETTING_IP6_CONFIG_METHOD_DISABLED,
@@ -13010,7 +13010,7 @@ activate_stage3_ip_config(NMDevice *self)
nm_device_state_changed(self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE); nm_device_state_changed(self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE);
/* Device should be up before we can do anything with it */ /* Device should be up before we can do anything with it */
if (!nm_device_sys_iface_state_is_external(self) && ifindex > 0 if (!nm_device_managed_type_is_external(self) && ifindex > 0
&& !nm_platform_link_is_up(nm_device_get_platform(self), ifindex)) && !nm_platform_link_is_up(nm_device_get_platform(self), ifindex))
_LOGW(LOGD_DEVICE, _LOGW(LOGD_DEVICE,
"interface %s not up for IP configuration", "interface %s not up for IP configuration",
@@ -13026,7 +13026,7 @@ activate_stage3_ip_config(NMDevice *self)
* let's do it! */ * let's do it! */
_commit_mtu(self); _commit_mtu(self);
if (!nm_device_sys_iface_state_is_external(self) if (!nm_device_managed_type_is_external(self)
&& (!klass->ready_for_ip_config || klass->ready_for_ip_config(self, TRUE))) { && (!klass->ready_for_ip_config || klass->ready_for_ip_config(self, TRUE))) {
if (priv->ipmanual_data.state_6 == NM_DEVICE_IP_STATE_NONE if (priv->ipmanual_data.state_6 == NM_DEVICE_IP_STATE_NONE
&& !NM_IN_STRSET(ipv6_method, && !NM_IN_STRSET(ipv6_method,
@@ -13042,7 +13042,7 @@ activate_stage3_ip_config(NMDevice *self)
* IPv6LL if this is not an assumed connection, since assumed connections * IPv6LL if this is not an assumed connection, since assumed connections
* will already have IPv6 set up. * will already have IPv6 set up.
*/ */
if (!nm_device_sys_iface_state_is_external_or_assume(self)) if (!nm_device_managed_type_is_external_or_assume(self))
_dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE); _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE);
/* Re-enable IPv6 on the interface */ /* Re-enable IPv6 on the interface */
@@ -13396,15 +13396,15 @@ act_request_set(NMDevice *self, NMActRequest *act_request)
case NM_ACTIVATION_TYPE_EXTERNAL: case NM_ACTIVATION_TYPE_EXTERNAL:
break; break;
case NM_ACTIVATION_TYPE_ASSUME: case NM_ACTIVATION_TYPE_ASSUME:
if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_EXTERNAL) if (priv->managed_type == NM_DEVICE_MANAGED_TYPE_EXTERNAL)
nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_ASSUME); nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_ASSUME);
break; break;
case NM_ACTIVATION_TYPE_MANAGED: case NM_ACTIVATION_TYPE_MANAGED:
if (NM_IN_SET_TYPED(NMDeviceSysIfaceState, if (NM_IN_SET_TYPED(NMDeviceManagedType,
priv->sys_iface_state, priv->managed_type,
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, NM_DEVICE_MANAGED_TYPE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_ASSUME)) NM_DEVICE_MANAGED_TYPE_ASSUME))
nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_MANAGED); nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_MANAGED);
break; break;
} }
} }
@@ -13947,8 +13947,8 @@ reapply_cb(NMDevice *self,
return; return;
} }
if (nm_device_sys_iface_state_is_external(self)) if (nm_device_managed_type_is_external(self))
nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_MANAGED); nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_MANAGED);
if (!check_and_reapply_connection(self, if (!check_and_reapply_connection(self,
connection connection
@@ -14432,10 +14432,10 @@ nm_device_disconnect_active_connection(NMActiveConnection *active,
if (NM_ACTIVE_CONNECTION(priv->act_request.obj) == active) { if (NM_ACTIVE_CONNECTION(priv->act_request.obj) == active) {
if (priv->state < NM_DEVICE_STATE_DEACTIVATING) { if (priv->state < NM_DEVICE_STATE_DEACTIVATING) {
/* When the user actively deactivates a profile, we set /* When the user actively deactivates a profile, we set
* the sys-iface-state to managed so that we deconfigure/cleanup the interface. * the managed-type to managed so that we deconfigure/cleanup the interface.
* But for external connections that go down otherwise, we don't want to touch the interface. */ * But for external connections that go down otherwise, we don't want to touch the interface. */
if (nm_device_sys_iface_state_is_external(self)) if (nm_device_managed_type_is_external(self))
nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_MANAGED); nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_MANAGED);
nm_device_state_changed(self, NM_DEVICE_STATE_DEACTIVATING, device_reason); nm_device_state_changed(self, NM_DEVICE_STATE_DEACTIVATING, device_reason);
} else { } else {
@@ -15702,8 +15702,7 @@ nm_device_update_firewall_zone(NMDevice *self)
priv = NM_DEVICE_GET_PRIVATE(self); priv = NM_DEVICE_GET_PRIVATE(self);
if (priv->fw_state >= FIREWALL_STATE_INITIALIZED if (priv->fw_state >= FIREWALL_STATE_INITIALIZED && !nm_device_managed_type_is_external(self))
&& !nm_device_sys_iface_state_is_external(self))
fw_change_zone(self); fw_change_zone(self);
} }
@@ -16350,7 +16349,7 @@ _cleanup_generic_pre(NMDevice *self, CleanupType cleanup_type)
} }
if (cleanup_type == CLEANUP_TYPE_DECONFIGURE && priv->fw_state >= FIREWALL_STATE_INITIALIZED if (cleanup_type == CLEANUP_TYPE_DECONFIGURE && priv->fw_state >= FIREWALL_STATE_INITIALIZED
&& priv->fw_mgr && !nm_device_sys_iface_state_is_external(self)) { && priv->fw_mgr && !nm_device_managed_type_is_external(self)) {
nm_firewalld_manager_remove_from_zone(priv->fw_mgr, nm_firewalld_manager_remove_from_zone(priv->fw_mgr,
nm_device_get_ip_iface(self), nm_device_get_ip_iface(self),
NULL, NULL,
@@ -16715,7 +16714,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
old_state = priv->state; old_state = priv->state;
if (state == NM_DEVICE_STATE_FAILED && nm_device_sys_iface_state_is_external_or_assume(self)) { if (state == NM_DEVICE_STATE_FAILED && nm_device_managed_type_is_external_or_assume(self)) {
/* Avoid tearing down assumed connection, assume it's connected */ /* Avoid tearing down assumed connection, assume it's connected */
state = NM_DEVICE_STATE_ACTIVATED; state = NM_DEVICE_STATE_ACTIVATED;
reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED; reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED;
@@ -16732,7 +16731,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
nm_device_state_to_string(old_state), nm_device_state_to_string(old_state),
nm_device_state_to_string(state), nm_device_state_to_string(state),
nm_device_state_reason_to_string_a(reason), nm_device_state_reason_to_string_a(reason),
nm_device_sys_iface_state_to_string(priv->sys_iface_state), nm_device_managed_type_to_string(priv->managed_type),
priv->firmware_missing ? ", missing firmware" : ""); priv->firmware_missing ? ", missing firmware" : "");
return; return;
} }
@@ -16742,7 +16741,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
nm_device_state_to_string(old_state), nm_device_state_to_string(old_state),
nm_device_state_to_string(state), nm_device_state_to_string(state),
nm_device_state_reason_to_string_a(reason), nm_device_state_reason_to_string_a(reason),
nm_device_sys_iface_state_to_string(priv->sys_iface_state)); nm_device_managed_type_to_string(priv->managed_type));
/* in order to prevent triggering any callback caused /* in order to prevent triggering any callback caused
* by the device not having any pending action anymore * by the device not having any pending action anymore
@@ -16764,11 +16763,11 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
if (state > NM_DEVICE_STATE_UNMANAGED && state <= NM_DEVICE_STATE_ACTIVATED if (state > NM_DEVICE_STATE_UNMANAGED && state <= NM_DEVICE_STATE_ACTIVATED
&& nm_device_state_reason_check(reason) == NM_DEVICE_STATE_REASON_NOW_MANAGED && nm_device_state_reason_check(reason) == NM_DEVICE_STATE_REASON_NOW_MANAGED
&& NM_IN_SET_TYPED(NMDeviceSysIfaceState, && NM_IN_SET_TYPED(NMDeviceManagedType,
priv->sys_iface_state, priv->managed_type,
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, NM_DEVICE_MANAGED_TYPE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_ASSUME)) NM_DEVICE_MANAGED_TYPE_ASSUME))
nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_MANAGED); nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_MANAGED);
if (state <= NM_DEVICE_STATE_DISCONNECTED || state >= NM_DEVICE_STATE_ACTIVATED) if (state <= NM_DEVICE_STATE_DISCONNECTED || state >= NM_DEVICE_STATE_ACTIVATED)
priv->auth_retries = NM_DEVICE_AUTH_RETRIES_UNSET; priv->auth_retries = NM_DEVICE_AUTH_RETRIES_UNSET;
@@ -16810,10 +16809,10 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
case NM_DEVICE_STATE_UNMANAGED: case NM_DEVICE_STATE_UNMANAGED:
nm_device_set_firmware_missing(self, FALSE); nm_device_set_firmware_missing(self, FALSE);
if (old_state > NM_DEVICE_STATE_UNMANAGED) { if (old_state > NM_DEVICE_STATE_UNMANAGED) {
if (priv->sys_iface_state != NM_DEVICE_SYS_IFACE_STATE_MANAGED) { if (priv->managed_type != NM_DEVICE_MANAGED_TYPE_MANAGED) {
nm_device_cleanup(self, nm_device_cleanup(self,
reason, reason,
priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_REMOVED priv->managed_type == NM_DEVICE_MANAGED_TYPE_REMOVED
? CLEANUP_TYPE_REMOVED ? CLEANUP_TYPE_REMOVED
: CLEANUP_TYPE_KEEP); : CLEANUP_TYPE_KEEP);
} else { } else {
@@ -16826,12 +16825,12 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
_dev_sysctl_restore_ip6_properties(self); _dev_sysctl_restore_ip6_properties(self);
} }
} }
nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_EXTERNAL); nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_EXTERNAL);
break; break;
case NM_DEVICE_STATE_UNAVAILABLE: case NM_DEVICE_STATE_UNAVAILABLE:
if (old_state == NM_DEVICE_STATE_UNMANAGED) { if (old_state == NM_DEVICE_STATE_UNMANAGED) {
_dev_sysctl_save_ip6_properties(self); _dev_sysctl_save_ip6_properties(self);
if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_MANAGED) if (priv->managed_type == NM_DEVICE_MANAGED_TYPE_MANAGED)
ip6_managed_setup(self); ip6_managed_setup(self);
device_init_static_sriov_num_vfs(self); device_init_static_sriov_num_vfs(self);
@@ -16843,7 +16842,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
carrier_detect_wait(self); carrier_detect_wait(self);
} }
if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_MANAGED) { if (priv->managed_type == NM_DEVICE_MANAGED_TYPE_MANAGED) {
if (old_state == NM_DEVICE_STATE_UNMANAGED || priv->firmware_missing) { if (old_state == NM_DEVICE_STATE_UNMANAGED || priv->firmware_missing) {
if (!nm_device_bring_up_full(self, TRUE, FALSE, &no_firmware) && no_firmware) if (!nm_device_bring_up_full(self, TRUE, FALSE, &no_firmware) && no_firmware)
_LOGW(LOGD_PLATFORM, "firmware may be missing."); _LOGW(LOGD_PLATFORM, "firmware may be missing.");
@@ -16867,13 +16866,13 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
* userspace IPv6LL enabled. * userspace IPv6LL enabled.
*/ */
_dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE); _dev_addrgenmode6_set(self, NM_IN6_ADDR_GEN_MODE_NONE);
if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_REMOVED) { if (priv->managed_type == NM_DEVICE_MANAGED_TYPE_REMOVED) {
nm_device_cleanup(self, reason, CLEANUP_TYPE_REMOVED); nm_device_cleanup(self, reason, CLEANUP_TYPE_REMOVED);
} else } else
nm_device_cleanup(self, reason, CLEANUP_TYPE_DECONFIGURE); nm_device_cleanup(self, reason, CLEANUP_TYPE_DECONFIGURE);
} else if (old_state < NM_DEVICE_STATE_DISCONNECTED) { } else if (old_state < NM_DEVICE_STATE_DISCONNECTED) {
if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_MANAGED) { if (priv->managed_type == NM_DEVICE_MANAGED_TYPE_MANAGED) {
/* Ensure IPv6 is set up as it may not have been done when /* Ensure IPv6 is set up as it may not have been done when
* entering the UNAVAILABLE state depending on the reason. * entering the UNAVAILABLE state depending on the reason.
*/ */
@@ -17036,7 +17035,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason,
{ {
gboolean change_zone = FALSE; gboolean change_zone = FALSE;
if (!nm_device_sys_iface_state_is_external(self)) { if (!nm_device_managed_type_is_external(self)) {
if (priv->ip_iface) { if (priv->ip_iface) {
/* The device now has a @ip_iface different from the /* The device now has a @ip_iface different from the
* @iface on which we previously set the zone. */ * @iface on which we previously set the zone. */
@@ -18628,14 +18627,14 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
managed = g_value_get_boolean(value); managed = g_value_get_boolean(value);
if (managed) { if (managed) {
reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED; reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED;
if (NM_IN_SET_TYPED(NMDeviceSysIfaceState, if (NM_IN_SET_TYPED(NMDeviceManagedType,
priv->sys_iface_state, priv->managed_type,
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, NM_DEVICE_MANAGED_TYPE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_REMOVED)) NM_DEVICE_MANAGED_TYPE_REMOVED))
nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_ASSUME); nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_ASSUME);
} else { } else {
reason = NM_DEVICE_STATE_REASON_REMOVED; reason = NM_DEVICE_STATE_REASON_REMOVED;
nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_REMOVED); nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_REMOVED);
} }
nm_device_set_unmanaged_by_flags(self, NM_UNMANAGED_USER_EXPLICIT, !managed, reason); nm_device_set_unmanaged_by_flags(self, NM_UNMANAGED_USER_EXPLICIT, !managed, reason);
} }
@@ -18723,10 +18722,10 @@ nm_device_init(NMDevice *self)
priv->available_connections = g_hash_table_new_full(nm_direct_hash, NULL, g_object_unref, NULL); priv->available_connections = g_hash_table_new_full(nm_direct_hash, NULL, g_object_unref, NULL);
priv->ip6_saved_properties = g_hash_table_new_full(nm_str_hash, g_str_equal, NULL, g_free); priv->ip6_saved_properties = g_hash_table_new_full(nm_str_hash, g_str_equal, NULL, g_free);
priv->sys_iface_state_ = NM_DEVICE_SYS_IFACE_STATE_EXTERNAL; priv->managed_type_ = NM_DEVICE_MANAGED_TYPE_EXTERNAL;
/* If networking is already disabled at boot, we want to manage all devices /* If networking is already disabled at boot, we want to manage all devices
* after re-enabling networking; hence, the initial state is MANAGED. */ * after re-enabling networking; hence, the initial state is MANAGED. */
priv->sys_iface_state_before_sleep = NM_DEVICE_SYS_IFACE_STATE_MANAGED; priv->managed_type_before_sleep = NM_DEVICE_MANAGED_TYPE_MANAGED;
priv->promisc_reset = NM_OPTION_BOOL_DEFAULT; priv->promisc_reset = NM_OPTION_BOOL_DEFAULT;
} }

View File

@@ -726,16 +726,16 @@ nm_device_autoconnect_blocked_unset(NMDevice *device, NMDeviceAutoconnectBlocked
void nm_device_recheck_auto_activate_schedule(NMDevice *device); void nm_device_recheck_auto_activate_schedule(NMDevice *device);
NMDeviceSysIfaceState nm_device_sys_iface_state_get(NMDevice *device); NMDeviceManagedType nm_device_managed_type_get(NMDevice *device);
gboolean nm_device_sys_iface_state_is_external(NMDevice *self); gboolean nm_device_managed_type_is_external(NMDevice *self);
gboolean nm_device_sys_iface_state_is_external_or_assume(NMDevice *self); gboolean nm_device_managed_type_is_external_or_assume(NMDevice *self);
void nm_device_sys_iface_state_set(NMDevice *device, NMDeviceSysIfaceState sys_iface_state); void nm_device_managed_type_set(NMDevice *device, NMDeviceManagedType managed_type);
void nm_device_notify_sleeping(NMDevice *self); void nm_device_notify_sleeping(NMDevice *self);
NMDeviceSysIfaceState nm_device_get_sys_iface_state_before_sleep(NMDevice *self); NMDeviceManagedType nm_device_get_managed_type_before_sleep(NMDevice *self);
void nm_device_state_changed(NMDevice *device, NMDeviceState state, NMDeviceStateReason reason); void nm_device_state_changed(NMDevice *device, NMDeviceState state, NMDeviceStateReason reason);

View File

@@ -218,9 +218,9 @@ detach_port(NMDevice *device,
gpointer user_data) gpointer user_data)
{ {
NMDeviceOvsPort *self = NM_DEVICE_OVS_PORT(device); NMDeviceOvsPort *self = NM_DEVICE_OVS_PORT(device);
bool port_not_managed = !NM_IN_SET(nm_device_sys_iface_state_get(port), bool port_not_managed = !NM_IN_SET(nm_device_managed_type_get(port),
NM_DEVICE_SYS_IFACE_STATE_MANAGED, NM_DEVICE_MANAGED_TYPE_MANAGED,
NM_DEVICE_SYS_IFACE_STATE_ASSUME); NM_DEVICE_MANAGED_TYPE_ASSUME);
NMTernary ret = TRUE; NMTernary ret = TRUE;
_LOGI(LOGD_DEVICE, "detaching ovs interface %s", nm_device_get_ip_iface(port)); _LOGI(LOGD_DEVICE, "detaching ovs interface %s", nm_device_get_ip_iface(port));

View File

@@ -763,10 +763,10 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason)
NMSettingTeam *s_team; NMSettingTeam *s_team;
const char *cfg; const char *cfg;
if (nm_device_sys_iface_state_is_external(device)) if (nm_device_managed_type_is_external(device))
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
if (nm_device_sys_iface_state_is_external_or_assume(device)) { if (nm_device_managed_type_is_external_or_assume(device)) {
if (ensure_teamd_connection(device, &error)) if (ensure_teamd_connection(device, &error))
return NM_ACT_STAGE_RETURN_SUCCESS; return NM_ACT_STAGE_RETURN_SUCCESS;
_LOGD(LOGD_TEAM, "could not connect to teamd: %s", error->message); _LOGD(LOGD_TEAM, "could not connect to teamd: %s", error->message);
@@ -832,7 +832,7 @@ deactivate(NMDevice *device)
priv->stage1_state = NM_DEVICE_STAGE_STATE_INIT; priv->stage1_state = NM_DEVICE_STAGE_STATE_INIT;
if (nm_device_sys_iface_state_is_external(device)) if (nm_device_managed_type_is_external(device))
return; return;
if (priv->teamd_pid || priv->tdc) if (priv->teamd_pid || priv->tdc)

View File

@@ -989,10 +989,10 @@ _set_activation_type_managed(NMActiveConnection *self)
_set_activation_type(self, NM_ACTIVATION_TYPE_MANAGED); _set_activation_type(self, NM_ACTIVATION_TYPE_MANAGED);
if (priv->device && self == NM_ACTIVE_CONNECTION(nm_device_get_act_request(priv->device)) if (priv->device && self == NM_ACTIVE_CONNECTION(nm_device_get_act_request(priv->device))
&& NM_IN_SET(nm_device_sys_iface_state_get(priv->device), && NM_IN_SET(nm_device_managed_type_get(priv->device),
NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, NM_DEVICE_MANAGED_TYPE_EXTERNAL,
NM_DEVICE_SYS_IFACE_STATE_ASSUME)) NM_DEVICE_MANAGED_TYPE_ASSUME))
nm_device_sys_iface_state_set(priv->device, NM_DEVICE_SYS_IFACE_STATE_MANAGED); nm_device_managed_type_set(priv->device, NM_DEVICE_MANAGED_TYPE_MANAGED);
} }
NMActivationReason NMActivationReason

View File

@@ -354,7 +354,7 @@ gboolean nm_l3cfg_remove_config_all_dirty(NML3Cfg *self, gconstpointer tag);
* nm_l3cfg_commit_type_register(). nm_l3cfg_commit_on_idle_schedule() also * nm_l3cfg_commit_type_register(). nm_l3cfg_commit_on_idle_schedule() also
* accepts a one-time commit-type argument. * accepts a one-time commit-type argument.
* *
* This is related to NMDevice's sys_iface_state, which we use to control whether * This is related to NMDevice's managed_type, which we use to control whether
* to touch/assume/manage the interface. * to touch/assume/manage the interface.
* *
* The numeric values of the enum matters: higher number mean more "important". * The numeric values of the enum matters: higher number mean more "important".

View File

@@ -2309,7 +2309,7 @@ remove_device(NMManager *self, NMDevice *device, gboolean quitting)
if (quitting) if (quitting)
nm_device_set_unmanaged_by_quitting(device); nm_device_set_unmanaged_by_quitting(device);
else { else {
nm_device_sys_iface_state_set(device, NM_DEVICE_SYS_IFACE_STATE_REMOVED); nm_device_managed_type_set(device, NM_DEVICE_MANAGED_TYPE_REMOVED);
nm_device_set_unmanaged_by_flags(device, nm_device_set_unmanaged_by_flags(device,
NM_UNMANAGED_PLATFORM_INIT, NM_UNMANAGED_PLATFORM_INIT,
NM_UNMAN_FLAG_OP_SET_UNMANAGED, NM_UNMAN_FLAG_OP_SET_UNMANAGED,
@@ -3694,9 +3694,9 @@ recheck_assume_connection(NMManager *self, NMDevice *device)
} }
} }
nm_device_sys_iface_state_set(device, nm_device_managed_type_set(device,
activation_type_assume ? NM_DEVICE_SYS_IFACE_STATE_ASSUME activation_type_assume ? NM_DEVICE_MANAGED_TYPE_ASSUME
: NM_DEVICE_SYS_IFACE_STATE_EXTERNAL); : NM_DEVICE_MANAGED_TYPE_EXTERNAL);
/* Move device to DISCONNECTED to activate the connection */ /* Move device to DISCONNECTED to activate the connection */
if (state == NM_DEVICE_STATE_UNMANAGED) { if (state == NM_DEVICE_STATE_UNMANAGED) {
@@ -3765,8 +3765,8 @@ recheck_assume_connection(NMManager *self, NMDevice *device)
"assume: deleting generated connection after assuming failed"); "assume: deleting generated connection after assuming failed");
nm_settings_connection_delete(sett_conn, FALSE); nm_settings_connection_delete(sett_conn, FALSE);
} else { } else {
if (nm_device_sys_iface_state_get(device) == NM_DEVICE_SYS_IFACE_STATE_ASSUME) if (nm_device_managed_type_get(device) == NM_DEVICE_MANAGED_TYPE_ASSUME)
nm_device_sys_iface_state_set(device, NM_DEVICE_SYS_IFACE_STATE_EXTERNAL); nm_device_managed_type_set(device, NM_DEVICE_MANAGED_TYPE_EXTERNAL);
} }
return FALSE; return FALSE;
} }
@@ -4374,7 +4374,7 @@ _platform_link_cb_idle(PlatformLinkCbData *data)
device = nm_manager_get_device_by_ifindex(self, ifindex); device = nm_manager_get_device_by_ifindex(self, ifindex);
if (device) { if (device) {
if (nm_device_is_software(device)) { if (nm_device_is_software(device)) {
nm_device_sys_iface_state_set(device, NM_DEVICE_SYS_IFACE_STATE_REMOVED); nm_device_managed_type_set(device, NM_DEVICE_MANAGED_TYPE_REMOVED);
if (!nm_device_unrealize(device, FALSE, &error)) { if (!nm_device_unrealize(device, FALSE, &error)) {
_LOG2W(LOGD_DEVICE, device, "failed to unrealize: %s", error->message); _LOG2W(LOGD_DEVICE, device, "failed to unrealize: %s", error->message);
g_clear_error(&error); g_clear_error(&error);
@@ -5768,7 +5768,7 @@ _internal_activate_device(NMManager *self, NMActiveConnection *active, GError **
} }
if (nm_active_connection_get_activation_type(active) == NM_ACTIVATION_TYPE_MANAGED) if (nm_active_connection_get_activation_type(active) == NM_ACTIVATION_TYPE_MANAGED)
nm_device_sys_iface_state_set(device, NM_DEVICE_SYS_IFACE_STATE_MANAGED); nm_device_managed_type_set(device, NM_DEVICE_MANAGED_TYPE_MANAGED);
/* Try to find the controller connection/device if the connection has a dependency */ /* Try to find the controller connection/device if the connection has a dependency */
if (!find_controller(self, if (!find_controller(self,
@@ -7404,11 +7404,11 @@ do_sleep_wake(NMManager *self, gboolean sleeping_changed)
nm_device_set_enabled(device, enabled); nm_device_set_enabled(device, enabled);
} }
/* The reason determines whether the device will be sys-iface-state=managed /* The reason determines whether the device will be managed_type=managed
* or sys-iface-state=external. Pass the correct reason to restore the state * or managed_type=external. Pass the correct reason to restore the state
* that was set before sleeping. */ * that was set before sleeping. */
reason = nm_device_get_sys_iface_state_before_sleep(device) reason =
== NM_DEVICE_SYS_IFACE_STATE_EXTERNAL nm_device_get_managed_type_before_sleep(device) == NM_DEVICE_MANAGED_TYPE_EXTERNAL
? NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED ? NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED
: NM_DEVICE_STATE_REASON_NOW_MANAGED; : NM_DEVICE_STATE_REASON_NOW_MANAGED;
nm_device_set_unmanaged_by_flags(device, nm_device_set_unmanaged_by_flags(device,

View File

@@ -429,7 +429,7 @@ get_best_active_connection(NMPolicy *self, int addr_family, gboolean fully_activ
if (state <= NM_DEVICE_STATE_DISCONNECTED || state >= NM_DEVICE_STATE_DEACTIVATING) if (state <= NM_DEVICE_STATE_DISCONNECTED || state >= NM_DEVICE_STATE_DEACTIVATING)
continue; continue;
if (nm_device_sys_iface_state_is_external(device)) if (nm_device_managed_type_is_external(device))
continue; continue;
r = nm_device_get_best_default_route(device, addr_family); r = nm_device_get_best_default_route(device, addr_family);
@@ -482,7 +482,7 @@ any_devices_active(NMPolicy *self)
state = nm_device_get_state(device); state = nm_device_get_state(device);
if (state <= NM_DEVICE_STATE_DISCONNECTED || state >= NM_DEVICE_STATE_DEACTIVATING) if (state <= NM_DEVICE_STATE_DISCONNECTED || state >= NM_DEVICE_STATE_DEACTIVATING)
continue; continue;
if (nm_device_sys_iface_state_is_external(device)) if (nm_device_managed_type_is_external(device))
continue; continue;
return TRUE; return TRUE;
} }
@@ -809,7 +809,7 @@ build_device_hostname_infos(NMPolicy *self)
if (!device) if (!device)
continue; continue;
if (nm_device_sys_iface_state_is_external(device)) if (nm_device_managed_type_is_external(device))
continue; continue;
only_from_default = only_from_default =
@@ -1307,7 +1307,7 @@ update_ip_dns(NMPolicy *self, int addr_family, NMDevice *changed_device)
/* Tell the DNS manager this config is preferred by re-adding it with /* Tell the DNS manager this config is preferred by re-adding it with
* a different IP config type. * a different IP config type.
*/ */
if (device && nm_device_sys_iface_state_is_external(device)) if (device && nm_device_managed_type_is_external(device))
ip_config_type = NM_DNS_IP_CONFIG_TYPE_REMOVED; ip_config_type = NM_DNS_IP_CONFIG_TYPE_REMOVED;
else if (vpn || (device && nm_device_is_vpn(device))) else if (vpn || (device && nm_device_is_vpn(device)))
ip_config_type = NM_DNS_IP_CONFIG_TYPE_VPN; ip_config_type = NM_DNS_IP_CONFIG_TYPE_VPN;
@@ -1447,7 +1447,7 @@ _auto_activate_device(NMPolicy *self, NMDevice *device)
// deactivate the device and activate the new connection instead of just // deactivate the device and activate the new connection instead of just
// bailing if the device is already active // bailing if the device is already active
if (nm_device_get_act_request(device)) { if (nm_device_get_act_request(device)) {
if (nm_device_sys_iface_state_is_external(device) if (nm_device_managed_type_is_external(device)
&& nm_device_get_allow_autoconnect_on_external(device)) { && nm_device_get_allow_autoconnect_on_external(device)) {
/* this is an external activation, and we allow autoconnecting on /* this is an external activation, and we allow autoconnecting on
* top of that. * top of that.
@@ -1781,7 +1781,7 @@ nm_policy_device_recheck_auto_activate_schedule(NMPolicy *self, NMDevice *device
nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) { nm_manager_for_each_active_connection (priv->manager, ac, tmp_list) {
if (nm_active_connection_get_device(ac) == device) { if (nm_active_connection_get_device(ac) == device) {
if (nm_device_sys_iface_state_is_external(device) if (nm_device_managed_type_is_external(device)
&& nm_device_get_allow_autoconnect_on_external(device)) { && nm_device_get_allow_autoconnect_on_external(device)) {
/* pass */ /* pass */
} else } else
@@ -2300,7 +2300,7 @@ device_state_changed(NMDevice *device,
* again when the device becomes ACTIVATED, we need also to update * again when the device becomes ACTIVATED, we need also to update
* routing and DNS here. */ * routing and DNS here. */
nm_dns_manager_begin_updates(priv->dns_manager, __func__); nm_dns_manager_begin_updates(priv->dns_manager, __func__);
if (!nm_device_sys_iface_state_is_external(device)) { if (!nm_device_managed_type_is_external(device)) {
nm_dns_manager_set_ip_config(priv->dns_manager, nm_dns_manager_set_ip_config(priv->dns_manager,
AF_UNSPEC, AF_UNSPEC,
device, device,