device: fix crash reapplying connection to slave devices

Slave devices don't have IPv4 and IPv6 configuration and so special
care must be taken when comparing their methods.

https://bugzilla.redhat.com/show_bug.cgi?id=1376446
(cherry picked from commit 8f92ead6e2)
This commit is contained in:
Beniamino Galvani 2016-09-16 05:12:45 +02:00
parent 5dfb3ec72c
commit dbb67694cb

View file

@ -7781,6 +7781,7 @@ nm_device_reactivate_ip4_config (NMDevice *self,
NMSettingIPConfig *s_ip4_new)
{
NMDevicePrivate *priv;
const char *method_old, *method_new;
g_return_if_fail (NM_IS_DEVICE (self));
priv = NM_DEVICE_GET_PRIVATE (self);
@ -7793,8 +7794,14 @@ nm_device_reactivate_ip4_config (NMDevice *self,
s_ip4_new,
nm_device_get_ip4_route_metric (self));
if (strcmp (nm_setting_ip_config_get_method (s_ip4_new),
nm_setting_ip_config_get_method (s_ip4_old))) {
method_old = s_ip4_old ?
nm_setting_ip_config_get_method (s_ip4_old) :
NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
method_new = s_ip4_new ?
nm_setting_ip_config_get_method (s_ip4_new) :
NM_SETTING_IP4_CONFIG_METHOD_DISABLED;
if (!nm_streq0 (method_old, method_new)) {
_cleanup_ip4_pre (self, CLEANUP_TYPE_DECONFIGURE);
priv->ip4_state = IP_WAIT;
if (!nm_device_activate_stage3_ip4_start (self))
@ -7812,6 +7819,7 @@ nm_device_reactivate_ip6_config (NMDevice *self,
NMSettingIPConfig *s_ip6_new)
{
NMDevicePrivate *priv;
const char *method_old, *method_new;
g_return_if_fail (NM_IS_DEVICE (self));
priv = NM_DEVICE_GET_PRIVATE (self);
@ -7824,8 +7832,14 @@ nm_device_reactivate_ip6_config (NMDevice *self,
s_ip6_new,
nm_device_get_ip6_route_metric (self));
if (strcmp (nm_setting_ip_config_get_method (s_ip6_new),
nm_setting_ip_config_get_method (s_ip6_old))) {
method_old = s_ip6_old ?
nm_setting_ip_config_get_method (s_ip6_old) :
NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
method_new = s_ip6_new ?
nm_setting_ip_config_get_method (s_ip6_new) :
NM_SETTING_IP6_CONFIG_METHOD_IGNORE;
if (!nm_streq0 (method_old, method_new)) {
_cleanup_ip6_pre (self, CLEANUP_TYPE_DECONFIGURE);
priv->ip6_state = IP_WAIT;
if (!nm_device_activate_stage3_ip6_start (self))