device: merge IPv4 and IPv6 variant of nm_device_set_wwan_ip_config()

(cherry picked from commit 99abcf0105)
This commit is contained in:
Thomas Haller 2019-03-02 18:34:09 +01:00
parent f0e0d24fd6
commit 0dcfe1a7e0
3 changed files with 23 additions and 19 deletions

View file

@ -146,8 +146,9 @@ void nm_device_queue_recheck_available (NMDevice *device,
NMDeviceStateReason available_reason,
NMDeviceStateReason unavailable_reason);
void nm_device_set_wwan_ip4_config (NMDevice *device, NMIP4Config *config);
void nm_device_set_wwan_ip6_config (NMDevice *device, NMIP6Config *config);
void nm_device_set_wwan_ip_config (NMDevice *device,
int addr_family,
NMIPConfig *config);
gboolean nm_device_hw_addr_is_explict (NMDevice *device);

View file

@ -12190,13 +12190,25 @@ nm_device_replace_vpn4_config (NMDevice *self, NMIP4Config *old, NMIP4Config *co
}
void
nm_device_set_wwan_ip4_config (NMDevice *self, NMIP4Config *config)
nm_device_set_wwan_ip_config (NMDevice *self,
int addr_family,
NMIPConfig *config)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
NMDevicePrivate *priv;
const gboolean IS_IPv4 = (addr_family == AF_INET);
applied_config_init (&priv->wwan_ip_config_4, config);
if (!ip_config_merge_and_apply (self, AF_INET, TRUE))
_LOGW (LOGD_IP4, "failed to set WWAN IPv4 configuration");
g_return_if_fail (NM_IS_DEVICE (self));
g_return_if_fail (NM_IN_SET (addr_family, AF_INET, AF_INET6));
g_return_if_fail ( !config
|| nm_ip_config_get_addr_family (config) == addr_family);
priv = NM_DEVICE_GET_PRIVATE (self);
applied_config_init (&priv->wwan_ip_config_x[IS_IPv4], config);
if (!ip_config_merge_and_apply (self, addr_family, TRUE)) {
_LOGW (LOGD_IP, "failed to set WWAN IPv%c configuration",
nm_utils_addr_family_to_char (addr_family));
}
}
void
@ -12217,16 +12229,6 @@ nm_device_replace_vpn6_config (NMDevice *self, NMIP6Config *old, NMIP6Config *co
_LOGW (LOGD_IP6, "failed to set VPN routes for device");
}
void
nm_device_set_wwan_ip6_config (NMDevice *self, NMIP6Config *config)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
applied_config_init (&priv->wwan_ip_config_6, config);
if (!ip_config_merge_and_apply (self, AF_INET6, TRUE))
_LOGW (LOGD_IP6, "failed to set WWAN IPv6 configuration");
}
NMDhcp6Config *
nm_device_get_dhcp6_config (NMDevice *self)
{

View file

@ -23,6 +23,7 @@
#include "nm-device-modem.h"
#include "nm-modem.h"
#include "nm-ip4-config.h"
#include "devices/nm-device-private.h"
#include "nm-rfkill-manager.h"
#include "settings/nm-settings-connection.h"
@ -211,7 +212,7 @@ modem_ip4_config_result (NMModem *modem,
AF_INET,
NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE);
} else {
nm_device_set_wwan_ip4_config (device, config);
nm_device_set_wwan_ip_config (device, AF_INET, NM_IP_CONFIG_CAST (config));
nm_device_activate_schedule_ip_config_result (device, AF_INET, NULL);
}
}
@ -245,7 +246,7 @@ modem_ip6_config_result (NMModem *modem,
nm_device_sysctl_ip_conf_set (device, AF_INET6, "disable_ipv6", "0");
if (config)
nm_device_set_wwan_ip6_config (device, config);
nm_device_set_wwan_ip_config (device, AF_INET6, NM_IP_CONFIG_CAST (config));
if (do_slaac == FALSE) {
if (got_config)