diff options
| author | Michael Biebl <biebl@debian.org> | 2018-02-07 02:39:23 +0100 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-02-07 02:39:23 +0100 |
| commit | 50f6b47074e01dffb8dc536c0a20961dcf28ae9b (patch) | |
| tree | b4bd771d78ebe38661b8c4ec8b9a8e0eb8261eb5 /src/devices | |
| parent | afcd268ea7b1149fbfb66bce4eca659b675da0a2 (diff) | |
New upstream version 1.10.4 upstream/1.10.4
Diffstat (limited to 'src/devices')
| -rw-r--r-- | src/devices/nm-device.c | 67 | ||||
| -rw-r--r-- | src/devices/nm-device.h | 2 | ||||
| -rw-r--r-- | src/devices/ovs/nm-device-ovs-interface.c | 24 | ||||
| -rw-r--r-- | src/devices/tests/test-arping.c | 2 | ||||
| -rw-r--r-- | src/devices/wwan/nm-modem-broadband.c | 52 | ||||
| -rw-r--r-- | src/devices/wwan/nm-modem.c | 5 |
6 files changed, 95 insertions, 57 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index afc81dcd..6f9289ee 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -87,7 +87,7 @@ _LOG_DECLARE_SELF (NMDevice); #define DHCP_NUM_TRIES_MAX 3 #define DEFAULT_AUTOCONNECT TRUE -#define CARRIER_WAIT_TIME_MS 5000 +#define CARRIER_WAIT_TIME_MS 6000 #define CARRIER_WAIT_TIME_AFTER_MTU_MS 10000 #define NM_DEVICE_AUTH_RETRIES_UNSET -1 @@ -650,6 +650,8 @@ NM_UTILS_LOOKUP_STR_DEFINE (nm_device_state_reason_to_str, NMDeviceStateReason, NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_REASON_PARENT_CHANGED, "parent-changed"), NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED, "parent-managed-changed"), NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_REASON_OVSDB_FAILED, "ovsdb-failed"), + NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_REASON_IP_ADDRESS_DUPLICATE, "ip-address-duplicate"), + NM_UTILS_LOOKUP_STR_ITEM (NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED, "ip-method-unsupported"), ); #define reason_to_string(reason) \ @@ -1616,8 +1618,8 @@ nm_device_get_metered (NMDevice *self) return NM_DEVICE_GET_PRIVATE (self)->metered; } -static guint32 -_get_route_metric_default (NMDevice *self) +guint32 +nm_device_get_route_metric_default (NMDeviceType device_type) { /* Device 'priority' is used for the default route-metric and is based on * the device type. The settings ipv4.route-metric and ipv6.route-metric @@ -1636,7 +1638,7 @@ _get_route_metric_default (NMDevice *self) * metrics (except for IPv6, where 0 means 1024). */ - switch (nm_device_get_device_type (self)) { + switch (device_type) { /* 50 is reserved for VPN (NM_VPN_ROUTE_METRIC_DEFAULT) */ case NM_DEVICE_TYPE_ETHERNET: case NM_DEVICE_TYPE_VETH: @@ -1765,7 +1767,10 @@ nm_device_get_route_metric (NMDevice *self, if (route_metric >= 0) goto out; } - route_metric = _get_route_metric_default (self); + + route_metric = nm_manager_device_route_metric_reserve (nm_manager_get (), + nm_device_get_ip_ifindex (self), + nm_device_get_device_type (self)); out: return nm_utils_ip_route_metric_normalize (addr_family, route_metric); } @@ -5490,7 +5495,7 @@ ipv4_manual_method_apply (NMDevice *self, NMIP4Config **configs, gboolean succes g_object_unref (empty); } else { nm_device_ip_method_failed (self, AF_INET, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); + NM_DEVICE_STATE_REASON_IP_ADDRESS_DUPLICATE); } } @@ -6074,7 +6079,7 @@ dhcp4_dad_cb (NMDevice *self, NMIP4Config **configs, gboolean success) nm_device_activate_schedule_ip4_config_result (self, configs[1]); else { nm_device_ip_method_failed (self, AF_INET, - NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); + NM_DEVICE_STATE_REASON_IP_ADDRESS_DUPLICATE); } } @@ -8156,6 +8161,12 @@ nm_device_activate_stage3_ip4_start (NMDevice *self) g_assert (priv->ip4_state == IP_WAIT); + if (nm_device_sys_iface_state_is_external (self)) { + _set_ip_state (self, AF_INET, IP_DONE); + check_ip_state (self, FALSE); + return TRUE; + } + _set_ip_state (self, AF_INET, IP_CONF); ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip4_config_start (self, &ip4_config, &failure_reason); if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { @@ -8197,6 +8208,12 @@ nm_device_activate_stage3_ip6_start (NMDevice *self) g_assert (priv->ip6_state == IP_WAIT); + if (nm_device_sys_iface_state_is_external (self)) { + _set_ip_state (self, AF_INET6, IP_DONE); + check_ip_state (self, FALSE); + return TRUE; + } + _set_ip_state (self, AF_INET6, IP_CONF); ret = NM_DEVICE_GET_CLASS (self)->act_stage3_ip6_config_start (self, &ip6_config, &failure_reason); if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { @@ -12482,6 +12499,11 @@ _cleanup_generic_pre (NMDevice *self, CleanupType cleanup_type) _cancel_activation (self); + if (cleanup_type != CLEANUP_TYPE_KEEP) { + nm_manager_device_route_metric_clear (nm_manager_get (), + nm_device_get_ip_ifindex (self)); + } + if ( cleanup_type == CLEANUP_TYPE_DECONFIGURE && priv->fw_state >= FIREWALL_STATE_INITIALIZED && priv->fw_mgr @@ -13512,6 +13534,7 @@ nm_device_update_permanent_hw_address (NMDevice *self, gboolean force_freeze) gboolean success_read; int ifindex; const NMPlatformLink *pllink; + const NMConfigDeviceStateData *dev_state; if (priv->hw_addr_perm) { /* the permanent hardware address is only read once and not @@ -13571,23 +13594,19 @@ nm_device_update_permanent_hw_address (NMDevice *self, gboolean force_freeze) /* We also persist our choice of the fake address to the device state * file to use the same address on restart of NetworkManager. * First, try to reload the address from the state file. */ - { - gs_free NMConfigDeviceStateData *dev_state = NULL; - - dev_state = nm_config_device_state_load (ifindex); - if ( dev_state - && dev_state->perm_hw_addr_fake - && nm_utils_hwaddr_aton (dev_state->perm_hw_addr_fake, buf, priv->hw_addr_len) - && !nm_utils_hwaddr_matches (buf, priv->hw_addr_len, priv->hw_addr, -1)) { - _LOGD (LOGD_PLATFORM | LOGD_ETHER, "hw-addr: %s (use from statefile: %s, current: %s)", - success_read - ? "read HW addr length of permanent MAC address differs" - : "unable to read permanent MAC address", - dev_state->perm_hw_addr_fake, - priv->hw_addr); - priv->hw_addr_perm = nm_utils_hwaddr_ntoa (buf, priv->hw_addr_len); - goto notify_and_out; - } + dev_state = nm_config_device_state_get (nm_config_get (), ifindex); + if ( dev_state + && dev_state->perm_hw_addr_fake + && nm_utils_hwaddr_aton (dev_state->perm_hw_addr_fake, buf, priv->hw_addr_len) + && !nm_utils_hwaddr_matches (buf, priv->hw_addr_len, priv->hw_addr, -1)) { + _LOGD (LOGD_PLATFORM | LOGD_ETHER, "hw-addr: %s (use from statefile: %s, current: %s)", + success_read + ? "read HW addr length of permanent MAC address differs" + : "unable to read permanent MAC address", + dev_state->perm_hw_addr_fake, + priv->hw_addr); + priv->hw_addr_perm = nm_utils_hwaddr_ntoa (buf, priv->hw_addr_len); + goto notify_and_out; } _LOGD (LOGD_PLATFORM | LOGD_ETHER, "hw-addr: %s (use current: %s)", diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index 810a613d..ac73ee0c 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -450,6 +450,8 @@ NMMetered nm_device_get_metered (NMDevice *dev); guint32 nm_device_get_route_table (NMDevice *self, int addr_family, gboolean fallback_main); guint32 nm_device_get_route_metric (NMDevice *dev, int addr_family); +guint32 nm_device_get_route_metric_default (NMDeviceType device_type); + const char * nm_device_get_hw_address (NMDevice *dev); const char * nm_device_get_permanent_hw_address (NMDevice *self); const char * nm_device_get_permanent_hw_address_full (NMDevice *self, diff --git a/src/devices/ovs/nm-device-ovs-interface.c b/src/devices/ovs/nm-device-ovs-interface.c index 426521c5..e746a3fd 100644 --- a/src/devices/ovs/nm-device-ovs-interface.c +++ b/src/devices/ovs/nm-device-ovs-interface.c @@ -35,8 +35,13 @@ _LOG_DECLARE_SELF(NMDeviceOvsInterface); /*****************************************************************************/ +typedef struct { + bool waiting_for_interface:1; +} NMDeviceOvsInterfacePrivate; + struct _NMDeviceOvsInterface { NMDevice parent; + NMDeviceOvsInterfacePrivate _priv; }; struct _NMDeviceOvsInterfaceClass { @@ -45,6 +50,8 @@ struct _NMDeviceOvsInterfaceClass { G_DEFINE_TYPE (NMDeviceOvsInterface, nm_device_ovs_interface, NM_TYPE_DEVICE) +#define NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMDeviceOvsInterface, NM_IS_DEVICE_OVS_INTERFACE) + /*****************************************************************************/ static const char * @@ -109,7 +116,10 @@ static void link_changed (NMDevice *device, const NMPlatformLink *pllink) { - if (nm_device_get_state (device) == NM_DEVICE_STATE_IP_CONFIG) { + NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE (device); + + if (priv->waiting_for_interface) { + priv->waiting_for_interface = FALSE; nm_device_bring_up (device, TRUE, NULL); nm_device_activate_schedule_stage3_ip_config_start (device); } @@ -131,11 +141,15 @@ act_stage3_ip4_config_start (NMDevice *device, NMIP4Config **out_config, NMDeviceStateReason *out_failure_reason) { + NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE (device); + if (!_is_internal_interface (device)) return NM_ACT_STAGE_RETURN_IP_FAIL; - if (!nm_device_get_ip_ifindex (device)) + if (!nm_device_get_ip_ifindex (device)) { + priv->waiting_for_interface = TRUE; return NM_ACT_STAGE_RETURN_POSTPONE; + } return NM_DEVICE_CLASS (nm_device_ovs_interface_parent_class)->act_stage3_ip4_config_start (device, out_config, out_failure_reason); } @@ -145,11 +159,15 @@ act_stage3_ip6_config_start (NMDevice *device, NMIP6Config **out_config, NMDeviceStateReason *out_failure_reason) { + NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE (device); + if (!_is_internal_interface (device)) return NM_ACT_STAGE_RETURN_IP_FAIL; - if (!nm_device_get_ip_ifindex (device)) + if (!nm_device_get_ip_ifindex (device)) { + priv->waiting_for_interface = TRUE; return NM_ACT_STAGE_RETURN_POSTPONE; + } return NM_DEVICE_CLASS (nm_device_ovs_interface_parent_class)->act_stage3_ip6_config_start (device, out_config, out_failure_reason); } diff --git a/src/devices/tests/test-arping.c b/src/devices/tests/test-arping.c index 4b4642f3..bcbc1140 100644 --- a/src/devices/tests/test-arping.c +++ b/src/devices/tests/test-arping.c @@ -85,7 +85,7 @@ test_arping_common (test_fixture *fixture, TestInfo *info) loop = g_main_loop_new (NULL, FALSE); g_signal_connect (manager, NM_ARPING_MANAGER_PROBE_TERMINATED, G_CALLBACK (arping_manager_probe_terminated), loop); - g_assert (nm_arping_manager_start_probe (manager, 100, NULL)); + g_assert (nm_arping_manager_start_probe (manager, 250, NULL)); g_assert (nmtst_main_loop_run (loop, 2000)); for (i = 0; info->addresses[i]; i++) { diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index 6e5f10a0..dc0ce303 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -875,32 +875,37 @@ static_stage3_ip4_done (NMModemBroadband *self) NMPlatformIP4Address address; const gchar **dns; guint i; + guint32 ip4_route_table, ip4_route_metric; + NMPlatformIP4Route *r; g_assert (self->_priv.ipv4_config); g_assert (self->_priv.bearer); + self->_priv.idle_id_ip4 = 0; + _LOGI ("IPv4 static configuration:"); /* Fully fail if invalid IP address retrieved */ address_string = mm_bearer_ip_config_get_address (self->_priv.ipv4_config); - if (!nm_utils_parse_inaddr_bin (AF_INET, address_string, &address_network)) { + if ( !address_string + || !nm_utils_parse_inaddr_bin (AF_INET, address_string, &address_network)) { error = g_error_new (NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, - "(%s) retrieving IP4 configuration failed: invalid address given '%s'", + "(%s) retrieving IP4 configuration failed: invalid address given %s%s%s", nm_modem_get_uid (NM_MODEM (self)), - address_string); + NM_PRINT_FMT_QUOTE_STRING (address_string)); goto out; } /* Missing gateway not a hard failure */ gw_string = mm_bearer_ip_config_get_gateway (self->_priv.ipv4_config); - if ( !gw_string - || !nm_utils_parse_inaddr_bin (AF_INET, gw_string, &gw)) { + if ( gw_string + && !nm_utils_parse_inaddr_bin (AF_INET, gw_string, &gw)) { error = g_error_new (NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, - "(%s) retrieving IP4 configuration failed: invalid gateway address %s%s%s", + "(%s) retrieving IP4 configuration failed: invalid gateway address \"%s\"", nm_modem_get_uid (NM_MODEM (self)), - NM_PRINT_FMT_QUOTE_STRING (gw_string)); + gw_string); goto out; } @@ -919,26 +924,20 @@ static_stage3_ip4_done (NMModemBroadband *self) _LOGI (" address %s/%d", address_string, address.plen); - if (gw) { - guint32 ip4_route_table, ip4_route_metric; - - nm_modem_get_route_parameters (NM_MODEM (self), - &ip4_route_table, - &ip4_route_metric, - NULL, - NULL); - { - const NMPlatformIP4Route r = { - .rt_source = NM_IP_CONFIG_SOURCE_WWAN, - .gateway = gw, - .table_coerced = nm_platform_route_table_coerce (ip4_route_table), - .metric = ip4_route_metric, - }; - _LOGI (" gateway %s", gw_string); - nm_ip4_config_add_route (config, &r, NULL); - } - } + nm_modem_get_route_parameters (NM_MODEM (self), + &ip4_route_table, + &ip4_route_metric, + NULL, + NULL); + r = &(NMPlatformIP4Route) { + .rt_source = NM_IP_CONFIG_SOURCE_WWAN, + .gateway = gw, + .table_coerced = nm_platform_route_table_coerce (ip4_route_table), + .metric = ip4_route_metric, + }; + nm_ip4_config_add_route (config, r, NULL); + _LOGI (" gateway %s", gw_string); /* DNS servers */ dns = mm_bearer_ip_config_get_dns (self->_priv.ipv4_config); @@ -989,6 +988,7 @@ stage3_ip6_done (NMModemBroadband *self) g_assert (self->_priv.ipv6_config); + self->_priv.idle_id_ip6 = 0; memset (&address, 0, sizeof (address)); ip_method = get_bearer_ip_method (self->_priv.ipv6_config); diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index 1c32791f..010a2b60 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -685,9 +685,8 @@ nm_modem_stage3_ip4_config_start (NMModem *self, return NM_ACT_STAGE_RETURN_SUCCESS; if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) != 0) { - _LOGW ("unhandled WWAN IPv4 method '%s'; will fail", - method); - NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE); + _LOGE ("unhandled WWAN IPv4 method '%s'; will fail", method); + NM_SET_OUT (out_failure_reason, NM_DEVICE_STATE_REASON_IP_METHOD_UNSUPPORTED); return NM_ACT_STAGE_RETURN_FAILURE; } |