diff options
Diffstat (limited to 'src')
63 files changed, 888 insertions, 336 deletions
diff --git a/src/core/devices/nm-device-bond.c b/src/core/devices/nm-device-bond.c index 06a02d1a..b60dd3f1 100644 --- a/src/core/devices/nm-device-bond.c +++ b/src/core/devices/nm-device-bond.c @@ -608,12 +608,12 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) s_bond = nm_connection_get_setting_bond(connection); 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; _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; _platform_lnk_bond_init_from_setting(s_bond, &props); diff --git a/src/core/devices/nm-device-bridge.c b/src/core/devices/nm-device-bridge.c index 7a496d96..a237c0b7 100644 --- a/src/core/devices/nm-device-bridge.c +++ b/src/core/devices/nm-device-bridge.c @@ -1049,7 +1049,7 @@ attach_port(NMDevice *device, nm_assert(s_bridge); 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); if (nm_setting_bridge_get_vlan_filtering(s_bridge)) { diff --git a/src/core/devices/nm-device-ethernet.c b/src/core/devices/nm-device-ethernet.c index 8c2a9643..16992524 100644 --- a/src/core/devices/nm-device-ethernet.c +++ b/src/core/devices/nm-device-ethernet.c @@ -988,8 +988,8 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) NMDeviceEthernet *self = NM_DEVICE_ETHERNET(device); NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE(self); - if (nm_device_sys_iface_state_is_external_or_assume(device)) { - if (!priv->ethtool_prev_set && !nm_device_sys_iface_state_is_external(device)) { + if (nm_device_managed_type_is_external_or_assume(device)) { + if (!priv->ethtool_prev_set && !nm_device_managed_type_is_external(device)) { NMSettingWired *s_wired; /* During restart of NetworkManager service we forget the original auto diff --git a/src/core/devices/nm-device-utils.c b/src/core/devices/nm-device-utils.c index 4597ba85..ccb6292b 100644 --- a/src/core/devices/nm-device-utils.c +++ b/src/core/devices/nm-device-utils.c @@ -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, "connection"), ); -NM_UTILS_LOOKUP_STR_DEFINE(nm_device_sys_iface_state_to_string, - NMDeviceSysIfaceState, +NM_UTILS_LOOKUP_STR_DEFINE(nm_device_managed_type_to_string, + NMDeviceManagedType, 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_SYS_IFACE_STATE_ASSUME, "assume"), - NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_SYS_IFACE_STATE_MANAGED, "managed"), - NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_SYS_IFACE_STATE_REMOVED, - "removed"), ); + NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_MANAGED_TYPE_EXTERNAL, "external"), + NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_MANAGED_TYPE_ASSUME, "assume"), + NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_MANAGED_TYPE_FULL, "full"), + NM_UTILS_LOOKUP_STR_ITEM(NM_DEVICE_MANAGED_TYPE_REMOVED, "removed"), ); NM_UTILS_LOOKUP_STR_DEFINE(nm_device_ip_state_to_string, NMDeviceIPState, diff --git a/src/core/devices/nm-device-utils.h b/src/core/devices/nm-device-utils.h index 7b879c90..e9e3b52f 100644 --- a/src/core/devices/nm-device-utils.h +++ b/src/core/devices/nm-device-utils.h @@ -57,19 +57,19 @@ const char *nm_device_mtu_source_to_string(NMDeviceMtuSource mtu_source); /*****************************************************************************/ typedef enum _nm_packed { - NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, - NM_DEVICE_SYS_IFACE_STATE_ASSUME, - NM_DEVICE_SYS_IFACE_STATE_MANAGED, + NM_DEVICE_MANAGED_TYPE_EXTERNAL, + NM_DEVICE_MANAGED_TYPE_ASSUME, + NM_DEVICE_MANAGED_TYPE_FULL, /* 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 * 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). */ - NM_DEVICE_SYS_IFACE_STATE_REMOVED, -} NMDeviceSysIfaceState; + NM_DEVICE_MANAGED_TYPE_REMOVED, +} 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); /*****************************************************************************/ diff --git a/src/core/devices/nm-device-vlan.c b/src/core/devices/nm-device-vlan.c index cc649ec9..d4630999 100644 --- a/src/core/devices/nm-device-vlan.c +++ b/src/core/devices/nm-device-vlan.c @@ -72,7 +72,7 @@ parent_hwaddr_maybe_changed(NMDevice *parent, GParamSpec *pspec, gpointer user_d const char *new_mac; /* 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; connection = nm_device_get_applied_connection(device); diff --git a/src/core/devices/nm-device-wireguard.c b/src/core/devices/nm-device-wireguard.c index dd40d11e..00a8c718 100644 --- a/src/core/devices/nm-device-wireguard.c +++ b/src/core/devices/nm-device-wireguard.c @@ -1586,26 +1586,25 @@ act_stage2_config(NMDevice *device, NMDeviceStateReason *out_failure_reason) { NMDeviceWireGuard *self = NM_DEVICE_WIREGUARD(device); NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE(self); - NMDeviceSysIfaceState sys_iface_state; + NMDeviceManagedType managed_type; NMDeviceStateReason failure_reason; 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); return NM_ACT_STAGE_RETURN_SUCCESS; } - ret = - link_config(NM_DEVICE_WIREGUARD(device), - "configure", - (sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_ASSUME) ? LINK_CONFIG_MODE_ASSUME - : LINK_CONFIG_MODE_FULL, - &failure_reason); + ret = link_config(NM_DEVICE_WIREGUARD(device), + "configure", + (managed_type == NM_DEVICE_MANAGED_TYPE_ASSUME) ? LINK_CONFIG_MODE_ASSUME + : LINK_CONFIG_MODE_FULL, + &failure_reason); 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. */ return NM_ACT_STAGE_RETURN_SUCCESS; } diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 799aca04..66eba209 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -571,11 +571,11 @@ typedef struct _NMDevicePrivate { }; union { - const NMDeviceSysIfaceState sys_iface_state; - NMDeviceSysIfaceState sys_iface_state_; + const NMDeviceManagedType managed_type; + NMDeviceManagedType managed_type_; }; - NMDeviceSysIfaceState sys_iface_state_before_sleep; + NMDeviceManagedType managed_type_before_sleep; bool carrier : 1; bool ignore_carrier : 1; @@ -3357,47 +3357,47 @@ nm_device_create_l3_config_data_from_connection(NMDevice *self, NMConnection *co /*****************************************************************************/ -NMDeviceSysIfaceState -nm_device_sys_iface_state_get(NMDevice *self) +NMDeviceManagedType +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 -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 -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), - NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, - NM_DEVICE_SYS_IFACE_STATE_ASSUME); + return NM_IN_SET(nm_device_managed_type_get(self), + NM_DEVICE_MANAGED_TYPE_EXTERNAL, + NM_DEVICE_MANAGED_TYPE_ASSUME); } 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; g_return_if_fail(NM_IS_DEVICE(self)); - g_return_if_fail(NM_IN_SET(sys_iface_state, - NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, - NM_DEVICE_SYS_IFACE_STATE_ASSUME, - NM_DEVICE_SYS_IFACE_STATE_MANAGED, - NM_DEVICE_SYS_IFACE_STATE_REMOVED)); + g_return_if_fail(NM_IN_SET(managed_type, + NM_DEVICE_MANAGED_TYPE_EXTERNAL, + NM_DEVICE_MANAGED_TYPE_ASSUME, + NM_DEVICE_MANAGED_TYPE_FULL, + NM_DEVICE_MANAGED_TYPE_REMOVED)); priv = NM_DEVICE_GET_PRIVATE(self); - if (priv->sys_iface_state != sys_iface_state) { + if (priv->managed_type != managed_type) { _LOGT(LOGD_DEVICE, - "sys-iface-state: %s -> %s", - nm_device_sys_iface_state_to_string(priv->sys_iface_state), - nm_device_sys_iface_state_to_string(sys_iface_state)); - priv->sys_iface_state_ = sys_iface_state; + "managed-type: %s -> %s", + nm_device_managed_type_to_string(priv->managed_type), + nm_device_managed_type_to_string(managed_type)); + priv->managed_type_ = managed_type; _dev_l3_cfg_commit_type_reset(self); 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. */ - nm_assert(priv->sys_iface_state == sys_iface_state); + nm_assert(priv->managed_type == managed_type); } void @@ -3414,15 +3414,15 @@ nm_device_notify_sleeping(NMDevice *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 -nm_device_get_sys_iface_state_before_sleep(NMDevice *self) +NMDeviceManagedType +nm_device_get_managed_type_before_sleep(NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE(self); - return priv->sys_iface_state_before_sleep; + return priv->managed_type_before_sleep; } static void @@ -3820,7 +3820,7 @@ _dev_ip_state_check(NMDevice *self, int addr_family) 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; goto got_ip_state; } @@ -4005,7 +4005,7 @@ got_ip_state: /* 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 * 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_INET6, NM_DEVICE_IP_STATE_READY, "assumed"); combinedip_state = NM_DEVICE_IP_STATE_READY; @@ -4458,7 +4458,7 @@ _dev_l3_register_l3cds(NMDevice *self, if (!l3cfg) return FALSE; - is_external = nm_device_sys_iface_state_is_external(self); + is_external = nm_device_managed_type_is_external(self); changed = FALSE; 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 */ - if (!nm_device_sys_iface_state_is_external(self)) + if (!nm_device_managed_type_is_external(self)) return; settings_connection = nm_device_get_settings_connection(self); @@ -4726,17 +4726,17 @@ _dev_l3_cfg_commit_type_reset(NMDevice *self) if (!priv->l3cfg) return; - switch (priv->sys_iface_state) { - case NM_DEVICE_SYS_IFACE_STATE_EXTERNAL: - case NM_DEVICE_SYS_IFACE_STATE_REMOVED: + switch (priv->managed_type) { + case NM_DEVICE_MANAGED_TYPE_EXTERNAL: + case NM_DEVICE_MANAGED_TYPE_REMOVED: commit_type = NM_L3_CFG_COMMIT_TYPE_NONE; goto do_set; - case NM_DEVICE_SYS_IFACE_STATE_ASSUME: - /* TODO: NM_DEVICE_SYS_IFACE_STATE_ASSUME, will be dropped from the code. + case NM_DEVICE_MANAGED_TYPE_ASSUME: + /* TODO: NM_DEVICE_MANAGED_TYPE_ASSUME, will be dropped from the code. * Meanwhile, the commit type must be updated. */ commit_type = NM_L3_CFG_COMMIT_TYPE_UPDATE; goto do_set; - case NM_DEVICE_SYS_IFACE_STATE_MANAGED: + case NM_DEVICE_MANAGED_TYPE_FULL: commit_type = NM_L3_CFG_COMMIT_TYPE_UPDATE; goto do_set; } @@ -6365,7 +6365,7 @@ concheck_update_state(NMDevice *self, _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); } @@ -6850,7 +6850,7 @@ nm_device_controller_release_port(NMDevice *self, nm_clear_g_cancellable(&info->cancellable); /* 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) { 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 * 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 nm_device_get_manage_reason_external(NMDevice *self) @@ -7294,14 +7294,14 @@ nm_device_get_manage_reason_external(NMDevice *self) NMDeviceStateReason reason; /* 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; /* 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 * had no addresses or no controller and now has. * 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) && !nm_device_get_unmanaged_flags(self, NM_UNMANAGED_EXTERNAL_DOWN)) { /* 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). */ 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); /* 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); - 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) nm_device_update_from_platform_link(self, plink); @@ -8469,9 +8469,9 @@ port_state_changed(NMDevice *port, } if (release) { - configure = (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_MANAGED - && 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; + configure = (priv->managed_type == NM_DEVICE_MANAGED_TYPE_FULL + && nm_device_managed_type_get(port) != NM_DEVICE_MANAGED_TYPE_EXTERNAL) + || nm_device_managed_type_get(port) == NM_DEVICE_MANAGED_TYPE_FULL; nm_device_controller_release_port(self, port, @@ -8610,7 +8610,7 @@ nm_device_controller_release_ports_all(NMDevice *self) PortInfo *safe; /* 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; 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) { 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, "controller: preserve external port %s", 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, * to ensure that entries are removed from the DNS manager. */ if (priv->l3cfg - && NM_IN_SET(priv->sys_iface_state, - NM_DEVICE_SYS_IFACE_STATE_REMOVED, - NM_DEVICE_SYS_IFACE_STATE_EXTERNAL)) { + && NM_IN_SET(priv->managed_type, + NM_DEVICE_MANAGED_TYPE_REMOVED, + NM_DEVICE_MANAGED_TYPE_EXTERNAL)) { l3cd_old = nm_l3cfg_get_combined_l3cd(priv->l3cfg, TRUE); if (l3cd_old) 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. */ nm_device_controller_add_port(controller, self, - !nm_device_sys_iface_state_is_external_or_assume(self)); + !nm_device_managed_type_is_external_or_assume(self)); } static void @@ -10093,7 +10093,7 @@ activate_stage1_device_prepare(NMDevice *self) if (priv->stage1_sriov_state != NM_DEVICE_STAGE_STATE_COMPLETED) { 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 */ } else if (priv->stage1_sriov_state == NM_DEVICE_STAGE_STATE_PENDING) { return; @@ -10163,7 +10163,7 @@ activate_stage1_device_prepare(NMDevice *self) klass = NM_DEVICE_GET_CLASS(self); 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)) { nm_device_state_changed(self, NM_DEVICE_STATE_FAILED, @@ -10173,7 +10173,7 @@ activate_stage1_device_prepare(NMDevice *self) } 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 || 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); - if (!nm_device_sys_iface_state_is_external(self)) { + if (!nm_device_managed_type_is_external(self)) { _ethtool_state_set(self); 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)) { _LOGW(LOGD_DEVICE, "failed applying traffic control rules"); nm_device_state_changed(self, @@ -10478,7 +10478,7 @@ activate_stage2_device_config(NMDevice *self) _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)) { nm_device_state_changed(self, NM_DEVICE_STATE_FAILED, @@ -10490,7 +10490,7 @@ activate_stage2_device_config(NMDevice *self) klass = NM_DEVICE_GET_CLASS(self); 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; ret = klass->act_stage2_config(self, &failure_reason); @@ -10511,7 +10511,7 @@ activate_stage2_device_config(NMDevice *self) 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) + else if (priv->act_request.obj && nm_device_managed_type_is_external(self) && port_state <= NM_DEVICE_STATE_DISCONNECTED) nm_device_queue_recheck_assume(info->port); } @@ -11061,7 +11061,7 @@ _dev_ipdhcpx_notify(NMDhcpClient *client, const NMDhcpClientNotifyData *notify_d priv->l3cfg, _dev_l3_config_data_tag_get(priv, L3_CONFIG_DATA_TYPE_DHCP_X(IS_IPv4)), dhcp_l3cd)) { - _dev_l3_cfg_commit(self, FALSE); + _dev_l3_cfg_commit(self, TRUE); } goto lease_update_out; } @@ -11136,7 +11136,7 @@ _dev_ipdhcpx_start(NMDevice *self, int addr_family) 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"); goto out_fail; } @@ -11745,7 +11745,7 @@ _dev_ipll6_start(NMDevice *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) { NMUtilsStableType stable_type; @@ -11977,7 +11977,7 @@ _commit_mtu(NMDevice *self) if (ifindex <= 0) 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. */ return; } @@ -12703,7 +12703,7 @@ activate_stage3_ip_config_for_addr_family(NMDevice *self, int addr_family, const NMConnection *connection; int ip_ifindex; - if (nm_device_sys_iface_state_is_external(self)) + if (nm_device_managed_type_is_external(self)) goto out; 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 */ switch (priv->fw_state) { case FIREWALL_STATE_UNMANAGED: - if (nm_device_sys_iface_state_is_external(self)) { + if (nm_device_managed_type_is_external(self)) { /* fake success */ priv->fw_state = FIREWALL_STATE_INITIALIZED; } 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); 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_SETTING_IP6_CONFIG_METHOD_AUTO, 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); /* 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)) _LOGW(LOGD_DEVICE, "interface %s not up for IP configuration", @@ -13026,7 +13026,7 @@ activate_stage3_ip_config(NMDevice *self) * let's do it! */ _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))) { if (priv->ipmanual_data.state_6 == NM_DEVICE_IP_STATE_NONE && !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 * 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); /* Re-enable IPv6 on the interface */ @@ -13396,15 +13396,15 @@ act_request_set(NMDevice *self, NMActRequest *act_request) case NM_ACTIVATION_TYPE_EXTERNAL: break; case NM_ACTIVATION_TYPE_ASSUME: - if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_EXTERNAL) - nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_ASSUME); + if (priv->managed_type == NM_DEVICE_MANAGED_TYPE_EXTERNAL) + nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_ASSUME); break; case NM_ACTIVATION_TYPE_MANAGED: - if (NM_IN_SET_TYPED(NMDeviceSysIfaceState, - priv->sys_iface_state, - NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, - NM_DEVICE_SYS_IFACE_STATE_ASSUME)) - nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_MANAGED); + if (NM_IN_SET_TYPED(NMDeviceManagedType, + priv->managed_type, + NM_DEVICE_MANAGED_TYPE_EXTERNAL, + NM_DEVICE_MANAGED_TYPE_ASSUME)) + nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_FULL); break; } } @@ -13947,8 +13947,8 @@ reapply_cb(NMDevice *self, return; } - if (nm_device_sys_iface_state_is_external(self)) - nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_MANAGED); + if (nm_device_managed_type_is_external(self)) + nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_FULL); if (!check_and_reapply_connection(self, connection @@ -14432,10 +14432,10 @@ nm_device_disconnect_active_connection(NMActiveConnection *active, if (NM_ACTIVE_CONNECTION(priv->act_request.obj) == active) { if (priv->state < NM_DEVICE_STATE_DEACTIVATING) { /* 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. */ - if (nm_device_sys_iface_state_is_external(self)) - nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_MANAGED); + if (nm_device_managed_type_is_external(self)) + nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_FULL); nm_device_state_changed(self, NM_DEVICE_STATE_DEACTIVATING, device_reason); } else { @@ -15702,8 +15702,7 @@ nm_device_update_firewall_zone(NMDevice *self) priv = NM_DEVICE_GET_PRIVATE(self); - if (priv->fw_state >= FIREWALL_STATE_INITIALIZED - && !nm_device_sys_iface_state_is_external(self)) + if (priv->fw_state >= FIREWALL_STATE_INITIALIZED && !nm_device_managed_type_is_external(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 - && 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_device_get_ip_iface(self), NULL, @@ -16715,7 +16714,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, 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 */ state = NM_DEVICE_STATE_ACTIVATED; reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED; @@ -16728,21 +16727,21 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, if ((priv->state == state) && (state != NM_DEVICE_STATE_UNAVAILABLE || !priv->firmware_missing)) { _LOGD(LOGD_DEVICE, - "state change: %s -> %s (reason '%s', sys-iface-state: '%s'%s)", + "state change: %s -> %s (reason '%s', managed-type: '%s'%s)", nm_device_state_to_string(old_state), nm_device_state_to_string(state), 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" : ""); return; } _LOGI(LOGD_DEVICE, - "state change: %s -> %s (reason '%s', sys-iface-state: '%s')", + "state change: %s -> %s (reason '%s', managed-type: '%s')", nm_device_state_to_string(old_state), nm_device_state_to_string(state), 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 * 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 && nm_device_state_reason_check(reason) == NM_DEVICE_STATE_REASON_NOW_MANAGED - && NM_IN_SET_TYPED(NMDeviceSysIfaceState, - priv->sys_iface_state, - NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, - NM_DEVICE_SYS_IFACE_STATE_ASSUME)) - nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_MANAGED); + && NM_IN_SET_TYPED(NMDeviceManagedType, + priv->managed_type, + NM_DEVICE_MANAGED_TYPE_EXTERNAL, + NM_DEVICE_MANAGED_TYPE_ASSUME)) + nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_FULL); if (state <= NM_DEVICE_STATE_DISCONNECTED || state >= NM_DEVICE_STATE_ACTIVATED) 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: nm_device_set_firmware_missing(self, FALSE); 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_FULL) { nm_device_cleanup(self, reason, - priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_REMOVED + priv->managed_type == NM_DEVICE_MANAGED_TYPE_REMOVED ? CLEANUP_TYPE_REMOVED : CLEANUP_TYPE_KEEP); } else { @@ -16826,12 +16825,12 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, _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; case NM_DEVICE_STATE_UNAVAILABLE: if (old_state == NM_DEVICE_STATE_UNMANAGED) { _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_FULL) ip6_managed_setup(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); } - if (priv->sys_iface_state == NM_DEVICE_SYS_IFACE_STATE_MANAGED) { + if (priv->managed_type == NM_DEVICE_MANAGED_TYPE_FULL) { if (old_state == NM_DEVICE_STATE_UNMANAGED || priv->firmware_missing) { if (!nm_device_bring_up_full(self, TRUE, FALSE, &no_firmware) && no_firmware) _LOGW(LOGD_PLATFORM, "firmware may be missing."); @@ -16867,13 +16866,13 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, * userspace IPv6LL enabled. */ _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); } else nm_device_cleanup(self, reason, CLEANUP_TYPE_DECONFIGURE); } 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_FULL) { /* Ensure IPv6 is set up as it may not have been done when * entering the UNAVAILABLE state depending on the reason. */ @@ -16893,10 +16892,6 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, _cleanup_ip_pre(self, AF_INET6, CLEANUP_TYPE_DECONFIGURE, FALSE); } break; - case NM_DEVICE_STATE_DEACTIVATING: - /* If we are now deactivating we should enforce IP cleanup. */ - _cleanup_ip_pre(self, AF_INET, CLEANUP_TYPE_DECONFIGURE, FALSE); - _cleanup_ip_pre(self, AF_INET6, CLEANUP_TYPE_DECONFIGURE, FALSE); default: break; } @@ -17040,7 +17035,7 @@ _set_state_full(NMDevice *self, NMDeviceState state, NMDeviceStateReason reason, { 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) { /* The device now has a @ip_iface different from the * @iface on which we previously set the zone. */ @@ -18632,14 +18627,14 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps managed = g_value_get_boolean(value); if (managed) { reason = NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED; - if (NM_IN_SET_TYPED(NMDeviceSysIfaceState, - priv->sys_iface_state, - NM_DEVICE_SYS_IFACE_STATE_EXTERNAL, - NM_DEVICE_SYS_IFACE_STATE_REMOVED)) - nm_device_sys_iface_state_set(self, NM_DEVICE_SYS_IFACE_STATE_ASSUME); + if (NM_IN_SET_TYPED(NMDeviceManagedType, + priv->managed_type, + NM_DEVICE_MANAGED_TYPE_EXTERNAL, + NM_DEVICE_MANAGED_TYPE_REMOVED)) + nm_device_managed_type_set(self, NM_DEVICE_MANAGED_TYPE_ASSUME); } else { 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); } @@ -18727,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->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 * 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_FULL; priv->promisc_reset = NM_OPTION_BOOL_DEFAULT; } diff --git a/src/core/devices/nm-device.h b/src/core/devices/nm-device.h index 37eda5c0..b84bbb65 100644 --- a/src/core/devices/nm-device.h +++ b/src/core/devices/nm-device.h @@ -726,16 +726,16 @@ nm_device_autoconnect_blocked_unset(NMDevice *device, NMDeviceAutoconnectBlocked 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_sys_iface_state_is_external_or_assume(NMDevice *self); +gboolean nm_device_managed_type_is_external(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); -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); diff --git a/src/core/devices/ovs/nm-device-ovs-port.c b/src/core/devices/ovs/nm-device-ovs-port.c index 2acafba2..2e8ab717 100644 --- a/src/core/devices/ovs/nm-device-ovs-port.c +++ b/src/core/devices/ovs/nm-device-ovs-port.c @@ -218,9 +218,9 @@ detach_port(NMDevice *device, gpointer user_data) { NMDeviceOvsPort *self = NM_DEVICE_OVS_PORT(device); - bool port_not_managed = !NM_IN_SET(nm_device_sys_iface_state_get(port), - NM_DEVICE_SYS_IFACE_STATE_MANAGED, - NM_DEVICE_SYS_IFACE_STATE_ASSUME); + bool port_not_managed = !NM_IN_SET(nm_device_managed_type_get(port), + NM_DEVICE_MANAGED_TYPE_FULL, + NM_DEVICE_MANAGED_TYPE_ASSUME); NMTernary ret = TRUE; _LOGI(LOGD_DEVICE, "detaching ovs interface %s", nm_device_get_ip_iface(port)); diff --git a/src/core/devices/team/nm-device-team.c b/src/core/devices/team/nm-device-team.c index 0f420a7a..a4c77f7f 100644 --- a/src/core/devices/team/nm-device-team.c +++ b/src/core/devices/team/nm-device-team.c @@ -763,10 +763,10 @@ act_stage1_prepare(NMDevice *device, NMDeviceStateReason *out_failure_reason) NMSettingTeam *s_team; 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; - 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)) return NM_ACT_STAGE_RETURN_SUCCESS; _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; - if (nm_device_sys_iface_state_is_external(device)) + if (nm_device_managed_type_is_external(device)) return; if (priv->teamd_pid || priv->tdc) diff --git a/src/core/devices/wifi/nm-device-iwd.c b/src/core/devices/wifi/nm-device-iwd.c index 89444640..d6e3ed08 100644 --- a/src/core/devices/wifi/nm-device-iwd.c +++ b/src/core/devices/wifi/nm-device-iwd.c @@ -3483,7 +3483,7 @@ nm_device_iwd_parse_netconfig(NMDeviceIwd *self, int addr_family, GVariantIter * /* Use SOURCE_DHCP as shorthand for the various autoconfiguration protocols */ source = NM_IP_CONFIG_SOURCE_DHCP; else - _LOGW(LOGD_WIFI, "iwd_parse_netconfig: Uknown Method value \"%s\"", str_value); + _LOGW(LOGD_WIFI, "iwd_parse_netconfig: Unknown Method value \"%s\"", str_value); } if (nm_streq(key, "Addresses")) { @@ -3527,7 +3527,7 @@ nm_device_iwd_parse_netconfig(NMDeviceIwd *self, int addr_family, GVariantIter * else if (nm_streq(str_value, "resolve")) mdns = NM_SETTING_CONNECTION_MDNS_RESOLVE; else - _LOGW(LOGD_WIFI, "iwd_parse_netconfig: Uknown MDNS value \"%s\"", str_value); + _LOGW(LOGD_WIFI, "iwd_parse_netconfig: Unknown MDNS value \"%s\"", str_value); } } diff --git a/src/core/devices/wifi/nm-device-wifi-p2p.c b/src/core/devices/wifi/nm-device-wifi-p2p.c index 981811a3..f06383b1 100644 --- a/src/core/devices/wifi/nm-device-wifi-p2p.c +++ b/src/core/devices/wifi/nm-device-wifi-p2p.c @@ -54,6 +54,7 @@ typedef struct { guint peer_missing_id; bool is_waiting_for_supplicant : 1; + bool enabled : 1; } NMDeviceWifiP2PPrivate; struct _NMDeviceWifiP2P { @@ -774,7 +775,6 @@ supplicant_group_iface_is_ready(NMDeviceWifiP2P *self) return; } - _set_is_waiting_for_supplicant(self, FALSE); check_group_iface_ready(self); } @@ -875,7 +875,6 @@ supplicant_iface_group_started_cb(NMSupplicantInterface *iface, state = nm_supplicant_interface_get_state(priv->group_iface); if (state == NM_SUPPLICANT_INTERFACE_STATE_STARTING) { - _set_is_waiting_for_supplicant(self, TRUE); return; } @@ -917,7 +916,7 @@ supplicant_interfaces_release(NMDeviceWifiP2P *self, gboolean set_is_waiting) supplicant_group_interface_release(self); - if (set_is_waiting) + if (set_is_waiting && priv->enabled) _set_is_waiting_for_supplicant(self, TRUE); } @@ -948,9 +947,10 @@ device_state_changed(NMDevice *device, case NM_DEVICE_STATE_UNMANAGED: break; case NM_DEVICE_STATE_UNAVAILABLE: - if (!priv->mgmt_iface - || !nm_supplicant_interface_state_is_operational( - nm_supplicant_interface_get_state(priv->mgmt_iface))) + if (priv->enabled + && (!priv->mgmt_iface + || !nm_supplicant_interface_state_is_operational( + nm_supplicant_interface_get_state(priv->mgmt_iface)))) _set_is_waiting_for_supplicant(self, TRUE); break; case NM_DEVICE_STATE_NEED_AUTH: @@ -1122,6 +1122,32 @@ impl_device_wifi_p2p_stop_find(NMDBusObject *obj, NULL); } +static gboolean +get_enabled(NMDevice *device) +{ + return NM_DEVICE_WIFI_P2P_GET_PRIVATE(device)->enabled; +} + +static void +set_enabled(NMDevice *device, gboolean enabled) +{ + NMDeviceWifiP2P *self = NM_DEVICE_WIFI_P2P(device); + NMDeviceWifiP2PPrivate *priv = NM_DEVICE_WIFI_P2P_GET_PRIVATE(self); + + enabled = !!enabled; + + if (priv->enabled == enabled) + return; + + priv->enabled = enabled; + + _LOGD(LOGD_DEVICE | LOGD_WIFI, "device now %s", enabled ? "enabled" : "disabled"); + + if (!enabled) { + _set_is_waiting_for_supplicant(self, FALSE); + } +} + /*****************************************************************************/ NMSupplicantInterface * @@ -1172,10 +1198,12 @@ done: nm_device_queue_recheck_available(NM_DEVICE(self), NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE, NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED); - _set_is_waiting_for_supplicant(self, - !priv->mgmt_iface - || !nm_supplicant_interface_state_is_operational( - nm_supplicant_interface_get_state(priv->mgmt_iface))); + _set_is_waiting_for_supplicant( + self, + priv->enabled + && (!priv->mgmt_iface + || !nm_supplicant_interface_state_is_operational( + nm_supplicant_interface_get_state(priv->mgmt_iface)))); } void @@ -1338,6 +1366,8 @@ nm_device_wifi_p2p_class_init(NMDeviceWifiP2PClass *klass) device_class->get_configured_mtu = get_configured_mtu; device_class->get_auto_ip_config_method = get_auto_ip_config_method; device_class->act_stage3_ip_config = act_stage3_ip_config; + device_class->set_enabled = set_enabled; + device_class->get_enabled = get_enabled; device_class->deactivate = deactivate; device_class->unmanaged_on_quit = unmanaged_on_quit; diff --git a/src/core/dhcp/nm-dhcp-listener.c b/src/core/dhcp/nm-dhcp-listener.c index 0854c1dc..05e428f8 100644 --- a/src/core/dhcp/nm-dhcp-listener.c +++ b/src/core/dhcp/nm-dhcp-listener.c @@ -27,21 +27,21 @@ const NMDhcpClientFactory *const _nm_dhcp_manager_factories[6] = { -/* the order here matters, as we will try the plugins in this order to find - * the first available plugin. */ + /* the order here matters, as we will try the plugins in this order to find + * the first available plugin. */ + &_nm_dhcp_client_factory_internal, #if WITH_DHCPCANON &_nm_dhcp_client_factory_dhcpcanon, #endif -#if WITH_DHCLIENT - &_nm_dhcp_client_factory_dhclient, -#endif #if WITH_DHCPCD &_nm_dhcp_client_factory_dhcpcd, #endif - &_nm_dhcp_client_factory_internal, &_nm_dhcp_client_factory_systemd, &_nm_dhcp_client_factory_nettools, +#if WITH_DHCLIENT + &_nm_dhcp_client_factory_dhclient, +#endif }; /*****************************************************************************/ diff --git a/src/core/dhcp/nm-dhcp-manager.c b/src/core/dhcp/nm-dhcp-manager.c index cfff23f8..68bb327b 100644 --- a/src/core/dhcp/nm-dhcp-manager.c +++ b/src/core/dhcp/nm-dhcp-manager.c @@ -90,8 +90,15 @@ _client_factory_find_by_name(const char *name) static const NMDhcpClientFactory * _client_factory_available(const NMDhcpClientFactory *client_factory) { - if (client_factory && (!client_factory->get_path || client_factory->get_path())) - return client_factory; + if (client_factory) { + if (nm_streq(client_factory->name, "dhclient")) { + _LOGW(AF_UNSPEC, + "attempting to used a deprecated DHCP client '%s' ", + client_factory->name); + } + if (!client_factory->get_path || client_factory->get_path()) + return client_factory; + } return NULL; } diff --git a/src/core/ndisc/nm-ndisc.c b/src/core/ndisc/nm-ndisc.c index 4800829f..86b7da6e 100644 --- a/src/core/ndisc/nm-ndisc.c +++ b/src/core/ndisc/nm-ndisc.c @@ -720,6 +720,7 @@ nm_ndisc_add_route(NMNDisc *ndisc, const NMNDiscRoute *new_item, gint64 now_msec * comparison is aborted, and both routes are added. */ if (IN6_ARE_ADDR_EQUAL(&item->network, &new_item->network) && item->plen == new_item->plen + && IN6_ARE_ADDR_EQUAL(&item->gateway, &new_item->gateway) && item->on_link == new_item->on_link) { if (new_item->expiry_msec <= now_msec) { g_array_remove_index(rdata->routes, i); diff --git a/src/core/nm-active-connection.c b/src/core/nm-active-connection.c index ca1993cf..ebfbc72b 100644 --- a/src/core/nm-active-connection.c +++ b/src/core/nm-active-connection.c @@ -989,10 +989,10 @@ _set_activation_type_managed(NMActiveConnection *self) _set_activation_type(self, NM_ACTIVATION_TYPE_MANAGED); 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_DEVICE_SYS_IFACE_STATE_EXTERNAL, - NM_DEVICE_SYS_IFACE_STATE_ASSUME)) - nm_device_sys_iface_state_set(priv->device, NM_DEVICE_SYS_IFACE_STATE_MANAGED); + && NM_IN_SET(nm_device_managed_type_get(priv->device), + NM_DEVICE_MANAGED_TYPE_EXTERNAL, + NM_DEVICE_MANAGED_TYPE_ASSUME)) + nm_device_managed_type_set(priv->device, NM_DEVICE_MANAGED_TYPE_FULL); } NMActivationReason diff --git a/src/core/nm-config-data.c b/src/core/nm-config-data.c index 9b3f958b..0a73695a 100644 --- a/src/core/nm-config-data.c +++ b/src/core/nm-config-data.c @@ -62,6 +62,7 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_CONFIG_MAIN_FILE, PROP_CONNECTIVITY_ENABLED, PROP_CONNECTIVITY_URI, PROP_CONNECTIVITY_INTERVAL, + PROP_CONNECTIVITY_TIMEOUT, PROP_CONNECTIVITY_RESPONSE, PROP_NO_AUTO_DEFAULT, ); @@ -86,6 +87,7 @@ typedef struct { char *uri; char *response; guint interval; + guint timeout; } connectivity; int autoconnect_retries_default; @@ -304,6 +306,14 @@ nm_config_data_get_connectivity_interval(const NMConfigData *self) return NM_CONFIG_DATA_GET_PRIVATE(self)->connectivity.interval; } +guint +nm_config_data_get_connectivity_timeout(const NMConfigData *self) +{ + g_return_val_if_fail(self, 0); + + return NM_CONFIG_DATA_GET_PRIVATE(self)->connectivity.timeout; +} + const char * nm_config_data_get_connectivity_response(const NMConfigData *self) { @@ -2006,6 +2016,8 @@ nm_config_data_diff(NMConfigData *old_data, NMConfigData *new_data) != nm_config_data_get_connectivity_enabled(new_data) || nm_config_data_get_connectivity_interval(old_data) != nm_config_data_get_connectivity_interval(new_data) + || nm_config_data_get_connectivity_timeout(old_data) + != nm_config_data_get_connectivity_timeout(new_data) || !nm_streq0(nm_config_data_get_connectivity_uri(old_data), nm_config_data_get_connectivity_uri(new_data)) || !nm_streq0(nm_config_data_get_connectivity_response(old_data), @@ -2079,6 +2091,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) case PROP_CONNECTIVITY_INTERVAL: g_value_set_uint(value, nm_config_data_get_connectivity_interval(self)); break; + case PROP_CONNECTIVITY_TIMEOUT: + g_value_set_uint(value, nm_config_data_get_connectivity_timeout(self)); + break; case PROP_CONNECTIVITY_RESPONSE: g_value_set_string(value, nm_config_data_get_connectivity_response(self)); break; @@ -2221,6 +2236,15 @@ constructed(GObject *object) NM_CONFIG_DEFAULT_CONNECTIVITY_INTERVAL); g_free(str); + /* On missing or invalid config value, fallback to 20. */ + str = g_key_file_get_string(priv->keyfile, + NM_CONFIG_KEYFILE_GROUP_CONNECTIVITY, + NM_CONFIG_KEYFILE_KEY_CONNECTIVITY_TIMEOUT, + NULL); + priv->connectivity.timeout = + _nm_utils_ascii_str_to_int64(str, 10, 0, G_MAXUINT, NM_CONFIG_DEFAULT_CONNECTIVITY_TIMEOUT); + g_free(str); + priv->dns_mode = nm_strstrip(g_key_file_get_string(priv->keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, NM_CONFIG_KEYFILE_KEY_MAIN_DNS, @@ -2420,6 +2444,15 @@ nm_config_data_class_init(NMConfigDataClass *config_class) 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_CONNECTIVITY_TIMEOUT] = + g_param_spec_uint(NM_CONFIG_DATA_CONNECTIVITY_TIMEOUT, + "", + "", + 0, + G_MAXUINT, + 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + obj_properties[PROP_CONNECTIVITY_RESPONSE] = g_param_spec_string(NM_CONFIG_DATA_CONNECTIVITY_RESPONSE, "", diff --git a/src/core/nm-config-data.h b/src/core/nm-config-data.h index b9427969..1ea0ccf2 100644 --- a/src/core/nm-config-data.h +++ b/src/core/nm-config-data.h @@ -47,6 +47,7 @@ typedef enum { #define NM_CONFIG_DATA_CONNECTIVITY_ENABLED "connectivity-enabled" #define NM_CONFIG_DATA_CONNECTIVITY_URI "connectivity-uri" #define NM_CONFIG_DATA_CONNECTIVITY_INTERVAL "connectivity-interval" +#define NM_CONFIG_DATA_CONNECTIVITY_TIMEOUT "connectivity-timeout" #define NM_CONFIG_DATA_CONNECTIVITY_RESPONSE "connectivity-response" #define NM_CONFIG_DATA_NO_AUTO_DEFAULT "no-auto-default" #define NM_CONFIG_DATA_DNS_MODE "dns" @@ -172,6 +173,7 @@ char **nm_config_data_get_plugins(const NMConfigData *config_data, gboolean gboolean nm_config_data_get_connectivity_enabled(const NMConfigData *config_data); const char *nm_config_data_get_connectivity_uri(const NMConfigData *config_data); guint nm_config_data_get_connectivity_interval(const NMConfigData *config_data); +guint nm_config_data_get_connectivity_timeout(const NMConfigData *config_data); const char *nm_config_data_get_connectivity_response(const NMConfigData *config_data); int nm_config_data_get_autoconnect_retries_default(const NMConfigData *config_data); diff --git a/src/core/nm-config.c b/src/core/nm-config.c index 43eb3646..878f343a 100644 --- a/src/core/nm-config.c +++ b/src/core/nm-config.c @@ -871,6 +871,7 @@ static const ConfigGroup config_groups[] = { .group = NM_CONFIG_KEYFILE_GROUP_CONNECTIVITY, .keys = NM_MAKE_STRV(NM_CONFIG_KEYFILE_KEY_CONNECTIVITY_ENABLED, NM_CONFIG_KEYFILE_KEY_CONNECTIVITY_INTERVAL, + NM_CONFIG_KEYFILE_KEY_CONNECTIVITY_TIMEOUT, NM_CONFIG_KEYFILE_KEY_CONNECTIVITY_RESPONSE, NM_CONFIG_KEYFILE_KEY_CONNECTIVITY_URI, ), }, diff --git a/src/core/nm-config.h b/src/core/nm-config.h index e65582c3..5518184c 100644 --- a/src/core/nm-config.h +++ b/src/core/nm-config.h @@ -28,6 +28,7 @@ #define NM_CONFIG_SIGNAL_CONFIG_CHANGED "config-changed" #define NM_CONFIG_DEFAULT_CONNECTIVITY_INTERVAL 300 +#define NM_CONFIG_DEFAULT_CONNECTIVITY_TIMEOUT 20 #define NM_CONFIG_DEFAULT_CONNECTIVITY_RESPONSE "NetworkManager is online" /* NOT LOCALIZED */ typedef struct NMConfigCmdLineOptions NMConfigCmdLineOptions; diff --git a/src/core/nm-connectivity.c b/src/core/nm-connectivity.c index 15dc31aa..65eec36d 100644 --- a/src/core/nm-connectivity.c +++ b/src/core/nm-connectivity.c @@ -56,6 +56,7 @@ typedef struct { char *host; char *port; char *response; + guint timeout; } ConConfig; struct _NMConnectivityCheckHandle { @@ -738,7 +739,9 @@ do_curl_request(NMConnectivityCheckHandle *cb_data, const char *hosts) cb_data->concheck.curl_mhandle = mhandle; cb_data->concheck.curl_ehandle = ehandle; cb_data->concheck.request_headers = curl_slist_append(NULL, "Connection: close"); - cb_data->timeout_source = nm_g_timeout_add_seconds_source(20, _timeout_cb, cb_data); + cb_data->timeout_source = nm_g_timeout_add_seconds_source(cb_data->concheck.con_config->timeout, + _timeout_cb, + cb_data); curl_multi_setopt(mhandle, CURLMOPT_SOCKETFUNCTION, multi_socket_cb); curl_multi_setopt(mhandle, CURLMOPT_SOCKETDATA, cb_data); @@ -1226,6 +1229,7 @@ update_config(NMConnectivity *self, NMConfigData *config_data) { NMConnectivityPrivate *priv = NM_CONNECTIVITY_GET_PRIVATE(self); guint interval; + guint new_timeout; gboolean enabled; gboolean changed = FALSE; const char *cur_uri = priv->con_config ? priv->con_config->uri : NULL; @@ -1237,6 +1241,8 @@ update_config(NMConnectivity *self, NMConfigData *config_data) gs_free char *new_host = NULL; gs_free char *new_port = NULL; + new_timeout = nm_config_data_get_connectivity_timeout(config_data); + new_uri = nm_config_data_get_connectivity_uri(config_data); if (!nm_streq0(new_uri, cur_uri)) { new_uri_valid = (new_uri && *new_uri); @@ -1277,6 +1283,7 @@ update_config(NMConnectivity *self, NMConfigData *config_data) changed = TRUE; if (!priv->con_config || !nm_streq0(new_uri, priv->con_config->uri) + || new_timeout != priv->con_config->timeout || !nm_streq0(new_response, priv->con_config->response)) { if (!new_host_port) { new_host = priv->con_config ? g_strdup(priv->con_config->host) : NULL; @@ -1290,6 +1297,7 @@ update_config(NMConnectivity *self, NMConfigData *config_data) .response = g_strdup(new_response), .host = g_steal_pointer(&new_host), .port = g_steal_pointer(&new_port), + .timeout = new_timeout, }; } priv->uri_valid = new_uri_valid; diff --git a/src/core/nm-core-utils.c b/src/core/nm-core-utils.c index dd1e9939..6aa38be2 100644 --- a/src/core/nm-core-utils.c +++ b/src/core/nm-core-utils.c @@ -5096,7 +5096,9 @@ helper_complete(HelperInfo *info, GError *error) } nm_clear_g_cancellable_disconnect(g_task_get_cancellable(info->task), &info->cancellable_id); - g_task_return_pointer(info->task, nm_str_buf_finalize(&info->in_buffer, NULL), g_free); + g_task_return_pointer(info->task, + nm_str_buf_finalize(&info->in_buffer, NULL) ?: g_new0(char, 1), + g_free); helper_info_free(info); } diff --git a/src/core/nm-l3cfg.h b/src/core/nm-l3cfg.h index 241fde02..f977b10f 100644 --- a/src/core/nm-l3cfg.h +++ b/src/core/nm-l3cfg.h @@ -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 * 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. * * The numeric values of the enum matters: higher number mean more "important". diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 0a7e7b2e..0d6c1e2f 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -2309,7 +2309,7 @@ remove_device(NMManager *self, NMDevice *device, gboolean quitting) if (quitting) nm_device_set_unmanaged_by_quitting(device); 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_UNMANAGED_PLATFORM_INIT, NM_UNMAN_FLAG_OP_SET_UNMANAGED, @@ -3694,9 +3694,9 @@ recheck_assume_connection(NMManager *self, NMDevice *device) } } - nm_device_sys_iface_state_set(device, - activation_type_assume ? NM_DEVICE_SYS_IFACE_STATE_ASSUME - : NM_DEVICE_SYS_IFACE_STATE_EXTERNAL); + nm_device_managed_type_set(device, + activation_type_assume ? NM_DEVICE_MANAGED_TYPE_ASSUME + : NM_DEVICE_MANAGED_TYPE_EXTERNAL); /* Move device to DISCONNECTED to activate the connection */ if (state == NM_DEVICE_STATE_UNMANAGED) { @@ -3765,8 +3765,8 @@ recheck_assume_connection(NMManager *self, NMDevice *device) "assume: deleting generated connection after assuming failed"); nm_settings_connection_delete(sett_conn, FALSE); } else { - if (nm_device_sys_iface_state_get(device) == NM_DEVICE_SYS_IFACE_STATE_ASSUME) - nm_device_sys_iface_state_set(device, NM_DEVICE_SYS_IFACE_STATE_EXTERNAL); + if (nm_device_managed_type_get(device) == NM_DEVICE_MANAGED_TYPE_ASSUME) + nm_device_managed_type_set(device, NM_DEVICE_MANAGED_TYPE_EXTERNAL); } return FALSE; } @@ -4374,7 +4374,7 @@ _platform_link_cb_idle(PlatformLinkCbData *data) device = nm_manager_get_device_by_ifindex(self, ifindex); if (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)) { _LOG2W(LOGD_DEVICE, device, "failed to unrealize: %s", error->message); 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) - nm_device_sys_iface_state_set(device, NM_DEVICE_SYS_IFACE_STATE_MANAGED); + nm_device_managed_type_set(device, NM_DEVICE_MANAGED_TYPE_FULL); /* Try to find the controller connection/device if the connection has a dependency */ if (!find_controller(self, @@ -7404,13 +7404,13 @@ do_sleep_wake(NMManager *self, gboolean sleeping_changed) nm_device_set_enabled(device, enabled); } - /* The reason determines whether the device will be sys-iface-state=managed - * or sys-iface-state=external. Pass the correct reason to restore the state + /* The reason determines whether the device will be managed_type=managed + * or managed_type=external. Pass the correct reason to restore the state * that was set before sleeping. */ - reason = nm_device_get_sys_iface_state_before_sleep(device) - == NM_DEVICE_SYS_IFACE_STATE_EXTERNAL - ? NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED - : NM_DEVICE_STATE_REASON_NOW_MANAGED; + reason = + nm_device_get_managed_type_before_sleep(device) == NM_DEVICE_MANAGED_TYPE_EXTERNAL + ? NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED + : NM_DEVICE_STATE_REASON_NOW_MANAGED; nm_device_set_unmanaged_by_flags(device, NM_UNMANAGED_SLEEPING, NM_UNMAN_FLAG_OP_SET_MANAGED, diff --git a/src/core/nm-policy.c b/src/core/nm-policy.c index 93b52526..05d4d006 100644 --- a/src/core/nm-policy.c +++ b/src/core/nm-policy.c @@ -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) continue; - if (nm_device_sys_iface_state_is_external(device)) + if (nm_device_managed_type_is_external(device)) continue; 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); if (state <= NM_DEVICE_STATE_DISCONNECTED || state >= NM_DEVICE_STATE_DEACTIVATING) continue; - if (nm_device_sys_iface_state_is_external(device)) + if (nm_device_managed_type_is_external(device)) continue; return TRUE; } @@ -809,7 +809,7 @@ build_device_hostname_infos(NMPolicy *self) if (!device) continue; - if (nm_device_sys_iface_state_is_external(device)) + if (nm_device_managed_type_is_external(device)) continue; 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 * 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; else if (vpn || (device && nm_device_is_vpn(device))) 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 // bailing if the device is already active 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)) { /* this is an external activation, and we allow autoconnecting on * 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) { 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)) { /* pass */ } else @@ -2300,7 +2300,7 @@ device_state_changed(NMDevice *device, * again when the device becomes ACTIVATED, we need also to update * routing and DNS here. */ 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, AF_UNSPEC, device, diff --git a/src/core/settings/nm-settings.c b/src/core/settings/nm-settings.c index 7fc20298..80b1f4b2 100644 --- a/src/core/settings/nm-settings.c +++ b/src/core/settings/nm-settings.c @@ -3520,7 +3520,7 @@ load_plugins(NMSettings *self, const char *const *plugins, GError **error) } if (NM_IN_STRSET(pname, "ifcfg-suse", "ifnet", "ibft", "no-ibft")) { - _LOGW("skipping deprecated plugin %s", pname); + _LOGW("skipping obsolete plugin %s", pname); continue; } diff --git a/src/core/supplicant/nm-supplicant-config.c b/src/core/supplicant/nm-supplicant-config.c index 7db614a2..4433e809 100644 --- a/src/core/supplicant/nm-supplicant-config.c +++ b/src/core/supplicant/nm-supplicant-config.c @@ -499,6 +499,52 @@ nm_supplicant_config_add_setting_macsec(NMSupplicantConfig *self, return TRUE; } +static void +get_ap_params(guint freq, + NMSettingWirelessChannelWidth width, + guint *out_ht40, + int *out_max_oper_chwidth, + guint *out_center_freq) +{ + *out_ht40 = 0; + *out_max_oper_chwidth = -1; + *out_center_freq = 0; + + switch (width) { + case NM_SETTING_WIRELESS_CHANNEL_WIDTH_40MHZ: + *out_ht40 = 1; + *out_max_oper_chwidth = 0; + return; + case NM_SETTING_WIRELESS_CHANNEL_WIDTH_80MHZ: + { + guint channel; + + if (freq < 5000) { + /* the setting is not valid */ + nm_assert_not_reached(); + return; + } + + /* Determine the center channel according to the table at + * https://en.wikipedia.org/wiki/List_of_WLAN_channels */ + channel = (freq - 5000) / 5; + channel = ((channel / 4 - 1) / 4) * 16 + 10; + + *out_ht40 = 1; + *out_max_oper_chwidth = 1; + *out_center_freq = 5000 + 5 * channel; + + return; + } + + case NM_SETTING_WIRELESS_CHANNEL_WIDTH_AUTO: + case NM_SETTING_WIRELESS_CHANNEL_WIDTH_20MHZ: + default: + /* in case of unknown enum value, fall back to the safest parameters */ + return; + } +} + gboolean nm_supplicant_config_add_setting_wireless(NMSupplicantConfig *self, NMSettingWireless *setting, @@ -562,10 +608,48 @@ nm_supplicant_config_add_setting_wireless(NMSupplicantConfig *self, if ((is_adhoc || is_ap || is_mesh) && fixed_freq) { gs_free char *str_freq = NULL; + guint ht40; + int max_oper_chwidth; + guint center_freq; str_freq = g_strdup_printf("%u", fixed_freq); if (!nm_supplicant_config_add_option(self, "frequency", str_freq, -1, NULL, error)) return FALSE; + + if (is_ap) { + get_ap_params(fixed_freq, + nm_setting_wireless_get_channel_width(setting), + &ht40, + &max_oper_chwidth, + ¢er_freq); + + if (!nm_supplicant_config_add_option(self, "ht40", ht40 ? "1" : "0", -1, NULL, error)) + return FALSE; + + if (center_freq != 0) { + g_free(str_freq); + str_freq = g_strdup_printf("%u", center_freq); + if (!nm_supplicant_config_add_option(self, + "vht_center_freq1", + str_freq, + -1, + NULL, + error)) + return FALSE; + } + + if (max_oper_chwidth >= 0) { + g_free(str_freq); + str_freq = g_strdup_printf("%u", max_oper_chwidth); + if (!nm_supplicant_config_add_option(self, + "max_oper_chwidth", + str_freq, + -1, + NULL, + error)) + return FALSE; + } + } } /* Except for Ad-Hoc, Hotspot and Mesh, request that the driver probe for the diff --git a/src/core/supplicant/nm-supplicant-settings-verify.c b/src/core/supplicant/nm-supplicant-settings-verify.c index 76328541..6e5e44d2 100644 --- a/src/core/supplicant/nm-supplicant-settings-verify.c +++ b/src/core/supplicant/nm-supplicant-settings-verify.c @@ -73,6 +73,7 @@ static const struct Opt opt_table[] = { OPT_KEYWORD("freq_list", NULL), OPT_INT("frequency", 2412, 5825), OPT_KEYWORD("group", NM_MAKE_STRV("CCMP", "TKIP", "WEP104", "WEP40", "GCMP-256", )), + OPT_INT("ht40", 0, 1), OPT_BYTES("identity", 0), OPT_INT("ieee80211w", 0, 2), OPT_INT("ignore_broadcast_ssid", 0, 2), @@ -99,6 +100,7 @@ static const struct Opt opt_table[] = { OPT_INT("macsec_offload", 0, 2), OPT_INT("macsec_policy", 0, 1), OPT_INT("macsec_port", 1, 65534), + OPT_INT("max_oper_chwidth", 0, 9), OPT_BYTES("mka_cak", 65536), OPT_BYTES("mka_ckn", 65536), OPT_BYTES("nai", 0), @@ -155,6 +157,7 @@ static const struct Opt opt_table[] = { OPT_BYTES("ssid", 32), OPT_BYTES("subject_match", 0), OPT_BYTES("subject_match2", 0), + OPT_INT("vht_center_freq1", 0, 100000), OPT_BYTES("wep_key0", 0), OPT_BYTES("wep_key1", 0), OPT_BYTES("wep_key2", 0), diff --git a/src/core/tests/config/NetworkManager.conf b/src/core/tests/config/NetworkManager.conf index a447b6d6..ae9f3e46 100644 --- a/src/core/tests/config/NetworkManager.conf +++ b/src/core/tests/config/NetworkManager.conf @@ -9,6 +9,7 @@ level=INFO [connectivity] uri=http://example.com interval=100 +timeout=42 response=Hello [extra-section] diff --git a/src/core/tests/config/test-config.c b/src/core/tests/config/test-config.c index 2b27d535..8365fc82 100644 --- a/src/core/tests/config/test-config.c +++ b/src/core/tests/config/test-config.c @@ -167,6 +167,9 @@ test_config_simple(void) g_assert_cmpint(nm_config_data_get_connectivity_interval(nm_config_get_data_orig(config)), ==, 100); + g_assert_cmpint(nm_config_data_get_connectivity_timeout(nm_config_get_data_orig(config)), + ==, + 42); plugins = nm_config_data_get_plugins(nm_config_get_data_orig(config), FALSE); g_assert_cmpint(g_strv_length((char **) plugins), ==, 3); diff --git a/src/libnm-base/nm-config-base.h b/src/libnm-base/nm-config-base.h index 6d050ae1..362a183c 100644 --- a/src/libnm-base/nm-config-base.h +++ b/src/libnm-base/nm-config-base.h @@ -44,6 +44,7 @@ #define NM_CONFIG_KEYFILE_KEY_CONNECTIVITY_ENABLED "enabled" #define NM_CONFIG_KEYFILE_KEY_CONNECTIVITY_INTERVAL "interval" +#define NM_CONFIG_KEYFILE_KEY_CONNECTIVITY_TIMEOUT "timeout" #define NM_CONFIG_KEYFILE_KEY_CONNECTIVITY_RESPONSE "response" #define NM_CONFIG_KEYFILE_KEY_CONNECTIVITY_URI "uri" diff --git a/src/libnm-client-impl/libnm.ver b/src/libnm-client-impl/libnm.ver index 666a22a8..23e6042f 100644 --- a/src/libnm-client-impl/libnm.ver +++ b/src/libnm-client-impl/libnm.ver @@ -2002,3 +2002,9 @@ global: nm_setting_wireless_remove_mac_denylist_item_by_value; nm_setting_802_1x_get_openssl_ciphers; } libnm_1_46_0; + +libnm_1_50_0 { +global: + nm_setting_wireless_channel_width_get_type; + nm_setting_wireless_get_channel_width; +} libnm_1_48_0; \ No newline at end of file diff --git a/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in b/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in index 2b231983..6d2b9254 100644 --- a/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in +++ b/src/libnm-core-impl/gen-metadata-nm-settings-libnm-core.xml.in @@ -85,6 +85,10 @@ dbus-type="u" gprop-type="guint" /> + <property name="channel-width" + dbus-type="i" + gprop-type="gint" + /> <property name="cloned-mac-address" dbus-type="ay" dbus-deprecated="1" diff --git a/src/libnm-core-impl/nm-connection.c b/src/libnm-core-impl/nm-connection.c index 95fe89a8..6dace2b7 100644 --- a/src/libnm-core-impl/nm-connection.c +++ b/src/libnm-core-impl/nm-connection.c @@ -3258,6 +3258,8 @@ nm_connection_get_virtual_device_description(NMConnection *connection) display_type = _("WireGuard"); else if (nm_streq(type, NM_SETTING_TUN_SETTING_NAME)) display_type = _("TUN/TAP"); + else if (nm_streq(type, NM_SETTING_VETH_SETTING_NAME)) + display_type = _("Veth"); if (!iface || !display_type) return NULL; diff --git a/src/libnm-core-impl/nm-setting-ip6-config.c b/src/libnm-core-impl/nm-setting-ip6-config.c index 2dbf7a34..eddac9f1 100644 --- a/src/libnm-core-impl/nm-setting-ip6-config.c +++ b/src/libnm-core-impl/nm-setting-ip6-config.c @@ -1097,7 +1097,7 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass) * property: addr-gen-mode * format: one of "eui64" (0), "stable-privacy" (1), "default" (3) or "default-or-eui64" (2) * description: Configure method for creating the - * IPv6 interface identifer of addresses with RFC4862 IPv6 Stateless + * IPv6 interface identifier of addresses with RFC4862 IPv6 Stateless * Address Autoconfiguration and Link Local addresses. * * The permitted values are: "eui64" (0), "stable-privacy" (1), "default" diff --git a/src/libnm-core-impl/nm-setting-wireless.c b/src/libnm-core-impl/nm-setting-wireless.c index 207b47d8..be08fa8c 100644 --- a/src/libnm-core-impl/nm-setting-wireless.c +++ b/src/libnm-core-impl/nm-setting-wireless.c @@ -44,7 +44,8 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingWireless, PROP_POWERSAVE, PROP_MAC_ADDRESS_RANDOMIZATION, PROP_WAKE_ON_WLAN, - PROP_AP_ISOLATION, ); + PROP_AP_ISOLATION, + PROP_CHANNEL_WIDTH, ); typedef struct { GBytes *ssid; @@ -57,6 +58,7 @@ typedef struct { char *generate_mac_address_mask; NMValueStrv mac_address_denylist; int ap_isolation; + int channel_width; guint32 mac_address_randomization; guint32 channel; guint32 rate; @@ -1012,6 +1014,24 @@ nm_setting_wireless_get_ap_isolation(NMSettingWireless *setting) return NM_SETTING_WIRELESS_GET_PRIVATE(setting)->ap_isolation; } +/** + * nm_setting_wireless_get_channel_width: + * @setting: the #NMSettingWireless + * + * Returns the #NMSettingWireless:channel-width property. + * + * Returns: the channel width + * + * Since: 1.50 + */ +NMSettingWirelessChannelWidth +nm_setting_wireless_get_channel_width(NMSettingWireless *setting) +{ + g_return_val_if_fail(NM_IS_SETTING_WIRELESS(setting), NM_SETTING_WIRELESS_CHANNEL_WIDTH_AUTO); + + return NM_SETTING_WIRELESS_GET_PRIVATE(setting)->channel_width; +} + /*****************************************************************************/ void @@ -1317,6 +1337,45 @@ verify(NMSetting *setting, NMConnection *connection, GError **error) return FALSE; } + if (priv->channel_width != NM_SETTING_WIRELESS_CHANNEL_WIDTH_AUTO) { + if (!nm_streq0(priv->mode, NM_SETTING_WIRELESS_MODE_AP)) { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a specific channel width can be set only in AP mode")); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRELESS_SETTING_NAME, + NM_SETTING_WIRELESS_CHANNEL_WIDTH); + return FALSE; + } + if (!priv->channel) { + g_set_error_literal( + error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("a specific channel width can be set only together with a fixed channel")); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRELESS_SETTING_NAME, + NM_SETTING_WIRELESS_CHANNEL_WIDTH); + return FALSE; + } + + if (priv->channel_width == NM_SETTING_WIRELESS_CHANNEL_WIDTH_80MHZ + && !nm_streq0(priv->band, "a")) { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("80MHz channels are only supported in the 5GHz band")); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRELESS_SETTING_NAME, + NM_SETTING_WIRELESS_CHANNEL_WIDTH); + return FALSE; + } + } + /* from here on, check for NM_SETTING_VERIFY_NORMALIZABLE conditions. */ _nm_setting_wireless_normalize_mac_address_randomization(NM_SETTING_WIRELESS(setting), @@ -2187,6 +2246,36 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass) NMSettingWirelessPrivate, ap_isolation); + /** + * NMSettingWireless:channel-width: + * + * Specifies width of the wireless channel in Access Point (AP) mode. + * + * When set to %NM_SETTING_WIRELESS_CHANNEL_WIDTH_AUTO (the default), the + * channel width is automatically determined. At the moment, this means that + * the safest (smallest) width is chosen. + * + * If the value is not %NM_SETTING_WIRELESS_CHANNEL_WIDTH_AUTO, then the + * 'channel' property must also be set. When using the 2.4GHz band, the width + * can be at most 40MHz. + * + * This property can be set to a value different from + * %NM_SETTING_WIRELESS_CHANNEL_WIDTH_AUTO only when the interface is configured + * in AP mode. + * + * Since: 1.50 + **/ + _nm_setting_property_define_direct_enum(properties_override, + obj_properties, + NM_SETTING_WIRELESS_CHANNEL_WIDTH, + PROP_CHANNEL_WIDTH, + NM_TYPE_SETTING_WIRELESS_CHANNEL_WIDTH, + NM_SETTING_WIRELESS_CHANNEL_WIDTH_AUTO, + NM_SETTING_PARAM_NONE, + NULL, + NMSettingWirelessPrivate, + channel_width); + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); _nm_setting_class_commit(setting_class, diff --git a/src/libnm-core-impl/nm-team-utils.c b/src/libnm-core-impl/nm-team-utils.c index bad78dee..6e7f85c7 100644 --- a/src/libnm-core-impl/nm-team-utils.c +++ b/src/libnm-core-impl/nm-team-utils.c @@ -2238,7 +2238,7 @@ _team_setting_verify_properties(const NMTeamSetting *self, GError **error) g_set_error(error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING, - _("value out or range")); + _("value out of range")); _team_setting_prefix_error_plain(self->d.is_port, attr_data->property_name, error); diff --git a/src/libnm-core-public/nm-setting-wireless.h b/src/libnm-core-public/nm-setting-wireless.h index e240a354..33d960a9 100644 --- a/src/libnm-core-public/nm-setting-wireless.h +++ b/src/libnm-core-public/nm-setting-wireless.h @@ -92,6 +92,7 @@ typedef enum /*< flags >*/ { #define NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION "mac-address-randomization" #define NM_SETTING_WIRELESS_WAKE_ON_WLAN "wake-on-wlan" #define NM_SETTING_WIRELESS_AP_ISOLATION "ap-isolation" +#define NM_SETTING_WIRELESS_CHANNEL_WIDTH "channel-width" /** * NM_SETTING_WIRELESS_MODE_ADHOC: @@ -145,6 +146,24 @@ typedef enum { NM_SETTING_WIRELESS_POWERSAVE_LAST = _NM_SETTING_WIRELESS_POWERSAVE_NUM - 1, /*< skip >*/ } NMSettingWirelessPowersave; +/** + * NMSettingWirelessChannelWidth: + * @NM_SETTING_WIRELESS_CHANNEL_WIDTH_AUTO: automatically determine the width + * @NM_SETTING_WIRELESS_CHANNEL_WIDTH_20MHZ: use a 20MHz channel width + * @NM_SETTING_WIRELESS_CHANNEL_WIDTH_40MHZ: use a 40MHz channel width + * @NM_SETTING_WIRELESS_CHANNEL_WIDTH_80MHZ: use a 80MHz channel width + * + * Indicates the wireless channel width. + * + * Since: 1.50 + **/ +typedef enum { + NM_SETTING_WIRELESS_CHANNEL_WIDTH_AUTO = 0, + NM_SETTING_WIRELESS_CHANNEL_WIDTH_20MHZ = 20, + NM_SETTING_WIRELESS_CHANNEL_WIDTH_40MHZ = 40, + NM_SETTING_WIRELESS_CHANNEL_WIDTH_80MHZ = 80, +} NMSettingWirelessChannelWidth; + typedef struct _NMSettingWirelessClass NMSettingWirelessClass; GType nm_setting_wireless_get_type(void); @@ -221,6 +240,9 @@ NMSettingWirelessWakeOnWLan nm_setting_wireless_get_wake_on_wlan(NMSettingWirele NM_AVAILABLE_IN_1_28 NMTernary nm_setting_wireless_get_ap_isolation(NMSettingWireless *setting); +NM_AVAILABLE_IN_1_50 +NMSettingWirelessChannelWidth nm_setting_wireless_get_channel_width(NMSettingWireless *setting); + G_END_DECLS #endif /* __NM_SETTING_WIRELESS_H__ */ diff --git a/src/libnm-core-public/nm-version-macros.h.in b/src/libnm-core-public/nm-version-macros.h.in index 7967f280..cecc1f25 100644 --- a/src/libnm-core-public/nm-version-macros.h.in +++ b/src/libnm-core-public/nm-version-macros.h.in @@ -75,6 +75,7 @@ #define NM_VERSION_1_44 (NM_ENCODE_VERSION(1, 44, 0)) #define NM_VERSION_1_46 (NM_ENCODE_VERSION(1, 46, 0)) #define NM_VERSION_1_48 (NM_ENCODE_VERSION(1, 48, 0)) +#define NM_VERSION_1_50 (NM_ENCODE_VERSION(1, 50, 0)) /* For releases, NM_API_VERSION is equal to NM_VERSION. * diff --git a/src/libnm-core-public/nm-version.h b/src/libnm-core-public/nm-version.h index 419da2e1..e8e18c75 100644 --- a/src/libnm-core-public/nm-version.h +++ b/src/libnm-core-public/nm-version.h @@ -397,6 +397,20 @@ #define NM_AVAILABLE_IN_1_48 #endif +#if NM_VERSION_MIN_REQUIRED >= NM_VERSION_1_50 +#define NM_DEPRECATED_IN_1_50 G_DEPRECATED +#define NM_DEPRECATED_IN_1_50_FOR(f) G_DEPRECATED_FOR(f) +#else +#define NM_DEPRECATED_IN_1_50 +#define NM_DEPRECATED_IN_1_50_FOR(f) +#endif + +#if NM_VERSION_MAX_ALLOWED < NM_VERSION_1_50 +#define NM_AVAILABLE_IN_1_50 G_UNAVAILABLE(1, 50) +#else +#define NM_AVAILABLE_IN_1_50 +#endif + /* * Synchronous API for calling D-Bus in libnm is deprecated. See * https://networkmanager.dev/docs/libnm/latest/usage.html#sync-api diff --git a/src/libnm-log-core/nm-logging.c b/src/libnm-log-core/nm-logging.c index 0909e799..a2bd2a27 100644 --- a/src/libnm-log-core/nm-logging.c +++ b/src/libnm-log-core/nm-logging.c @@ -92,7 +92,6 @@ typedef struct { typedef struct { NMLogLevel log_level; bool uses_syslog : 1; - bool init_pre_done : 1; bool init_done : 1; bool debug_stderr : 1; const char *prefix; @@ -927,40 +926,6 @@ nm_logging_syslog_enabled(void) } void -nm_logging_init_pre(const char *syslog_identifier, char *prefix_take) -{ - /* this function may be called zero or one times, and only - * - on the main thread - * - not after nm_logging_init(). */ - - NM_ASSERT_ON_MAIN_THREAD(); - - if (gl.imm.init_pre_done) - g_return_if_reached(); - - if (gl.imm.init_done) - g_return_if_reached(); - - if (!_syslog_identifier_valid_domain(syslog_identifier)) - g_return_if_reached(); - - if (!prefix_take || !prefix_take[0]) - g_return_if_reached(); - - G_LOCK(log); - - gl.mut.init_pre_done = TRUE; - - gl.mut.syslog_identifier = g_strdup_printf("SYSLOG_IDENTIFIER=%s", syslog_identifier); - nm_assert(_syslog_identifier_assert(gl.imm.syslog_identifier)); - - /* we pass the allocated string on and never free it. */ - gl.mut.prefix = prefix_take; - - G_UNLOCK(log); -} - -void nm_logging_init(const char *logging_backend, gboolean debug) { gboolean fetch_monotonic_timestamp = FALSE; diff --git a/src/libnm-log-core/nm-logging.h b/src/libnm-log-core/nm-logging.h index 80719675..82d8fc2d 100644 --- a/src/libnm-log-core/nm-logging.h +++ b/src/libnm-log-core/nm-logging.h @@ -145,8 +145,6 @@ const char *nm_logging_all_domains_to_string(void); gboolean nm_logging_setup(const char *level, const char *domains, char **bad_domains, GError **error); -void nm_logging_init_pre(const char *syslog_identifier, char *prefix_take); - void nm_logging_init(const char *logging_backend, gboolean debug); gboolean nm_logging_syslog_enabled(void); diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c index 53f678fc..bd495fe2 100644 --- a/src/libnm-platform/nm-linux-platform.c +++ b/src/libnm-platform/nm-linux-platform.c @@ -350,6 +350,11 @@ struct _ifla_vf_vlan_info { #define BRIDGE_VLAN_INFO_RANGE_END (1 << 4) /* VLAN is end of vlan range */ #endif +/* Appeared in kernel 4.2 dated August 2015 */ +#ifndef RTM_F_LOOKUP_TABLE +#define RTM_F_LOOKUP_TABLE 0x1000 /* set rtm_table to FIB lookup result */ +#endif + /*****************************************************************************/ #define PSCHED_TIME_UNITS_PER_SEC 1000000 @@ -3917,10 +3922,16 @@ _new_from_nl_addr(const struct nlmsghdr *nlh, gboolean id_only) return g_steal_pointer(&obj); } +#define IP_ROUTE_TRACKED_PROTOCOLS \ + RTPROT_UNSPEC, RTPROT_REDIRECT, RTPROT_KERNEL, RTPROT_BOOT, RTPROT_STATIC, RTPROT_RA, \ + RTPROT_DHCP + +static const guint8 ip_route_tracked_protocols[] = {IP_ROUTE_TRACKED_PROTOCOLS}; + static gboolean ip_route_is_tracked(guint8 proto, guint8 type) { - if (proto > RTPROT_STATIC && !NM_IN_SET(proto, RTPROT_DHCP, RTPROT_RA)) { + if (!NM_IN_SET(proto, IP_ROUTE_TRACKED_PROTOCOLS)) { /* We ignore certain rtm_protocol, because NetworkManager would only ever * configure certain protocols. Other routes are not configured by NetworkManager * and we don't track them in the platform cache. @@ -5613,6 +5624,7 @@ _nl_msg_new_route(uint16_t nlmsg_type, uint16_t nlmsg_flags, const NMPObject *ob nm_assert( NM_IN_SET(NMP_OBJECT_GET_TYPE(obj), NMP_OBJECT_TYPE_IP4_ROUTE, NMP_OBJECT_TYPE_IP6_ROUTE)); nm_assert(NM_IN_SET(nlmsg_type, RTM_NEWROUTE, RTM_DELROUTE)); + nm_assert(NM_IN_SET(rtmsg.rtm_protocol, IP_ROUTE_TRACKED_PROTOCOLS)); if (NM_FLAGS_HAS(obj->ip_route.r_rtm_flags, ((unsigned) (RTNH_F_ONLINK)))) { if (IS_IPv4 && obj->ip4_route.gateway == 0) { @@ -7798,17 +7810,42 @@ _nl_msg_new_dump_rtnl(NMPObjectType obj_type, int preferred_addr_family) g_return_val_if_reached(NULL); } break; case NMP_OBJECT_TYPE_LINK: + { + struct ifinfomsg ifm = {}; + + if (nlmsg_append_struct(nlmsg, &ifm) < 0) + g_return_val_if_reached(NULL); + break; + } case NMP_OBJECT_TYPE_IP4_ADDRESS: case NMP_OBJECT_TYPE_IP6_ADDRESS: + { + struct ifaddrmsg ifm = { + .ifa_family = preferred_addr_family, + }; + + if (nlmsg_append_struct(nlmsg, &ifm) < 0) + g_return_val_if_reached(NULL); + break; + } case NMP_OBJECT_TYPE_IP4_ROUTE: case NMP_OBJECT_TYPE_IP6_ROUTE: + { + struct rtmsg rtm = { + .rtm_family = preferred_addr_family, + }; + + if (nlmsg_append_struct(nlmsg, &rtm) < 0) + g_return_val_if_reached(NULL); + break; + } case NMP_OBJECT_TYPE_ROUTING_RULE: { - const struct rtgenmsg gmsg = { - .rtgen_family = preferred_addr_family, + struct fib_rule_hdr frh = { + .family = preferred_addr_family, }; - if (nlmsg_append_struct(nlmsg, &gmsg) < 0) + if (nlmsg_append_struct(nlmsg, &frh) < 0) g_return_val_if_reached(NULL); } break; default: @@ -7883,13 +7920,11 @@ do_request_all_no_delayed_actions(NMPlatform *platform, DelayedActionType action FOR_EACH_DELAYED_ACTION (iflags, action_type) { RefreshAllType refresh_all_type = delayed_action_type_to_refresh_all_type(iflags); const RefreshAllInfo *refresh_all_info = refresh_all_type_get_info(refresh_all_type); - nm_auto_nlmsg struct nl_msg *nlmsg = NULL; - int *out_refresh_all_in_progress; + int *out_refresh_all_in_progress; out_refresh_all_in_progress = &priv->delayed_action.refresh_all_in_progress[refresh_all_type]; nm_assert(*out_refresh_all_in_progress >= 0); - *out_refresh_all_in_progress += 1; /* clear any delayed action that request a refresh of this object type. */ priv->delayed_action.flags &= ~iflags; @@ -7908,28 +7943,93 @@ do_request_all_no_delayed_actions(NMPlatform *platform, DelayedActionType action } } - event_handler_read_netlink(platform, refresh_all_info->protocol, FALSE); + /* Routes are handled specially because we want to request only routes + * for protocols we track. The reason is that there might be millions of + * BGP routes we don't track and it would be very inefficient to dump them + * all. Therefore, perform separate dumps, each for a specific protocol we + * track. */ + if (NM_IN_SET(refresh_all_type, + REFRESH_ALL_TYPE_RTNL_IP4_ROUTES, + REFRESH_ALL_TYPE_RTNL_IP6_ROUTES)) { + struct rtmsg rtm = { + .rtm_family = refresh_all_info->addr_family_for_dump, + }; + guint retry_count = 0; + guint i; + + for (i = 0; i < G_N_ELEMENTS(ip_route_tracked_protocols); i++) { + nm_auto_nlmsg struct nl_msg *nlmsg = NULL; + + if (retry_count > 0) { + /* Try again previous protocol */ + i--; + } - if (refresh_all_info->protocol == NMP_NETLINK_ROUTE) { - nlmsg = _nl_msg_new_dump_rtnl(refresh_all_info->obj_type, - refresh_all_info->addr_family_for_dump); + /* If we try to request a new dump while the previous is still + * in progress, kernel returns -EBUSY. Complete the previous + * dump by reading from the socket. */ + event_handler_read_netlink(platform, refresh_all_info->protocol, FALSE); + + nlmsg = nlmsg_alloc_new(0, RTM_GETROUTE, NLM_F_DUMP); + if (!nlmsg) + goto next_after_fail; + + rtm.rtm_protocol = ip_route_tracked_protocols[i]; + + if (nlmsg_append_struct(nlmsg, &rtm) < 0) + g_return_if_fail(FALSE); + + *out_refresh_all_in_progress += 1; + + if (_netlink_send_nlmsg(platform, + refresh_all_info->protocol, + nlmsg, + NULL, + NULL, + DELAYED_ACTION_RESPONSE_TYPE_REFRESH_ALL_IN_PROGRESS, + out_refresh_all_in_progress) + < 0) { + *out_refresh_all_in_progress -= 1; + retry_count++; + if (retry_count > 4) { + _LOGE("failed dumping IPv%c routes with protocol %u, cache might be " + "inconsistent", + nm_utils_addr_family_to_char(rtm.rtm_family), + rtm.rtm_protocol); + retry_count = 0; + /* Give up and try the next protocol */ + } + } else { + retry_count = 0; + } + } } else { - nm_assert(refresh_all_type == REFRESH_ALL_TYPE_GENL_FAMILIES); - nlmsg = _nl_msg_new_dump_genl_families(); - } + nm_auto_nlmsg struct nl_msg *nlmsg = NULL; - if (!nlmsg) - goto next_after_fail; + *out_refresh_all_in_progress += 1; + event_handler_read_netlink(platform, refresh_all_info->protocol, FALSE); - if (_netlink_send_nlmsg(platform, - refresh_all_info->protocol, - nlmsg, - NULL, - NULL, - DELAYED_ACTION_RESPONSE_TYPE_REFRESH_ALL_IN_PROGRESS, - out_refresh_all_in_progress) - < 0) - goto next_after_fail; + if (refresh_all_info->protocol == NMP_NETLINK_ROUTE) { + nlmsg = _nl_msg_new_dump_rtnl(refresh_all_info->obj_type, + refresh_all_info->addr_family_for_dump); + } else { + nm_assert(refresh_all_type == REFRESH_ALL_TYPE_GENL_FAMILIES); + nlmsg = _nl_msg_new_dump_genl_families(); + } + + if (!nlmsg) + goto next_after_fail; + + if (_netlink_send_nlmsg(platform, + refresh_all_info->protocol, + nlmsg, + NULL, + NULL, + DELAYED_ACTION_RESPONSE_TYPE_REFRESH_ALL_IN_PROGRESS, + out_refresh_all_in_progress) + < 0) + goto next_after_fail; + } continue; next_after_fail: @@ -10458,7 +10558,7 @@ ip_route_get(NMPlatform *platform, .r.rtm_family = addr_family, .r.rtm_tos = 0, .r.rtm_dst_len = IS_IPv4 ? 32 : 128, - .r.rtm_flags = 0x1000 /* RTM_F_LOOKUP_TABLE */, + .r.rtm_flags = IS_IPv4 ? RTM_F_LOOKUP_TABLE : 0, }; nm_clear_pointer(&route, nmp_object_unref); diff --git a/src/libnm-platform/nm-netlink.c b/src/libnm-platform/nm-netlink.c index 6d153128..5bbbcc84 100644 --- a/src/libnm-platform/nm-netlink.c +++ b/src/libnm-platform/nm-netlink.c @@ -1152,6 +1152,7 @@ nl_socket_new(struct nl_sock **out_sk, i_val = 1; (void) setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_EXT_ACK, &i_val, sizeof(i_val)); + (void) setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_GET_STRICT_CHK, &i_val, sizeof(i_val)); if (NM_FLAGS_HAS(flags, NL_SOCKET_FLAGS_PASSCRED)) { err = nl_socket_set_passcred(sk, 1); diff --git a/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp-duid.c b/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp-duid.c index e664a4a7..28abddfb 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp-duid.c +++ b/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp-duid.c @@ -193,6 +193,7 @@ int sd_dhcp_duid_set_en(sd_dhcp_duid *duid) { return 0; } +#if 0 /* NM_IGNORED */ int sd_dhcp_duid_set_uuid(sd_dhcp_duid *duid) { sd_id128_t machine_id; int r; @@ -209,6 +210,7 @@ int sd_dhcp_duid_set_uuid(sd_dhcp_duid *duid) { duid->size = offsetof(struct duid, uuid.uuid) + sizeof(machine_id); return 0; } +#endif /* NM_IGNORED */ int dhcp_duid_to_string_internal(uint16_t type, const void *data, size_t data_size, char **ret) { _cleanup_free_ char *p = NULL, *x = NULL; diff --git a/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c b/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c index 7c201164..a6b55d07 100644 --- a/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libnm-systemd-core/src/libsystemd-network/sd-dhcp6-client.c @@ -244,6 +244,7 @@ int sd_dhcp6_client_set_duid_en(sd_dhcp6_client *client) { return 0; } +#if 0 /* NM_IGNORED */ int sd_dhcp6_client_set_duid_uuid(sd_dhcp6_client *client) { int r; @@ -256,6 +257,7 @@ int sd_dhcp6_client_set_duid_uuid(sd_dhcp6_client *client) { return 0; } +#endif /* NM_IGNORED */ int sd_dhcp6_client_set_duid_raw(sd_dhcp6_client *client, uint16_t duid_type, const uint8_t *duid, size_t duid_len) { int r; diff --git a/src/libnmc-base/nm-secret-agent-simple.c b/src/libnmc-base/nm-secret-agent-simple.c index 9d1a2ae9..b6945de7 100644 --- a/src/libnmc-base/nm-secret-agent-simple.c +++ b/src/libnmc-base/nm-secret-agent-simple.c @@ -907,9 +907,15 @@ request_secrets_from_ui(RequestData *request) ssid_utf8 = nm_utils_ssid_to_utf8(g_bytes_get_data(ssid, NULL), g_bytes_get_size(ssid)); title = _("Authentication required by wireless network"); - msg = g_strdup_printf( - _("Passwords or encryption keys are required to access the wireless network '%s'."), - ssid_utf8); + if (request->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_WPS_PBC_ACTIVE) { + msg = g_strdup_printf(_("Push of the WPS button on the router or a password is " + "required to access the wireless network '%s'."), + ssid_utf8); + } else { + msg = g_strdup_printf( + _("Passwords or encryption keys are required to access the wireless network '%s'."), + ssid_utf8); + } if (!add_wireless_secrets(request, secrets)) goto out_fail; diff --git a/src/libnmc-setting/nm-meta-setting-desc.c b/src/libnmc-setting/nm-meta-setting-desc.c index 9d8a02f2..b3a51ba0 100644 --- a/src/libnmc-setting/nm-meta-setting-desc.c +++ b/src/libnmc-setting/nm-meta-setting-desc.c @@ -8339,6 +8339,9 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS[] = { PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_AP_ISOLATION, .property_type = &_pt_gobject_ternary, ), + PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_CHANNEL_WIDTH, + .property_type = &_pt_gobject_enum, + ), NULL }; diff --git a/src/libnmc-setting/settings-docs.h.in b/src/libnmc-setting/settings-docs.h.in index f741a920..091dcd64 100644 --- a/src/libnmc-setting/settings-docs.h.in +++ b/src/libnmc-setting/settings-docs.h.in @@ -195,7 +195,7 @@ #define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_ROUTE_TABLE N_("Enable policy routing (source routing) and set the routing table used when adding routes. This affects all routes, including device-routes, IPv4LL, DHCP, SLAAC, default-routes and static routes. But note that static routes can individually overwrite the setting by explicitly specifying a non-zero routing table. If the table setting is left at zero, it is eligible to be overwritten via global configuration. If the property is zero even after applying the global configuration value, policy routing is disabled for the address family of this connection. Policy routing disabled means that NetworkManager will add all routes to the main table (except static routes that explicitly configure a different table). Additionally, NetworkManager will not delete any extraneous routes from tables except the main table. This is to preserve backward compatibility for users who manage routing tables outside of NetworkManager.") #define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_ROUTES N_("A list of IPv4 destination addresses, prefix length, optional IPv4 next hop addresses, optional route metric, optional attribute. The valid syntax is: \"ip[/prefix] [next-hop] [metric] [attribute=val]...[,ip[/prefix]...]\". For example \"192.0.2.0/24 10.1.1.1 77, 198.51.100.0/24\".") #define DESCRIBE_DOC_NM_SETTING_IP4_CONFIG_ROUTING_RULES N_("A comma separated list of routing rules for policy routing.") -#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE N_("Configure method for creating the IPv6 interface identifer of addresses with RFC4862 IPv6 Stateless Address Autoconfiguration and Link Local addresses. The permitted values are: \"eui64\" (0), \"stable-privacy\" (1), \"default\" (3) or \"default-or-eui64\" (2). If the property is set to \"eui64\", the addresses will be generated using the interface token derived from hardware address. This makes the host part of the address to stay constant, making it possible to track the host's presence when it changes networks. The address changes when the interface hardware is replaced. If a duplicate address is detected, there is also no fallback to generate another address. When configured, the \"ipv6.token\" is used instead of the MAC address to generate addresses for stateless autoconfiguration. If the property is set to \"stable-privacy\", the interface identifier is generated as specified by RFC7217. This works by hashing a host specific key (see NetworkManager(8) manual), the interface name, the connection's \"connection.stable-id\" property and the address prefix. This improves privacy by making it harder to use the address to track the host's presence and the address is stable when the network interface hardware is replaced. The special values \"default\" and \"default-or-eui64\" will fallback to the global connection default as documented in the NetworkManager.conf(5) manual. If the global default is not specified, the fallback value is \"stable-privacy\" or \"eui64\", respectively. If not specified, when creating a new profile the default is \"default\". Note that this setting is distinct from the Privacy Extensions as configured by \"ip6-privacy\" property and it does not affect the temporary addresses configured with this option.") +#define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE N_("Configure method for creating the IPv6 interface identifier of addresses with RFC4862 IPv6 Stateless Address Autoconfiguration and Link Local addresses. The permitted values are: \"eui64\" (0), \"stable-privacy\" (1), \"default\" (3) or \"default-or-eui64\" (2). If the property is set to \"eui64\", the addresses will be generated using the interface token derived from hardware address. This makes the host part of the address to stay constant, making it possible to track the host's presence when it changes networks. The address changes when the interface hardware is replaced. If a duplicate address is detected, there is also no fallback to generate another address. When configured, the \"ipv6.token\" is used instead of the MAC address to generate addresses for stateless autoconfiguration. If the property is set to \"stable-privacy\", the interface identifier is generated as specified by RFC7217. This works by hashing a host specific key (see NetworkManager(8) manual), the interface name, the connection's \"connection.stable-id\" property and the address prefix. This improves privacy by making it harder to use the address to track the host's presence and the address is stable when the network interface hardware is replaced. The special values \"default\" and \"default-or-eui64\" will fallback to the global connection default as documented in the NetworkManager.conf(5) manual. If the global default is not specified, the fallback value is \"stable-privacy\" or \"eui64\", respectively. If not specified, when creating a new profile the default is \"default\". Note that this setting is distinct from the Privacy Extensions as configured by \"ip6-privacy\" property and it does not affect the temporary addresses configured with this option.") #define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_ADDRESSES N_("A list of IPv6 addresses and their prefix length. Multiple addresses can be separated by comma. For example \"2001:db8:85a3::8a2e:370:7334/64, 2001:db8:85a3::5/64\". The addresses are listed in decreasing priority, meaning the first address will be the primary address. This can make a difference with IPv6 source address selection (RFC 6724, section 5).") #define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_AUTO_ROUTE_EXT_GW N_("VPN connections will default to add the route automatically unless this setting is set to FALSE. For other connection types, adding such an automatic route is currently not supported and setting this to TRUE has no effect.") #define DESCRIBE_DOC_NM_SETTING_IP6_CONFIG_DAD_TIMEOUT N_("Maximum timeout in milliseconds used to check for the presence of duplicate IP addresses on the network. If an address conflict is detected, the activation will fail. The property is currently implemented only for IPv4. A zero value means that no duplicate address detection is performed, -1 means the default value (either the value configured globally in NetworkManger.conf or 200ms). A value greater than zero is a timeout in milliseconds. Note that the time intervals are subject to randomization as per RFC 5227 and so the actual duration can be between half and the full time specified in this property.") @@ -417,6 +417,7 @@ #define DESCRIBE_DOC_NM_SETTING_WIRELESS_BAND N_("802.11 frequency band of the network. One of \"a\" for 5GHz 802.11a or \"bg\" for 2.4GHz 802.11. This will lock associations to the Wi-Fi network to the specific band, i.e. if \"a\" is specified, the device will not associate with the same network in the 2.4GHz band even if the network's settings are compatible. This setting depends on specific driver capability and may not work with all drivers.") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_BSSID N_("If specified, directs the device to only associate with the given access point. This capability is highly driver dependent and not supported by all devices. Note: this property does not control the BSSID used when creating an Ad-Hoc network and is unlikely to in the future. Locking a client profile to a certain BSSID will prevent roaming and also disable background scanning. That can be useful, if there is only one access point for the SSID.") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_CHANNEL N_("Wireless channel to use for the Wi-Fi connection. The device will only join (or create for Ad-Hoc networks) a Wi-Fi network on the specified channel. Because channel numbers overlap between bands, this property also requires the \"band\" property to be set.") +#define DESCRIBE_DOC_NM_SETTING_WIRELESS_CHANNEL_WIDTH N_("Specifies width of the wireless channel in Access Point (AP) mode. When set to \"auto\" (0) (the default), the channel width is automatically determined. At the moment, this means that the safest (smallest) width is chosen. If the value is not \"auto\" (0), then the 'channel' property must also be set. When using the 2.4GHz band, the width can be at most 40MHz. This property can be set to a value different from \"auto\" (0) only when the interface is configured in AP mode.") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS N_("If specified, request that the device use this MAC address instead. This is known as MAC cloning or spoofing. Beside explicitly specifying a MAC address, the special values \"preserve\", \"permanent\", \"random\", \"stable\" and \"stable-ssid\" are supported. \"preserve\" means not to touch the MAC address on activation. \"permanent\" means to use the permanent hardware address of the device. \"random\" creates a random MAC address on each connect. \"stable\" creates a hashed MAC address based on connection.stable-id and a machine dependent key. \"stable-ssid\" creates a hashed MAC address based on the SSID, the same as setting the stable-id to \"${NETWORK_SSID}\". If unspecified, the value can be overwritten via global defaults, see manual of NetworkManager.conf. If still unspecified, it defaults to \"preserve\" (older versions of NetworkManager may use a different default value). On D-Bus, this field is expressed as \"assigned-mac-address\" or the deprecated \"cloned-mac-address\".") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK N_("With \"cloned-mac-address\" setting \"random\" or \"stable\", by default all bits of the MAC address are scrambled and a locally-administered, unicast MAC address is created. This property allows to specify that certain bits are fixed. Note that the least significant bit of the first MAC address will always be unset to create a unicast MAC address. If the property is NULL, it is eligible to be overwritten by a default connection setting. If the value is still NULL or an empty string, the default is to create a locally-administered, unicast MAC address. If the value contains one MAC address, this address is used as mask. The set bits of the mask are to be filled with the current MAC address of the device, while the unset bits are subject to randomization. Setting \"FE:FF:FF:00:00:00\" means to preserve the OUI of the current MAC address and only randomize the lower 3 bytes using the \"random\" or \"stable\" algorithm. If the value contains one additional MAC address after the mask, this address is used instead of the current MAC address to fill the bits that shall not be randomized. For example, a value of \"FE:FF:FF:00:00:00 68:F7:28:00:00:00\" will set the OUI of the MAC address to 68:F7:28, while the lower bits are randomized. A value of \"02:00:00:00:00:00 00:00:00:00:00:00\" will create a fully scrambled globally-administered, burned-in MAC address. If the value contains more than one additional MAC addresses, one of them is chosen randomly. For example, \"02:00:00:00:00:00 00:00:00:00:00:00 02:00:00:00:00:00\" will create a fully scrambled MAC address, randomly locally or globally administered.") #define DESCRIBE_DOC_NM_SETTING_WIRELESS_HIDDEN N_("If TRUE, indicates that the network is a non-broadcasting network that hides its SSID. This works both in infrastructure and AP mode. In infrastructure mode, various workarounds are used for a more reliable discovery of hidden networks, such as probe-scanning the SSID. However, these workarounds expose inherent insecurities with hidden SSID networks, and thus hidden SSID networks should be used with caution. In AP mode, the created network does not broadcast its SSID. Note that marking the network as hidden may be a privacy issue for you (in infrastructure mode) or client stations (in AP mode), as the explicit probe-scans are distinctly recognizable on the air.") diff --git a/src/nm-cloud-setup/nm-cloud-setup.service.in b/src/nm-cloud-setup/nm-cloud-setup.service.in index e73654d8..ecb70e1c 100644 --- a/src/nm-cloud-setup/nm-cloud-setup.service.in +++ b/src/nm-cloud-setup/nm-cloud-setup.service.in @@ -8,6 +8,17 @@ After=NetworkManager.service Type=oneshot ExecStart=@libexecdir@/nm-cloud-setup +# The service restart gets triggered from dispatcher script +# (pre-up and dhcp4-change actions), possibly ending up with many +# restart requests at the same time (e.g. on initial daemon startup +# on a machine with multiple NICs). The systemd handles multiple +# concurrent restart requests gracefully (the newer requests supersede +# older, which wait for them to finish), but the default limits are way +# too low: 5 restarts in 10 seconds. Raise that high enough for us to +# be on the safe side. +StartLimitIntervalSec=1 +StartLimitBurst=100 + #Environment=NM_CLOUD_SETUP_LOG=TRACE # Cloud providers are disabled by default. You need to diff --git a/src/nm-cloud-setup/nmcs-provider-azure.c b/src/nm-cloud-setup/nmcs-provider-azure.c index 771c43d9..78eda16c 100644 --- a/src/nm-cloud-setup/nmcs-provider-azure.c +++ b/src/nm-cloud-setup/nmcs-provider-azure.c @@ -102,6 +102,11 @@ typedef struct { guint n_iface_data_pending; } AzureIfaceData; +typedef struct { + AzureIfaceData *iface_data; + guint64 ipaddress_idx; +} AzureIpAddressReqData; + static void _azure_iface_data_destroy(AzureIfaceData *iface_data) { @@ -112,7 +117,8 @@ static void _get_config_fetch_done_cb(NMHttpClient *http_client, GAsyncResult *result, AzureIfaceData *iface_data, - GetConfigFetchType fetch_type) + GetConfigFetchType fetch_type, + guint64 ipaddress_idx) { NMCSProviderGetConfigTaskData *get_config_data; NMCSProviderGetConfigIfaceData *iface_get_config; @@ -149,9 +155,7 @@ _get_config_fetch_done_cb(NMHttpClient *http_client, _LOGD("interface[%" G_GSSIZE_FORMAT "]: received address %s", iface_data->intern_iface_idx, nm_inet4_ntop(tmp_addr, tmp_addr_str)); - iface_get_config->ipv4s_arr[iface_get_config->ipv4s_len] = tmp_addr; - iface_get_config->has_ipv4s = TRUE; - iface_get_config->ipv4s_len++; + iface_get_config->ipv4s_arr[ipaddress_idx] = tmp_addr; break; case GET_CONFIG_FETCH_TYPE_IPV4_SUBNET_0_ADDRESS: @@ -203,10 +207,14 @@ _get_config_fetch_done_cb_ipv4_ipaddress_x_privateipaddress(GObject *source GAsyncResult *result, gpointer user_data) { + AzureIpAddressReqData *ipaddress_req_data = user_data; + _get_config_fetch_done_cb(NM_HTTP_CLIENT(source), result, - user_data, - GET_CONFIG_FETCH_TYPE_IPV4_IPADDRESS_X_PRIVATEIPADDRESS); + ipaddress_req_data->iface_data, + GET_CONFIG_FETCH_TYPE_IPV4_IPADDRESS_X_PRIVATEIPADDRESS, + ipaddress_req_data->ipaddress_idx); + g_free(ipaddress_req_data); } static void @@ -217,7 +225,8 @@ _get_config_fetch_done_cb_ipv4_subnet_0_address(GObject *source, _get_config_fetch_done_cb(NM_HTTP_CLIENT(source), result, user_data, - GET_CONFIG_FETCH_TYPE_IPV4_SUBNET_0_ADDRESS); + GET_CONFIG_FETCH_TYPE_IPV4_SUBNET_0_ADDRESS, + 0); } static void @@ -228,7 +237,8 @@ _get_config_fetch_done_cb_ipv4_subnet_0_prefix(GObject *source, _get_config_fetch_done_cb(NM_HTTP_CLIENT(source), result, user_data, - GET_CONFIG_FETCH_TYPE_IPV4_SUBNET_0_PREFIX); + GET_CONFIG_FETCH_TYPE_IPV4_SUBNET_0_PREFIX, + 0); } static void @@ -265,9 +275,10 @@ _get_config_ips_prefix_list_cb(GObject *source, GAsyncResult *result, gpointer u nm_sprintf_buf(iface_idx_str, "%" G_GSSIZE_FORMAT, iface_data->intern_iface_idx); while (nm_utils_parse_next_line(&response_str, &response_len, &line, &line_len)) { - gint64 ips_prefix_idx; - gs_free char *uri = NULL; - char buf[100]; + AzureIpAddressReqData *ipaddress_req_data; + gint64 ips_prefix_idx; + gs_free char *uri = NULL; + char buf[100]; if (line_len == 0) continue; @@ -284,8 +295,11 @@ _get_config_ips_prefix_list_cb(GObject *source, GAsyncResult *result, gpointer u if (ips_prefix_idx < 0) continue; - iface_data->n_iface_data_pending++; + ipaddress_req_data = g_new(AzureIpAddressReqData, 1); + ipaddress_req_data->iface_data = iface_data; + ipaddress_req_data->ipaddress_idx = ips_prefix_idx; + iface_data->n_iface_data_pending++; nm_http_client_poll_req( NM_HTTP_CLIENT(source), (uri = _azure_uri_interfaces(iface_idx_str, @@ -302,11 +316,12 @@ _get_config_ips_prefix_list_cb(GObject *source, GAsyncResult *result, gpointer u NULL, NULL, _get_config_fetch_done_cb_ipv4_ipaddress_x_privateipaddress, - iface_data); + ipaddress_req_data); } - iface_data->iface_get_config->ipv4s_len = 0; iface_data->iface_get_config->ipv4s_arr = g_new(in_addr_t, iface_data->n_iface_data_pending); + iface_data->iface_get_config->has_ipv4s = TRUE; + iface_data->iface_get_config->ipv4s_len = iface_data->n_iface_data_pending; { gs_free char *uri = NULL; diff --git a/src/nmcli/common.c b/src/nmcli/common.c index 2f205e50..fbabdffc 100644 --- a/src/nmcli/common.c +++ b/src/nmcli/common.c @@ -824,7 +824,7 @@ static char *rl_string; /** * nmc_cleanup_readline: * - * Cleanup readline when nmcli is terminated with a signal. + * Cleanup readline when nmcli is terminated. * It makes sure the terminal is not garbled. */ void diff --git a/src/nmcli/connections.c b/src/nmcli/connections.c index 7e192388..002dd402 100644 --- a/src/nmcli/connections.c +++ b/src/nmcli/connections.c @@ -3799,6 +3799,7 @@ check_valid_name_toplevel(const char *val, const char **port_type, GError **erro gs_unref_ptrarray GPtrArray *tmp_arr = NULL; const NMMetaSettingInfoEditor *setting_info; gs_free_error GError *tmp_err = NULL; + GType gtype = G_TYPE_INVALID; const char *str; int i; @@ -3808,6 +3809,13 @@ check_valid_name_toplevel(const char *val, const char **port_type, GError **erro tmp_arr = g_ptr_array_sized_new(32); for (i = 0; i < _NM_META_SETTING_TYPE_NUM; i++) { setting_info = &nm_meta_setting_infos_editor[i]; + + /* skip "non-base" settings (that means, not valid for a connection's "type") */ + gtype = setting_info->general->get_setting_gtype(); + if (nm_meta_setting_info_get_base_type_priority(setting_info->general, gtype) + == NM_SETTING_PRIORITY_INVALID) + continue; + g_ptr_array_add(tmp_arr, (gpointer) setting_info->general->setting_name); if (setting_info->alias) g_ptr_array_add(tmp_arr, (gpointer) setting_info->alias); @@ -6629,9 +6637,11 @@ get_setting_and_property(const char *prompt, valid_settings_port = nm_meta_setting_info_valid_parts_for_port_type(s_type, NULL); setting_name = check_valid_name(sett, valid_settings_main, valid_settings_port, NULL); - setting = nm_meta_setting_info_editor_new_setting( - nm_meta_setting_info_editor_find_by_name(setting_name, FALSE), - NM_META_ACCESSOR_SETTING_INIT_TYPE_DEFAULT); + if (setting_name) { + setting = nm_meta_setting_info_editor_new_setting( + nm_meta_setting_info_editor_find_by_name(setting_name, FALSE), + NM_META_ACCESSOR_SETTING_INIT_TYPE_DEFAULT); + } } else setting = nm_g_object_ref(nmc_tab_completion.setting); diff --git a/src/nmcli/devices.c b/src/nmcli/devices.c index c55f0a39..f6163757 100644 --- a/src/nmcli/devices.c +++ b/src/nmcli/devices.c @@ -2221,6 +2221,13 @@ add_and_activate_cb(GObject *client, GAsyncResult *result, gpointer user_data) return; } + if (nmc->secret_agent) { + NMRemoteConnection *connection = nm_active_connection_get_connection(active); + + nm_secret_agent_simple_enable(nmc->secret_agent, + nm_connection_get_path(NM_CONNECTION(connection))); + } + if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY) progress_id = g_timeout_add(120, progress_cb, info->device); @@ -3662,8 +3669,7 @@ do_device_wifi_connect(const NMCCommand *cmd, NmCli *nmc, int argc, const char * GByteArray *bssid2_arr = NULL; gs_free NMDevice **devices = NULL; int devices_idx; - char *ssid_ask = NULL; - char *passwd_ask = NULL; + char *ssid_ask = NULL; const GPtrArray *avail_cons; gboolean name_match = FALSE; int i; @@ -4021,29 +4027,15 @@ do_device_wifi_connect(const NMCCommand *cmd, NmCli *nmc, int argc, const char * || (ap_rsn_flags != NM_802_11_AP_SEC_NONE && !NM_FLAGS_ANY(ap_rsn_flags, NM_802_11_AP_SEC_KEY_MGMT_OWE | NM_802_11_AP_SEC_KEY_MGMT_OWE_TM))) { - const char *con_password = NULL; - NMSettingWirelessSecurity *s_wsec = NULL; - - if (connection) { - s_wsec = nm_connection_get_setting_wireless_security(connection); - if (s_wsec) { - if (ap_wpa_flags == NM_802_11_AP_SEC_NONE - && ap_rsn_flags == NM_802_11_AP_SEC_NONE) { - /* WEP */ - con_password = nm_setting_wireless_security_get_wep_key(s_wsec, 0); - } else if ((ap_wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK) - || (ap_rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK) - || (ap_rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_SAE)) { - /* WPA PSK */ - con_password = nm_setting_wireless_security_get_psk(s_wsec); - } - } - } - - /* Ask for missing password when one is expected and '--ask' is used */ - if (!password && !con_password && nmc->ask) { - password = passwd_ask = - nmc_readline_echo(&nmc->nmc_config, nmc->nmc_config.show_secrets, _("Password: ")); + NMSettingWirelessSecurity *s_wsec = NULL; + + /* Create secret agent */ + nmc->secret_agent = nm_secret_agent_simple_new("nmcli-connect"); + if (nmc->secret_agent) { + g_signal_connect(nmc->secret_agent, + NM_SECRET_AGENT_SIMPLE_REQUEST_SECRETS, + G_CALLBACK(nmc_secrets_requested), + nmc); } if (password) { @@ -4091,7 +4083,6 @@ finish: if (bssid2_arr) g_byte_array_free(bssid2_arr, TRUE); g_free(ssid_ask); - nm_free_secret(passwd_ask); } static GBytes * diff --git a/src/nmcli/gen-metadata-nm-settings-nmcli.xml.in b/src/nmcli/gen-metadata-nm-settings-nmcli.xml.in index b35a96a4..7f5bc2c7 100644 --- a/src/nmcli/gen-metadata-nm-settings-nmcli.xml.in +++ b/src/nmcli/gen-metadata-nm-settings-nmcli.xml.in @@ -89,6 +89,10 @@ nmcli-description="Configures AP isolation, which prevents communication between wireless devices connected to this AP. This property can be set to a value different from "default" (-1) only when the interface is configured in AP mode. If set to "true" (1), devices are not able to communicate with each other. This increases security because it protects devices against attacks from other clients in the network. At the same time, it prevents devices to access resources on the same wireless networks as file shares, printers, etc. If set to "false" (0), devices can talk to each other. When set to "default" (-1), the global default is used; in case the global default is unspecified it is assumed to be "false" (0)." format="ternary" values="true/yes/on, false/no/off, default/unknown" /> + <property name="channel-width" + nmcli-description="Specifies width of the wireless channel in Access Point (AP) mode. When set to "auto" (0) (the default), the channel width is automatically determined. At the moment, this means that the safest (smallest) width is chosen. If the value is not "auto" (0), then the 'channel' property must also be set. When using the 2.4GHz band, the width can be at most 40MHz. This property can be set to a value different from "auto" (0) only when the interface is configured in AP mode." + format="choice (NMSettingWirelessChannelWidth)" + values="auto (0), 20mhz (20), 40mhz (40), 80mhz (80)" /> </setting> <setting name="802-11-wireless-security" alias="wifi-sec" > @@ -1468,7 +1472,7 @@ values="0 - 2147483647" special-values="default (0)" /> <property name="addr-gen-mode" - nmcli-description="Configure method for creating the IPv6 interface identifer of addresses with RFC4862 IPv6 Stateless Address Autoconfiguration and Link Local addresses. The permitted values are: "eui64" (0), "stable-privacy" (1), "default" (3) or "default-or-eui64" (2). If the property is set to "eui64", the addresses will be generated using the interface token derived from hardware address. This makes the host part of the address to stay constant, making it possible to track the host's presence when it changes networks. The address changes when the interface hardware is replaced. If a duplicate address is detected, there is also no fallback to generate another address. When configured, the "ipv6.token" is used instead of the MAC address to generate addresses for stateless autoconfiguration. If the property is set to "stable-privacy", the interface identifier is generated as specified by RFC7217. This works by hashing a host specific key (see NetworkManager(8) manual), the interface name, the connection's "connection.stable-id" property and the address prefix. This improves privacy by making it harder to use the address to track the host's presence and the address is stable when the network interface hardware is replaced. The special values "default" and "default-or-eui64" will fallback to the global connection default as documented in the NetworkManager.conf(5) manual. If the global default is not specified, the fallback value is "stable-privacy" or "eui64", respectively. If not specified, when creating a new profile the default is "default". Note that this setting is distinct from the Privacy Extensions as configured by "ip6-privacy" property and it does not affect the temporary addresses configured with this option." + nmcli-description="Configure method for creating the IPv6 interface identifier of addresses with RFC4862 IPv6 Stateless Address Autoconfiguration and Link Local addresses. The permitted values are: "eui64" (0), "stable-privacy" (1), "default" (3) or "default-or-eui64" (2). If the property is set to "eui64", the addresses will be generated using the interface token derived from hardware address. This makes the host part of the address to stay constant, making it possible to track the host's presence when it changes networks. The address changes when the interface hardware is replaced. If a duplicate address is detected, there is also no fallback to generate another address. When configured, the "ipv6.token" is used instead of the MAC address to generate addresses for stateless autoconfiguration. If the property is set to "stable-privacy", the interface identifier is generated as specified by RFC7217. This works by hashing a host specific key (see NetworkManager(8) manual), the interface name, the connection's "connection.stable-id" property and the address prefix. This improves privacy by making it harder to use the address to track the host's presence and the address is stable when the network interface hardware is replaced. The special values "default" and "default-or-eui64" will fallback to the global connection default as documented in the NetworkManager.conf(5) manual. If the global default is not specified, the fallback value is "stable-privacy" or "eui64", respectively. If not specified, when creating a new profile the default is "default". Note that this setting is distinct from the Privacy Extensions as configured by "ip6-privacy" property and it does not affect the temporary addresses configured with this option." format="choice (NMSettingIP6ConfigAddrGenMode)" values="eui64 (0), stable-privacy (1), default-or-eui64 (2), default (3)" /> <property name="ra-timeout" diff --git a/src/nmcli/nmcli.c b/src/nmcli/nmcli.c index be177847..cfe4c5f4 100644 --- a/src/nmcli/nmcli.c +++ b/src/nmcli/nmcli.c @@ -163,17 +163,18 @@ complete_one(gpointer key, gpointer value, gpointer user_data) last = prefix; if ((!*last && !strchr(name, '.')) || matches(last, name)) { - if (option != prefix) { + if (!nm_streq0(option, prefix)) { /* value prefix was not a standalone argument, * it was part of --option=<value> argument. * Repeat the part leading to "=". */ - nmc_print("%s=", option); + nmc_print("%s\n", option); + } else { + nmc_print("%.*s%s%s\n", + (int) (last - prefix), + prefix, + name, + nm_streq(last, name) ? "," : ""); } - nmc_print("%.*s%s%s\n", - (int) (last - prefix), - prefix, - name, - strcmp(last, name) == 0 ? "," : ""); } } @@ -225,13 +226,14 @@ complete_option_with_value(const char *option, const char *prefix, ...) va_start(args, prefix); while ((candidate = va_arg(args, const char *))) { if (!*prefix || matches(prefix, candidate)) { - if (option != prefix) { + if (!nm_streq0(option, prefix)) { /* value prefix was not a standalone argument, * it was part of --option=<value> argument. * Repeat the part leading to "=". */ - nmc_print("%s=", option); + nmc_print("%s%s\n", option, candidate + strlen(prefix)); + } else { + nmc_print("%s\n", candidate); } - nmc_print("%s\n", candidate); } } va_end(args); @@ -1044,6 +1046,8 @@ main(int argc, char *argv[]) if (process_command_line(&nm_cli, argc, argv)) g_main_loop_run(loop); + nmc_cleanup_readline(); + if (nm_cli.complete) { /* Remove error statuses from command completion runs. */ if (nm_cli.return_value < NMC_RESULT_COMPLETE_FILE) diff --git a/src/nmtui/meson.build b/src/nmtui/meson.build index 13aa8647..eecfaa99 100644 --- a/src/nmtui/meson.build +++ b/src/nmtui/meson.build @@ -32,6 +32,7 @@ executable( 'nmt-page-ppp.c', 'nmt-page-team.c', 'nmt-page-team-port.c', + 'nmt-page-veth.c', 'nmt-page-vlan.c', 'nmt-page-wifi.c', 'nmt-page-wireguard.c', diff --git a/src/nmtui/nmt-connect-connection-list.c b/src/nmtui/nmt-connect-connection-list.c index 70264d3e..1fd44b29 100644 --- a/src/nmtui/nmt-connect-connection-list.c +++ b/src/nmtui/nmt-connect-connection-list.c @@ -96,6 +96,7 @@ static const char *device_sort_order[] = {"NMDeviceEthernet", "NMDeviceInfiniband", "NMDeviceWifi", NM_SETTING_VLAN_SETTING_NAME, + NM_SETTING_VETH_SETTING_NAME, NM_SETTING_BOND_SETTING_NAME, NM_SETTING_TEAM_SETTING_NAME, NM_SETTING_BRIDGE_SETTING_NAME, diff --git a/src/nmtui/nmt-editor.c b/src/nmtui/nmt-editor.c index 6e502778..6205736a 100644 --- a/src/nmtui/nmt-editor.c +++ b/src/nmtui/nmt-editor.c @@ -39,6 +39,7 @@ #include "nmt-page-ppp.h" #include "nmt-page-team.h" #include "nmt-page-team-port.h" +#include "nmt-page-veth.h" #include "nmt-page-vlan.h" #include "nmt-page-wifi.h" #include "nmt-page-wireguard.h" @@ -369,6 +370,8 @@ nmt_editor_constructed(GObject *object) page = nmt_page_dsl_new(priv->edit_connection, deventry); else if (nm_connection_is_type(priv->edit_connection, NM_SETTING_TEAM_SETTING_NAME)) page = nmt_page_team_new(priv->edit_connection, deventry); + else if (nm_connection_is_type(priv->edit_connection, NM_SETTING_VETH_SETTING_NAME)) + page = nmt_page_veth_new(priv->edit_connection, deventry); else if (nm_connection_is_type(priv->edit_connection, NM_SETTING_VLAN_SETTING_NAME)) page = nmt_page_vlan_new(priv->edit_connection, deventry); else if (nm_connection_is_type(priv->edit_connection, NM_SETTING_WIRED_SETTING_NAME)) diff --git a/src/nmtui/nmt-page-veth.c b/src/nmtui/nmt-page-veth.c new file mode 100644 index 00000000..35d0d78d --- /dev/null +++ b/src/nmtui/nmt-page-veth.c @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024 Red Hat, Inc. + */ +/** + * SECTION:nmt-page-veth + * @short_description: The editor page for veth connections + */ + +#include "libnm-client-aux-extern/nm-default-client.h" + +#include <linux/if_ether.h> + +#include "nmt-page-veth.h" + +#include "libnm-core-aux-intern/nm-libnm-core-utils.h" +#include "nmt-device-entry.h" +#include "nmt-mac-entry.h" +#include "nmt-mtu-entry.h" + +G_DEFINE_TYPE(NmtPageVeth, nmt_page_veth, NMT_TYPE_EDITOR_PAGE_DEVICE) + +#define NMT_PAGE_VETH_GET_PRIVATE(o) _NM_GET_PRIVATE(self, NmtPageVeth, NMT_IS_PAGE_VETH) + +static void +nmt_page_veth_init(NmtPageVeth *veth) +{} + +NmtEditorPage * +nmt_page_veth_new(NMConnection *conn, NmtDeviceEntry *deventry) +{ + return g_object_new(NMT_TYPE_PAGE_VETH, "connection", conn, "device-entry", deventry, NULL); +} + +static void +nmt_page_veth_constructed(GObject *object) +{ + NmtPageVeth *veth = NMT_PAGE_VETH(object); + NmtEditorSection *section; + NmtEditorGrid *grid; + NMSettingVeth *s_veth; + NMSettingWired *s_wired; + NmtNewtWidget *widget; + NMConnection *conn; + + conn = nmt_editor_page_get_connection(NMT_EDITOR_PAGE(veth)); + s_veth = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_VETH); + s_wired = _nm_connection_ensure_setting(conn, NM_TYPE_SETTING_WIRED); + + section = nmt_editor_section_new(_("VETH"), NULL, TRUE); + grid = nmt_editor_section_get_body(section); + + widget = nmt_newt_entry_new(40, 0); + nmt_editor_grid_append(grid, _("Peer"), widget, NULL); + g_object_bind_property(s_veth, + NM_SETTING_VETH_PEER, + widget, + "text", + G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL); + + nmt_editor_page_add_section(NMT_EDITOR_PAGE(veth), section); + + section = nmt_editor_section_new(_("ETHERNET"), NULL, FALSE); + grid = nmt_editor_section_get_body(section); + + widget = nmt_mac_entry_new(40, ETH_ALEN, NMT_MAC_ENTRY_TYPE_CLONED_ETHERNET); + g_object_bind_property(s_wired, + NM_SETTING_WIRED_CLONED_MAC_ADDRESS, + widget, + "mac-address", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + nmt_editor_grid_append(grid, _("Cloned MAC address"), widget, NULL); + + widget = nmt_mtu_entry_new(); + g_object_bind_property(s_wired, + NM_SETTING_WIRED_MTU, + widget, + "mtu", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + nmt_editor_grid_append(grid, _("MTU"), widget, NULL); + + nmt_editor_page_add_section(NMT_EDITOR_PAGE(veth), section); + + G_OBJECT_CLASS(nmt_page_veth_parent_class)->constructed(object); +} + +static void +nmt_page_veth_class_init(NmtPageVethClass *veth_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS(veth_class); + object_class->constructed = nmt_page_veth_constructed; +} diff --git a/src/nmtui/nmt-page-veth.h b/src/nmtui/nmt-page-veth.h new file mode 100644 index 00000000..8822f3a2 --- /dev/null +++ b/src/nmtui/nmt-page-veth.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024 Red Hat, Inc. + */ + +#ifndef NMT_PAGE_VETH_H +#define NMT_PAGE_VETH_H + +#include "nmt-editor-page-device.h" + +#define NMT_TYPE_PAGE_VETH (nmt_page_veth_get_type()) +#define NMT_PAGE_VETH(obj) (_NM_G_TYPE_CHECK_INSTANCE_CAST((obj), NMT_TYPE_PAGE_VETH, NmtPageVeth)) +#define NMT_PAGE_VETH_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), NMT_TYPE_PAGE_VETH, NmtPageVethClass)) +#define NMT_IS_PAGE_VETH(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NMT_TYPE_PAGE_VETH)) +#define NMT_IS_PAGE_VETH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NMT_TYPE_PAGE_VETH)) +#define NMT_PAGE_VETH_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS((obj), NMT_TYPE_PAGE_VETH, NmtPageVethClass)) + +typedef struct { + NmtEditorPageDevice parent; +} NmtPageVeth; + +typedef struct { + NmtEditorPageDeviceClass parent; +} NmtPageVethClass; + +GType nmt_page_veth_get_type(void); + +NmtEditorPage *nmt_page_veth_new(NMConnection *conn, NmtDeviceEntry *deventry); + +#endif /* NMT_PAGE_VETH_H */ diff --git a/src/tests/client/test-client.check-on-disk/test_004.expected b/src/tests/client/test-client.check-on-disk/test_004.expected index b3703b25..b10b604f 100644 --- a/src/tests/client/test-client.check-on-disk/test_004.expected +++ b/src/tests/client/test-client.check-on-disk/test_004.expected @@ -58,12 +58,12 @@ location: src/tests/client/test-client.py:test_004()/7 cmd: $NMCLI connection mod con-xx1 ipv4.addresses 192.168.77.5/24 ipv4.routes '2.3.4.5/32 192.168.77.1' ipv6.addresses 1:2:3:4::6/64 ipv6.routes 1:2:3:4:5:6::5/128 lang: C returncode: 0 -size: 5598 +size: 5647 location: src/tests/client/test-client.py:test_004()/8 cmd: $NMCLI con s con-xx1 lang: C returncode: 0 -stdout: 5467 bytes +stdout: 5516 bytes >>> connection.id: con-xx1 connection.uuid: UUID-con-xx1-REPLACED-REPLACED-REPLA @@ -112,6 +112,7 @@ connection.wait-activation-delay: -1 802-11-wireless.powersave: 0 (default) 802-11-wireless.wake-on-wlan: 0x1 (default) 802-11-wireless.ap-isolation: -1 (default) +802-11-wireless.channel-width: 0 (auto) ipv4.method: auto ipv4.dns: -- ipv4.dns-search: -- @@ -182,12 +183,12 @@ proxy.pac-url: -- proxy.pac-script: -- <<< -size: 5633 +size: 5682 location: src/tests/client/test-client.py:test_004()/9 cmd: $NMCLI con s con-xx1 lang: pl_PL.UTF-8 returncode: 0 -stdout: 5492 bytes +stdout: 5541 bytes >>> connection.id: con-xx1 connection.uuid: UUID-con-xx1-REPLACED-REPLACED-REPLA @@ -236,6 +237,7 @@ connection.wait-activation-delay: -1 802-11-wireless.powersave: 0 (default) 802-11-wireless.wake-on-wlan: 0x1 (default) 802-11-wireless.ap-isolation: -1 (default) +802-11-wireless.channel-width: 0 (auto) ipv4.method: auto ipv4.dns: -- ipv4.dns-search: -- |