From e73c15eec98a134de519dfaae269c9e2b57c2fc9 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Wed, 29 Mar 2017 14:05:53 +0200 Subject: [PATCH] device: don't update disconnected devices routes after connectivity check When the device is not activated it does not make sense to try to update its default route metric based on connectivity status. Fixes the following: nm_ip4_config_commit: assertion 'ifindex > 0' failed #0 raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:37 #1 g_logv (breakpoint=1) at gmessages.c:324 #2 g_logv (log_domain=<> "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=, args=) at gmessages.c:1081 #3 g_log (log_domain=, log_level=, format=) at gmessages.c:1119 #4 g_return_if_fail_warning (log_domain=, pretty_function=, expression=) at gmessages.c:1128 #5 nm_ip4_config_commit (config=<> [NMIP4Config], ifindex=, routes_full_sync=, default_route_metric=-1) at src/nm-ip4-config.c:339 #6 nm_device_set_ip4_config (self=<> [NMDeviceTun], new_config=<> [NMIP4Config], default_route_metric=450, commit=1, routes_full_sync=) at src/devices/nm-device.c:9635 #7 ip4_config_merge_and_apply (self=<> [NMDeviceTun], config=0x0, commit=1) at src/devices/nm-device.c:5541 #8 update_connectivity_state (self=<> [NMDeviceTun], state=NM_CONNECTIVITY_NONE) at src/devices/nm-device.c:1743 #9 concheck_periodic_update (self=<> [NMDeviceTun]) at src/devices/nm-device.c:1872 #10 nm_device_set_ip4_config (self=<> [NMDeviceTun], new_config=0x0, default_route_metric=0, commit=1, routes_full_sync=1) at src/devices/nm-device.c:9669 #11 _cleanup_generic_post (self=<> [NMDeviceTun], cleanup_type=CLEANUP_TYPE_KEEP) at src/devices/nm-device.c:11863 #12 nm_device_cleanup (self=<> [NMDeviceTun], reason=NM_DEVICE_STATE_REASON_NOW_UNMANAGED, cleanup_type=) at src/devices/nm-device.c:12006 #13 _set_state_full (self=<> [NMDeviceTun], state=, reason=, quitting=) at src/devices/nm-device.c:12376 #14 nm_device_unrealize (self=<> [NMDeviceTun], remove_resources=, error=<>) at src/devices/nm-device.c:3183 #15 _platform_link_cb_idle (data=<>) at src/nm-manager.c:2359 #16 g_idle_dispatch (source=, callback=, user_data=) at gmain.c:5439 #17 g_main_context_dispatch (context=<>) at gmain.c:3152 #18 g_main_context_dispatch (context=<>) at gmain.c:3767 #19 g_main_context_iterate (context=<>, block=1, dispatch=1, self=) a Fixes: 6b7e9f9b225e81d365fd95901a88a7bc59c1eb39 https://bugzilla.redhat.com/show_bug.cgi?id=1436978 --- src/devices/nm-device.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 2cba9fddbb..06ed121f47 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1740,10 +1740,12 @@ update_connectivity_state (NMDevice *self, NMConnectivityState state) priv->connectivity_state = state; _notify (self, PROP_CONNECTIVITY); - if (!ip4_config_merge_and_apply (self, NULL, TRUE)) - _LOGW (LOGD_IP4, "Failed to update IPv4 default route metric"); - if (!ip6_config_merge_and_apply (self, TRUE)) - _LOGW (LOGD_IP6, "Failed to update IPv6 default route metric"); + if (nm_device_get_state (self) == NM_DEVICE_STATE_ACTIVATED) { + if (!ip4_config_merge_and_apply (self, NULL, TRUE)) + _LOGW (LOGD_IP4, "Failed to update IPv4 default route metric"); + if (!ip6_config_merge_and_apply (self, TRUE)) + _LOGW (LOGD_IP6, "Failed to update IPv6 default route metric"); + } } }