Blob Blame History Raw
From 73a214a863e902df3df45e426b2eb1ef315461f4 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Wed, 21 Sep 2016 17:07:42 +0200
Subject: [PATCH 1/2] device: fix nm_utils_match_connection() for
 NMSettingInfiniband:mac-address

    <debug> [1474469475.3318] Connection 'inf_ib0' differs from candidate 't-inf' in infiniband.mac-address
    <debug> [1474469475.3318] manager: (inf_ib0): generated connection 'inf_ib0'

https://bugzilla.redhat.com/show_bug.cgi?id=1375558
(cherry picked from commit 78957c0d399c715969b3989b2678d1e8179983f4)
(cherry picked from commit f6c0c2d46e8dcdf42e6a8dc826b34c8e8bbb5856)
---
 src/NetworkManagerUtils.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
index 7eb6cf1..7cfe03f 100644
--- a/src/NetworkManagerUtils.c
+++ b/src/NetworkManagerUtils.c
@@ -528,6 +528,39 @@ check_connection_mac_address (NMConnection *orig,
 }
 
 static gboolean
+check_connection_infiniband_mac_address (NMConnection *orig,
+                                         NMConnection *candidate,
+                                         GHashTable *settings)
+{
+	GHashTable *props;
+	const char *orig_mac = NULL, *cand_mac = NULL;
+	NMSettingInfiniband *s_infiniband_orig, *s_infiniband_cand;
+
+	props = check_property_in_hash (settings,
+	                                NM_SETTING_INFINIBAND_SETTING_NAME,
+	                                NM_SETTING_INFINIBAND_MAC_ADDRESS);
+	if (!props)
+		return TRUE;
+
+	/* If one of the MAC addresses is NULL, we accept that connection */
+	s_infiniband_orig = nm_connection_get_setting_infiniband (orig);
+	if (s_infiniband_orig)
+		orig_mac = nm_setting_infiniband_get_mac_address (s_infiniband_orig);
+
+	s_infiniband_cand = nm_connection_get_setting_infiniband (candidate);
+	if (s_infiniband_cand)
+		cand_mac = nm_setting_infiniband_get_mac_address (s_infiniband_cand);
+
+	if (!orig_mac || !cand_mac) {
+		remove_from_hash (settings, props,
+		                  NM_SETTING_INFINIBAND_SETTING_NAME,
+		                  NM_SETTING_INFINIBAND_MAC_ADDRESS);
+		return TRUE;
+	}
+	return FALSE;
+}
+
+static gboolean
 check_connection_cloned_mac_address (NMConnection *orig,
                                      NMConnection *candidate,
                                      GHashTable *settings)
@@ -640,6 +673,9 @@ check_possible_match (NMConnection *orig,
 	if (!check_connection_mac_address (orig, candidate, settings))
 		return NULL;
 
+	if (!check_connection_infiniband_mac_address (orig, candidate, settings))
+		return NULL;
+
 	if (!check_connection_cloned_mac_address (orig, candidate, settings))
 		return NULL;
 
-- 
2.7.4


From ed33ddbdb33da478be62a20c2e4f5286df081969 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Thu, 22 Sep 2016 18:15:19 +0200
Subject: [PATCH 2/2] libnm: relax comparison of bond-option for INFERRABLE
 match

When comparing the bond-settings of an activated device against
the settings from the connection, some properties might easily
differ. Hack them around in NMSettingBond:compare_property().

For example:

the setting in the connection has:
    [bond]
    mode=active-backup

later, the device gets:
    [bond]
    active_slave=inf_ib0
    fail_over_mac=active
    mode=active-backup

Note that the fail_over_mac changes due to:
  kernel: nm-bond: enslaved VLAN challenged slave inf_ib0. Adding VLANs will be blocked as long as inf_ib0 is part of bond nm-bond
  kernel: nm-bond: The slave device specified does not support setting the MAC address
  kernel: nm-bond: Setting fail_over_mac to active for active-backup mode

https://bugzilla.redhat.com/show_bug.cgi?id=1375558
(cherry picked from commit 0fb723e7205f7c0ba038c463047eb780171e85a2)
(cherry picked from commit 8e6a706e20d517645b0201e663659f7b6a2b8b52)
---
 libnm-core/nm-setting-bond.c | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/libnm-core/nm-setting-bond.c b/libnm-core/nm-setting-bond.c
index a82d0d7..0364c49 100644
--- a/libnm-core/nm-setting-bond.c
+++ b/libnm-core/nm-setting-bond.c
@@ -775,13 +775,27 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
 }
 
 static gboolean
-options_hash_match (NMSettingBond *s_bond, GHashTable *options1, GHashTable *options2)
+options_hash_match (NMSettingBond *s_bond,
+                    GHashTable *options1,
+                    GHashTable *options2,
+                    NMSettingCompareFlags flags)
 {
 	GHashTableIter iter;
 	const char *key, *value, *value2;
 
 	g_hash_table_iter_init (&iter, options1);
 	while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) {
+
+		if (NM_FLAGS_HAS (flags, NM_SETTING_COMPARE_FLAG_INFERRABLE)) {
+			/* when doing an inferrable match, the active-slave should be ignored
+			 * as it might be differ from the setting in the connection.
+			 *
+			 * Also, the fail_over_mac setting can change, see for example
+			 * https://bugzilla.redhat.com/show_bug.cgi?id=1375558#c8 */
+			if (NM_IN_STRSET (key, "fail_over_mac", "active_slave"))
+				continue;
+		}
+
 		value2 = g_hash_table_lookup (options2, key);
 
 		if (!value2) {
@@ -806,10 +820,13 @@ options_hash_match (NMSettingBond *s_bond, GHashTable *options1, GHashTable *opt
 }
 
 static gboolean
-options_equal (NMSettingBond *s_bond, GHashTable *options1, GHashTable *options2)
+options_equal (NMSettingBond *s_bond,
+               GHashTable *options1,
+               GHashTable *options2,
+               NMSettingCompareFlags flags)
 {
-	return    options_hash_match (s_bond, options1, options2)
-	       && options_hash_match (s_bond, options2, options1);
+	return    options_hash_match (s_bond, options1, options2, flags)
+	       && options_hash_match (s_bond, options2, options1, flags);
 }
 
 static gboolean
@@ -823,7 +840,8 @@ compare_property (NMSetting *setting,
 	if (nm_streq0 (prop_spec->name, NM_SETTING_BOND_OPTIONS)) {
 		return options_equal (NM_SETTING_BOND (setting),
 		                      NM_SETTING_BOND_GET_PRIVATE (setting)->options,
-		                      NM_SETTING_BOND_GET_PRIVATE (other)->options);
+		                      NM_SETTING_BOND_GET_PRIVATE (other)->options,
+		                      flags);
 	}
 
 	/* Otherwise chain up to parent to handle generic compare */
-- 
2.7.4