device: factor out config argument to ip4_config_merge_and_apply()

This commit is contained in:
Thomas Haller 2017-09-28 14:22:07 +02:00
parent b31226532d
commit a4e506ead5

View file

@ -504,7 +504,6 @@ static gboolean nm_device_set_ip4_config (NMDevice *self,
gboolean commit,
GPtrArray *ip4_dev_route_blacklist);
static gboolean ip4_config_merge_and_apply (NMDevice *self,
NMIP4Config *config,
gboolean commit);
static gboolean nm_device_set_ip6_config (NMDevice *self,
@ -1929,7 +1928,7 @@ update_connectivity_state (NMDevice *self, NMConnectivityState state)
if ( priv->state == NM_DEVICE_STATE_ACTIVATED
&& !nm_device_sys_iface_state_is_external (self)) {
if ( nm_device_get_best_default_route (self, AF_INET)
&& !ip4_config_merge_and_apply (self, NULL, TRUE))
&& !ip4_config_merge_and_apply (self, TRUE))
_LOGW (LOGD_IP4, "Failed to update IPv4 route metric");
if ( nm_device_get_best_default_route (self, AF_INET6)
&& !ip6_config_merge_and_apply (self, TRUE))
@ -2733,7 +2732,7 @@ device_link_changed (NMDevice *self)
/* the link was down and just came up. That happens for example, while changing MTU.
* We must restore IP configuration. */
if (priv->ip4_state == IP_DONE) {
if (!ip4_config_merge_and_apply (self, NULL, TRUE))
if (!ip4_config_merge_and_apply (self, TRUE))
_LOGW (LOGD_IP4, "failed applying IP4 config after link comes up again");
}
if (priv->ip6_state == IP_DONE) {
@ -5549,7 +5548,9 @@ nm_device_handle_ipv4ll_event (sd_ipv4ll *ll, int event, void *data)
nm_clear_g_source (&priv->ipv4ll_timeout);
nm_device_activate_schedule_ip4_config_result (self, config);
} else if (priv->ip4_state == IP_DONE) {
if (!ip4_config_merge_and_apply (self, config, TRUE)) {
g_clear_object (&priv->dev_ip4_config);
priv->dev_ip4_config = g_object_ref (config);
if (!ip4_config_merge_and_apply (self, TRUE)) {
_LOGE (LOGD_AUTOIP4, "failed to update IP4 config for autoip change.");
nm_device_ip_method_failed (self, AF_INET, NM_DEVICE_STATE_REASON_AUTOIP_FAILED);
}
@ -5726,7 +5727,6 @@ dhcp4_cleanup (NMDevice *self, CleanupType cleanup_type, gboolean release)
static gboolean
ip4_config_merge_and_apply (NMDevice *self,
NMIP4Config *config,
gboolean commit)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
@ -5743,12 +5743,6 @@ ip4_config_merge_and_apply (NMDevice *self,
gs_unref_ptrarray GPtrArray *ip4_dev_route_blacklist = NULL;
gboolean add_default_route = TRUE;
/* Merge all the configs into the composite config */
if (config) {
g_clear_object (&priv->dev_ip4_config);
priv->dev_ip4_config = g_object_ref (config);
}
/* Apply ignore-auto-routes and ignore-auto-dns settings */
connection = nm_device_get_applied_connection (self);
if (connection) {
@ -5885,9 +5879,14 @@ END_ADD_DEFAULT_ROUTE:
static gboolean
dhcp4_lease_change (NMDevice *self, NMIP4Config *config)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
g_return_val_if_fail (config, FALSE);
if (!ip4_config_merge_and_apply (self, config, TRUE)) {
g_clear_object (&priv->dev_ip4_config);
priv->dev_ip4_config = g_object_ref (config);
if (!ip4_config_merge_and_apply (self, TRUE)) {
_LOGW (LOGD_DHCP4, "failed to update IPv4 config for DHCP change.");
return FALSE;
}
@ -8551,7 +8550,7 @@ activate_stage5_ip4_config_result (NMDevice *self)
}
/* NULL to use the existing priv->dev_ip4_config */
if (!ip4_config_merge_and_apply (self, NULL, TRUE)) {
if (!ip4_config_merge_and_apply (self, TRUE)) {
_LOGD (LOGD_DEVICE | LOGD_IP4, "Activation: Stage 5 of 5 (IPv4 Commit) failed");
nm_device_ip_method_failed (self, AF_INET, NM_DEVICE_STATE_REASON_CONFIG_FAILED);
return;
@ -9103,7 +9102,7 @@ nm_device_reactivate_ip4_config (NMDevice *self,
if (!nm_device_activate_stage3_ip4_start (self))
_LOGW (LOGD_IP4, "Failed to apply IPv4 configuration");
} else {
if (!ip4_config_merge_and_apply (self, NULL, TRUE))
if (!ip4_config_merge_and_apply (self, TRUE))
_LOGW (LOGD_IP4, "Failed to reapply IPv4 configuration");
}
}
@ -10184,7 +10183,7 @@ nm_device_replace_vpn4_config (NMDevice *self, NMIP4Config *old, NMIP4Config *co
return;
/* NULL to use existing configs */
if (!ip4_config_merge_and_apply (self, NULL, TRUE))
if (!ip4_config_merge_and_apply (self, TRUE))
_LOGW (LOGD_IP4, "failed to set VPN routes for device");
}
@ -10201,7 +10200,7 @@ nm_device_set_wwan_ip4_config (NMDevice *self, NMIP4Config *config)
priv->wwan_ip4_config = g_object_ref (config);
/* NULL to use existing configs */
if (!ip4_config_merge_and_apply (self, NULL, TRUE))
if (!ip4_config_merge_and_apply (self, TRUE))
_LOGW (LOGD_IP4, "failed to set WWAN IPv4 configuration");
}
@ -10725,7 +10724,7 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware)
/* when the link comes up, we must restore IP configuration if necessary. */
if (priv->ip4_state == IP_DONE) {
if (!ip4_config_merge_and_apply (self, NULL, TRUE))
if (!ip4_config_merge_and_apply (self, TRUE))
_LOGW (LOGD_IP4, "failed applying IP4 config after bringing link up");
}
if (priv->ip6_state == IP_DONE) {
@ -11035,7 +11034,7 @@ update_ip_config (NMDevice *self, int addr_family, gboolean initial)
if (update_ext_ip_config (self, addr_family, initial, TRUE)) {
if (addr_family == AF_INET) {
if (priv->ext_ip4_config)
ip4_config_merge_and_apply (self, NULL, FALSE);
ip4_config_merge_and_apply (self, FALSE);
} else {
if (priv->ext_ip6_config_captured)
ip6_config_merge_and_apply (self, FALSE);