diff options
| author | Michael Biebl <biebl@debian.org> | 2023-10-04 11:44:49 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2023-10-04 11:44:49 +0200 |
| commit | d4d8b2b91f7ba000d97a8b2aab48c85000c11314 (patch) | |
| tree | 4bae747b430c9dae89c22cbf298cbf6c862a52b8 /src/core | |
| parent | 05e4a733f2141995181a551854d5df929f084adf (diff) | |
New upstream version 1.44.2 upstream/1.44.2
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/devices/nm-device.c | 16 | ||||
| -rw-r--r-- | src/core/devices/wwan/nm-device-modem.c | 15 | ||||
| -rw-r--r-- | src/core/devices/wwan/nm-modem-ofono.c | 7 | ||||
| -rw-r--r-- | src/core/main-utils.c | 15 | ||||
| -rw-r--r-- | src/core/nm-checkpoint.c | 23 | ||||
| -rw-r--r-- | src/core/nm-l3cfg.c | 27 | ||||
| -rw-r--r-- | src/core/nm-l3cfg.h | 1 | ||||
| -rw-r--r-- | src/core/nm-manager.c | 15 |
8 files changed, 80 insertions, 39 deletions
diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 2038e2f2..d1212560 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -4247,6 +4247,20 @@ _dev_l3_cfg_notify_cb(NML3Cfg *l3cfg, const NML3ConfigNotifyData *notify_data, N case NM_L3_CONFIG_NOTIFY_TYPE_ACD_EVENT: { const NML3AcdAddrInfo *addr_info = ¬ify_data->acd_event.info; + char buf_addr[NM_INET_ADDRSTRLEN]; + + if (addr_info->state == NM_L3_ACD_ADDR_STATE_USED) { + _LOGI(LOGD_DEVICE, + "IP address %s cannot be configured because it is already in use in the " + "network by host %s", + nm_inet4_ntop(addr_info->addr, buf_addr), + nm_ether_addr_to_string_a(&addr_info->last_conflict_addr)); + } else if (addr_info->state == NM_L3_ACD_ADDR_STATE_CONFLICT) { + _LOGI(LOGD_DEVICE, + "conflict detected for IP address %s with host %s", + nm_inet4_ntop(addr_info->addr, buf_addr), + nm_ether_addr_to_string_a(&addr_info->last_conflict_addr)); + } if (addr_info->state > NM_L3_ACD_ADDR_STATE_PROBING) _dev_ipmanual_check_ready(self); @@ -8740,7 +8754,7 @@ _get_maybe_ipv6_disabled(NMDevice *self) return FALSE; path = nm_sprintf_bufa(128, "/proc/sys/net/ipv6/conf/%s/disable_ipv6", ifname); - return (nm_platform_sysctl_get_int32(platform, NMP_SYSCTL_PATHID_ABSOLUTE(path), 0) == 0); + return (nm_platform_sysctl_get_int32(platform, NMP_SYSCTL_PATHID_ABSOLUTE(path), 1) != 0); } /* diff --git a/src/core/devices/wwan/nm-device-modem.c b/src/core/devices/wwan/nm-device-modem.c index a1050c3f..929bda15 100644 --- a/src/core/devices/wwan/nm-device-modem.c +++ b/src/core/devices/wwan/nm-device-modem.c @@ -70,14 +70,17 @@ ppp_failed(NMModem *modem, guint i_reason, gpointer user_data) static void modem_prepare_result(NMModem *modem, gboolean success, guint i_reason, gpointer user_data) { - NMDeviceModem *self = NM_DEVICE_MODEM(user_data); - NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); - NMDevice *device = NM_DEVICE(self); - NMDeviceStateReason reason = i_reason; + NMDeviceModem *self = NM_DEVICE_MODEM(user_data); + NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self); + NMDevice *device = NM_DEVICE(self); + NMDeviceStateReason reason = i_reason; + NMDeviceState device_state = nm_device_get_state(device); - if (nm_device_get_state(device) != NM_DEVICE_STATE_PREPARE + if (device_state != NM_DEVICE_STATE_PREPARE || priv->stage1_state != NM_DEVICE_STAGE_STATE_PENDING) { - nm_assert_not_reached(); + _LOGD(LOGD_MB, + "device no longer in prepare state when modem prepare finished ('%s')", + nm_device_state_to_string(device_state)); success = FALSE; } diff --git a/src/core/devices/wwan/nm-modem-ofono.c b/src/core/devices/wwan/nm-modem-ofono.c index de105bbd..3e0bbd48 100644 --- a/src/core/devices/wwan/nm-modem-ofono.c +++ b/src/core/devices/wwan/nm-modem-ofono.c @@ -1276,8 +1276,11 @@ handle_settings(NMModemOfono *self, GVariant *v_dict) nm_l3_config_data_add_address_4(priv->l3cd_4, &address); if (!g_variant_lookup(v_dict, "Gateway", "&s", &s) || !s) { - _LOGW("Settings 'Gateway' missing"); - goto out; + /* It is normal for point-to-point connections to not have a gateway IP + * specified. Use 0.0.0.0 in that case. + */ + _LOGD("Settings 'Gateway' missing. Setting it to 0.0.0.0"); + s = "0.0.0.0"; } if (!nm_inet_parse_bin(AF_INET, s, NULL, &gateway_network)) { _LOGW("invalid 'Gateway': %s", s); diff --git a/src/core/main-utils.c b/src/core/main-utils.c index c6fa05c0..9360d688 100644 --- a/src/core/main-utils.c +++ b/src/core/main-utils.c @@ -158,7 +158,8 @@ nm_main_utils_ensure_not_running_pidfile(const char *pidfile) gs_free char *contents = NULL; gs_free char *proc_cmdline = NULL; gsize len = 0; - long pid; + pid_t pid; + gint64 pid64; const char *process_name; const char *prgname = g_get_prgname(); @@ -173,12 +174,13 @@ nm_main_utils_ensure_not_running_pidfile(const char *pidfile) return; errno = 0; - pid = strtol(contents, NULL, 10); - if (pid <= 0 || pid > 65536 || errno) + pid64 = _nm_utils_ascii_str_to_int64(contents, 10, 0, G_MAXINT64, -1); + pid = (pid_t) pid64; + if (pid <= 0 || (gint64) pid != pid64) return; nm_clear_g_free(&contents); - proc_cmdline = g_strdup_printf("/proc/%ld/cmdline", pid); + proc_cmdline = g_strdup_printf("/proc/%" G_GINT64_FORMAT "/cmdline", (gint64) pid); if (!g_file_get_contents(proc_cmdline, &contents, &len, NULL)) return; @@ -190,7 +192,10 @@ nm_main_utils_ensure_not_running_pidfile(const char *pidfile) if (strcmp(process_name, prgname) == 0) { /* Check that the process exists */ if (kill(pid, 0) == 0) { - fprintf(stderr, _("%s is already running (pid %ld)\n"), prgname, pid); + fprintf(stderr, + _("%s is already running (pid %" G_GINT64_FORMAT ")\n"), + prgname, + (gint64) pid); exit(1); } } diff --git a/src/core/nm-checkpoint.c b/src/core/nm-checkpoint.c index 5c4d4e53..74adf484 100644 --- a/src/core/nm-checkpoint.c +++ b/src/core/nm-checkpoint.c @@ -460,24 +460,27 @@ next_dev: NMDeviceState state; nm_manager_for_each_device (priv->manager, device, tmp_lst) { - gboolean found = FALSE; - if (g_hash_table_contains(priv->devices, device)) continue; /* Also ignore devices that were in the checkpoint initially and * were moved to 'removed_devices' because they got removed from * the system. */ - for (i = 0; i < priv->removed_devices->len; i++) { - dev_checkpoint = priv->removed_devices->pdata[i]; - if (dev_checkpoint->dev_type == nm_device_get_device_type(device) - && nm_streq0(dev_checkpoint->original_dev_name, nm_device_get_iface(device))) { - found = TRUE; - break; + if (priv->removed_devices) { + gboolean found = FALSE; + + for (i = 0; i < priv->removed_devices->len; i++) { + dev_checkpoint = priv->removed_devices->pdata[i]; + if (dev_checkpoint->dev_type == nm_device_get_device_type(device) + && nm_streq0(dev_checkpoint->original_dev_name, + nm_device_get_iface(device))) { + found = TRUE; + break; + } } + if (found) + continue; } - if (found) - continue; state = nm_device_get_state(device); if (state > NM_DEVICE_STATE_DISCONNECTED && state < NM_DEVICE_STATE_DEACTIVATING) { diff --git a/src/core/nm-l3cfg.c b/src/core/nm-l3cfg.c index 3c2d3ec8..ce9d5849 100644 --- a/src/core/nm-l3cfg.c +++ b/src/core/nm-l3cfg.c @@ -101,8 +101,6 @@ typedef struct { * timestamp when we start probing. */ guint32 probing_timeout_msec; - NMEtherAddr last_conflict_addr; - NML3AcdDefendType acd_defend_type_desired : 3; NML3AcdDefendType acd_defend_type_current : 3; bool acd_defend_type_is_active : 1; @@ -168,7 +166,6 @@ typedef struct { /* This flag is only used temporarily to do a bulk update and * clear all the ones that are no longer in used. */ bool os_dirty : 1; - bool os_tna_dirty : 1; } ObjStateData; G_STATIC_ASSERT(G_STRUCT_OFFSET(ObjStateData, obj) == 0); @@ -2663,8 +2660,8 @@ handle_init: nm_assert(acd_data->info.state == NM_L3_ACD_ADDR_STATE_PROBING); nm_assert(acd_data->nacd_probe); - acd_data->nacd_probe = n_acd_probe_free(acd_data->nacd_probe); - acd_data->last_conflict_addr = *sender_addr; + acd_data->nacd_probe = n_acd_probe_free(acd_data->nacd_probe); + acd_data->info.last_conflict_addr = *sender_addr; _l3_acd_data_state_set_full(self, acd_data, NM_L3_ACD_ADDR_STATE_USED, @@ -2676,7 +2673,7 @@ handle_init: _l3_acd_data_timeout_schedule(acd_data, ACD_WAIT_TIME_PROBING_FULL_RESTART_MSEC); if (!_l3_acd_data_defendconflict_warning_ratelimited(acd_data, p_now_msec)) { - _LOGI("IPv4 address %s is used on network connected to interface %d%s%s%s from " + _LOGD("IPv4 address %s is used on network connected to interface %d%s%s%s from " "host %s", nm_inet4_ntop(acd_data->info.addr, sbuf_addr), self->priv.ifindex, @@ -2707,7 +2704,7 @@ handle_init: nm_ether_addr_to_string_a(sender_addr)); if (!_l3_acd_data_defendconflict_warning_ratelimited(acd_data, p_now_msec)) { - _LOGW("IPv4 address collision detection sees conflict on interface %d%s%s%s for " + _LOGD("IPv4 address collision detection sees conflict on interface %d%s%s%s for " "address %s from host %s", self->priv.ifindex, NM_PRINT_FMT_QUOTED(self->priv.plobj_next, @@ -2719,8 +2716,8 @@ handle_init: nm_ether_addr_to_string_a(sender_addr)); } - acd_data->nacd_probe = n_acd_probe_free(acd_data->nacd_probe); - acd_data->last_conflict_addr = *sender_addr; + acd_data->nacd_probe = n_acd_probe_free(acd_data->nacd_probe); + acd_data->info.last_conflict_addr = *sender_addr; _l3_acd_data_state_set(self, acd_data, NM_L3_ACD_ADDR_STATE_CONFLICT, TRUE); if (!acd_data->acd_data_timeout_source) _l3_acd_data_timeout_schedule(acd_data, ACD_WAIT_TIME_CONFLICT_RESTART_MSEC); @@ -4035,7 +4032,7 @@ again: &obj_state->os_failedobj_prioq_idx); _LOGW( "missing IPv%c route: %s", - nm_utils_addr_family_to_char(NMP_OBJECT_GET_TYPE(obj_state->obj)), + nm_utils_addr_family_to_char(NMP_OBJECT_GET_ADDR_FAMILY(obj_state->obj)), nmp_object_to_string(obj_state->obj, NMP_OBJECT_TO_STRING_PUBLIC, sbuf, sizeof(sbuf))); goto again; } @@ -4076,7 +4073,7 @@ _failedobj_handle_routes(NML3Cfg *self, int addr_family, GPtrArray *routes_faile gboolean just_failed = FALSE; gboolean arm_timer = FALSE; int grace_timeout_msec; - gint64 grace_expiry_mesc; + gint64 grace_expiry_msec; nm_assert(NMP_OBJECT_GET_TYPE(o) == NMP_OBJECT_TYPE_IP_ROUTE(NM_IS_IPv4(addr_family))); @@ -4108,11 +4105,11 @@ _failedobj_handle_routes(NML3Cfg *self, int addr_family, GPtrArray *routes_faile grace_timeout_msec = 0; } - grace_expiry_mesc = now_msec + grace_timeout_msec; + grace_expiry_msec = now_msec + grace_timeout_msec; if (obj_state->os_failedobj_expiry_msec == 0) { /* This is a new failure that we didn't see before... */ - obj_state->os_failedobj_expiry_msec = grace_expiry_mesc; + obj_state->os_failedobj_expiry_msec = grace_expiry_msec; if (grace_timeout_msec == 0) just_failed = TRUE; else { @@ -4120,9 +4117,9 @@ _failedobj_handle_routes(NML3Cfg *self, int addr_family, GPtrArray *routes_faile just_started_to_fail = TRUE; } } else { - if (obj_state->os_failedobj_expiry_msec > grace_expiry_mesc) { + if (obj_state->os_failedobj_expiry_msec > grace_expiry_msec) { /* Shorten the grace timeout. We anyway rearm below... */ - obj_state->os_failedobj_expiry_msec = grace_expiry_mesc; + obj_state->os_failedobj_expiry_msec = grace_expiry_msec; } if (obj_state->os_failedobj_expiry_msec <= now_msec) { /* The grace period is (already) expired. */ diff --git a/src/core/nm-l3cfg.h b/src/core/nm-l3cfg.h index 5ee201e7..9b8ec67f 100644 --- a/src/core/nm-l3cfg.h +++ b/src/core/nm-l3cfg.h @@ -92,6 +92,7 @@ typedef struct { NML3AcdAddrState state; NML3Cfg *l3cfg; const NML3AcdAddrTrackInfo *track_infos; + NMEtherAddr last_conflict_addr; } NML3AcdAddrInfo; static inline const NML3AcdAddrTrackInfo * diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c index 9c721220..937acbba 100644 --- a/src/core/nm-manager.c +++ b/src/core/nm-manager.c @@ -3222,6 +3222,13 @@ device_auth_done_cb(NMAuthChain *chain, GDBusMethodInvocation *context, gpointer nm_assert(error || (result == NM_AUTH_CALL_RESULT_YES)); } + if (!error && !nm_dbus_object_is_exported(NM_DBUS_OBJECT(device))) { + g_set_error(&error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_UNKNOWN_DEVICE, + "device no longer exists"); + } + callback(device, context, subject, error, nm_auth_chain_get_data(chain, "user-data")); } @@ -3287,6 +3294,14 @@ nm_manager_device_auth_request(NMManager *self, &error)) goto fail_on_idle; + if (!nm_dbus_object_is_exported(NM_DBUS_OBJECT(device))) { + g_set_error(&error, + NM_MANAGER_ERROR, + NM_MANAGER_ERROR_UNKNOWN_DEVICE, + "device no longer exists"); + goto fail_on_idle; + } + chain = nm_auth_chain_new_subject(subject, context, device_auth_done_cb, self); if (cancellable) nm_auth_chain_set_cancellable(chain, cancellable); |