core: don't select s390 subchannel-locked connections on non-s390 devices

The autoactivation code wasn't excluding subchannel-locked connections
when matching for devices that don't have subchannels.  This only
produced a warning message though as the connection activation would
be failed by the check_connection_compatible hook.
This commit is contained in:
Dan Williams 2010-08-09 17:53:01 -05:00
parent 1a3381df3e
commit 11ed2f737f

View file

@ -785,6 +785,39 @@ real_is_available (NMDevice *dev)
return TRUE;
}
static gboolean
match_subchans (NMDeviceEthernet *self, NMSettingWired *s_wired, gboolean *try_mac)
{
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
const GPtrArray *subchans;
int i;
*try_mac = TRUE;
subchans = nm_setting_wired_get_s390_subchannels (s_wired);
if (!subchans)
return TRUE;
/* connection requires subchannels but the device has none */
if (!priv->subchannels)
return FALSE;
/* Make sure each subchannel in the connection is a subchannel of this device */
for (i = 0; i < subchans->len; i++) {
const char *candidate = g_ptr_array_index (subchans, i);
if ( (priv->subchan1 && !strcmp (priv->subchan1, candidate))
|| (priv->subchan2 && !strcmp (priv->subchan2, candidate))
|| (priv->subchan3 && !strcmp (priv->subchan3, candidate)))
continue;
return FALSE; /* a subchannel was not found */
}
*try_mac = FALSE;
return TRUE;
}
static NMConnection *
real_get_best_auto_connection (NMDevice *dev,
GSList *connections,
@ -820,9 +853,13 @@ real_get_best_auto_connection (NMDevice *dev,
if (s_wired) {
const GByteArray *mac;
gboolean try_mac = TRUE;
if (!match_subchans (self, s_wired, &try_mac))
continue;
mac = nm_setting_wired_get_mac_address (s_wired);
if (mac && memcmp (mac->data, &priv->perm_hw_addr, ETH_ALEN))
if (try_mac && mac && memcmp (mac->data, &priv->perm_hw_addr, ETH_ALEN))
continue;
}
@ -1702,41 +1739,6 @@ real_deactivate_quickly (NMDevice *device)
_set_hw_addr (self, priv->perm_hw_addr, "reset");
}
static gboolean
match_subchans (NMDeviceEthernet *self, NMSettingWired *s_wired, gboolean *try_mac)
{
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
const GPtrArray *subchans;
int i;
*try_mac = TRUE;
subchans = nm_setting_wired_get_s390_subchannels (s_wired);
if (!subchans)
return TRUE;
/* connection requires subchannels but the device has none */
if (!priv->subchannels)
return FALSE;
/* Make sure each subchannel in the connection is a subchannel of this device */
for (i = 0; i < subchans->len; i++) {
const char *candidate = g_ptr_array_index (subchans, i);
gboolean found = FALSE;
if ( (priv->subchan1 && !strcmp (priv->subchan1, candidate))
|| (priv->subchan2 && !strcmp (priv->subchan2, candidate))
|| (priv->subchan3 && !strcmp (priv->subchan3, candidate)))
found = TRUE;
if (!found)
return FALSE;
}
*try_mac = FALSE;
return TRUE;
}
static gboolean
real_check_connection_compatible (NMDevice *device,
NMConnection *connection,