summary refs log tree commit diff
path: root/src/libnm-core-impl/nm-connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnm-core-impl/nm-connection.c')
-rw-r--r--src/libnm-core-impl/nm-connection.c230
1 files changed, 130 insertions, 100 deletions
diff --git a/src/libnm-core-impl/nm-connection.c b/src/libnm-core-impl/nm-connection.c
index b017a6e5..6ffc750a 100644
--- a/src/libnm-core-impl/nm-connection.c
+++ b/src/libnm-core-impl/nm-connection.c
@@ -276,26 +276,7 @@ nm_connection_remove_setting(NMConnection *connection, GType setting_type)
 }
 
 static gpointer
-_connection_get_setting(NMConnection *connection, GType setting_type)
-{
-    NMSetting               *setting;
-    const NMMetaSettingInfo *setting_info;
-
-    nm_assert(NM_IS_CONNECTION(connection));
-    nm_assert(g_type_is_a(setting_type, NM_TYPE_SETTING));
-
-    setting_info = _nm_meta_setting_info_from_gtype(setting_type);
-    if (!setting_info)
-        g_return_val_if_reached(NULL);
-
-    setting = NM_CONNECTION_GET_PRIVATE(connection)->settings[setting_info->meta_type];
-
-    nm_assert(!setting || G_TYPE_CHECK_INSTANCE_TYPE(setting, setting_type));
-    return setting;
-}
-
-static gpointer
-_connection_get_setting_by_meta_type(NMConnectionPrivate *priv, NMMetaSettingType meta_type)
+_get_setting_by_metatype(NMConnectionPrivate *priv, NMMetaSettingType meta_type)
 {
     nm_assert(priv);
     nm_assert(_NM_INT_NOT_NEGATIVE(meta_type));
@@ -304,20 +285,15 @@ _connection_get_setting_by_meta_type(NMConnectionPrivate *priv, NMMetaSettingTyp
     return priv->settings[meta_type];
 }
 
-static gpointer
-_connection_get_setting_check(NMConnection *connection, GType setting_type)
+/* The "unsafe" part here is that _nm_connection_get_setting_by_metatype() has a compile
+ * time check that meta_type is valid. With the unsafe variant, the caller must ensure that,
+ * and we only get an nm_assert() check -- which is basically nothing. */
+gpointer
+_nm_connection_get_setting_by_metatype_unsafe(NMConnection *connection, NMMetaSettingType meta_type)
 {
     g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
 
-    return _connection_get_setting(connection, setting_type);
-}
-
-static gpointer
-_connection_get_setting_by_meta_type_check(NMConnection *connection, NMMetaSettingType meta_type)
-{
-    g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
-
-    return _connection_get_setting_by_meta_type(NM_CONNECTION_GET_PRIVATE(connection), meta_type);
+    return _get_setting_by_metatype(NM_CONNECTION_GET_PRIVATE(connection), meta_type);
 }
 
 /**
@@ -334,19 +310,34 @@ _connection_get_setting_by_meta_type_check(NMConnection *connection, NMMetaSetti
 NMSetting *
 nm_connection_get_setting(NMConnection *connection, GType setting_type)
 {
-    g_return_val_if_fail(g_type_is_a(setting_type, NM_TYPE_SETTING), NULL);
+    NMSetting               *setting;
+    const NMMetaSettingInfo *setting_info;
 
-    return _connection_get_setting_check(connection, setting_type);
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
+
+    setting_info = _nm_meta_setting_info_from_gtype(setting_type);
+
+    if (!setting_info)
+        g_return_val_if_reached(NULL);
+
+    setting = NM_CONNECTION_GET_PRIVATE(connection)->settings[setting_info->meta_type];
+
+    nm_assert(!setting || G_TYPE_CHECK_INSTANCE_TYPE(setting, setting_type));
+
+    return setting;
 }
 
 NMSettingIPConfig *
 nm_connection_get_setting_ip_config(NMConnection *connection, int addr_family)
 {
+    g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
+
     nm_assert_addr_family(addr_family);
 
-    return NM_SETTING_IP_CONFIG(_connection_get_setting(
-        connection,
-        (addr_family == AF_INET) ? NM_TYPE_SETTING_IP4_CONFIG : NM_TYPE_SETTING_IP6_CONFIG));
+    return NM_SETTING_IP_CONFIG(_get_setting_by_metatype(NM_CONNECTION_GET_PRIVATE(connection),
+                                                         (addr_family == AF_INET)
+                                                             ? NM_META_SETTING_TYPE_IP4_CONFIG
+                                                             : NM_META_SETTING_TYPE_IP6_CONFIG));
 }
 
 /**
@@ -363,12 +354,14 @@ nm_connection_get_setting_ip_config(NMConnection *connection, int addr_family)
 NMSetting *
 nm_connection_get_setting_by_name(NMConnection *connection, const char *name)
 {
-    GType type;
+    const NMMetaSettingInfo *setting_info;
 
     g_return_val_if_fail(NM_IS_CONNECTION(connection), NULL);
 
-    type = nm_setting_lookup_type(name);
-    return type ? _connection_get_setting(connection, type) : NULL;
+    setting_info = nm_meta_setting_infos_by_name(name);
+    return setting_info ? _get_setting_by_metatype(NM_CONNECTION_GET_PRIVATE(connection),
+                                                   setting_info->meta_type)
+                        : NULL;
 }
 
 /*****************************************************************************/
@@ -764,10 +757,11 @@ diff_one_connection(NMConnection         *a,
  * @a: a #NMConnection
  * @b: a second #NMConnection to compare with the first
  * @flags: compare flags, e.g. %NM_SETTING_COMPARE_FLAG_EXACT
- * @out_settings: (element-type utf8 GLib.HashTable): if the
- * connections differ, on return a hash table mapping setting names to
- * second-level GHashTable (utf8 to guint32), which contains the key names that
- * differ mapped to one or more of %NMSettingDiffResult as a bitfield
+ * @out_settings: (out) (element-type utf8 GLib.HashTable(utf8,uint32)) (optional) (nullable):
+ * if the connections differ, on return a hash table
+ * mapping setting names to second-level GHashTable (utf8 to guint32), which
+ * contains the key names that differ mapped to one or more of
+ * %NMSettingDiffResult as a bitfield
  *
  * Compares two #NMConnection objects for similarity, with comparison behavior
  * modified by a set of flags.  See nm_setting_compare() for a description of
@@ -882,6 +876,20 @@ _normalize_connection_uuid(NMConnection *self)
     return TRUE;
 }
 
+static gboolean
+_normalize_connection(NMConnection *self)
+{
+    NMSettingConnection *s_con   = nm_connection_get_setting_connection(self);
+    gboolean             changed = FALSE;
+
+    if (nm_setting_connection_get_read_only(s_con)) {
+        g_object_set(s_con, NM_SETTING_CONNECTION_READ_ONLY, FALSE, NULL);
+        changed = TRUE;
+    }
+
+    return changed;
+}
+
 gboolean
 _nm_setting_connection_verify_secondaries(GArray *secondaries, GError **error)
 {
@@ -1471,6 +1479,28 @@ _normalize_wireless_mac_address_randomization(NMConnection *self)
 }
 
 static gboolean
+_normalize_wireless(NMConnection *self)
+{
+    NMSettingWireless *s_wifi  = nm_connection_get_setting_wireless(self);
+    gboolean           changed = FALSE;
+
+    if (!s_wifi)
+        return FALSE;
+
+    if (nm_setting_wireless_get_rate(s_wifi) != 0) {
+        g_object_set(s_wifi, NM_SETTING_WIRELESS_RATE, 0u, NULL);
+        changed = TRUE;
+    }
+
+    if (nm_setting_wireless_get_tx_power(s_wifi) != 0) {
+        g_object_set(s_wifi, NM_SETTING_WIRELESS_TX_POWER, 0u, NULL);
+        changed = TRUE;
+    }
+
+    return changed;
+}
+
+static gboolean
 _normalize_macsec(NMConnection *self)
 {
     NMSettingMacsec *s_macsec = nm_connection_get_setting_macsec(self);
@@ -1658,8 +1688,8 @@ _normalize_802_1x_empty_strings(NMConnection *self)
     NMSetting8021x *s_8021x;
     gboolean        changed = FALSE;
 
-    s_8021x = _connection_get_setting_by_meta_type(NM_CONNECTION_GET_PRIVATE(self),
-                                                   NM_META_SETTING_TYPE_802_1X);
+    s_8021x =
+        _get_setting_by_metatype(NM_CONNECTION_GET_PRIVATE(self), NM_META_SETTING_TYPE_802_1X);
     if (!s_8021x)
         return FALSE;
 
@@ -1809,7 +1839,7 @@ _nm_connection_verify(NMConnection *connection, GError **error)
 
     priv = NM_CONNECTION_GET_PRIVATE(connection);
 
-    if (!_connection_get_setting_by_meta_type(priv, NM_META_SETTING_TYPE_CONNECTION)) {
+    if (!_get_setting_by_metatype(priv, NM_META_SETTING_TYPE_CONNECTION)) {
         g_set_error_literal(error,
                             NM_CONNECTION_ERROR,
                             NM_CONNECTION_ERROR_MISSING_SETTING,
@@ -1854,9 +1884,9 @@ _nm_connection_verify(NMConnection *connection, GError **error)
         g_clear_error(&verify_error);
     }
 
-    s_ip4   = _connection_get_setting_by_meta_type(priv, NM_META_SETTING_TYPE_IP4_CONFIG);
-    s_ip6   = _connection_get_setting_by_meta_type(priv, NM_META_SETTING_TYPE_IP6_CONFIG);
-    s_proxy = _connection_get_setting_by_meta_type(priv, NM_META_SETTING_TYPE_PROXY);
+    s_ip4   = _get_setting_by_metatype(priv, NM_META_SETTING_TYPE_IP4_CONFIG);
+    s_ip6   = _get_setting_by_metatype(priv, NM_META_SETTING_TYPE_IP6_CONFIG);
+    s_proxy = _get_setting_by_metatype(priv, NM_META_SETTING_TYPE_PROXY);
 
     nm_assert(normalizable_error_type != NM_SETTING_VERIFY_ERROR);
     if (NM_IN_SET(normalizable_error_type,
@@ -2005,6 +2035,7 @@ _connection_normalize(NMConnection *connection,
     was_modified |= _normalize_connection_type(connection);
     was_modified |= _normalize_connection_slave_type(connection);
     was_modified |= _normalize_connection_secondaries(connection);
+    was_modified |= _normalize_connection(connection);
     was_modified |= _normalize_required_settings(connection);
     was_modified |= _normalize_invalid_slave_port_settings(connection);
     was_modified |= _normalize_ip_config(connection, parameters);
@@ -2013,6 +2044,7 @@ _connection_normalize(NMConnection *connection,
     was_modified |= _normalize_bond_mode(connection);
     was_modified |= _normalize_bond_options(connection);
     was_modified |= _normalize_wireless_mac_address_randomization(connection);
+    was_modified |= _normalize_wireless(connection);
     was_modified |= _normalize_macsec(connection);
     was_modified |= _normalize_team_config(connection);
     was_modified |= _normalize_team_port_config(connection);
@@ -2057,12 +2089,12 @@ _connection_normalize(NMConnection *connection,
 /**
  * nm_connection_normalize:
  * @connection: the #NMConnection to normalize
- * @parameters: (allow-none) (element-type utf8 gpointer): a #GHashTable with
+ * @parameters: (nullable) (element-type utf8 gpointer): a #GHashTable with
  * normalization parameters to allow customization of the normalization by providing
  * specific arguments. Unknown arguments will be ignored and the default will be
  * used. The keys must be strings compared with g_str_equal() function.
  * The values are opaque and depend on the parameter name.
- * @modified: (out) (allow-none): outputs whether any settings were modified.
+ * @modified: (out) (optional): outputs whether any settings were modified.
  * @error: location to store error, or %NULL. Contains the reason,
  * why the connection is invalid, if the function returns an error.
  *
@@ -2413,7 +2445,7 @@ _need_secrets(NMConnection *connection, gboolean check_rerequest, GPtrArray **hi
 /**
  * nm_connection_need_secrets:
  * @connection: the #NMConnection
- * @hints: (out) (element-type utf8) (allow-none) (transfer container):
+ * @hints: (out) (element-type utf8) (nullable) (transfer container):
  *   the address of a pointer to a #GPtrArray, initialized to %NULL, which on
  *   return points to an allocated #GPtrArray containing the property names of
  *   secrets of the #NMSetting which may be required; the caller owns the array
@@ -2426,8 +2458,8 @@ _need_secrets(NMConnection *connection, gboolean check_rerequest, GPtrArray **hi
  * circumstances, there is no way to conclusively determine exactly which
  * secrets are needed.
  *
- * Returns: the setting name of the #NMSetting object which has invalid or
- *   missing secrets
+ * Returns: (nullable): the setting name of the #NMSetting object which has
+ *   invalid or missing secrets
  **/
 const char *
 nm_connection_need_secrets(NMConnection *connection, GPtrArray **hints)
@@ -2442,7 +2474,7 @@ nm_connection_need_secrets(NMConnection *connection, GPtrArray **hints)
  * nm_connection_need_secrets_for_rerequest:
  * @connection: the #NMConnection
  *
- * Returns TRUE if some secret needs to be re-requested
+ * Returns: %TRUE if some secret needs to be re-requested
  **/
 gboolean
 nm_connection_need_secrets_for_rerequest(NMConnection *connection)
@@ -2468,7 +2500,7 @@ nm_connection_clear_secrets(NMConnection *connection)
 /**
  * nm_connection_clear_secrets_with_flags:
  * @connection: the #NMConnection
- * @func: (scope call) (allow-none): function to be called to determine whether a
+ * @func: (scope call) (nullable): function to be called to determine whether a
  *     specific secret should be cleared or not. If %NULL, all secrets are cleared.
  * @user_data: caller-supplied data passed to @func
  *
@@ -2780,15 +2812,14 @@ _nm_connection_get_settings_arr(NMConnection *connection)
 /**
  * nm_connection_get_settings:
  * @connection: the #NMConnection instance
- * @out_length: (allow-none) (out): the length of the returned array
+ * @out_length: (out) (optional): the length of the returned array
  *
  * Retrieves the settings in @connection.
  *
  * The returned array is %NULL-terminated.
  *
- * Returns: (array length=out_length) (transfer container): a
- *   %NULL-terminated array containing every setting of
- *   @connection.
+ * Returns: (array length=out_length) (transfer container) (nullable): a
+ *   %NULL-terminated array containing every setting of @connection.
  *   If the connection has no settings, %NULL is returned.
  *
  * Since: 1.10
@@ -3247,7 +3278,7 @@ nm_connection_get_virtual_device_description(NMConnection *connection)
 NMSetting8021x *
 nm_connection_get_setting_802_1x(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_802_1X);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_802_1X);
 }
 
 /**
@@ -3261,7 +3292,7 @@ nm_connection_get_setting_802_1x(NMConnection *connection)
 NMSettingBluetooth *
 nm_connection_get_setting_bluetooth(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_BLUETOOTH);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_BLUETOOTH);
 }
 
 /**
@@ -3275,7 +3306,7 @@ nm_connection_get_setting_bluetooth(NMConnection *connection)
 NMSettingBond *
 nm_connection_get_setting_bond(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_BOND);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_BOND);
 }
 
 /**
@@ -3289,7 +3320,7 @@ nm_connection_get_setting_bond(NMConnection *connection)
 NMSettingTeam *
 nm_connection_get_setting_team(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_TEAM);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_TEAM);
 }
 
 /**
@@ -3303,7 +3334,7 @@ nm_connection_get_setting_team(NMConnection *connection)
 NMSettingTeamPort *
 nm_connection_get_setting_team_port(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_TEAM_PORT);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_TEAM_PORT);
 }
 
 /**
@@ -3317,7 +3348,7 @@ nm_connection_get_setting_team_port(NMConnection *connection)
 NMSettingBridge *
 nm_connection_get_setting_bridge(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_BRIDGE);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_BRIDGE);
 }
 
 /**
@@ -3331,7 +3362,7 @@ nm_connection_get_setting_bridge(NMConnection *connection)
 NMSettingCdma *
 nm_connection_get_setting_cdma(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_CDMA);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_CDMA);
 }
 
 /**
@@ -3345,7 +3376,7 @@ nm_connection_get_setting_cdma(NMConnection *connection)
 NMSettingConnection *
 nm_connection_get_setting_connection(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_CONNECTION);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_CONNECTION);
 }
 
 /**
@@ -3359,7 +3390,7 @@ nm_connection_get_setting_connection(NMConnection *connection)
 NMSettingDcb *
 nm_connection_get_setting_dcb(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_DCB);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_DCB);
 }
 
 /**
@@ -3375,7 +3406,7 @@ nm_connection_get_setting_dcb(NMConnection *connection)
 NMSettingDummy *
 nm_connection_get_setting_dummy(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_DUMMY);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_DUMMY);
 }
 
 /**
@@ -3389,7 +3420,7 @@ nm_connection_get_setting_dummy(NMConnection *connection)
 NMSettingGeneric *
 nm_connection_get_setting_generic(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_GENERIC);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_GENERIC);
 }
 
 /**
@@ -3403,7 +3434,7 @@ nm_connection_get_setting_generic(NMConnection *connection)
 NMSettingGsm *
 nm_connection_get_setting_gsm(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_GSM);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_GSM);
 }
 
 /**
@@ -3417,7 +3448,7 @@ nm_connection_get_setting_gsm(NMConnection *connection)
 NMSettingInfiniband *
 nm_connection_get_setting_infiniband(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_INFINIBAND);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_INFINIBAND);
 }
 
 /**
@@ -3436,7 +3467,7 @@ nm_connection_get_setting_infiniband(NMConnection *connection)
 NMSettingIPConfig *
 nm_connection_get_setting_ip4_config(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_IP4_CONFIG);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_IP4_CONFIG);
 }
 
 /**
@@ -3452,7 +3483,7 @@ nm_connection_get_setting_ip4_config(NMConnection *connection)
 NMSettingIPTunnel *
 nm_connection_get_setting_ip_tunnel(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_IP_TUNNEL);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_IP_TUNNEL);
 }
 
 /**
@@ -3471,7 +3502,7 @@ nm_connection_get_setting_ip_tunnel(NMConnection *connection)
 NMSettingIPConfig *
 nm_connection_get_setting_ip6_config(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_IP6_CONFIG);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_IP6_CONFIG);
 }
 
 /**
@@ -3487,7 +3518,7 @@ nm_connection_get_setting_ip6_config(NMConnection *connection)
 NMSettingMacsec *
 nm_connection_get_setting_macsec(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_MACSEC);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_MACSEC);
 }
 
 /**
@@ -3503,7 +3534,7 @@ nm_connection_get_setting_macsec(NMConnection *connection)
 NMSettingMacvlan *
 nm_connection_get_setting_macvlan(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_MACVLAN);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_MACVLAN);
 }
 
 /**
@@ -3517,7 +3548,7 @@ nm_connection_get_setting_macvlan(NMConnection *connection)
 NMSettingOlpcMesh *
 nm_connection_get_setting_olpc_mesh(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_OLPC_MESH);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_OLPC_MESH);
 }
 
 /**
@@ -3533,7 +3564,7 @@ nm_connection_get_setting_olpc_mesh(NMConnection *connection)
 NMSettingOvsBridge *
 nm_connection_get_setting_ovs_bridge(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_OVS_BRIDGE);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_OVS_BRIDGE);
 }
 
 /**
@@ -3549,8 +3580,7 @@ nm_connection_get_setting_ovs_bridge(NMConnection *connection)
 NMSettingOvsInterface *
 nm_connection_get_setting_ovs_interface(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection,
-                                                      NM_META_SETTING_TYPE_OVS_INTERFACE);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_OVS_INTERFACE);
 }
 
 /**
@@ -3566,7 +3596,7 @@ nm_connection_get_setting_ovs_interface(NMConnection *connection)
 NMSettingOvsPatch *
 nm_connection_get_setting_ovs_patch(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_OVS_PATCH);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_OVS_PATCH);
 }
 
 /**
@@ -3582,7 +3612,7 @@ nm_connection_get_setting_ovs_patch(NMConnection *connection)
 NMSettingOvsPort *
 nm_connection_get_setting_ovs_port(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_OVS_PORT);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_OVS_PORT);
 }
 
 /**
@@ -3596,7 +3626,7 @@ nm_connection_get_setting_ovs_port(NMConnection *connection)
 NMSettingPpp *
 nm_connection_get_setting_ppp(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_PPP);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_PPP);
 }
 
 /**
@@ -3610,7 +3640,7 @@ nm_connection_get_setting_ppp(NMConnection *connection)
 NMSettingPppoe *
 nm_connection_get_setting_pppoe(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_PPPOE);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_PPPOE);
 }
 
 /**
@@ -3626,7 +3656,7 @@ nm_connection_get_setting_pppoe(NMConnection *connection)
 NMSettingProxy *
 nm_connection_get_setting_proxy(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_PROXY);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_PROXY);
 }
 
 /**
@@ -3640,7 +3670,7 @@ nm_connection_get_setting_proxy(NMConnection *connection)
 NMSettingSerial *
 nm_connection_get_setting_serial(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_SERIAL);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_SERIAL);
 }
 
 /**
@@ -3656,7 +3686,7 @@ nm_connection_get_setting_serial(NMConnection *connection)
 NMSettingTCConfig *
 nm_connection_get_setting_tc_config(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_TC_CONFIG);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_TC_CONFIG);
 }
 
 /**
@@ -3672,7 +3702,7 @@ nm_connection_get_setting_tc_config(NMConnection *connection)
 NMSettingTun *
 nm_connection_get_setting_tun(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_TUN);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_TUN);
 }
 
 /**
@@ -3686,7 +3716,7 @@ nm_connection_get_setting_tun(NMConnection *connection)
 NMSettingVpn *
 nm_connection_get_setting_vpn(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_VPN);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_VPN);
 }
 
 /**
@@ -3702,7 +3732,7 @@ nm_connection_get_setting_vpn(NMConnection *connection)
 NMSettingVxlan *
 nm_connection_get_setting_vxlan(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_VXLAN);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_VXLAN);
 }
 
 /**
@@ -3716,7 +3746,7 @@ nm_connection_get_setting_vxlan(NMConnection *connection)
 NMSettingWimax *
 nm_connection_get_setting_wimax(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_WIMAX);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_WIMAX);
 }
 
 /**
@@ -3730,7 +3760,7 @@ nm_connection_get_setting_wimax(NMConnection *connection)
 NMSettingWired *
 nm_connection_get_setting_wired(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_WIRED);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_WIRED);
 }
 
 /**
@@ -3744,7 +3774,7 @@ nm_connection_get_setting_wired(NMConnection *connection)
 NMSettingAdsl *
 nm_connection_get_setting_adsl(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_ADSL);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_ADSL);
 }
 
 /**
@@ -3758,7 +3788,7 @@ nm_connection_get_setting_adsl(NMConnection *connection)
 NMSettingWireless *
 nm_connection_get_setting_wireless(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_WIRELESS);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_WIRELESS);
 }
 
 /**
@@ -3772,8 +3802,8 @@ nm_connection_get_setting_wireless(NMConnection *connection)
 NMSettingWirelessSecurity *
 nm_connection_get_setting_wireless_security(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection,
-                                                      NM_META_SETTING_TYPE_WIRELESS_SECURITY);
+    return _nm_connection_get_setting_by_metatype(connection,
+                                                  NM_META_SETTING_TYPE_WIRELESS_SECURITY);
 }
 
 /**
@@ -3787,7 +3817,7 @@ nm_connection_get_setting_wireless_security(NMConnection *connection)
 NMSettingBridgePort *
 nm_connection_get_setting_bridge_port(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_BRIDGE_PORT);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_BRIDGE_PORT);
 }
 
 /**
@@ -3801,7 +3831,7 @@ nm_connection_get_setting_bridge_port(NMConnection *connection)
 NMSettingVlan *
 nm_connection_get_setting_vlan(NMConnection *connection)
 {
-    return _connection_get_setting_by_meta_type_check(connection, NM_META_SETTING_TYPE_VLAN);
+    return _nm_connection_get_setting_by_metatype(connection, NM_META_SETTING_TYPE_VLAN);
 }
 
 NMSettingBluetooth *