summaryrefslogtreecommitdiff
path: root/libnm-util
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2013-11-13 11:05:02 -0600
committerDan Williams <dcbw@redhat.com>2013-12-05 16:07:24 -0600
commit5f15409684259f32b42e35dc097453a6ddb329fa (patch)
tree958730d861dfb3c304a62d85189d8962402efc8e /libnm-util
parent5f32b8588ec4f70ebff88c9f7803353a1894e6c3 (diff)
downloadNetworkManager-5f15409684259f32b42e35dc097453a6ddb329fa.tar.gz
libnm-util: add INFERRABLE flag and remove CANDIDATE
INFERRABLE means the opposite of CANDIDATE; a property which NetworkManager can read ("infer") from the system or the kernel when generating connections. CANDIDATE isn't a great name and thus dies.
Diffstat (limited to 'libnm-util')
-rw-r--r--libnm-util/nm-connection.c4
-rw-r--r--libnm-util/nm-setting-bluetooth.c4
-rw-r--r--libnm-util/nm-setting-bond.c4
-rw-r--r--libnm-util/nm-setting-bridge-port.c7
-rw-r--r--libnm-util/nm-setting-bridge.c14
-rw-r--r--libnm-util/nm-setting-connection.c8
-rw-r--r--libnm-util/nm-setting-infiniband.c8
-rw-r--r--libnm-util/nm-setting-ip4-config.c12
-rw-r--r--libnm-util/nm-setting-ip6-config.c8
-rw-r--r--libnm-util/nm-setting-olpc-mesh.c4
-rw-r--r--libnm-util/nm-setting-private.h25
-rw-r--r--libnm-util/nm-setting-team-port.c2
-rw-r--r--libnm-util/nm-setting-team.c4
-rw-r--r--libnm-util/nm-setting-vlan.c12
-rw-r--r--libnm-util/nm-setting-wired.c10
-rw-r--r--libnm-util/nm-setting.c6
-rw-r--r--libnm-util/nm-setting.h3
-rw-r--r--libnm-util/tests/test-general.c65
18 files changed, 139 insertions, 61 deletions
diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c
index 7e588aeec1..991fed62a8 100644
--- a/libnm-util/nm-connection.c
+++ b/libnm-util/nm-connection.c
@@ -451,10 +451,6 @@ nm_connection_compare (NMConnection *a,
if (!a || !b)
return FALSE;
- /* CANDIDATE flag also implies FUZZY */
- if (flags & NM_SETTING_COMPARE_FLAG_CANDIDATE)
- flags |= NM_SETTING_COMPARE_FLAG_FUZZY;
-
/* A / B: ensure all settings in A match corresponding ones in B */
g_hash_table_iter_init (&iter, NM_CONNECTION_GET_PRIVATE (a)->settings);
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &src)) {
diff --git a/libnm-util/nm-setting-bluetooth.c b/libnm-util/nm-setting-bluetooth.c
index d03c04cc80..874effcf3a 100644
--- a/libnm-util/nm-setting-bluetooth.c
+++ b/libnm-util/nm-setting-bluetooth.c
@@ -284,7 +284,7 @@ nm_setting_bluetooth_class_init (NMSettingBluetoothClass *setting_class)
"Bluetooth address",
"The Bluetooth address of the device",
DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingBluetooth:type:
@@ -301,5 +301,5 @@ nm_setting_bluetooth_class_init (NMSettingBluetoothClass *setting_class)
"'" NM_SETTING_BLUETOOTH_TYPE_PANU "' for "
"Personal Area Networking connections.",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
}
diff --git a/libnm-util/nm-setting-bond.c b/libnm-util/nm-setting-bond.c
index 3459300ec9..426dfe03df 100644
--- a/libnm-util/nm-setting-bond.c
+++ b/libnm-util/nm-setting-bond.c
@@ -802,7 +802,7 @@ nm_setting_bond_class_init (NMSettingBondClass *setting_class)
"InterfaceName",
"The name of the virtual in-kernel bonding network interface",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingBond:options:
@@ -820,5 +820,5 @@ nm_setting_bond_class_init (NMSettingBondClass *setting_class)
"strings. Option names must contain only "
"alphanumeric characters (ie, [a-zA-Z0-9]).",
DBUS_TYPE_G_MAP_OF_STRING,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
}
diff --git a/libnm-util/nm-setting-bridge-port.c b/libnm-util/nm-setting-bridge-port.c
index 07d5dbd6bd..214e9d3cfb 100644
--- a/libnm-util/nm-setting-bridge-port.c
+++ b/libnm-util/nm-setting-bridge-port.c
@@ -269,7 +269,7 @@ nm_setting_bridge_port_class_init (NMSettingBridgePortClass *setting_class)
"Priority",
"The Spanning Tree Protocol (STP) priority of this bridge port",
0, BR_MAX_PORT_PRIORITY, BR_DEF_PRIORITY,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingBridgePort:path-cost:
@@ -285,7 +285,7 @@ nm_setting_bridge_port_class_init (NMSettingBridgePortClass *setting_class)
"The Spanning Tree Protocol (STP) port cost for "
"destinations via this port.",
0, BR_MAX_PATH_COST, 100,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingBridgePort:hairpin-mode:
@@ -303,6 +303,5 @@ nm_setting_bridge_port_class_init (NMSettingBridgePortClass *setting_class)
"port, which allows frames to be sent back out "
"through the port the frame was received on.",
FALSE,
- G_PARAM_READWRITE));
-
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
}
diff --git a/libnm-util/nm-setting-bridge.c b/libnm-util/nm-setting-bridge.c
index f5131e50a3..0890c45173 100644
--- a/libnm-util/nm-setting-bridge.c
+++ b/libnm-util/nm-setting-bridge.c
@@ -434,7 +434,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class)
"InterfaceName",
"The name of the virtual in-kernel bridging network interface",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingBridge:stp:
@@ -450,7 +450,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class)
"Controls whether Spanning Tree Protocol (STP) "
"is enabled for this bridge.",
TRUE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingBridge:priority:
@@ -470,7 +470,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class)
"lowest priority bridge will be elected the root "
"bridge.",
0, G_MAXUINT16, 0x80,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingBridge:forward-delay:
@@ -486,7 +486,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class)
"The Spanning Tree Protocol (STP) forwarding "
"delay, in seconds.",
0, BR_MAX_FORWARD_DELAY, 15,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingBridge:hello-time:
@@ -502,7 +502,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class)
"The Spanning Tree Protocol (STP) hello time, in "
"seconds.",
0, BR_MAX_HELLO_TIME, 2,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingBridge:max-age:
@@ -518,7 +518,7 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class)
"The Spanning Tree Protocol (STP) maximum message "
"age, in seconds.",
0, BR_MAX_MAX_AGE, 20,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingBridge:ageing-time:
@@ -533,6 +533,6 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class)
"AgeingTime",
"The ethernet MAC address aging time, in seconds.",
0, BR_MAX_AGEING_TIME, 300,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
}
diff --git a/libnm-util/nm-setting-connection.c b/libnm-util/nm-setting-connection.c
index 19c57d1ae2..48ca028a38 100644
--- a/libnm-util/nm-setting-connection.c
+++ b/libnm-util/nm-setting-connection.c
@@ -1099,7 +1099,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
"reordered the connection may be applied to the wrong "
"interface.",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingConnection:type:
@@ -1121,7 +1121,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
"otherwise, should contain the setting name of that "
"setting type (ie, 'vpn' or 'bridge', etc).",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingConnection:permissions:
@@ -1251,7 +1251,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
"Interface name of the master device or UUID of "
"the master connection",
NULL,
- G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingConnection:slave-type:
@@ -1267,7 +1267,7 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
"this connection is (ie, 'bond') or NULL if this "
"connection is not a slave.",
NULL,
- G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingConnection:secondaries:
diff --git a/libnm-util/nm-setting-infiniband.c b/libnm-util/nm-setting-infiniband.c
index 9739afeadf..4995940239 100644
--- a/libnm-util/nm-setting-infiniband.c
+++ b/libnm-util/nm-setting-infiniband.c
@@ -367,7 +367,7 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class)
"This property does not change the MAC address "
"of the device (i.e. MAC spoofing).",
DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingInfiniband:mtu:
@@ -397,7 +397,7 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class)
"Transport Mode",
"The IPoIB transport mode. Either 'datagram' or 'connected'.",
NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingInfiniband:p-key:
@@ -414,7 +414,7 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class)
"The InfiniBand P_Key. Either -1 for the "
"default, or a 16-bit unsigned integer.",
-1, 0xFFFF, -1,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingInfiniband:parent:
@@ -430,6 +430,6 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class)
"Parent",
"The interface name of the parent device, or NULL",
NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
}
diff --git a/libnm-util/nm-setting-ip4-config.c b/libnm-util/nm-setting-ip4-config.c
index 83d72d6c5f..5fd1cfd48e 100644
--- a/libnm-util/nm-setting-ip4-config.c
+++ b/libnm-util/nm-setting-ip4-config.c
@@ -1027,7 +1027,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"connection. 'disabled' means IPv4 will not be "
"used on this connection. This property must be set.",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingIP4Config:dns:
@@ -1107,7 +1107,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"'disabled' methods as addressing is either "
"automatic or disabled with these methods.",
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingIP4Config:routes:
@@ -1138,7 +1138,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"'shared', 'link-local', or 'disabled', methods "
"as there is no upstream network.",
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingIP4Config:ignore-auto-routes:
@@ -1231,7 +1231,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"the specified name will be sent to the DHCP server "
"when acquiring a lease.",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingIP4Config:never-default:
@@ -1247,7 +1247,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"IPv4 connection, meaning it will never be assigned "
"the default route by NetworkManager.",
FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingIP4Config:may-fail:
@@ -1272,7 +1272,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
"configuration to succeed if IPv4 configuration "
"fails but IPv6 configuration completes successfully.",
TRUE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
}
diff --git a/libnm-util/nm-setting-ip6-config.c b/libnm-util/nm-setting-ip6-config.c
index 1ed89f7939..c4ec4d373e 100644
--- a/libnm-util/nm-setting-ip6-config.c
+++ b/libnm-util/nm-setting-ip6-config.c
@@ -924,7 +924,7 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
"property must be set. Note: the 'shared' method "
"is not yet supported.",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingIP6Config:dhcp-hostname:
@@ -1028,7 +1028,7 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
"as the interface is automatically assigned an "
"address with these methods.",
DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingIP6Config:routes:
@@ -1059,7 +1059,7 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
"used with the 'shared' or 'link-local' methods "
"because there is no upstream network.",
DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingIP6Config:ignore-auto-routes:
@@ -1167,7 +1167,7 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN,
NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR,
NM_SETTING_IP6_CONFIG_PRIVACY_UNKNOWN,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
}
/********************************************************************/
diff --git a/libnm-util/nm-setting-olpc-mesh.c b/libnm-util/nm-setting-olpc-mesh.c
index 834aa29028..c98bad5432 100644
--- a/libnm-util/nm-setting-olpc-mesh.c
+++ b/libnm-util/nm-setting-olpc-mesh.c
@@ -248,7 +248,7 @@ nm_setting_olpc_mesh_class_init (NMSettingOlpcMeshClass *setting_class)
"SSID",
"SSID of the mesh network to join.",
DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingOlpcMesh:channel:
@@ -261,7 +261,7 @@ nm_setting_olpc_mesh_class_init (NMSettingOlpcMeshClass *setting_class)
"Channel",
"Channel on which the mesh network to join is located.",
0, G_MAXUINT32, 0,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingOlpcMesh:dhcp-anycast-address:
diff --git a/libnm-util/nm-setting-private.h b/libnm-util/nm-setting-private.h
index 485a667d37..a90721e93a 100644
--- a/libnm-util/nm-setting-private.h
+++ b/libnm-util/nm-setting-private.h
@@ -38,13 +38,26 @@ GType _nm_setting_lookup_setting_type (const char *name);
GType _nm_setting_lookup_setting_type_by_quark (GQuark error_quark);
gint _nm_setting_compare_priority (gconstpointer a, gconstpointer b);
-/* NM_SETTING_COMPARE_FLAG_CANDIDATE: check a whether a device-generated connection
- * can be meaningfully replaced by a configured connection. With this flag
- * the matching function is asymetric and only takes into account properties
- * mandated by the candidate configured connection. It is for internal use by
- * NetworkManager.
+/* NM_SETTING_COMPARE_FLAG_INFERRABLE: check whether a device-generated
+ * connection can be replaced by a already-defined connection. This flag only
+ * takes into account properties marked with the %NM_SETTING_PARAM_INFERRABLE
+ * flag.
*/
-#define NM_SETTING_COMPARE_FLAG_CANDIDATE 0x80000000
+#define NM_SETTING_COMPARE_FLAG_INFERRABLE 0x80000000
+
+/* The property of the #NMSetting should be considered during comparisons that
+ * use the %NM_SETTING_COMPARE_FLAG_INFERRABLE flag. Properties that don't have
+ * this flag, are ignored when doing an infrerrable comparison. This flag should
+ * be set on all properties that are read from the kernel or the system when a
+ * connection is generated. eg, IP addresses/routes can be read from the
+ * kernel, but the 'autoconnect' property cannot, so
+ * %NM_SETTING_IP4_CONFIG_ADDRESSES gets the INFERRABLE flag, but
+ * %NM_SETTING_CONNECTION_AUTOCONNECT would not.
+ *
+ * This flag should not be used with properties where the default cannot be
+ * read separately from the current value, like MTU or wired duplex mode.
+ */
+#define NM_SETTING_PARAM_INFERRABLE (1 << (4 + G_PARAM_USER_SHIFT))
/* Ensure the setting's GType is registered at library load time */
#define NM_SETTING_REGISTER_TYPE(x) \
diff --git a/libnm-util/nm-setting-team-port.c b/libnm-util/nm-setting-team-port.c
index e70c24714a..0b61bab871 100644
--- a/libnm-util/nm-setting-team-port.c
+++ b/libnm-util/nm-setting-team-port.c
@@ -179,5 +179,5 @@ nm_setting_team_port_class_init (NMSettingTeamPortClass *setting_class)
"teamd. If not specified, the dafault configuration is used. "
"See man teamd.conf for the format details.",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
}
diff --git a/libnm-util/nm-setting-team.c b/libnm-util/nm-setting-team.c
index 35d4ef719e..06dd064108 100644
--- a/libnm-util/nm-setting-team.c
+++ b/libnm-util/nm-setting-team.c
@@ -238,7 +238,7 @@ nm_setting_team_class_init (NMSettingTeamClass *setting_class)
"InterfaceName",
"The name of the virtual in-kernel team network interface",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingTeam:config:
@@ -259,5 +259,5 @@ nm_setting_team_class_init (NMSettingTeamClass *setting_class)
"teamd. If not specified, the default configuration is used. "
"See man teamd.conf for the format details.",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
}
diff --git a/libnm-util/nm-setting-vlan.c b/libnm-util/nm-setting-vlan.c
index 32f8e35c94..9ea6fc09fa 100644
--- a/libnm-util/nm-setting-vlan.c
+++ b/libnm-util/nm-setting-vlan.c
@@ -696,7 +696,7 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
"the 'parent' property or by the 'mac-address' "
"property of a 'wired' setting.",
NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingVlan:parent:
@@ -716,7 +716,7 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
"not specified, the connection must contain a "
"'wired' setting with a 'mac-address' property.",
NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingVlan:id:
@@ -731,7 +731,7 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
"The VLAN indentifier the interface created by "
"this connection should be assigned.",
0, 4095, 0,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingVlan:flags:
@@ -750,7 +750,7 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
"of the interface to its master device's operating "
"state (0x04).",
0, G_MAXUINT32, 0,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingVlan:ingress-priority-map:
@@ -769,7 +769,7 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
"format 'from:to' where both 'from' and "
"'to' are unsigned integers, ie '7:3'.",
DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingVlan:egress-priority-map:
@@ -788,5 +788,5 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
"format 'from:to' where both 'from' and "
"'to' are unsigned integers, ie '7:3'.",
DBUS_TYPE_G_LIST_OF_STRING,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
}
diff --git a/libnm-util/nm-setting-wired.c b/libnm-util/nm-setting-wired.c
index d04e70fbe1..67f0fa26eb 100644
--- a/libnm-util/nm-setting-wired.c
+++ b/libnm-util/nm-setting-wired.c
@@ -897,7 +897,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
"This property does not change the MAC address "
"of the device (i.e. MAC spoofing).",
DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingWired:cloned-mac-address:
@@ -913,7 +913,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
"this MAC address instead of its permanent MAC address. "
"This is known as MAC cloning or spoofing.",
DBUS_TYPE_G_UCHAR_ARRAY,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingWired:mac-address-blacklist:
@@ -974,7 +974,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
"string may only be composed of hexadecimal "
"characters and the period (.) character.",
DBUS_TYPE_G_ARRAY_OF_STRING,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingWired:s390-nettype:
@@ -990,7 +990,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
"'ctc', representing the different types of virtual "
"network devices available on s390 systems.",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
/**
* NMSettingWired:s390-options:
@@ -1009,6 +1009,6 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
"strings. Allowed keys include 'portno', "
"'layer2', 'portname', 'protocol', among others.",
DBUS_TYPE_G_MAP_OF_STRING,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE));
}
diff --git a/libnm-util/nm-setting.c b/libnm-util/nm-setting.c
index ceabc56451..7921483ca0 100644
--- a/libnm-util/nm-setting.c
+++ b/libnm-util/nm-setting.c
@@ -569,6 +569,9 @@ nm_setting_compare (NMSetting *a,
&& (prop_spec->flags & (NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_SECRET)))
continue;
+ if ((flags & NM_SETTING_COMPARE_FLAG_INFERRABLE) && !(prop_spec->flags & NM_SETTING_PARAM_INFERRABLE))
+ continue;
+
if ( (flags & NM_SETTING_COMPARE_FLAG_IGNORE_SECRETS)
&& (prop_spec->flags & NM_SETTING_PARAM_SECRET))
continue;
@@ -591,6 +594,9 @@ should_compare_prop (NMSetting *setting,
&& (prop_flags & (NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_SECRET)))
return FALSE;
+ if ((comp_flags & NM_SETTING_COMPARE_FLAG_INFERRABLE) && !(prop_flags & NM_SETTING_PARAM_INFERRABLE))
+ return FALSE;
+
if (prop_flags & NM_SETTING_PARAM_SECRET) {
NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
diff --git a/libnm-util/nm-setting.h b/libnm-util/nm-setting.h
index ca8334f6f8..e054288509 100644
--- a/libnm-util/nm-setting.h
+++ b/libnm-util/nm-setting.h
@@ -78,6 +78,9 @@ GQuark nm_setting_error_quark (void);
*/
#define NM_SETTING_PARAM_FUZZY_IGNORE (1 << (3 + G_PARAM_USER_SHIFT))
+/* Note: all non-glib GParamFlags bits are reserved by NetworkManager */
+
+
#define NM_SETTING_NAME "name"
/**
diff --git a/libnm-util/tests/test-general.c b/libnm-util/tests/test-general.c
index 56d6e679e2..e4703d267c 100644
--- a/libnm-util/tests/test-general.c
+++ b/libnm-util/tests/test-general.c
@@ -28,6 +28,7 @@
#include "nm-test-helpers.h"
#include <nm-utils.h>
+#include "nm-setting-private.h"
#include "nm-setting-connection.h"
#include "nm-setting-vpn.h"
#include "nm-setting-gsm.h"
@@ -1062,7 +1063,7 @@ test_connection_compare_key_only_in_a (void)
b = nm_connection_duplicate (a);
s_con = (NMSettingConnection *) nm_connection_get_setting (b, NM_TYPE_SETTING_CONNECTION);
g_assert (s_con);
- g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (gulong) 0, NULL);
+ g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (guint64) 0, NULL);
g_assert (!nm_connection_compare (a, b, NM_SETTING_COMPARE_FLAG_EXACT));
g_object_unref (a);
@@ -1092,7 +1093,7 @@ test_connection_compare_key_only_in_b (void)
b = nm_connection_duplicate (a);
s_con = (NMSettingConnection *) nm_connection_get_setting (b, NM_TYPE_SETTING_CONNECTION);
g_assert (s_con);
- g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (gulong) 0, NULL);
+ g_object_set (s_con, NM_SETTING_CONNECTION_TIMESTAMP, (guint64) 0, NULL);
g_assert (!nm_connection_compare (a, b, NM_SETTING_COMPARE_FLAG_EXACT));
g_object_unref (a);
@@ -1321,6 +1322,65 @@ test_connection_diff_no_secrets (void)
}
static void
+test_connection_diff_inferrable (void)
+{
+ NMConnection *a, *b;
+ GHashTable *out_diffs = NULL;
+ gboolean same;
+ NMSettingConnection *s_con;
+ NMSettingWired *s_wired;
+ NMSettingIP4Config *s_ip4;
+ char *uuid;
+ const DiffSetting settings[] = {
+ { NM_SETTING_CONNECTION_SETTING_NAME, {
+ { NM_SETTING_CONNECTION_INTERFACE_NAME, NM_SETTING_DIFF_RESULT_IN_A },
+ { NULL, NM_SETTING_DIFF_RESULT_UNKNOWN },
+ } },
+ };
+
+ a = new_test_connection ();
+ b = nm_connection_duplicate (a);
+
+ /* Change the UUID, wired MTU, and set ignore-auto-dns */
+ s_con = nm_connection_get_setting_connection (a);
+ g_assert (s_con);
+ uuid = nm_utils_uuid_generate ();
+ g_object_set (G_OBJECT (s_con),
+ NM_SETTING_CONNECTION_UUID, uuid,
+ NM_SETTING_CONNECTION_ID, "really neat connection",
+ NULL);
+ g_free (uuid);
+
+ s_wired = nm_connection_get_setting_wired (a);
+ g_assert (s_wired);
+ g_object_set (G_OBJECT (s_wired), NM_SETTING_WIRED_MTU, 300, NULL);
+
+ s_ip4 = nm_connection_get_setting_ip4_config (a);
+ g_assert (s_ip4);
+ g_object_set (G_OBJECT (s_ip4), NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, TRUE, NULL);
+
+ /* Make sure the diff returns no results as secrets are ignored */
+ same = nm_connection_diff (a, b, NM_SETTING_COMPARE_FLAG_INFERRABLE, &out_diffs);
+ g_assert (same == TRUE);
+ g_assert (out_diffs == NULL);
+
+ /* And change a INFERRABLE property to ensure that it shows up in the diff results */
+ g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_INTERFACE_NAME, "usb0", NULL);
+
+ /* Make sure the diff returns no results as secrets are ignored */
+ same = nm_connection_diff (a, b, NM_SETTING_COMPARE_FLAG_INFERRABLE, &out_diffs);
+ g_assert (same == FALSE);
+ g_assert (out_diffs != NULL);
+ g_assert (g_hash_table_size (out_diffs) > 0);
+
+ ensure_diffs (out_diffs, settings, ARRAY_LEN (settings));
+
+ g_hash_table_destroy (out_diffs);
+ g_object_unref (a);
+ g_object_unref (b);
+}
+
+static void
add_generic_settings (NMConnection *connection, const char *ctype)
{
NMSetting *setting;
@@ -2150,6 +2210,7 @@ int main (int argc, char **argv)
test_connection_diff_same ();
test_connection_diff_different ();
test_connection_diff_no_secrets ();
+ test_connection_diff_inferrable ();
test_connection_good_base_types ();
test_connection_bad_base_types ();