From 7251e4ea22f0a281da87e0d1c28c3405bf75068a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Tue, 8 Apr 2014 10:49:16 +0200 Subject: [PATCH] utils: allow matching connections with no MAC (missing HWADDR) (rh #1083196) --- src/NetworkManagerUtils.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index e0a232e873..52b7c43827 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -791,6 +791,36 @@ check_connection_interface_name (NMConnection *orig, return FALSE; } +static gboolean +check_connection_mac_address (NMConnection *orig, + NMConnection *candidate, + GHashTable *settings) +{ + GHashTable *props; + const GByteArray *orig_mac, *cand_mac; + NMSettingWired *s_wired_orig, *s_wired_cand; + + props = check_property_in_hash (settings, + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_WIRED_MAC_ADDRESS); + if (!props) + return TRUE; + + /* If one of the MAC addresses is NULL, we accept that connection */ + s_wired_orig = nm_connection_get_setting_wired (orig); + s_wired_cand = nm_connection_get_setting_wired (candidate); + orig_mac = nm_setting_wired_get_mac_address (s_wired_orig); + cand_mac = nm_setting_wired_get_mac_address (s_wired_cand); + + if (!orig_mac || !cand_mac) { + remove_from_hash (settings, props, + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_WIRED_MAC_ADDRESS); + return TRUE; + } + return FALSE; +} + static NMConnection * check_possible_match (NMConnection *orig, NMConnection *candidate, @@ -808,6 +838,9 @@ check_possible_match (NMConnection *orig, if (!check_connection_interface_name (orig, candidate, settings)) return NULL; + if (!check_connection_mac_address (orig, candidate, settings)) + return NULL; + if (g_hash_table_size (settings) == 0) return candidate; else