diff options
| author | Dan Winship <danw@gnome.org> | 2013-04-11 10:41:49 -0400 |
|---|---|---|
| committer | Dan Winship <danw@gnome.org> | 2013-04-11 14:54:40 -0400 |
| commit | f1d31e36da79ae9676fa0ed6b91665f2fb213227 (patch) | |
| tree | 11e79465b5361b2d0383ad01461a0d48b2bdbb6c | |
| parent | c36200a225aefb2a3919618e75682646899b82c0 (diff) | |
| download | NetworkManager-f1d31e36da79ae9676fa0ed6b91665f2fb213227.tar.gz | |
settings: consider :interface-name in default wired connection matching
The code to check if an ethernet device had a matching connection was
not taking NMSettingConnection:interface-name into account, meaning it
might think a device had a matching connection when that connection
actually only matched a different device.
Fix this by calling nm_setting_connection_get_interface_name() rather
than nm_connection_get_virtual_iface_name() (which would always be
NULL for ethernet connections anyway).
Also, simplify the code a bit.
https://bugzilla.gnome.org/show_bug.cgi?id=696722
| -rw-r--r-- | src/settings/nm-settings.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 4c9203eb6f..0afe100ecf 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -1307,7 +1307,6 @@ have_connection_for_device (NMSettings *self, NMDevice *device) const GByteArray *setting_mac; const guint8 *hwaddr; guint hwaddr_len = 0; - gboolean ret = FALSE; g_return_val_if_fail (NM_IS_SETTINGS (self), FALSE); @@ -1320,27 +1319,21 @@ have_connection_for_device (NMSettings *self, NMDevice *device) const char *ctype, *iface; s_con = nm_connection_get_setting_connection (connection); - ctype = nm_setting_connection_get_connection_type (s_con); - iface = nm_connection_get_virtual_iface_name (connection); - if (iface) { - if (!strcmp (iface, nm_device_get_iface (device))) { - ret = TRUE; - break; - } else - continue; - } + iface = nm_setting_connection_get_interface_name (s_con); + if (iface && strcmp (iface, nm_device_get_iface (device)) != 0) + continue; + ctype = nm_setting_connection_get_connection_type (s_con); if ( strcmp (ctype, NM_SETTING_WIRED_SETTING_NAME) && strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME)) continue; s_wired = nm_connection_get_setting_wired (connection); - /* No wired setting; therefore the PPPoE connection applies to any device */ if (!s_wired && !strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME)) { - ret = TRUE; - break; + /* No wired setting; therefore the PPPoE connection applies to any device */ + return TRUE; } g_assert (s_wired != NULL); @@ -1349,18 +1342,15 @@ have_connection_for_device (NMSettings *self, NMDevice *device) if (setting_mac) { /* A connection mac-locked to this device */ if (hwaddr_len == setting_mac->len && - !memcmp (setting_mac->data, hwaddr, hwaddr_len)) { - ret = TRUE; - break; - } + !memcmp (setting_mac->data, hwaddr, hwaddr_len)) + return TRUE; } else { /* A connection that applies to any wired device */ - ret = TRUE; - break; + return TRUE; } } - return ret; + return FALSE; } #define DEFAULT_WIRED_TAG "default-wired" |
