diff options
author | Thomas Haller <thaller@redhat.com> | 2015-04-20 22:21:59 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-04-21 11:38:00 +0200 |
commit | 982958612b5bcbca2abb0ae03bb6c131c2791561 (patch) | |
tree | add34e4c0dd7718b1d514de717777d663e2e14b6 | |
parent | f844dcc3c06ba6eaa9d17be7db0cc2e15161cc7c (diff) | |
download | NetworkManager-982958612b5bcbca2abb0ae03bb6c131c2791561.tar.gz |
fixup! platform: add self argument to platform functions
I prefer this version with NM_PLATFORM_GET, over defining
a "SINGLETON" name.
The advantage of having "NM_PLATFORM_GET" over "nm_platform_get ()"
is that the former is one word (without brackets) that the editor
auto-completes.
46 files changed, 505 insertions, 509 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index 86bd8ec047..3153edc77c 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -1302,7 +1302,7 @@ get_new_connection_ifname (const GSList *existing, for (i = 0; i < 500; i++) { name = g_strdup_printf ("%s%d", prefix, i); - if (nm_platform_link_exists (SINGLETON, name)) + if (nm_platform_link_exists (NM_PLATFORM_GET, name)) goto next; for (iter = existing, found = FALSE; iter; iter = g_slist_next (iter)) { diff --git a/src/devices/adsl/nm-device-adsl.c b/src/devices/adsl/nm-device-adsl.c index 99689f9035..fe26adbfcf 100644 --- a/src/devices/adsl/nm-device-adsl.c +++ b/src/devices/adsl/nm-device-adsl.c @@ -144,7 +144,7 @@ set_nas_iface (NMDeviceAdsl *self, int idx, const char *name) g_return_if_fail (name != NULL); g_warn_if_fail (priv->nas_ifindex <= 0); - priv->nas_ifindex = idx > 0 ? idx : nm_platform_link_get_ifindex (SINGLETON, name); + priv->nas_ifindex = idx > 0 ? idx : nm_platform_link_get_ifindex (NM_PLATFORM_GET, name); g_warn_if_fail (priv->nas_ifindex > 0); g_warn_if_fail (priv->nas_ifname == NULL); @@ -352,7 +352,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_reason) _LOGD (LOGD_ADSL, "ATM setup successful"); /* otherwise we're good for stage3 */ - nm_platform_link_set_up (SINGLETON, priv->nas_ifindex); + nm_platform_link_set_up (NM_PLATFORM_GET, priv->nas_ifindex); ret = NM_ACT_STAGE_RETURN_SUCCESS; } else if (g_strcmp0 (protocol, NM_SETTING_ADSL_PROTOCOL_PPPOA) == 0) { @@ -492,7 +492,7 @@ carrier_update_cb (gpointer user_data) path = g_strdup_printf ("/sys/class/atm/%s/carrier", ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (NM_DEVICE (self)))); - carrier = (int) nm_platform_sysctl_get_int_checked (SINGLETON, path, 10, 0, 1, -1); + carrier = (int) nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, path, 10, 0, 1, -1); g_free (path); if (carrier != -1) @@ -526,7 +526,7 @@ get_atm_index (const char *iface) path = g_strdup_printf ("/sys/class/atm/%s/atmindex", ASSERT_VALID_PATH_COMPONENT (iface)); - idx = (int) nm_platform_sysctl_get_int_checked (SINGLETON, path, 10, 0, G_MAXINT, -1); + idx = (int) nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET, path, 10, 0, G_MAXINT, -1); g_free (path); return idx; diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 430e13bb64..b41bd14eee 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -143,7 +143,7 @@ set_bond_attr (NMDevice *device, const char *attr, const char *value) gboolean ret; int ifindex = nm_device_get_ifindex (device); - ret = nm_platform_master_set_option (SINGLETON, ifindex, attr, value); + ret = nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, attr, value); if (!ret) _LOGW (LOGD_HW, "failed to set bonding attribute '%s' to '%s'", attr, value); return ret; @@ -177,7 +177,7 @@ update_connection (NMDevice *device, NMConnection *connection) /* Read bond options from sysfs and update the Bond setting to match */ options = nm_setting_bond_get_valid_options (s_bond); while (options && *options) { - gs_free char *value = nm_platform_master_get_option (SINGLETON, ifindex, *options); + gs_free char *value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, *options); const char *defvalue = nm_setting_bond_get_option_default (s_bond, *options); if (value && !ignore_if_zero (*options, value) && (g_strcmp0 (value, defvalue) != 0)) { @@ -333,7 +333,7 @@ apply_bonding_config (NMDevice *device) } /* Clear ARP targets */ - contents = nm_platform_master_get_option (SINGLETON, ifindex, "arp_ip_target"); + contents = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "arp_ip_target"); set_arp_targets (device, contents, " \n", "-"); g_free (contents); @@ -409,7 +409,7 @@ enslave_slave (NMDevice *device, if (configure) { nm_device_take_down (slave, TRUE); - success = nm_platform_link_enslave (SINGLETON, + success = nm_platform_link_enslave (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)); nm_device_bring_up (slave, TRUE, &no_firmware); @@ -434,7 +434,7 @@ release_slave (NMDevice *device, gboolean success = TRUE, no_firmware = FALSE; if (configure) { - success = nm_platform_link_release (SINGLETON, + success = nm_platform_link_release (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)); @@ -581,11 +581,11 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, iface = nm_connection_get_interface_name (connection); g_return_val_if_fail (iface != NULL, NULL); - if ( !nm_platform_bond_add (SINGLETON, iface) - && nm_platform_get_error (SINGLETON) != NM_PLATFORM_ERROR_EXISTS) { + if ( !nm_platform_bond_add (NM_PLATFORM_GET, iface) + && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { nm_log_warn (LOGD_DEVICE | LOGD_BOND, "(%s): failed to create bonding master interface for '%s': %s", iface, nm_connection_get_id (connection), - nm_platform_get_error_msg (SINGLETON)); + nm_platform_get_error_msg (NM_PLATFORM_GET)); return NULL; } diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index d7d8fe9e07..0d9a76c466 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -212,9 +212,9 @@ commit_option (NMDevice *device, NMSetting *setting, const Option *option, gbool value = g_strdup_printf ("%u", uval); if (slave) - nm_platform_slave_set_option (SINGLETON, ifindex, option->sysname, value); + nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, option->sysname, value); else - nm_platform_master_set_option (SINGLETON, ifindex, option->sysname, value); + nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, option->sysname, value); } static void @@ -258,7 +258,7 @@ update_connection (NMDevice *device, NMConnection *connection) } for (option = master_options; option->name; option++) { - gs_free char *str = nm_platform_master_get_option (SINGLETON, ifindex, option->sysname); + gs_free char *str = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, option->sysname); int value; if (str) { @@ -297,7 +297,7 @@ master_update_slave_connection (NMDevice *device, } for (option = slave_options; option->name; option++) { - gs_free char *str = nm_platform_slave_get_option (SINGLETON, ifindex_slave, option->sysname); + gs_free char *str = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex_slave, option->sysname); int value; if (str) { @@ -345,7 +345,7 @@ enslave_slave (NMDevice *device, NMDeviceBridge *self = NM_DEVICE_BRIDGE (device); if (configure) { - if (!nm_platform_link_enslave (SINGLETON, nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave))) + if (!nm_platform_link_enslave (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave))) return FALSE; commit_slave_options (slave, nm_connection_get_setting_bridge_port (connection)); @@ -371,7 +371,7 @@ release_slave (NMDevice *device, gboolean success = TRUE; if (configure) { - success = nm_platform_link_release (SINGLETON, + success = nm_platform_link_release (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)); @@ -519,14 +519,14 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, mac_address_str = NULL; } - if ( !nm_platform_bridge_add (SINGLETON, + if ( !nm_platform_bridge_add (NM_PLATFORM_GET, iface, mac_address_str ? mac_address : NULL, mac_address_str ? ETH_ALEN : 0) - && nm_platform_get_error (SINGLETON) != NM_PLATFORM_ERROR_EXISTS) { + && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { nm_log_warn (LOGD_DEVICE | LOGD_BRIDGE, "(%s): failed to create bridge master interface for '%s': %s", iface, nm_connection_get_id (connection), - nm_platform_get_error_msg (SINGLETON)); + nm_platform_get_error_msg (NM_PLATFORM_GET)); return NULL; } diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index 376b368597..05bde3584d 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -210,7 +210,7 @@ _update_s390_subchannels (NMDeviceEthernet *self) || !strcmp (item, "portno")) { char *path, *value; path = g_strdup_printf ("%s/%s", parent_path, item); - value = nm_platform_sysctl_get (SINGLETON, path); + value = nm_platform_sysctl_get (NM_PLATFORM_GET, path); if (value && *value) g_hash_table_insert (priv->s390_options, g_strdup (item), g_strdup (value)); else @@ -263,7 +263,7 @@ constructor (GType type, if (object) { #ifndef G_DISABLE_ASSERT int ifindex = nm_device_get_ifindex (NM_DEVICE (object)); - NMLinkType link_type = nm_platform_link_get_type (SINGLETON, ifindex); + NMLinkType link_type = nm_platform_link_get_type (NM_PLATFORM_GET, ifindex); g_assert ( link_type == NM_LINK_TYPE_ETHERNET || link_type == NM_LINK_TYPE_VETH @@ -375,7 +375,7 @@ get_generic_capabilities (NMDevice *device) { NMDeviceEthernet *self = NM_DEVICE_ETHERNET (device); - if (nm_platform_link_supports_carrier_detect (SINGLETON, nm_device_get_ifindex (device))) + if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, nm_device_get_ifindex (device))) return NM_DEVICE_CAP_CARRIER_DETECT; else { _LOGI (LOGD_HW, "driver '%s' does not support carrier detection.", @@ -1160,7 +1160,7 @@ dcb_state (NMDevice *device, gboolean timeout) g_return_if_fail (nm_device_get_state (device) == NM_DEVICE_STATE_CONFIG); - carrier = nm_platform_link_is_connected (SINGLETON, nm_device_get_ifindex (device)); + carrier = nm_platform_link_is_connected (NM_PLATFORM_GET, nm_device_get_ifindex (device)); _LOGD (LOGD_DCB, "dcb_state() wait %d carrier %d timeout %d", priv->dcb_wait, carrier, timeout); switch (priv->dcb_wait) { @@ -1278,7 +1278,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) s_dcb = (NMSettingDcb *) device_get_setting (device, NM_TYPE_SETTING_DCB); if (s_dcb) { /* lldpad really really wants the carrier to be up */ - if (nm_platform_link_is_connected (SINGLETON, nm_device_get_ifindex (device))) { + if (nm_platform_link_is_connected (NM_PLATFORM_GET, nm_device_get_ifindex (device))) { if (!dcb_enable (device)) { *reason = NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED; return NM_ACT_STAGE_RETURN_FAILURE; diff --git a/src/devices/nm-device-generic.c b/src/devices/nm-device-generic.c index 18f725d64c..8b328e07fe 100644 --- a/src/devices/nm-device-generic.c +++ b/src/devices/nm-device-generic.c @@ -48,7 +48,7 @@ enum { static NMDeviceCapabilities get_generic_capabilities (NMDevice *dev) { - if (nm_platform_link_supports_carrier_detect (SINGLETON, nm_device_get_ifindex (dev))) + if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, nm_device_get_ifindex (dev))) return NM_DEVICE_CAP_CARRIER_DETECT; else return NM_DEVICE_CAP_NONE; @@ -117,7 +117,7 @@ constructed (GObject *object) int ifindex = nm_device_get_ip_ifindex (NM_DEVICE (self)); if (ifindex != 0) - priv->type_description = g_strdup (nm_platform_link_get_type_name (SINGLETON, ifindex)); + priv->type_description = g_strdup (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex)); } G_OBJECT_CLASS (nm_device_generic_parent_class)->constructed (object); diff --git a/src/devices/nm-device-gre.c b/src/devices/nm-device-gre.c index 47cad8cc82..6313bfd714 100644 --- a/src/devices/nm-device-gre.c +++ b/src/devices/nm-device-gre.c @@ -71,7 +71,7 @@ update_properties (NMDevice *device) GObject *object = G_OBJECT (device); NMPlatformGreProperties props; - if (!nm_platform_gre_get_properties (SINGLETON, nm_device_get_ifindex (device), &props)) { + if (!nm_platform_gre_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) { _LOGW (LOGD_HW, "could not read gre properties"); return; } diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index 6a36584d91..0a3b17c708 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -105,7 +105,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) } } - ok = nm_platform_sysctl_set (SINGLETON, mode_path, transport_mode); + ok = nm_platform_sysctl_set (NM_PLATFORM_GET, mode_path, transport_mode); g_free (mode_path); if (!ok) { @@ -226,7 +226,7 @@ update_connection (NMDevice *device, NMConnection *connection) mode_path = g_strdup_printf ("/sys/class/net/%s/mode", ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (device))); - contents = nm_platform_sysctl_get (SINGLETON, mode_path); + contents = nm_platform_sysctl_get (NM_PLATFORM_GET, mode_path); g_free (mode_path); if (contents) { if (strstr (contents, "datagram")) @@ -328,11 +328,11 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, parent_ifindex = nm_device_get_ifindex (parent); p_key = nm_setting_infiniband_get_p_key (s_infiniband); - if ( !nm_platform_infiniband_partition_add (SINGLETON, parent_ifindex, p_key) - && nm_platform_get_error (SINGLETON) != NM_PLATFORM_ERROR_EXISTS) { + if ( !nm_platform_infiniband_partition_add (NM_PLATFORM_GET, parent_ifindex, p_key) + && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { nm_log_warn (LOGD_DEVICE | LOGD_INFINIBAND, "(%s): failed to add InfiniBand P_Key interface for '%s': %s", iface, nm_connection_get_id (connection), - nm_platform_get_error_msg (SINGLETON)); + nm_platform_get_error_msg (NM_PLATFORM_GET)); return NULL; } diff --git a/src/devices/nm-device-macvlan.c b/src/devices/nm-device-macvlan.c index 15ab56617d..608e541db0 100644 --- a/src/devices/nm-device-macvlan.c +++ b/src/devices/nm-device-macvlan.c @@ -64,7 +64,7 @@ update_properties (NMDevice *device) GObject *object = G_OBJECT (device); NMPlatformMacvlanProperties props; - if (!nm_platform_macvlan_get_properties (SINGLETON, nm_device_get_ifindex (device), &props)) { + if (!nm_platform_macvlan_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) { _LOGW (LOGD_HW, "could not read macvlan properties"); return; } diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index ffa56923d3..4f4ed69b25 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -65,7 +65,7 @@ reload_tun_properties (NMDeviceTun *self) GObject *object = G_OBJECT (self); NMPlatformTunProperties props; - if (!nm_platform_tun_get_properties (SINGLETON, nm_device_get_ifindex (NM_DEVICE (self)), &props)) { + if (!nm_platform_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), &props)) { _LOGD (LOGD_HW, "could not read tun properties"); return; } @@ -123,7 +123,7 @@ constructed (GObject *object) gboolean properties_read; NMDeviceTunPrivate *priv = NM_DEVICE_TUN_GET_PRIVATE (self); - properties_read = nm_platform_tun_get_properties (SINGLETON, nm_device_get_ifindex (NM_DEVICE (self)), &priv->props); + properties_read = nm_platform_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), &priv->props); G_OBJECT_CLASS (nm_device_tun_parent_class)->constructed (object); diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c index 92c4900107..7650502c2d 100644 --- a/src/devices/nm-device-veth.c +++ b/src/devices/nm-device-veth.c @@ -82,7 +82,7 @@ get_peer (NMDeviceVeth *self) if (priv->ever_had_peer) return priv->peer; - if (!nm_platform_veth_get_properties (SINGLETON, nm_device_get_ifindex (device), &props)) { + if (!nm_platform_veth_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) { _LOGW (LOGD_HW, "could not read veth properties"); return NULL; } diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 5b769972ef..34fa585488 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -281,7 +281,7 @@ update_connection (NMDevice *device, NMConnection *connection) nm_connection_add_setting (connection, (NMSetting *) s_vlan); } - if (!nm_platform_vlan_get_info (SINGLETON, ifindex, &parent_ifindex, &vlan_id)) { + if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &parent_ifindex, &vlan_id)) { _LOGW (LOGD_VLAN, "failed to get VLAN interface info while updating connection."); return; } @@ -353,12 +353,12 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason) num = nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_INGRESS_MAP); for (i = 0; i < num; i++) { if (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_INGRESS_MAP, i, &from, &to)) - nm_platform_vlan_set_ingress_map (SINGLETON, ifindex, from, to); + nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, from, to); } num = nm_setting_vlan_get_num_priorities (s_vlan, NM_VLAN_EGRESS_MAP); for (i = 0; i < num; i++) { if (nm_setting_vlan_get_priority (s_vlan, NM_VLAN_EGRESS_MAP, i, &from, &to)) - nm_platform_vlan_set_egress_map (SINGLETON, ifindex, from, to); + nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, from, to); } } @@ -437,14 +437,14 @@ constructed (GObject *object) return; } - itype = nm_platform_link_get_type (SINGLETON, ifindex); + itype = nm_platform_link_get_type (NM_PLATFORM_GET, ifindex); if (itype != NM_LINK_TYPE_VLAN) { _LOGE (LOGD_VLAN, "failed to get VLAN interface type."); priv->invalid = TRUE; return; } - if (!nm_platform_vlan_get_info (SINGLETON, ifindex, &parent_ifindex, &vlan_id)) { + if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &parent_ifindex, &vlan_id)) { _LOGW (LOGD_VLAN, "failed to get VLAN interface info."); priv->invalid = TRUE; return; @@ -603,7 +603,7 @@ new_link (NMDeviceFactory *factory, NMPlatformLink *plink, GError **error) return NULL; /* Have to find the parent device */ - if (!nm_platform_vlan_get_info (SINGLETON, plink->ifindex, &parent_ifindex, NULL)) { + if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, plink->ifindex, &parent_ifindex, NULL)) { nm_log_err (LOGD_HW, "(%s): failed to get VLAN parent ifindex", plink->name); return NULL; } @@ -662,12 +662,12 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, nm_setting_vlan_get_id (s_vlan)); } - if ( !nm_platform_vlan_add (SINGLETON, + if ( !nm_platform_vlan_add (NM_PLATFORM_GET, iface, nm_device_get_ifindex (parent), nm_setting_vlan_get_id (s_vlan), nm_setting_vlan_get_flags (s_vlan)) - && nm_platform_get_error (SINGLETON) != NM_PLATFORM_ERROR_EXISTS) { + && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { nm_log_warn (LOGD_DEVICE | LOGD_VLAN, "(%s) failed to add VLAN interface for '%s'", iface, nm_connection_get_id (connection)); g_free (iface); diff --git a/src/devices/nm-device-vxlan.c b/src/devices/nm-device-vxlan.c index 1b97164b9a..25ee804dfa 100644 --- a/src/devices/nm-device-vxlan.c +++ b/src/devices/nm-device-vxlan.c @@ -76,7 +76,7 @@ update_properties (NMDevice *device) GObject *object = G_OBJECT (device); NMPlatformVxlanProperties props; - if (!nm_platform_vxlan_get_properties (SINGLETON, nm_device_get_ifindex (device), &props)) { + if (!nm_platform_vxlan_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) { _LOGW (LOGD_HW, "could not read vxlan properties"); return; } diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 465a38b910..1de4e4730b 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -466,13 +466,13 @@ reason_to_string (NMDeviceStateReason reason) gboolean nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value) { - return nm_platform_sysctl_set (SINGLETON, nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value); + return nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), value); } static guint32 nm_device_ipv6_sysctl_get_int32 (NMDevice *self, const char *property, gint32 fallback) { - return nm_platform_sysctl_get_int32 (SINGLETON, nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), fallback); + return nm_platform_sysctl_get_int32 (NM_PLATFORM_GET, nm_utils_ip6_property_path (nm_device_get_ip_iface (self), property), fallback); } gboolean @@ -580,13 +580,13 @@ nm_device_set_ip_iface (NMDevice *self, const char *iface) priv->ip_iface = g_strdup (iface); if (priv->ip_iface) { - priv->ip_ifindex = nm_platform_link_get_ifindex (SINGLETON, priv->ip_iface); + priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface); if (priv->ip_ifindex > 0) { - if (nm_platform_check_support_user_ipv6ll (SINGLETON)) - nm_platform_link_set_user_ipv6ll_enabled (SINGLETON, priv->ip_ifindex, TRUE); + if (nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET)) + nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, priv->ip_ifindex, TRUE); - if (!nm_platform_link_is_up (SINGLETON, priv->ip_ifindex)) - nm_platform_link_set_up (SINGLETON, priv->ip_ifindex); + if (!nm_platform_link_is_up (NM_PLATFORM_GET, priv->ip_ifindex)) + nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex); } else { /* Device IP interface must always be a kernel network interface */ _LOGW (LOGD_HW, "failed to look up interface index"); @@ -616,10 +616,10 @@ get_ip_iface_identifier (NMDevice *self, NMUtilsIPv6IfaceId *out_iid) ifindex = nm_device_get_ip_ifindex (self); g_assert (ifindex); - link_type = nm_platform_link_get_type (SINGLETON, ifindex); + link_type = nm_platform_link_get_type (NM_PLATFORM_GET, ifindex); g_return_val_if_fail (link_type > NM_LINK_TYPE_UNKNOWN, 0); - hwaddr = nm_platform_link_get_address (SINGLETON, ifindex, &hwaddr_len); + hwaddr = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &hwaddr_len); if (!hwaddr_len) return FALSE; @@ -1051,7 +1051,7 @@ nm_device_finish_init (NMDevice *self) /* Do not manage externally created software devices until they are IFF_UP */ if ( NM_DEVICE_GET_CLASS (self)->can_unmanaged_external_down (self) - && !nm_platform_link_is_up (SINGLETON, priv->ifindex) + && !nm_platform_link_is_up (NM_PLATFORM_GET, priv->ifindex) && priv->ifindex > 0) nm_device_set_initial_unmanaged_flag (self, NM_UNMANAGED_EXTERNAL_DOWN, TRUE); @@ -1239,7 +1239,7 @@ device_set_master (NMDevice *self, int ifindex) } else { _LOGW (LOGD_DEVICE, "enslaved to unknown device %d %s", ifindex, - nm_platform_link_get_name (SINGLETON, ifindex)); + nm_platform_link_get_name (NM_PLATFORM_GET, ifindex)); } } @@ -1295,7 +1295,7 @@ device_link_changed (NMDevice *self, NMPlatformLink *info) nm_device_enslave_slave (priv->master, self, NULL); } - if (priv->rdisc && nm_platform_link_get_ipv6_token (SINGLETON, priv->ifindex, &token_iid)) { + if (priv->rdisc && nm_platform_link_get_ipv6_token (NM_PLATFORM_GET, priv->ifindex, &token_iid)) { _LOGD (LOGD_DEVICE, "IPv6 tokenized identifier present on device %s", priv->iface); if (nm_rdisc_set_iid (priv->rdisc, token_iid)) nm_rdisc_start (priv->rdisc); @@ -1988,7 +1988,7 @@ device_has_config (NMDevice *self) return TRUE; /* Slaves are also configured by definition */ - if (nm_platform_link_get_master (SINGLETON, priv->ifindex) > 0) + if (nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex) > 0) return TRUE; return FALSE; @@ -2854,9 +2854,9 @@ _device_get_default_route_from_platform (NMDevice *self, int addr_family, NMPlat GArray *routes; if (addr_family == AF_INET) - routes = nm_platform_ip4_route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT); + routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT); else - routes = nm_platform_ip6_route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT); + routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT); if (routes) { guint route_metric = G_MAXUINT32, m; @@ -3206,7 +3206,7 @@ dhcp4_start (NMDevice *self, g_object_unref (priv->dhcp4_config); priv->dhcp4_config = nm_dhcp4_config_new (); - hw_addr = nm_platform_link_get_address (SINGLETON, nm_device_get_ip_ifindex (self), &hw_addr_len); + hw_addr = nm_platform_link_get_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), &hw_addr_len); if (hw_addr_len) { tmp = g_byte_array_sized_new (hw_addr_len); g_byte_array_append (tmp, hw_addr, hw_addr_len); @@ -3822,7 +3822,7 @@ dhcp6_start_with_link_ready (NMDevice *self, NMConnection *connection) s_ip6 = nm_connection_get_setting_ip6_config (connection); g_assert (s_ip6); - hw_addr = nm_platform_link_get_address (SINGLETON, nm_device_get_ip_ifindex (self), &hw_addr_len); + hw_addr = nm_platform_link_get_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), &hw_addr_len); if (hw_addr_len) { tmp = g_byte_array_sized_new (hw_addr_len); g_byte_array_append (tmp, hw_addr, hw_addr_len); @@ -4027,7 +4027,7 @@ check_and_add_ipv6ll_addr (NMDevice *self) lladdr.s6_addr16[0] = htons (0xfe80); nm_utils_ipv6_addr_set_interface_identfier (&lladdr, iid); _LOGD (LOGD_IP6, "adding IPv6LL address %s", nm_utils_inet6_ntop (&lladdr, NULL)); - if (!nm_platform_ip6_address_add (SINGLETON, + if (!nm_platform_ip6_address_add (NM_PLATFORM_GET, ip_ifindex, lladdr, in6addr_any, @@ -4078,7 +4078,7 @@ print_support_extended_ifa_flags (NMSettingIP6ConfigPrivacy use_tempaddr) if (s_libnl == -1) { s_libnl = !!nm_platform_check_support_libnl_extended_ifa_flags (); - s_kernel = !!nm_platform_check_support_kernel_extended_ifa_flags (SINGLETON); + s_kernel = !!nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET); if (s_libnl && s_kernel) { nm_log_dbg (LOGD_IP6, "kernel and libnl support extended IFA_FLAGS (needed by NM for IPv6 private addresses)"); @@ -4129,8 +4129,8 @@ nm_device_set_mtu (NMDevice *self, guint32 mtu) if (priv->ip6_mtu) nm_device_ipv6_set_mtu (self, priv->ip6_mtu); - if (priv->mtu != nm_platform_link_get_mtu (SINGLETON, ifindex)) - nm_platform_link_set_mtu (SINGLETON, ifindex, priv->mtu); + if (priv->mtu != nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex)) + nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, priv->mtu); } static void @@ -4183,7 +4183,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self) * from adding a prefix route for this address. **/ system_support = nm_platform_check_support_libnl_extended_ifa_flags () && - nm_platform_check_support_kernel_extended_ifa_flags (SINGLETON); + nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET); } if (system_support) @@ -4350,7 +4350,7 @@ addrconf6_start_with_link_ready (NMDevice *self) g_assert (priv->rdisc); - if (nm_platform_link_get_ipv6_token (SINGLETON, priv->ifindex, &iid)) { + if (nm_platform_link_get_ipv6_token (NM_PLATFORM_GET, priv->ifindex, &iid)) { _LOGD (LOGD_DEVICE, "IPv6 tokenized identifier present on device %s", priv->iface); } else if (!nm_device_get_ip_iface_identifier (self, &iid)) { _LOGW (LOGD_IP6, "failed to get interface identifier; IPv6 cannot continue"); @@ -4465,7 +4465,7 @@ save_ip6_properties (NMDevice *self) g_hash_table_remove_all (priv->ip6_saved_properties); for (i = 0; i < G_N_ELEMENTS (ip6_properties_to_save); i++) { - value = nm_platform_sysctl_get (SINGLETON, nm_utils_ip6_property_path (ifname, ip6_properties_to_save[i])); + value = nm_platform_sysctl_get (NM_PLATFORM_GET, nm_utils_ip6_property_path (ifname, ip6_properties_to_save[i])); if (value) { g_hash_table_insert (priv->ip6_saved_properties, (char *) ip6_properties_to_save[i], @@ -4506,7 +4506,7 @@ set_nm_ipv6ll (NMDevice *self, gboolean enable) const char *iface = nm_device_get_ip_iface (self); char *value; - if (!nm_platform_check_support_user_ipv6ll (SINGLETON)) + if (!nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET)) return; priv->nm_ipv6ll = enable; @@ -4514,13 +4514,13 @@ set_nm_ipv6ll (NMDevice *self, gboolean enable) const char *detail = enable ? "enable" : "disable"; _LOGD (LOGD_IP6, "will %s userland IPv6LL", detail); - if ( !nm_platform_link_set_user_ipv6ll_enabled (SINGLETON, ifindex, enable) - && nm_platform_get_error (SINGLETON) != NM_PLATFORM_ERROR_NOT_FOUND) + if ( !nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, ifindex, enable) + && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_NOT_FOUND) _LOGW (LOGD_IP6, "failed to %s userspace IPv6LL address handling", detail); if (enable) { /* Bounce IPv6 to ensure the kernel stops IPv6LL address generation */ - value = nm_platform_sysctl_get (SINGLETON, nm_utils_ip6_property_path (iface, "disable_ipv6")); + value = nm_platform_sysctl_get (NM_PLATFORM_GET, nm_utils_ip6_property_path (iface, "disable_ipv6")); if (g_strcmp0 (value, "0") == 0) nm_device_ipv6_sysctl_set (self, "disable_ipv6", "1"); g_free (value); @@ -4885,7 +4885,7 @@ nm_device_activate_stage3_ip_config_start (gpointer user_data) nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE); /* Device should be up before we can do anything with it */ - if (!nm_platform_link_is_up (SINGLETON, nm_device_get_ip_ifindex (self))) + if (!nm_platform_link_is_up (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self))) _LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self)); /* If the device is a slave, then we don't do any IP configuration but we @@ -5140,14 +5140,14 @@ share_init (void) char **iter; int errsv; - if (!nm_platform_sysctl_set (SINGLETON, "/proc/sys/net/ipv4/ip_forward", "1")) { + if (!nm_platform_sysctl_set (NM_PLATFORM_GET, "/proc/sys/net/ipv4/ip_forward", "1")) { errsv = errno; nm_log_err (LOGD_SHARING, "share: error starting IP forwarding: (%d) %s", errsv, strerror (errsv)); return FALSE; } - if (!nm_platform_sysctl_set (SINGLETON, "/proc/sys/net/ipv4/ip_dynaddr", "1")) { + if (!nm_platform_sysctl_set (NM_PLATFORM_GET, "/proc/sys/net/ipv4/ip_dynaddr", "1")) { errsv = errno; nm_log_err (LOGD_SHARING, "share: error starting IP forwarding: (%d) %s", errsv, strerror (errsv)); @@ -5357,9 +5357,9 @@ nm_device_activate_ip4_config_commit (gpointer user_data) /* Interface must be IFF_UP before IP config can be applied */ ip_ifindex = nm_device_get_ip_ifindex (self); - if (!nm_platform_link_is_up (SINGLETON, ip_ifindex) && !nm_device_uses_assumed_connection (self)) { - nm_platform_link_set_up (SINGLETON, ip_ifindex); - if (!nm_platform_link_is_up (SINGLETON, ip_ifindex)) + if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex) && !nm_device_uses_assumed_connection (self)) { + nm_platform_link_set_up (NM_PLATFORM_GET, ip_ifindex); + if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex)) _LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self)); } @@ -5478,9 +5478,9 @@ nm_device_activate_ip6_config_commit (gpointer user_data) /* Interface must be IFF_UP before IP config can be applied */ ip_ifindex = nm_device_get_ip_ifindex (self); - if (!nm_platform_link_is_up (SINGLETON, ip_ifindex) && !nm_device_uses_assumed_connection (self)) { - nm_platform_link_set_up (SINGLETON, ip_ifindex); - if (!nm_platform_link_is_up (SINGLETON, ip_ifindex)) + if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex) && !nm_device_uses_assumed_connection (self)) { + nm_platform_link_set_up (NM_PLATFORM_GET, ip_ifindex); + if (!nm_platform_link_is_up (NM_PLATFORM_GET, ip_ifindex)) _LOGW (LOGD_DEVICE, "interface %s not up for IP configuration", nm_device_get_ip_iface (self)); } @@ -5649,7 +5649,7 @@ delete_on_deactivate_link_delete (gpointer user_data) _LOGD (LOGD_DEVICE, "delete_on_deactivate: cleanup and delete virtual link #%d (id=%u)", data->ifindex, data->idle_add_id); - nm_platform_link_delete (SINGLETON, data->ifindex); + nm_platform_link_delete (NM_PLATFORM_GET, data->ifindex); g_free (data); return FALSE; } @@ -5783,7 +5783,7 @@ delete_cb (NMDevice *self, } /* Authorized */ - nm_platform_link_delete (SINGLETON, nm_device_get_ifindex (self)); + nm_platform_link_delete (NM_PLATFORM_GET, nm_device_get_ifindex (self)); dbus_g_method_return (context); } @@ -6535,7 +6535,7 @@ is_up (NMDevice *self) { int ifindex = nm_device_get_ip_ifindex (self); - return ifindex > 0 ? nm_platform_link_is_up (SINGLETON, ifindex) : TRUE; + return ifindex > 0 ? nm_platform_link_is_up (NM_PLATFORM_GET, ifindex) : TRUE; } gboolean @@ -6560,7 +6560,7 @@ nm_device_bring_up (NMDevice *self, gboolean block, gboolean *no_firmware) do { g_usleep (200); - if (!nm_platform_link_refresh (SINGLETON, ifindex)) + if (!nm_platform_link_refresh (NM_PLATFORM_GET, ifindex)) return FALSE; device_is_up = nm_device_is_up (self); } while (!device_is_up && nm_utils_get_monotonic_timestamp_us () < wait_until); @@ -6600,7 +6600,7 @@ check_carrier (NMDevice *self) int ifindex = nm_device_get_ip_ifindex (self); if (!nm_device_has_capability (self, NM_DEVICE_CAP_NONSTANDARD_CARRIER)) - nm_device_set_carrier (self, nm_platform_link_is_connected (SINGLETON, ifindex)); + nm_device_set_carrier (self, nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); } static gboolean @@ -6615,9 +6615,9 @@ bring_up (NMDevice *self, gboolean *no_firmware) return TRUE; } - result = nm_platform_link_set_up (SINGLETON, ifindex); + result = nm_platform_link_set_up (NM_PLATFORM_GET, ifindex); if (no_firmware) - *no_firmware = nm_platform_get_error (SINGLETON) == NM_PLATFORM_ERROR_NO_FIRMWARE; + *no_firmware = nm_platform_get_error (NM_PLATFORM_GET) == NM_PLATFORM_ERROR_NO_FIRMWARE; /* Store carrier immediately. */ if (result && nm_device_has_capability (self, NM_DEVICE_CAP_CARRIER_DETECT)) @@ -6647,7 +6647,7 @@ nm_device_take_down (NMDevice *self, gboolean block) do { g_usleep (200); - if (!nm_platform_link_refresh (SINGLETON, ifindex)) + if (!nm_platform_link_refresh (NM_PLATFORM_GET, ifindex)) return; device_is_up = nm_device_is_up (self); } while (device_is_up && nm_utils_get_monotonic_timestamp_us () < wait_until); @@ -6667,7 +6667,7 @@ take_down (NMDevice *self) int ifindex = nm_device_get_ip_ifindex (self); if (ifindex > 0) - return nm_platform_link_set_down (SINGLETON, ifindex); + return nm_platform_link_set_down (NM_PLATFORM_GET, ifindex); /* devices without ifindex are always up. */ _LOGD (LOGD_HW, "cannot take down device without ifindex"); @@ -7307,7 +7307,7 @@ cp_connection_updated (NMConnectionProvider *cp, NMConnection *connection, gpoin gboolean nm_device_supports_vlans (NMDevice *self) { - return nm_platform_link_supports_vlans (SINGLETON, nm_device_get_ifindex (self)); + return nm_platform_link_supports_vlans (NM_PLATFORM_GET, nm_device_get_ifindex (self)); } /** @@ -7571,7 +7571,7 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, gboolean deconfig ifindex = nm_device_get_ip_ifindex (self); if (ifindex > 0) { nm_route_manager_route_flush (nm_route_manager_get (), ifindex); - nm_platform_address_flush (SINGLETON, ifindex); + nm_platform_address_flush (NM_PLATFORM_GET, ifindex); } _cleanup_generic_post (self, deconfigure); @@ -8242,7 +8242,7 @@ nm_device_update_hw_address (NMDevice *self) if (ifindex <= 0) return; - hwaddr = nm_platform_link_get_address (SINGLETON, ifindex, &hwaddrlen); + hwaddr = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &hwaddrlen); if (hwaddrlen) { if (!priv->hw_addr || !nm_utils_hwaddr_matches (priv->hw_addr, -1, hwaddr, hwaddrlen)) { @@ -8288,7 +8288,7 @@ nm_device_set_hw_addr (NMDevice *self, const char *addr, /* Can't change MAC address while device is up */ nm_device_take_down (self, FALSE); - success = nm_platform_link_set_address (SINGLETON, nm_device_get_ip_ifindex (self), addr_bytes, priv->hw_addr_len); + success = nm_platform_link_set_address (NM_PLATFORM_GET, nm_device_get_ip_ifindex (self), addr_bytes, priv->hw_addr_len); if (success) { /* MAC address succesfully changed; update the current MAC to match */ nm_device_update_hw_address (self); @@ -8481,11 +8481,11 @@ constructor (GType type, /* trigger initial ip config change to initialize ip-config */ priv->queued_ip_config_id = g_idle_add (queued_ip_config_change, self); - if (nm_platform_check_support_user_ipv6ll (SINGLETON)) { + if (nm_platform_check_support_user_ipv6ll (NM_PLATFORM_GET)) { int ip_ifindex = nm_device_get_ip_ifindex (self); if (ip_ifindex > 0) - priv->nm_ipv6ll = nm_platform_link_get_user_ipv6ll_enabled (SINGLETON, ip_ifindex); + priv->nm_ipv6ll = nm_platform_link_get_user_ipv6ll_enabled (NM_PLATFORM_GET, ip_ifindex); } return object; @@ -8525,17 +8525,17 @@ constructed (GObject *object) } if (priv->ifindex > 0) { - priv->is_software = nm_platform_link_is_software (SINGLETON, priv->ifindex); - priv->physical_port_id = nm_platform_link_get_physical_port_id (SINGLETON, priv->ifindex); - priv->dev_id = nm_platform_link_get_dev_id (SINGLETON, priv->ifindex); - priv->mtu = nm_platform_link_get_mtu (SINGLETON, priv->ifindex); + priv->is_software = nm_platform_link_is_software (NM_PLATFORM_GET, priv->ifindex); + priv->physical_port_id = nm_platform_link_get_physical_port_id (NM_PLATFORM_GET, priv->ifindex); + priv->dev_id = nm_platform_link_get_dev_id (NM_PLATFORM_GET, priv->ifindex); + priv->mtu = nm_platform_link_get_mtu (NM_PLATFORM_GET, priv->ifindex); } /* Indicate software device in capabilities. */ if (priv->is_software) priv->capabilities |= NM_DEVICE_CAP_IS_SOFTWARE; /* Enslave ourselves */ - master = nm_platform_link_get_master (SINGLETON, priv->ifindex); + master = nm_platform_link_get_master (NM_PLATFORM_GET, priv->ifindex); if (master) device_set_master (self, master); @@ -8682,9 +8682,9 @@ set_property (GObject *object, guint prop_id, if (g_value_get_string (value)) { g_free (priv->iface); priv->iface = g_value_dup_string (value); - priv->ifindex = nm_platform_link_get_ifindex (SINGLETON, priv->iface); + priv->ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->iface); if (priv->ifindex > 0) - priv->up = nm_platform_link_is_up (SINGLETON, priv->ifindex); + priv->up = nm_platform_link_is_up (NM_PLATFORM_GET, priv->ifindex); } break; case PROP_DRIVER: diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index f5ef20d064..6b58014393 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -618,7 +618,7 @@ enslave_slave (NMDevice *device, } } } - success = nm_platform_link_enslave (SINGLETON, + success = nm_platform_link_enslave (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)); nm_device_bring_up (slave, TRUE, &no_firmware); @@ -644,7 +644,7 @@ release_slave (NMDevice *device, gboolean success = TRUE, no_firmware = FALSE; if (configure) { - success = nm_platform_link_release (SINGLETON, + success = nm_platform_link_release (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device), nm_device_get_ip_ifindex (slave)); @@ -697,14 +697,14 @@ nm_device_team_new_for_connection (NMConnection *connection, GError **error) iface = nm_connection_get_interface_name (connection); g_return_val_if_fail (iface != NULL, NULL); - if ( !nm_platform_team_add (SINGLETON, iface) - && nm_platform_get_error (SINGLETON) != NM_PLATFORM_ERROR_EXISTS) { + if ( !nm_platform_team_add (NM_PLATFORM_GET, iface) + && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "failed to create team master interface '%s' for connection '%s': %s", iface, nm_connection_get_id (connection), - nm_platform_get_error_msg (SINGLETON)); + nm_platform_get_error_msg (NM_PLATFORM_GET)); return NULL; } diff --git a/src/devices/wifi/nm-device-olpc-mesh.c b/src/devices/wifi/nm-device-olpc-mesh.c index 1945b7e192..f8bf2f7d97 100644 --- a/src/devices/wifi/nm-device-olpc-mesh.c +++ b/src/devices/wifi/nm-device-olpc-mesh.c @@ -197,8 +197,8 @@ _mesh_set_channel (NMDeviceOlpcMesh *self, guint32 channel) { int ifindex = nm_device_get_ifindex (NM_DEVICE (self)); - if (nm_platform_mesh_get_channel (SINGLETON, ifindex) != channel) { - if (nm_platform_mesh_set_channel (SINGLETON, ifindex, channel)) + if (nm_platform_mesh_get_channel (NM_PLATFORM_GET, ifindex) != channel) { + if (nm_platform_mesh_set_channel (NM_PLATFORM_GET, ifindex, channel)) g_object_notify (G_OBJECT (self), NM_DEVICE_OLPC_MESH_ACTIVE_CHANNEL); } } @@ -224,7 +224,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) _mesh_set_channel (self, channel); ssid = nm_setting_olpc_mesh_get_ssid (s_mesh); - nm_platform_mesh_set_ssid (SINGLETON, + nm_platform_mesh_set_ssid (NM_PLATFORM_GET, nm_device_get_ifindex (device), g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid)); @@ -454,7 +454,7 @@ constructor (GType type, self = NM_DEVICE_OLPC_MESH (object); - if (!nm_platform_wifi_get_capabilities (SINGLETON, nm_device_get_ifindex (NM_DEVICE (self)), &caps)) { + if (!nm_platform_wifi_get_capabilities (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), &caps)) { _LOGW (LOGD_HW | LOGD_OLPC, "failed to initialize WiFi driver"); g_object_unref (object); return NULL; @@ -483,7 +483,7 @@ get_property (GObject *object, guint prop_id, g_value_set_boxed (value, "/"); break; case PROP_ACTIVE_CHANNEL: - g_value_set_uint (value, nm_platform_mesh_get_channel (SINGLETON, nm_device_get_ifindex (NM_DEVICE (device)))); + g_value_set_uint (value, nm_platform_mesh_get_channel (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (device)))); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 3afed543d0..747c021c6d 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -219,7 +219,7 @@ constructor (GType type, self = NM_DEVICE_WIFI (object); priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - if (!nm_platform_wifi_get_capabilities (SINGLETON, + if (!nm_platform_wifi_get_capabilities (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), &priv->capabilities)) { _LOGW (LOGD_HW | LOGD_WIFI, "failed to initialize WiFi driver"); @@ -440,14 +440,14 @@ periodic_update (NMDeviceWifi *self) if (priv->current_ap) { /* Smooth out the strength to work around crappy drivers */ - percent = nm_platform_wifi_get_quality (SINGLETON, ifindex); + percent = nm_platform_wifi_get_quality (NM_PLATFORM_GET, ifindex); if (percent >= 0 || ++priv->invalid_strength_counter > 3) { nm_ap_set_strength (priv->current_ap, (gint8) percent); priv->invalid_strength_counter = 0; } } - new_rate = nm_platform_wifi_get_rate (SINGLETON, ifindex); + new_rate = nm_platform_wifi_get_rate (NM_PLATFORM_GET, ifindex); if (new_rate != priv->rate) { priv->rate = new_rate; g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_BITRATE); @@ -534,20 +534,20 @@ deactivate (NMDevice *device) set_current_ap (self, NULL, TRUE, FALSE); /* Clear any critical protocol notification in the Wi-Fi stack */ - nm_platform_wifi_indicate_addressing_running (SINGLETON, ifindex, FALSE); + nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, ifindex, FALSE); /* Reset MAC address back to initial address */ if (priv->initial_hw_addr) nm_device_set_hw_addr (device, priv->initial_hw_addr, "reset", LOGD_WIFI); - nm_platform_wifi_set_powersave (SINGLETON, ifindex, 0); + nm_platform_wifi_set_powersave (NM_PLATFORM_GET, ifindex, 0); /* Ensure we're in infrastructure mode after deactivation; some devices * (usually older ones) don't scan well in adhoc mode. */ - if (nm_platform_wifi_get_mode (SINGLETON, ifindex) != NM_802_11_MODE_INFRA) { + if (nm_platform_wifi_get_mode (NM_PLATFORM_GET, ifindex) != NM_802_11_MODE_INFRA) { nm_device_take_down (NM_DEVICE (self), TRUE); - nm_platform_wifi_set_mode (SINGLETON, ifindex, NM_802_11_MODE_INFRA); + nm_platform_wifi_set_mode (NM_PLATFORM_GET, ifindex, NM_802_11_MODE_INFRA); nm_device_bring_up (NM_DEVICE (self), TRUE, NULL); } @@ -2514,9 +2514,9 @@ ensure_hotspot_frequency (NMDeviceWifi *self, return; if (g_strcmp0 (band, "a") == 0) - freq = nm_platform_wifi_find_frequency (SINGLETON, nm_device_get_ifindex (NM_DEVICE (self)), a_freqs); + freq = nm_platform_wifi_find_frequency (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), a_freqs); else - freq = nm_platform_wifi_find_frequency (SINGLETON, nm_device_get_ifindex (NM_DEVICE (self)), bg_freqs); + freq = nm_platform_wifi_find_frequency (NM_PLATFORM_GET, nm_device_get_ifindex (NM_DEVICE (self)), bg_freqs); if (!freq) freq = (g_strcmp0 (band, "a") == 0) ? 5180 : 2462; @@ -2590,7 +2590,7 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) ensure_hotspot_frequency (self, s_wireless, ap); if (nm_ap_get_mode (ap) == NM_802_11_MODE_INFRA) { - nm_platform_wifi_set_powersave (SINGLETON, + nm_platform_wifi_set_powersave (NM_PLATFORM_GET, nm_device_get_ifindex (device), nm_setting_wireless_get_powersave (s_wireless)); } @@ -2656,7 +2656,7 @@ act_stage3_ip4_config_start (NMDevice *device, /* Indicate that a critical protocol is about to start */ if (strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) == 0) - nm_platform_wifi_indicate_addressing_running (SINGLETON, nm_device_get_ifindex (device), TRUE); + nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), TRUE); return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip4_config_start (device, out_config, reason); } @@ -2679,7 +2679,7 @@ act_stage3_ip6_config_start (NMDevice *device, /* Indicate that a critical protocol is about to start */ if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0 || strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) - nm_platform_wifi_indicate_addressing_running (SINGLETON, nm_device_get_ifindex (device), TRUE); + nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), TRUE); return NM_DEVICE_CLASS (nm_device_wifi_parent_class)->act_stage3_ip6_config_start (device, out_config, reason); } @@ -2828,7 +2828,7 @@ activation_success_handler (NMDevice *device) g_assert (connection); /* Clear any critical protocol notification in the wifi stack */ - nm_platform_wifi_indicate_addressing_running (SINGLETON, ifindex, FALSE); + nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, ifindex, FALSE); /* Clear wireless secrets tries on success */ g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL); @@ -2849,16 +2849,16 @@ activation_success_handler (NMDevice *device) guint8 bssid[ETH_ALEN] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; gs_free char *bssid_str = NULL; - if ( nm_platform_wifi_get_bssid (SINGLETON, ifindex, bssid) + if ( nm_platform_wifi_get_bssid (NM_PLATFORM_GET, ifindex, bssid) && nm_ethernet_address_is_valid (bssid, ETH_ALEN)) { bssid_str = nm_utils_hwaddr_ntoa (bssid, ETH_ALEN); nm_ap_set_address (priv->current_ap, bssid_str); } } if (!nm_ap_get_freq (priv->current_ap)) - nm_ap_set_freq (priv->current_ap, nm_platform_wifi_get_frequency (SINGLETON, ifindex)); + nm_ap_set_freq (priv->current_ap, nm_platform_wifi_get_frequency (NM_PLATFORM_GET, ifindex)); if (!nm_ap_get_max_bitrate (priv->current_ap)) - nm_ap_set_max_bitrate (priv->current_ap, nm_platform_wifi_get_rate (SINGLETON, ifindex)); + nm_ap_set_max_bitrate (priv->current_ap, nm_platform_wifi_get_rate (NM_PLATFORM_GET, ifindex)); } nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req), nm_ap_get_dbus_path (priv->current_ap)); @@ -2882,7 +2882,7 @@ activation_failure_handler (NMDevice *device) g_object_set_data (G_OBJECT (connection), WIRELESS_SECRETS_TRIES, NULL); /* Clear any critical protocol notification in the wifi stack */ - nm_platform_wifi_indicate_addressing_running (SINGLETON, nm_device_get_ifindex (device), FALSE); + nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), FALSE); } static void @@ -2932,7 +2932,7 @@ device_state_changed (NMDevice *device, break; case NM_DEVICE_STATE_IP_CHECK: /* Clear any critical protocol notification in the wifi stack */ - nm_platform_wifi_indicate_addressing_running (SINGLETON, nm_device_get_ifindex (device), FALSE); + nm_platform_wifi_indicate_addressing_running (NM_PLATFORM_GET, nm_device_get_ifindex (device), FALSE); break; case NM_DEVICE_STATE_ACTIVATED: activation_success_handler (device); diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index 07897afd70..2c07b36f65 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -747,7 +747,7 @@ static_stage3_ip4_done (NMModemBroadband *self) data_port = mm_bearer_get_interface (self->priv->bearer); g_assert (data_port); - config = nm_ip4_config_new (nm_platform_link_get_ifindex (SINGLETON, data_port)); + config = nm_ip4_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port)); memset (&address, 0, sizeof (address)); address.address = address_network; @@ -840,7 +840,7 @@ stage3_ip6_done (NMModemBroadband *self) data_port = mm_bearer_get_interface (self->priv->bearer); g_assert (data_port); - config = nm_ip6_config_new (nm_platform_link_get_ifindex (SINGLETON, data_port)); + config = nm_ip6_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, data_port)); address.plen = mm_bearer_ip_config_get_prefix (self->priv->ipv6_config); nm_ip6_config_add_address (config, &address); diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index d7eeabca58..3385a6fd3b 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -616,7 +616,7 @@ nm_modem_ip4_pre_commit (NMModem *modem, g_assert (address); if (address->plen == 32) - nm_platform_link_set_noarp (SINGLETON, nm_device_get_ip_ifindex (device)); + nm_platform_link_set_noarp (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device)); } } @@ -914,8 +914,8 @@ deactivate_cleanup (NMModem *self, NMDevice *device) ifindex = nm_device_get_ip_ifindex (device); if (ifindex > 0) { nm_route_manager_route_flush (nm_route_manager_get (), ifindex); - nm_platform_address_flush (SINGLETON, ifindex); - nm_platform_link_set_down (SINGLETON, ifindex); + nm_platform_address_flush (NM_PLATFORM_GET, ifindex); + nm_platform_link_set_down (NM_PLATFORM_GET, ifindex); } } } diff --git a/src/main.c b/src/main.c index 12930fc735..a5851dc558 100644 --- a/src/main.c +++ b/src/main.c @@ -478,7 +478,7 @@ main (int argc, char *argv[]) * physical interfaces. */ nm_log_dbg (LOGD_CORE, "setting up local loopback"); - nm_platform_link_set_up (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, "lo")); + nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, "lo")); success = TRUE; diff --git a/src/nm-dcb.c b/src/nm-dcb.c index 05c342cfb2..8bf3858a3d 100644 --- a/src/nm-dcb.c +++ b/src/nm-dcb.c @@ -354,7 +354,7 @@ carrier_wait (const char *iface, guint secs, gboolean up) g_return_if_fail (iface != NULL); - ifindex = nm_platform_link_get_ifindex (SINGLETON, iface); + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, iface); if (ifindex > 0) { /* To work around driver quirks and lldpad handling of carrier status, * we must wait a short period of time to see if the carrier goes @@ -365,9 +365,9 @@ carrier_wait (const char *iface, guint secs, gboolean up) nm_log_dbg (LOGD_DCB, "(%s): cleanup waiting for carrier %s", iface, up ? "up" : "down"); g_usleep (G_USEC_PER_SEC / 4); - while (nm_platform_link_is_connected (SINGLETON, ifindex) != up && count-- > 0) { + while (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex) != up && count-- > 0) { g_usleep (G_USEC_PER_SEC / 10); - nm_platform_link_refresh (SINGLETON, ifindex); + nm_platform_link_refresh (NM_PLATFORM_GET, ifindex); } } } diff --git a/src/nm-default-route-manager.c b/src/nm-default-route-manager.c index 7c783e472c..c04dd96fa7 100644 --- a/src/nm-default-route-manager.c +++ b/src/nm-default-route-manager.c @@ -256,7 +256,7 @@ _platform_route_sync_add (const VTableIP *vtable, NMDefaultRouteManager *self, g return FALSE; if (vtable->vt->is_ip4) { - success = nm_platform_ip4_route_add (SINGLETON, + success = nm_platform_ip4_route_add (NM_PLATFORM_GET, entry->route.rx.ifindex, entry->route.rx.source, 0, @@ -266,7 +266,7 @@ _platform_route_sync_add (const VTableIP *vtable, NMDefaultRouteManager *self, g entry->effective_metric, entry->route.rx.mss); } else { - success = nm_platform_ip6_route_add (SINGLETON, + success = nm_platform_ip6_route_add (NM_PLATFORM_GET, entry->route.rx.ifindex, entry->route.rx.source, in6addr_any, @@ -292,7 +292,7 @@ _platform_route_sync_flush (const VTableIP *vtable, NMDefaultRouteManager *self, gboolean changed = FALSE; /* prune all other default routes from this device. */ - routes = vtable->vt->route_get_all (SINGLETON, 0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT); + routes = vtable->vt->route_get_all (NM_PLATFORM_GET, 0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT); for (i = 0; i < routes->len; i++) { const NMPlatformIPRoute *route; @@ -324,7 +324,7 @@ _platform_route_sync_flush (const VTableIP *vtable, NMDefaultRouteManager *self, */ if ( !entry && (has_ifindex_synced || ifindex_to_flush == route->ifindex)) { - vtable->vt->route_delete_default (SINGLETON, route->ifindex, route->metric); + vtable->vt->route_delete_default (NM_PLATFORM_GET, route->ifindex, route->metric); changed = TRUE; } } @@ -454,7 +454,7 @@ _resync_all (const VTableIP *vtable, NMDefaultRouteManager *self, const Entry *c entries = vtable->get_entries (priv); - routes = vtable->vt->route_get_all (SINGLETON, 0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT); + routes = vtable->vt->route_get_all (NM_PLATFORM_GET, 0, NM_PLATFORM_GET_ROUTE_MODE_ONLY_DEFAULT); assumed_metrics = _get_assumed_interface_metrics (vtable, self, routes); diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index df8f092d9d..756af2a1b4 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -146,7 +146,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da * from adding a prefix route for this address. **/ system_support = nm_platform_check_support_libnl_extended_ifa_flags () && - nm_platform_check_support_kernel_extended_ifa_flags (SINGLETON); + nm_platform_check_support_kernel_extended_ifa_flags (NM_PLATFORM_GET); } if (system_support) @@ -233,14 +233,14 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da char val[16]; g_snprintf (val, sizeof (val), "%d", rdisc->hop_limit); - nm_platform_sysctl_set (SINGLETON, nm_utils_ip6_property_path (global_opt.ifname, "hop_limit"), val); + nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "hop_limit"), val); } if (changed & NM_RDISC_CONFIG_MTU) { char val[16]; g_snprintf (val, sizeof (val), "%d", rdisc->mtu); - nm_platform_sysctl_set (SINGLETON, nm_utils_ip6_property_path (global_opt.ifname, "mtu"), val); + nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "mtu"), val); } existing = nm_ip6_config_capture (ifindex, FALSE, global_opt.tempaddr); @@ -426,7 +426,7 @@ main (int argc, char *argv[]) /* Set up platform interaction layer */ nm_linux_platform_setup (); - tmp = nm_platform_link_get_address (SINGLETON, ifindex, &hwaddr_len); + tmp = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &hwaddr_len); if (tmp) { hwaddr = g_byte_array_sized_new (hwaddr_len); g_byte_array_append (hwaddr, tmp, hwaddr_len); @@ -445,7 +445,7 @@ main (int argc, char *argv[]) } if (global_opt.dhcp4_address) { - nm_platform_sysctl_set (SINGLETON, nm_utils_ip4_property_path (global_opt.ifname, "promote_secondaries"), "1"); + nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip4_property_path (global_opt.ifname, "promote_secondaries"), "1"); dhcp4_client = nm_dhcp_manager_start_ip4 (nm_dhcp_manager_get (), global_opt.ifname, @@ -467,7 +467,7 @@ main (int argc, char *argv[]) } if (global_opt.slaac) { - nm_platform_link_set_user_ipv6ll_enabled (SINGLETON, ifindex, TRUE); + nm_platform_link_set_user_ipv6ll_enabled (NM_PLATFORM_GET, ifindex, TRUE); rdisc = nm_lndp_rdisc_new (ifindex, global_opt.ifname); g_assert (rdisc); @@ -475,10 +475,10 @@ main (int argc, char *argv[]) if (iid) nm_rdisc_set_iid (rdisc, *iid); - nm_platform_sysctl_set (SINGLETON, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra"), "1"); - nm_platform_sysctl_set (SINGLETON, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_defrtr"), "0"); - nm_platform_sysctl_set (SINGLETON, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_pinfo"), "0"); - nm_platform_sysctl_set (SINGLETON, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_rtr_pref"), "0"); + nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra"), "1"); + nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_defrtr"), "0"); + nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_pinfo"), "0"); + nm_platform_sysctl_set (NM_PLATFORM_GET, nm_utils_ip6_property_path (global_opt.ifname, "accept_ra_rtr_pref"), "0"); g_signal_connect (rdisc, NM_RDISC_CONFIG_CHANGED, diff --git a/src/nm-ip4-config.c b/src/nm-ip4-config.c index c37b8904be..8b1596dd0d 100644 --- a/src/nm-ip4-config.c +++ b/src/nm-ip4-config.c @@ -196,7 +196,7 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf) gboolean has_gateway = FALSE; /* Slaves have no IP configuration */ - if (nm_platform_link_get_master (SINGLETON, ifindex) > 0) + if (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex) > 0) return NULL; config = nm_ip4_config_new (ifindex); @@ -205,8 +205,8 @@ nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf) g_array_unref (priv->addresses); g_array_unref (priv->routes); - priv->addresses = nm_platform_ip4_address_get_all (SINGLETON, ifindex); - priv->routes = nm_platform_ip4_route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); + priv->addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex); + priv->routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); /* Extract gateway from default route */ old_gateway = priv->gateway; @@ -270,7 +270,7 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro g_return_val_if_fail (config != NULL, FALSE); /* Addresses */ - nm_platform_ip4_address_sync (SINGLETON, ifindex, priv->addresses, default_route_metric); + nm_platform_ip4_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, default_route_metric); /* Routes */ { diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index bdda59fcc8..2077af81b3 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -310,7 +310,7 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co gboolean notify_nameservers = FALSE; /* Slaves have no IP configuration */ - if (nm_platform_link_get_master (SINGLETON, ifindex) > 0) + if (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex) > 0) return NULL; config = nm_ip6_config_new (ifindex); @@ -319,8 +319,8 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co g_array_unref (priv->addresses); g_array_unref (priv->routes); - priv->addresses = nm_platform_ip6_address_get_all (SINGLETON, ifindex); - priv->routes = nm_platform_ip6_route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); + priv->addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex); + priv->routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); /* Extract gateway from default route */ old_gateway = priv->gateway; @@ -387,7 +387,7 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex) g_return_val_if_fail (config != NULL, FALSE); /* Addresses */ - nm_platform_ip6_address_sync (SINGLETON, ifindex, priv->addresses, TRUE); + nm_platform_ip6_address_sync (NM_PLATFORM_GET, ifindex, priv->addresses, TRUE); /* Routes */ { diff --git a/src/nm-manager.c b/src/nm-manager.c index e4f43bc2de..f8815b6481 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -1090,7 +1090,7 @@ system_create_virtual_device (NMManager *self, NMConnection *connection, GError */ priv->ignore_link_added_cb++; - nm_owned = !nm_platform_link_exists (SINGLETON, iface); + nm_owned = !nm_platform_link_exists (NM_PLATFORM_GET, iface); for (iter = priv->factories; iter; iter = iter->next) { device = nm_device_factory_create_virtual_device_for_connection (NM_DEVICE_FACTORY (iter->data), @@ -1572,13 +1572,13 @@ get_existing_connection (NMManager *manager, NMDevice *device, gboolean *out_gen nm_device_capture_initial_config (device); if (ifindex) { - int master_ifindex = nm_platform_link_get_master (SINGLETON, ifindex); + int master_ifindex = nm_platform_link_get_master (NM_PLATFORM_GET, ifindex); if (master_ifindex) { master = nm_manager_get_device_by_ifindex (manager, master_ifindex); if (!master) { nm_log_dbg (LOGD_DEVICE, "(%s): cannot generate connection for slave before its master (%s/%d)", - nm_device_get_iface (device), nm_platform_link_get_name (SINGLETON, master_ifindex), master_ifindex); + nm_device_get_iface (device), nm_platform_link_get_name (NM_PLATFORM_GET, master_ifindex), master_ifindex); return NULL; } if (!nm_device_get_act_request (master)) { @@ -1870,7 +1870,7 @@ add_device (NMManager *self, NMDevice *device, gboolean try_assume) user_unmanaged = nm_device_spec_match_list (device, unmanaged_specs); nm_device_set_initial_unmanaged_flag (device, NM_UNMANAGED_USER, user_unmanaged); - if (nm_platform_link_get_unmanaged (SINGLETON, nm_device_get_ifindex (device), &platform_unmanaged)) + if (nm_platform_link_get_unmanaged (NM_PLATFORM_GET, nm_device_get_ifindex (device), &platform_unmanaged)) nm_device_set_initial_unmanaged_flag (device, NM_UNMANAGED_DEFAULT, platform_unmanaged); sleeping = manager_sleeping (self); @@ -3665,7 +3665,7 @@ done: static gboolean device_is_wake_on_lan (NMDevice *device) { - return nm_platform_link_get_wake_on_lan (SINGLETON, nm_device_get_ip_ifindex (device)); + return nm_platform_link_get_wake_on_lan (NM_PLATFORM_GET, nm_device_get_ip_ifindex (device)); } static void @@ -4260,7 +4260,7 @@ nm_manager_start (NMManager *self) for (iter = priv->factories; iter; iter = iter->next) nm_device_factory_start (iter->data); - nm_platform_query_devices (SINGLETON); + nm_platform_query_devices (NM_PLATFORM_GET); /* * Connections added before the manager is started do not emit diff --git a/src/nm-route-manager.c b/src/nm-route-manager.c index e6069cb0aa..7c9d688392 100644 --- a/src/nm-route-manager.c +++ b/src/nm-route-manager.c @@ -358,7 +358,7 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const NMPlatformIPXRoute *cur_ipx_route; ipx_routes = vtable->vt->is_ip4 ? &priv->ip4_routes : &priv->ip6_routes; - plat_routes = vtable->vt->route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT); + plat_routes = vtable->vt->route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT); plat_routes_idx = _route_index_create (vtable, plat_routes); known_routes_idx = _route_index_create (vtable, known_routes); @@ -494,7 +494,7 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const /* if @cur_ipx_route is not equal to @plat_route, the route must be deleted. */ if (!(cur_ipx_route && route_id_cmp_result == 0)) - vtable->vt->route_delete (SINGLETON, ifindex, cur_plat_route); + vtable->vt->route_delete (NM_PLATFORM_GET, ifindex, cur_plat_route); cur_plat_route = _get_next_plat_route (plat_routes_idx, FALSE, &i_plat_routes); } @@ -515,7 +515,7 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const * device routes, on the second the others (gateway routes). */ continue; } - vtable->vt->route_add (SINGLETON, 0, rest_route, 0); + vtable->vt->route_add (NM_PLATFORM_GET, 0, rest_route, 0); } } g_array_unref (to_restore_routes); @@ -560,7 +560,7 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const || !_route_equals_ignoring_ifindex (vtable, cur_plat_route, cur_ipx_route)) { gboolean s; - s = vtable->vt->route_add (SINGLETON, ifindex, cur_ipx_route, 0); + s = vtable->vt->route_add (NM_PLATFORM_GET, ifindex, cur_ipx_route, 0); if (!s && cur_ipx_route->rx.source < NM_IP_CONFIG_SOURCE_USER) { _LOGD (vtable->vt->addr_family, "ignore error adding IPv%c route to kernel: %s", vtable->vt->is_ip4 ? '4' : '6', diff --git a/src/nm-types.h b/src/nm-types.h index 60dab8543c..f22272d91f 100644 --- a/src/nm-types.h +++ b/src/nm-types.h @@ -21,8 +21,6 @@ #ifndef __NETWORKMANAGER_TYPES_H__ #define __NETWORKMANAGER_TYPES_H__ -#define SINGLETON ((void *) 0x01) - /* core */ typedef struct _NMActiveConnection NMActiveConnection; typedef struct _NMVpnConnection NMVpnConnection; diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 660845df30..1bc907b667 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -67,8 +67,6 @@ static NMPlatform *singleton_instance = NULL; #define _CHECK_SELF_VOID(self, klass) \ NMPlatformClass *klass; \ do { \ - if ((void *) self == SINGLETON) \ - self = singleton_instance; \ g_return_if_fail (NM_IS_PLATFORM (self)); \ klass = NM_PLATFORM_GET_CLASS (self); \ (void) klass; \ @@ -77,8 +75,6 @@ static NMPlatform *singleton_instance = NULL; #define _CHECK_SELF(self, klass, err_val) \ NMPlatformClass *klass; \ do { \ - if ((void *) self == SINGLETON) \ - self = singleton_instance; \ g_return_val_if_fail (NM_IS_PLATFORM (self), err_val); \ klass = NM_PLATFORM_GET_CLASS (self); \ (void) klass; \ diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 58a25198e3..aee1ee8160 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -494,6 +494,8 @@ void nm_platform_setup (GType type); NMPlatform *nm_platform_get (void); void nm_platform_free (void); +#define NM_PLATFORM_GET (nm_platform_get ()) + /******************************************************************/ void nm_platform_set_error (NMPlatform *self, NMPlatformError error); diff --git a/src/platform/tests/dump.c b/src/platform/tests/dump.c index 92eb9f852a..e356df0b45 100644 --- a/src/platform/tests/dump.c +++ b/src/platform/tests/dump.c @@ -44,21 +44,21 @@ dump_interface (NMPlatformLink *link) if (link->driver) printf (" driver: %s\n", link->driver); printf (" UDI: %s\n", link->udi); - if (!nm_platform_vlan_get_info (SINGLETON, link->ifindex, &vlan_parent, &vlan_id)) + if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, link->ifindex, &vlan_parent, &vlan_id)) g_assert_not_reached (); if (vlan_parent) printf (" vlan parent %d id %d\n", vlan_parent, vlan_id); - if (nm_platform_link_is_software (SINGLETON, link->ifindex)) + if (nm_platform_link_is_software (NM_PLATFORM_GET, link->ifindex)) printf (" class software\n"); - if (nm_platform_link_supports_slaves (SINGLETON, link->ifindex)) + if (nm_platform_link_supports_slaves (NM_PLATFORM_GET, link->ifindex)) printf (" class supports-slaves\n"); - if (nm_platform_link_supports_carrier_detect (SINGLETON, link->ifindex)) + if (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, link->ifindex)) printf (" feature carrier-detect\n"); - if (nm_platform_link_supports_vlans (SINGLETON, link->ifindex)) + if (nm_platform_link_supports_vlans (NM_PLATFORM_GET, link->ifindex)) printf (" feature vlans\n"); - address = nm_platform_link_get_address (SINGLETON, link->ifindex, &addrlen); + address = nm_platform_link_get_address (NM_PLATFORM_GET, link->ifindex, &addrlen); if (address) { printf (" link-address "); for (i = 0; i < addrlen; i++) @@ -66,8 +66,8 @@ dump_interface (NMPlatformLink *link) printf ("\n"); } - ip4_addresses = nm_platform_ip4_address_get_all (SINGLETON, link->ifindex); - ip6_addresses = nm_platform_ip6_address_get_all (SINGLETON, link->ifindex); + ip4_addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, link->ifindex); + ip6_addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, link->ifindex); g_assert (ip4_addresses); g_assert (ip6_addresses); @@ -85,8 +85,8 @@ dump_interface (NMPlatformLink *link) g_array_unref (ip4_addresses); g_array_unref (ip6_addresses); - ip4_routes = nm_platform_ip4_route_get_all (SINGLETON, link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); - ip6_routes = nm_platform_ip6_route_get_all (SINGLETON, link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); + ip4_routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); + ip6_routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, link->ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); g_assert (ip4_routes); g_assert (ip6_routes); @@ -112,7 +112,7 @@ dump_interface (NMPlatformLink *link) static void dump_all (void) { - GArray *links = nm_platform_link_get_all (SINGLETON); + GArray *links = nm_platform_link_get_all (NM_PLATFORM_GET); int i; for (i = 0; i < links->len; i++) diff --git a/src/platform/tests/platform.c b/src/platform/tests/platform.c index 5ed4121bd7..07ca8f9108 100644 --- a/src/platform/tests/platform.c +++ b/src/platform/tests/platform.c @@ -44,13 +44,13 @@ typedef const char *string_t; static gboolean do_sysctl_set (char **argv) { - return nm_platform_sysctl_set (SINGLETON, argv[0], argv[1]); + return nm_platform_sysctl_set (NM_PLATFORM_GET, argv[0], argv[1]); } static gboolean do_sysctl_get (char **argv) { - gs_free char *value = nm_platform_sysctl_get (SINGLETON, argv[0]); + gs_free char *value = nm_platform_sysctl_get (NM_PLATFORM_GET, argv[0]); printf ("%s\n", value); @@ -66,7 +66,7 @@ parse_ifindex (const char *str) ifindex = strtol (str, &endptr, 10); if (*endptr) { - ifindex = nm_platform_link_get_ifindex (SINGLETON, str); + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, str); } return ifindex; @@ -79,7 +79,7 @@ do_link_get_all (char **argv) NMPlatformLink *device; int i; - links = nm_platform_link_get_all (SINGLETON); + links = nm_platform_link_get_all (NM_PLATFORM_GET); for (i = 0; i < links->len; i++) { device = &g_array_index (links, NMPlatformLink, i); @@ -93,25 +93,25 @@ do_link_get_all (char **argv) static gboolean do_dummy_add (char **argv) { - return nm_platform_dummy_add (SINGLETON, argv[0]); + return nm_platform_dummy_add (NM_PLATFORM_GET, argv[0]); } static gboolean do_bridge_add (char **argv) { - return nm_platform_bridge_add (SINGLETON, argv[0], NULL, 0); + return nm_platform_bridge_add (NM_PLATFORM_GET, argv[0], NULL, 0); } static gboolean do_bond_add (char **argv) { - return nm_platform_bond_add (SINGLETON, argv[0]); + return nm_platform_bond_add (NM_PLATFORM_GET, argv[0]); } static gboolean do_team_add (char **argv) { - return nm_platform_team_add (SINGLETON, argv[0]); + return nm_platform_team_add (NM_PLATFORM_GET, argv[0]); } static gboolean @@ -122,13 +122,13 @@ do_vlan_add (char **argv) int vlanid = strtol (*argv++, NULL, 10); guint32 vlan_flags = strtol (*argv++, NULL, 10); - return nm_platform_vlan_add (SINGLETON, name, parent, vlanid, vlan_flags); + return nm_platform_vlan_add (NM_PLATFORM_GET, name, parent, vlanid, vlan_flags); } static gboolean do_link_exists (char **argv) { - gboolean value = nm_platform_link_exists (SINGLETON, argv[0]); + gboolean value = nm_platform_link_exists (NM_PLATFORM_GET, argv[0]); print_boolean (value); @@ -140,7 +140,7 @@ do_link_exists (char **argv) do_link_##cmdname (char **argv) \ { \ int ifindex = parse_ifindex (argv[0]); \ - return ifindex ? nm_platform_link_##cmdname (SINGLETON, ifindex) : FALSE; \ + return ifindex ? nm_platform_link_##cmdname (NM_PLATFORM_GET, ifindex) : FALSE; \ } #define LINK_CMD_GET_FULL(cmdname, type, cond) \ @@ -149,7 +149,7 @@ do_link_exists (char **argv) { \ int ifindex = parse_ifindex (argv[0]); \ if (ifindex) { \ - type##_t value = nm_platform_link_##cmdname (SINGLETON, ifindex); \ + type##_t value = nm_platform_link_##cmdname (NM_PLATFORM_GET, ifindex); \ if (cond) { \ print_##type (value); \ return TRUE; \ @@ -169,7 +169,7 @@ LINK_CMD (delete) static gboolean do_link_get_ifindex (char **argv) { - int ifindex = nm_platform_link_get_ifindex (SINGLETON, argv[0]); + int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, argv[0]); if (ifindex) printf ("%d\n", ifindex); @@ -213,7 +213,7 @@ do_link_set_address (char **argv) g_assert (!*endptr); } - return nm_platform_link_set_address (SINGLETON, ifindex, address, sizeof (address)); + return nm_platform_link_set_address (NM_PLATFORM_GET, ifindex, address, sizeof (address)); } static gboolean @@ -224,7 +224,7 @@ do_link_get_address (char **argv) size_t length; int i; - address = nm_platform_link_get_address (SINGLETON, ifindex, &length); + address = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &length); if (!address || length <= 0) return FALSE; @@ -242,7 +242,7 @@ do_link_set_mtu (char **argv) int ifindex = parse_ifindex (*argv++); int mtu = strtoul (*argv++, NULL, 10); - return nm_platform_link_set_mtu (SINGLETON, ifindex, mtu); + return nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, mtu); } LINK_CMD_GET (get_mtu, decimal); @@ -255,7 +255,7 @@ do_link_enslave (char **argv) int master = parse_ifindex (*argv++); int slave = parse_ifindex (*argv++); - return nm_platform_link_enslave (SINGLETON, master, slave); + return nm_platform_link_enslave (NM_PLATFORM_GET, master, slave); } static gboolean @@ -264,7 +264,7 @@ do_link_release (char **argv) int master = parse_ifindex (*argv++); int slave = parse_ifindex (*argv++); - return nm_platform_link_release (SINGLETON, master, slave); + return nm_platform_link_release (NM_PLATFORM_GET, master, slave); } LINK_CMD_GET (get_master, decimal) @@ -276,7 +276,7 @@ do_master_set_option (char **argv) const char *option = *argv++; const char *value = *argv++; - return nm_platform_master_set_option (SINGLETON, ifindex, option, value); + return nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, option, value); } static gboolean @@ -284,7 +284,7 @@ do_master_get_option (char **argv) { int ifindex = parse_ifindex (*argv++); const char *option = *argv++; - gs_free char *value = nm_platform_master_get_option (SINGLETON, ifindex, option); + gs_free char *value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, option); printf ("%s\n", value); @@ -298,7 +298,7 @@ do_slave_set_option (char **argv) const char *option = *argv++; const char *value = *argv++; - return nm_platform_slave_set_option (SINGLETON, ifindex, option, value); + return nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, option, value); } static gboolean @@ -306,7 +306,7 @@ do_slave_get_option (char **argv) { int ifindex = parse_ifindex (*argv++); const char *option = *argv++; - gs_free char *value = nm_platform_slave_get_option (SINGLETON, ifindex, option); + gs_free char *value = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex, option); printf ("%s\n", value); @@ -320,7 +320,7 @@ do_vlan_get_info (char **argv) int parent; int vlanid; - if (!nm_platform_vlan_get_info (SINGLETON, ifindex, &parent, &vlanid)) + if (!nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &parent, &vlanid)) return FALSE; printf ("%d %d\n", parent, vlanid); @@ -335,7 +335,7 @@ do_vlan_set_ingress_map (char **argv) int from = strtol (*argv++, NULL, 10); int to = strtol (*argv++, NULL, 10); - return nm_platform_vlan_set_ingress_map (SINGLETON, ifindex, from, to); + return nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, from, to); } static gboolean @@ -345,7 +345,7 @@ do_vlan_set_egress_map (char **argv) int from = strtol (*argv++, NULL, 10); int to = strtol (*argv++, NULL, 10); - return nm_platform_vlan_set_egress_map (SINGLETON, ifindex, from, to); + return nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, from, to); } static gboolean @@ -354,7 +354,7 @@ do_veth_get_properties (char **argv) int ifindex = parse_ifindex (*argv++); NMPlatformVethProperties props; - if (!nm_platform_veth_get_properties (SINGLETON, ifindex, &props)) + if (!nm_platform_veth_get_properties (NM_PLATFORM_GET, ifindex, &props)) return FALSE; printf ("peer: %d\n", props.peer); @@ -368,7 +368,7 @@ do_tun_get_properties (char **argv) int ifindex = parse_ifindex (*argv++); NMPlatformTunProperties props; - if (!nm_platform_tun_get_properties (SINGLETON, ifindex, &props)) + if (!nm_platform_tun_get_properties (NM_PLATFORM_GET, ifindex, &props)) return FALSE; printf ("mode: %s\n", props.mode); @@ -396,7 +396,7 @@ do_macvlan_get_properties (char **argv) int ifindex = parse_ifindex (*argv++); NMPlatformMacvlanProperties props; - if (!nm_platform_macvlan_get_properties (SINGLETON, ifindex, &props)) + if (!nm_platform_macvlan_get_properties (NM_PLATFORM_GET, ifindex, &props)) return FALSE; printf ("parent: %d\n", props.parent_ifindex); @@ -413,7 +413,7 @@ do_vxlan_get_properties (char **argv) NMPlatformVxlanProperties props; char addrstr[INET6_ADDRSTRLEN]; - if (!nm_platform_vxlan_get_properties (SINGLETON, ifindex, &props)) + if (!nm_platform_vxlan_get_properties (NM_PLATFORM_GET, ifindex, &props)) return FALSE; printf ("parent-ifindex: %u\n", props.parent_ifindex); @@ -460,7 +460,7 @@ do_gre_get_properties (char **argv) NMPlatformGreProperties props; char addrstr[INET_ADDRSTRLEN]; - if (!nm_platform_gre_get_properties (SINGLETON, ifindex, &props)) + if (!nm_platform_gre_get_properties (NM_PLATFORM_GET, ifindex, &props)) return FALSE; printf ("parent-ifindex: %u\n", props.parent_ifindex); @@ -496,7 +496,7 @@ do_ip4_address_get_all (char **argv) int i; if (ifindex) { - addresses = nm_platform_ip4_address_get_all (SINGLETON, ifindex); + addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex); for (i = 0; i < addresses->len; i++) { address = &g_array_index (addresses, NMPlatformIP4Address, i); inet_ntop (AF_INET, &address->address, addrstr, sizeof (addrstr)); @@ -518,7 +518,7 @@ do_ip6_address_get_all (char **argv) int i; if (ifindex) { - addresses = nm_platform_ip6_address_get_all (SINGLETON, ifindex); + addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex); for (i = 0; i < addresses->len; i++) { address = &g_array_index (addresses, NMPlatformIP6Address, i); inet_ntop (AF_INET6, &address->address, addrstr, sizeof (addrstr)); @@ -576,7 +576,7 @@ do_ip4_address_add (char **argv) guint32 lifetime = strtol (*argv++, NULL, 10); guint32 preferred = strtol (*argv++, NULL, 10); - gboolean value = nm_platform_ip4_address_add (SINGLETON, ifindex, address, 0, plen, lifetime, preferred, NULL); + gboolean value = nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, address, 0, plen, lifetime, preferred, NULL); return value; } else return FALSE; @@ -594,7 +594,7 @@ do_ip6_address_add (char **argv) guint32 preferred = strtol (*argv++, NULL, 10); guint flags = (*argv) ? rtnl_addr_str2flags (*argv++) : 0; - gboolean value = nm_platform_ip6_address_add (SINGLETON, ifindex, address, in6addr_any, plen, lifetime, preferred, flags); + gboolean value = nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, address, in6addr_any, plen, lifetime, preferred, flags); return value; } else return FALSE; @@ -608,7 +608,7 @@ do_ip6_address_add (char **argv) v##_t address; \ int plen; \ if (ifindex && parse_##v##_address (*argv++, &address, &plen)) { \ - gboolean value = nm_platform_##v##_address_##cmdname (SINGLETON, ifindex, address, plen, ##__VA_ARGS__); \ + gboolean value = nm_platform_##v##_address_##cmdname (NM_PLATFORM_GET, ifindex, address, plen, ##__VA_ARGS__); \ if (print) { \ print_boolean (value); \ return TRUE; \ @@ -633,7 +633,7 @@ do_ip4_route_get_all (char **argv) int i; if (ifindex) { - routes = nm_platform_ip4_route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); + routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); for (i = 0; i < routes->len; i++) { route = &g_array_index (routes, NMPlatformIP4Route, i); inet_ntop (AF_INET, &route->network, networkstr, sizeof (networkstr)); @@ -657,7 +657,7 @@ do_ip6_route_get_all (char **argv) int i; if (ifindex) { - routes = nm_platform_ip6_route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); + routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); for (i = 0; i < routes->len; i++) { route = &g_array_index (routes, NMPlatformIP6Route, i); inet_ntop (AF_INET6, &route->network, networkstr, sizeof (networkstr)); @@ -683,7 +683,7 @@ do_ip4_route_add (char **argv) metric = strtol (*argv++, NULL, 10); mss = strtol (*argv++, NULL, 10); - return nm_platform_ip4_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, + return nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss); } @@ -699,7 +699,7 @@ do_ip6_route_add (char **argv) parse_ip6_address (*argv++, &gateway, NULL); metric = strtol (*argv++, NULL, 10); mss = strtol (*argv++, NULL, 10); - return nm_platform_ip6_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, + return nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss); } @@ -714,7 +714,7 @@ do_ip4_route_delete (char **argv) parse_ip4_address (*argv++, &network, &plen); metric = strtol (*argv++, NULL, 10); - return nm_platform_ip4_route_delete (SINGLETON, ifindex, network, plen, metric); + return nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric); } static gboolean @@ -727,7 +727,7 @@ do_ip6_route_delete (char **argv) parse_ip6_address (*argv++, &network, &plen); metric = strtol (*argv++, NULL, 10); - return nm_platform_ip6_route_delete (SINGLETON, ifindex, network, plen, metric); + return nm_platform_ip6_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric); } static gboolean @@ -740,7 +740,7 @@ do_ip4_route_exists (char **argv) parse_ip4_address (*argv++, &network, &plen); metric = strtol (*argv++, NULL, 10); - print_boolean (nm_platform_ip4_route_exists (SINGLETON, ifindex, network, plen, metric)); + print_boolean (nm_platform_ip4_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric)); return TRUE; } @@ -754,7 +754,7 @@ do_ip6_route_exists (char **argv) parse_ip6_address (*argv++, &network, &plen); metric = strtol (*argv++, NULL, 10); - print_boolean (nm_platform_ip6_route_exists (SINGLETON, ifindex, network, plen, metric)); + print_boolean (nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric)); return TRUE; } @@ -892,9 +892,9 @@ main (int argc, char **argv) error ("\n"); } - error = nm_platform_get_error (SINGLETON); + error = nm_platform_get_error (NM_PLATFORM_GET); if (error) { - const char *msg = nm_platform_get_error_msg (SINGLETON); + const char *msg = nm_platform_get_error_msg (NM_PLATFORM_GET); error ("nm-platform: %s\n", msg); } diff --git a/src/platform/tests/test-address.c b/src/platform/tests/test-address.c index 81b3808ef8..9463ae4e9f 100644 --- a/src/platform/tests/test-address.c +++ b/src/platform/tests/test-address.c @@ -55,7 +55,7 @@ ip6_address_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Address *r static void test_ip4_address (void) { - int ifindex = nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME); + int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); SignalData *address_added = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_address_callback, ifindex); SignalData *address_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_address_callback, ifindex); SignalData *address_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_address_callback, ifindex); @@ -68,21 +68,21 @@ test_ip4_address (void) inet_pton (AF_INET, IP4_ADDRESS, &addr); /* Add address */ - g_assert (!nm_platform_ip4_address_exists (SINGLETON, ifindex, addr, IP4_PLEN)); + g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN)); no_error (); - g_assert (nm_platform_ip4_address_add (SINGLETON, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL)); + g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL)); no_error (); - g_assert (nm_platform_ip4_address_exists (SINGLETON, ifindex, addr, IP4_PLEN)); + g_assert (nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN)); no_error (); accept_signal (address_added); /* Add address again (aka update) */ - g_assert (nm_platform_ip4_address_add (SINGLETON, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL)); + g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL)); no_error (); accept_signal (address_changed); /* Test address listing */ - addresses = nm_platform_ip4_address_get_all (SINGLETON, ifindex); + addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex); g_assert (addresses); no_error (); g_assert_cmpint (addresses->len, ==, 1); @@ -93,13 +93,13 @@ test_ip4_address (void) g_array_unref (addresses); /* Remove address */ - g_assert (nm_platform_ip4_address_delete (SINGLETON, ifindex, addr, IP4_PLEN, 0)); + g_assert (nm_platform_ip4_address_delete (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0)); no_error (); - g_assert (!nm_platform_ip4_address_exists (SINGLETON, ifindex, addr, IP4_PLEN)); + g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN)); accept_signal (address_removed); /* Remove address again */ - g_assert (nm_platform_ip4_address_delete (SINGLETON, ifindex, addr, IP4_PLEN, 0)); + g_assert (nm_platform_ip4_address_delete (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0)); no_error (); free_signal (address_added); @@ -110,7 +110,7 @@ test_ip4_address (void) static void test_ip6_address (void) { - int ifindex = nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME); + int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); SignalData *address_added = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_address_callback, ifindex); SignalData *address_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip6_address_callback, ifindex); SignalData *address_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_address_callback, ifindex); @@ -124,21 +124,21 @@ test_ip6_address (void) inet_pton (AF_INET6, IP6_ADDRESS, &addr); /* Add address */ - g_assert (!nm_platform_ip6_address_exists (SINGLETON, ifindex, addr, IP6_PLEN)); + g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); no_error (); - g_assert (nm_platform_ip6_address_add (SINGLETON, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags)); + g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags)); no_error (); - g_assert (nm_platform_ip6_address_exists (SINGLETON, ifindex, addr, IP6_PLEN)); + g_assert (nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); no_error (); accept_signal (address_added); /* Add address again (aka update) */ - g_assert (nm_platform_ip6_address_add (SINGLETON, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags)); + g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags)); no_error (); accept_signal (address_changed); /* Test address listing */ - addresses = nm_platform_ip6_address_get_all (SINGLETON, ifindex); + addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex); g_assert (addresses); no_error (); g_assert_cmpint (addresses->len, ==, 1); @@ -149,13 +149,13 @@ test_ip6_address (void) g_array_unref (addresses); /* Remove address */ - g_assert (nm_platform_ip6_address_delete (SINGLETON, ifindex, addr, IP6_PLEN)); + g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); no_error (); - g_assert (!nm_platform_ip6_address_exists (SINGLETON, ifindex, addr, IP6_PLEN)); + g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); accept_signal (address_removed); /* Remove address again */ - g_assert (nm_platform_ip6_address_delete (SINGLETON, ifindex, addr, IP6_PLEN)); + g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); no_error (); free_signal (address_added); @@ -168,7 +168,7 @@ test_ip4_address_external (void) { SignalData *address_added = add_signal (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_address_callback); SignalData *address_removed = add_signal (NM_PLATFORM_SIGNAL_IP4_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_address_callback); - int ifindex = nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME); + int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); in_addr_t addr; guint32 lifetime = 2000; guint32 preferred = 1000; @@ -179,28 +179,28 @@ test_ip4_address_external (void) /* Looks like addresses are not announced by kerenl when the interface * is down. Link-local IPv6 address is automatically added. */ - g_assert (nm_platform_link_set_up (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME))); + g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME))); /* Add/delete notification */ run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d", IP4_ADDRESS, IP4_PLEN, DEVICE_NAME, lifetime, preferred); wait_signal (address_added); - g_assert (nm_platform_ip4_address_exists (SINGLETON, ifindex, addr, IP4_PLEN)); + g_assert (nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN)); run_command ("ip address delete %s/%d dev %s", IP4_ADDRESS, IP4_PLEN, DEVICE_NAME); wait_signal (address_removed); - g_assert (!nm_platform_ip4_address_exists (SINGLETON, ifindex, addr, IP4_PLEN)); + g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN)); /* Add/delete conflict */ run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d", IP4_ADDRESS, IP4_PLEN, DEVICE_NAME, lifetime, preferred); - g_assert (nm_platform_ip4_address_add (SINGLETON, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL)); + g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL)); no_error (); - g_assert (nm_platform_ip4_address_exists (SINGLETON, ifindex, addr, IP4_PLEN)); + g_assert (nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN)); accept_signal (address_added); /*run_command ("ip address delete %s/%d dev %s", IP4_ADDRESS, IP4_PLEN, DEVICE_NAME); g_assert (nm_platform_ip4_address_delete (ifindex, addr, IP4_PLEN, 0)); no_error (); - g_assert (!nm_platform_ip4_address_exists (SINGLETON, ifindex, addr, IP4_PLEN)); + g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN)); accept_signal (address_removed);*/ free_signal (address_added); @@ -212,7 +212,7 @@ test_ip6_address_external (void) { SignalData *address_added = add_signal (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_address_callback); SignalData *address_removed = add_signal (NM_PLATFORM_SIGNAL_IP6_ADDRESS_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_address_callback); - int ifindex = nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME); + int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); struct in6_addr addr; guint32 lifetime = 2000; guint32 preferred = 1000; @@ -224,22 +224,22 @@ test_ip6_address_external (void) run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d", IP6_ADDRESS, IP6_PLEN, DEVICE_NAME, lifetime, preferred); wait_signal (address_added); - g_assert (nm_platform_ip6_address_exists (SINGLETON, ifindex, addr, IP6_PLEN)); + g_assert (nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); run_command ("ip address delete %s/%d dev %s", IP6_ADDRESS, IP6_PLEN, DEVICE_NAME); wait_signal (address_removed); - g_assert (!nm_platform_ip6_address_exists (SINGLETON, ifindex, addr, IP6_PLEN)); + g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); /* Add/delete conflict */ run_command ("ip address add %s/%d dev %s valid_lft %d preferred_lft %d", IP6_ADDRESS, IP6_PLEN, DEVICE_NAME, lifetime, preferred); - g_assert (nm_platform_ip6_address_add (SINGLETON, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags)); + g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags)); no_error (); - g_assert (nm_platform_ip6_address_exists (SINGLETON, ifindex, addr, IP6_PLEN)); + g_assert (nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); accept_signal (address_added); /*run_command ("ip address delete %s/%d dev %s", IP6_ADDRESS, IP6_PLEN, DEVICE_NAME); - g_assert (nm_platform_ip6_address_delete (SINGLETON, ifindex, addr, IP6_PLEN)); + g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); no_error (); - g_assert (!nm_platform_ip6_address_exists (SINGLETON, ifindex, addr, IP6_PLEN)); + g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); wait_signal (address_removed);*/ free_signal (address_added); @@ -257,9 +257,9 @@ setup_tests (void) { SignalData *link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME); - nm_platform_link_delete (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME)); - g_assert (!nm_platform_link_exists (SINGLETON, DEVICE_NAME)); - g_assert (nm_platform_dummy_add (SINGLETON, DEVICE_NAME)); + nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); + g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME)); wait_signal (link_added); free_signal (link_added); diff --git a/src/platform/tests/test-cleanup.c b/src/platform/tests/test-cleanup.c index 4cb85235fa..29892c9c83 100644 --- a/src/platform/tests/test-cleanup.c +++ b/src/platform/tests/test-cleanup.c @@ -35,27 +35,27 @@ test_cleanup_internal (void) inet_pton (AF_INET6, "2001:db8:e:f:1:2:3:4", &gateway6); /* Create and set up device */ - g_assert (nm_platform_dummy_add (SINGLETON, DEVICE_NAME)); + g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME)); wait_signal (link_added); free_signal (link_added); - g_assert (nm_platform_link_set_up (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME))); - ifindex = nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME); + g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME))); + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); g_assert (ifindex > 0); /* Add routes and addresses */ - g_assert (nm_platform_ip4_address_add (SINGLETON, ifindex, addr4, 0, plen4, lifetime, preferred, NULL)); - g_assert (nm_platform_ip6_address_add (SINGLETON, ifindex, addr6, in6addr_any, plen6, lifetime, preferred, flags)); - g_assert (nm_platform_ip4_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway4, 32, INADDR_ANY, 0, metric, mss)); - g_assert (nm_platform_ip4_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, network4, plen4, gateway4, 0, metric, mss)); - g_assert (nm_platform_ip4_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway4, 0, metric, mss)); - g_assert (nm_platform_ip6_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway6, 128, in6addr_any, metric, mss)); - g_assert (nm_platform_ip6_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, network6, plen6, gateway6, metric, mss)); - g_assert (nm_platform_ip6_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway6, metric, mss)); - - addresses4 = nm_platform_ip4_address_get_all (SINGLETON, ifindex); - addresses6 = nm_platform_ip6_address_get_all (SINGLETON, ifindex); - routes4 = nm_platform_ip4_route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); - routes6 = nm_platform_ip6_route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); + g_assert (nm_platform_ip4_address_add (NM_PLATFORM_GET, ifindex, addr4, 0, plen4, lifetime, preferred, NULL)); + g_assert (nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, addr6, in6addr_any, plen6, lifetime, preferred, flags)); + g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway4, 32, INADDR_ANY, 0, metric, mss)); + g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network4, plen4, gateway4, 0, metric, mss)); + g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway4, 0, metric, mss)); + g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway6, 128, in6addr_any, metric, mss)); + g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network6, plen6, gateway6, metric, mss)); + g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway6, metric, mss)); + + addresses4 = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex); + addresses6 = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex); + routes4 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); + routes6 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); g_assert_cmpint (addresses4->len, ==, 1); g_assert_cmpint (addresses6->len, ==, 1); @@ -68,12 +68,12 @@ test_cleanup_internal (void) g_array_unref (routes6); /* Delete interface with all addresses and routes */ - g_assert (nm_platform_link_delete (SINGLETON, ifindex)); + g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex)); - addresses4 = nm_platform_ip4_address_get_all (SINGLETON, ifindex); - addresses6 = nm_platform_ip6_address_get_all (SINGLETON, ifindex); - routes4 = nm_platform_ip4_route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); - routes6 = nm_platform_ip6_route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); + addresses4 = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex); + addresses6 = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex); + routes4 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); + routes6 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); g_assert_cmpint (addresses4->len, ==, 0); g_assert_cmpint (addresses6->len, ==, 0); @@ -95,8 +95,8 @@ init_tests (int *argc, char ***argv) void setup_tests (void) { - nm_platform_link_delete (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME)); - g_assert (!nm_platform_link_exists (SINGLETON, DEVICE_NAME)); + nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); g_test_add_func ("/internal", test_cleanup_internal); /* FIXME: add external cleanup check */ diff --git a/src/platform/tests/test-common.c b/src/platform/tests/test-common.c index 6f82dc95b9..708e2cad82 100644 --- a/src/platform/tests/test-common.c +++ b/src/platform/tests/test-common.c @@ -84,7 +84,7 @@ link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPl if (data->ifindex && data->ifindex != received->ifindex) return; - if (data->ifname && g_strcmp0 (data->ifname, nm_platform_link_get_name (SINGLETON, ifindex)) != 0) + if (data->ifname && g_strcmp0 (data->ifname, nm_platform_link_get_name (NM_PLATFORM_GET, ifindex)) != 0) return; if (change_type != data->change_type) return; @@ -101,13 +101,13 @@ link_callback (NMPlatform *platform, int ifindex, NMPlatformLink *received, NMPl data->received = TRUE; if (change_type == NM_PLATFORM_SIGNAL_REMOVED) - g_assert (!nm_platform_link_get_name (SINGLETON, ifindex)); + g_assert (!nm_platform_link_get_name (NM_PLATFORM_GET, ifindex)); else - g_assert (nm_platform_link_get_name (SINGLETON, ifindex)); + g_assert (nm_platform_link_get_name (NM_PLATFORM_GET, ifindex)); /* Check the data */ g_assert (received->ifindex > 0); - links = nm_platform_link_get_all (SINGLETON); + links = nm_platform_link_get_all (NM_PLATFORM_GET); for (i = 0; i < links->len; i++) { cached = &g_array_index (links, NMPlatformLink, i); if (cached->ifindex == received->ifindex) { @@ -221,9 +221,9 @@ _assert_ip4_route_exists (const char *file, guint line, const char *func, gboole exists ? "doesn't" : "does"); } - ifindex = nm_platform_link_get_ifindex (SINGLETON, ifname); + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname); g_assert (ifindex > 0); - if (!nm_platform_ip4_route_exists (SINGLETON, ifindex, network, plen, metric) != !exists) { + if (!nm_platform_ip4_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric) != !exists) { g_error ("[%s:%u] %s(): The ip4 route %s/%d metric %u %s, but platform thinks %s", file, line, func, nm_utils_inet4_ntop (network, NULL), plen, metric, @@ -278,7 +278,7 @@ main (int argc, char **argv) result = g_test_run (); - nm_platform_link_delete (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME)); + nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)); nm_platform_free (); return result; diff --git a/src/platform/tests/test-common.h b/src/platform/tests/test-common.h index 34cead3b15..e51f26ab2f 100644 --- a/src/platform/tests/test-common.h +++ b/src/platform/tests/test-common.h @@ -15,7 +15,7 @@ #define debug(...) nm_log_dbg (LOGD_PLATFORM, __VA_ARGS__) -#define error(err) g_assert (nm_platform_get_error (SINGLETON) == err) +#define error(err) g_assert (nm_platform_get_error (NM_PLATFORM_GET) == err) #define no_error() error (NM_PLATFORM_ERROR_NONE) typedef struct { diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index dea06f785b..dcce8827f2 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -21,68 +21,68 @@ test_bogus(void) { size_t addrlen; - g_assert (!nm_platform_link_exists (SINGLETON, BOGUS_NAME)); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, BOGUS_NAME)); no_error (); - g_assert (!nm_platform_link_delete (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_get_ifindex (SINGLETON, BOGUS_NAME)); + g_assert (!nm_platform_link_get_ifindex (NM_PLATFORM_GET, BOGUS_NAME)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_get_name (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_get_name (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_get_type (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_get_type (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_get_type_name (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_get_type_name (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_set_up (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_set_up (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_set_down (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_set_down (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_set_arp (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_set_arp (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_set_noarp (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_set_noarp (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_is_up (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_is_connected (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_uses_arp (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_get_address (SINGLETON, BOGUS_IFINDEX, &addrlen)); + g_assert (!nm_platform_link_get_address (NM_PLATFORM_GET, BOGUS_IFINDEX, &addrlen)); g_assert (!addrlen); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_get_address (SINGLETON, BOGUS_IFINDEX, NULL)); + g_assert (!nm_platform_link_get_address (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_set_mtu (SINGLETON, BOGUS_IFINDEX, MTU)); + g_assert (!nm_platform_link_set_mtu (NM_PLATFORM_GET, BOGUS_IFINDEX, MTU)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_get_mtu (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_get_mtu (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_supports_carrier_detect (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_supports_vlans (SINGLETON, BOGUS_IFINDEX)); + g_assert (!nm_platform_link_supports_vlans (NM_PLATFORM_GET, BOGUS_IFINDEX)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_vlan_get_info (SINGLETON, BOGUS_IFINDEX, NULL, NULL)); + g_assert (!nm_platform_vlan_get_info (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL, NULL)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_vlan_set_ingress_map (SINGLETON, BOGUS_IFINDEX, 0, 0)); + g_assert (!nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0)); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_vlan_set_egress_map (SINGLETON, BOGUS_IFINDEX, 0, 0)); + g_assert (!nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0)); error (NM_PLATFORM_ERROR_NOT_FOUND); } static void test_loopback (void) { - g_assert (nm_platform_link_exists (SINGLETON, LO_NAME)); - g_assert_cmpint (nm_platform_link_get_type (SINGLETON, LO_INDEX), ==, NM_LINK_TYPE_LOOPBACK); - g_assert_cmpint (nm_platform_link_get_ifindex (SINGLETON, LO_NAME), ==, LO_INDEX); - g_assert_cmpstr (nm_platform_link_get_name (SINGLETON, LO_INDEX), ==, LO_NAME); - g_assert_cmpstr (nm_platform_link_get_type_name (SINGLETON, LO_INDEX), ==, LO_TYPEDESC); - - g_assert (nm_platform_link_supports_carrier_detect (SINGLETON, LO_INDEX)); - g_assert (!nm_platform_link_supports_vlans (SINGLETON, LO_INDEX)); + g_assert (nm_platform_link_exists (NM_PLATFORM_GET, LO_NAME)); + g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, LO_INDEX), ==, NM_LINK_TYPE_LOOPBACK); + g_assert_cmpint (nm_platform_link_get_ifindex (NM_PLATFORM_GET, LO_NAME), ==, LO_INDEX); + g_assert_cmpstr (nm_platform_link_get_name (NM_PLATFORM_GET, LO_INDEX), ==, LO_NAME); + g_assert_cmpstr (nm_platform_link_get_type_name (NM_PLATFORM_GET, LO_INDEX), ==, LO_TYPEDESC); + + g_assert (nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, LO_INDEX)); + g_assert (!nm_platform_link_supports_vlans (NM_PLATFORM_GET, LO_INDEX)); } static int @@ -90,43 +90,43 @@ software_add (NMLinkType link_type, const char *name) { switch (link_type) { case NM_LINK_TYPE_DUMMY: - return nm_platform_dummy_add (SINGLETON, name); + return nm_platform_dummy_add (NM_PLATFORM_GET, name); case NM_LINK_TYPE_BRIDGE: - return nm_platform_bridge_add (SINGLETON, name, NULL, 0); + return nm_platform_bridge_add (NM_PLATFORM_GET, name, NULL, 0); case NM_LINK_TYPE_BOND: { - gboolean bond0_exists = nm_platform_link_exists (SINGLETON, "bond0"); - gboolean result = nm_platform_bond_add (SINGLETON, name); - NMPlatformError error = nm_platform_get_error (SINGLETON); + gboolean bond0_exists = nm_platform_link_exists (NM_PLATFORM_GET, "bond0"); + gboolean result = nm_platform_bond_add (NM_PLATFORM_GET, name); + NMPlatformError error = nm_platform_get_error (NM_PLATFORM_GET); /* Check that bond0 is *not* automatically created. */ if (!bond0_exists) - g_assert (!nm_platform_link_exists (SINGLETON, "bond0")); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, "bond0")); - nm_platform_set_error (SINGLETON, error); + nm_platform_set_error (NM_PLATFORM_GET, error); return result; } case NM_LINK_TYPE_TEAM: - return nm_platform_team_add (SINGLETON, name); + return nm_platform_team_add (NM_PLATFORM_GET, name); case NM_LINK_TYPE_VLAN: { SignalData *parent_added; SignalData *parent_changed; /* Don't call link_callback for the bridge interface */ parent_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, PARENT_NAME); - if (nm_platform_bridge_add (SINGLETON, PARENT_NAME, NULL, 0)) + if (nm_platform_bridge_add (NM_PLATFORM_GET, PARENT_NAME, NULL, 0)) wait_signal (parent_added); free_signal (parent_added); { - int parent_ifindex = nm_platform_link_get_ifindex (SINGLETON, PARENT_NAME); + int parent_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, PARENT_NAME); parent_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, parent_ifindex); - g_assert (nm_platform_link_set_up (SINGLETON, parent_ifindex)); + g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, parent_ifindex)); accept_signal (parent_changed); free_signal (parent_changed); - return nm_platform_vlan_add (SINGLETON, name, parent_ifindex, VLAN_ID, 0); + return nm_platform_vlan_add (NM_PLATFORM_GET, name, parent_ifindex, VLAN_ID, 0); } } default: @@ -144,7 +144,7 @@ test_slave (int master, int type, SignalData *master_changed) char *value; g_assert (software_add (type, SLAVE_NAME)); - ifindex = nm_platform_link_get_ifindex (SINGLETON, SLAVE_NAME); + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, SLAVE_NAME); g_assert (ifindex > 0); link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex); link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex); @@ -154,19 +154,19 @@ test_slave (int master, int type, SignalData *master_changed) * * See https://bugzilla.redhat.com/show_bug.cgi?id=910348 */ - g_assert (nm_platform_link_set_down (SINGLETON, ifindex)); - g_assert (!nm_platform_link_is_up (SINGLETON, ifindex)); + g_assert (nm_platform_link_set_down (NM_PLATFORM_GET, ifindex)); + g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); accept_signal (link_changed); /* Enslave */ link_changed->ifindex = ifindex; - g_assert (nm_platform_link_enslave (SINGLETON, master, ifindex)); no_error (); - g_assert_cmpint (nm_platform_link_get_master (SINGLETON, ifindex), ==, master); no_error (); + g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex)); no_error (); + g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, master); no_error (); accept_signal (link_changed); accept_signal (master_changed); /* Set master up */ - g_assert (nm_platform_link_set_up (SINGLETON, master)); + g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, master)); accept_signal (master_changed); /* Master with a disconnected slave is disconnected @@ -174,26 +174,26 @@ test_slave (int master, int type, SignalData *master_changed) * For some reason, bonding and teaming slaves are automatically set up. We * need to set them back down for this test. */ - switch (nm_platform_link_get_type (SINGLETON, master)) { + switch (nm_platform_link_get_type (NM_PLATFORM_GET, master)) { case NM_LINK_TYPE_BOND: case NM_LINK_TYPE_TEAM: - g_assert (nm_platform_link_set_down (SINGLETON, ifindex)); + g_assert (nm_platform_link_set_down (NM_PLATFORM_GET, ifindex)); accept_signal (link_changed); accept_signal (master_changed); break; default: break; } - g_assert (!nm_platform_link_is_up (SINGLETON, ifindex)); - g_assert (!nm_platform_link_is_connected (SINGLETON, ifindex)); - if (nm_platform_link_is_connected (SINGLETON, master)) { - if (nm_platform_link_get_type (SINGLETON, master) == NM_LINK_TYPE_TEAM) { + g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); + g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); + if (nm_platform_link_is_connected (NM_PLATFORM_GET, master)) { + if (nm_platform_link_get_type (NM_PLATFORM_GET, master) == NM_LINK_TYPE_TEAM) { /* Older team versions (e.g. Fedora 17) have a bug that team master stays * IFF_LOWER_UP even if its slave is down. Double check it with iproute2 and if * `ip link` also claims master to be up, accept it. */ char *stdout_str = NULL; - nmtst_spawn_sync (NULL, &stdout_str, NULL, 0, "/sbin/ip", "link", "show", "dev", nm_platform_link_get_name (SINGLETON, master)); + nmtst_spawn_sync (NULL, &stdout_str, NULL, 0, "/sbin/ip", "link", "show", "dev", nm_platform_link_get_name (NM_PLATFORM_GET, master)); g_assert (strstr (stdout_str, "LOWER_UP")); g_free (stdout_str); @@ -202,9 +202,9 @@ test_slave (int master, int type, SignalData *master_changed) } /* Set slave up and see if master gets up too */ - g_assert (nm_platform_link_set_up (SINGLETON, ifindex)); no_error (); - g_assert (nm_platform_link_is_connected (SINGLETON, ifindex)); - g_assert (nm_platform_link_is_connected (SINGLETON, master)); + g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, ifindex)); no_error (); + g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); + g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, master)); accept_signal (link_changed); accept_signal (master_changed); @@ -212,16 +212,16 @@ test_slave (int master, int type, SignalData *master_changed) * * Gracefully succeed if already enslaved. */ - g_assert (nm_platform_link_enslave (SINGLETON, master, ifindex)); no_error (); + g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex)); no_error (); accept_signal (link_changed); accept_signal (master_changed); /* Set slave option */ switch (type) { case NM_LINK_TYPE_BRIDGE: - g_assert (nm_platform_slave_set_option (SINGLETON, ifindex, "priority", "789")); + g_assert (nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, "priority", "789")); no_error (); - value = nm_platform_slave_get_option (SINGLETON, ifindex, "priority"); + value = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex, "priority"); no_error (); g_assert_cmpstr (value, ==, "789"); g_free (value); @@ -231,17 +231,17 @@ test_slave (int master, int type, SignalData *master_changed) } /* Release */ - g_assert (nm_platform_link_release (SINGLETON, master, ifindex)); - g_assert_cmpint (nm_platform_link_get_master (SINGLETON, ifindex), ==, 0); no_error (); + g_assert (nm_platform_link_release (NM_PLATFORM_GET, master, ifindex)); + g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, 0); no_error (); accept_signal (link_changed); accept_signal (master_changed); /* Release again */ - g_assert (!nm_platform_link_release (SINGLETON, master, ifindex)); + g_assert (!nm_platform_link_release (NM_PLATFORM_GET, master, ifindex)); error (NM_PLATFORM_ERROR_NOT_SLAVE); /* Remove */ - g_assert (nm_platform_link_delete (SINGLETON, ifindex)); + g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex)); no_error (); accept_signal (link_removed); @@ -264,16 +264,16 @@ test_software (NMLinkType link_type, const char *link_typename) g_assert (software_add (link_type, DEVICE_NAME)); no_error (); wait_signal (link_added); - g_assert (nm_platform_link_exists (SINGLETON, DEVICE_NAME)); - ifindex = nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME); + g_assert (nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); g_assert (ifindex >= 0); - g_assert_cmpint (nm_platform_link_get_type (SINGLETON, ifindex), ==, link_type); - g_assert_cmpstr (nm_platform_link_get_type_name (SINGLETON, ifindex), ==, link_typename); + g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, link_type); + g_assert_cmpstr (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex), ==, link_typename); link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex); link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex); if (link_type == NM_LINK_TYPE_VLAN) { - g_assert (nm_platform_vlan_get_info (SINGLETON, ifindex, &vlan_parent, &vlan_id)); - g_assert_cmpint (vlan_parent, ==, nm_platform_link_get_ifindex (SINGLETON, PARENT_NAME)); + g_assert (nm_platform_vlan_get_info (NM_PLATFORM_GET, ifindex, &vlan_parent, &vlan_id)); + g_assert_cmpint (vlan_parent, ==, nm_platform_link_get_ifindex (NM_PLATFORM_GET, PARENT_NAME)); g_assert_cmpint (vlan_id, ==, VLAN_ID); no_error (); } @@ -283,28 +283,28 @@ test_software (NMLinkType link_type, const char *link_typename) error (NM_PLATFORM_ERROR_EXISTS); /* Set ARP/NOARP */ - g_assert (nm_platform_link_uses_arp (SINGLETON, ifindex)); - g_assert (nm_platform_link_set_noarp (SINGLETON, ifindex)); - g_assert (!nm_platform_link_uses_arp (SINGLETON, ifindex)); + g_assert (nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex)); + g_assert (nm_platform_link_set_noarp (NM_PLATFORM_GET, ifindex)); + g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex)); accept_signal (link_changed); - g_assert (nm_platform_link_set_arp (SINGLETON, ifindex)); - g_assert (nm_platform_link_uses_arp (SINGLETON, ifindex)); + g_assert (nm_platform_link_set_arp (NM_PLATFORM_GET, ifindex)); + g_assert (nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex)); accept_signal (link_changed); /* Set master option */ switch (link_type) { case NM_LINK_TYPE_BRIDGE: - g_assert (nm_platform_master_set_option (SINGLETON, ifindex, "forward_delay", "789")); + g_assert (nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, "forward_delay", "789")); no_error (); - value = nm_platform_master_get_option (SINGLETON, ifindex, "forward_delay"); + value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "forward_delay"); no_error (); g_assert_cmpstr (value, ==, "789"); g_free (value); break; case NM_LINK_TYPE_BOND: - g_assert (nm_platform_master_set_option (SINGLETON, ifindex, "mode", "active-backup")); + g_assert (nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, "mode", "active-backup")); no_error (); - value = nm_platform_master_get_option (SINGLETON, ifindex, "mode"); + value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "mode"); no_error (); /* When reading back, the output looks slightly different. */ g_assert (g_str_has_prefix (value, "active-backup")); @@ -328,24 +328,24 @@ test_software (NMLinkType link_type, const char *link_typename) } /* Delete */ - g_assert (nm_platform_link_delete (SINGLETON, ifindex)); + g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex)); no_error (); - g_assert (!nm_platform_link_exists (SINGLETON, DEVICE_NAME)); no_error (); - g_assert_cmpint (nm_platform_link_get_type (SINGLETON, ifindex), ==, NM_LINK_TYPE_NONE); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); no_error (); + g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, NM_LINK_TYPE_NONE); error (NM_PLATFORM_ERROR_NOT_FOUND); - g_assert (!nm_platform_link_get_type (SINGLETON, ifindex)); + g_assert (!nm_platform_link_get_type (NM_PLATFORM_GET, ifindex)); error (NM_PLATFORM_ERROR_NOT_FOUND); accept_signal (link_removed); /* Delete again */ - g_assert (!nm_platform_link_delete (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME))); + g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME))); error (NM_PLATFORM_ERROR_NOT_FOUND); /* VLAN: Delete parent */ if (link_type == NM_LINK_TYPE_VLAN) { SignalData *link_removed_parent = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, vlan_parent); - g_assert (nm_platform_link_delete (SINGLETON, vlan_parent)); + g_assert (nm_platform_link_delete (NM_PLATFORM_GET, vlan_parent)); accept_signal (link_removed_parent); free_signal (link_removed_parent); } @@ -400,75 +400,75 @@ test_internal (void) int ifindex; /* Check the functions for non-existent devices */ - g_assert (!nm_platform_link_exists (SINGLETON, DEVICE_NAME)); no_error (); - g_assert (!nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME)); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); no_error (); + g_assert (!nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)); error (NM_PLATFORM_ERROR_NOT_FOUND); /* Add device */ - g_assert (nm_platform_dummy_add (SINGLETON, DEVICE_NAME)); + g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME)); no_error (); wait_signal (link_added); /* Try to add again */ - g_assert (!nm_platform_dummy_add (SINGLETON, DEVICE_NAME)); + g_assert (!nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME)); error (NM_PLATFORM_ERROR_EXISTS); /* Check device index, name and type */ - ifindex = nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME); + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); g_assert (ifindex > 0); - g_assert_cmpstr (nm_platform_link_get_name (SINGLETON, ifindex), ==, DEVICE_NAME); - g_assert_cmpint (nm_platform_link_get_type (SINGLETON, ifindex), ==, NM_LINK_TYPE_DUMMY); - g_assert_cmpstr (nm_platform_link_get_type_name (SINGLETON, ifindex), ==, DUMMY_TYPEDESC); + g_assert_cmpstr (nm_platform_link_get_name (NM_PLATFORM_GET, ifindex), ==, DEVICE_NAME); + g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, NM_LINK_TYPE_DUMMY); + g_assert_cmpstr (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex), ==, DUMMY_TYPEDESC); link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex); link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex); /* Up/connected */ - g_assert (!nm_platform_link_is_up (SINGLETON, ifindex)); no_error (); - g_assert (!nm_platform_link_is_connected (SINGLETON, ifindex)); no_error (); - g_assert (nm_platform_link_set_up (SINGLETON, ifindex)); no_error (); - g_assert (nm_platform_link_is_up (SINGLETON, ifindex)); no_error (); - g_assert (nm_platform_link_is_connected (SINGLETON, ifindex)); no_error (); + g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); no_error (); + g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); no_error (); + g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, ifindex)); no_error (); + g_assert (nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); no_error (); + g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); no_error (); accept_signal (link_changed); - g_assert (nm_platform_link_set_down (SINGLETON, ifindex)); no_error (); - g_assert (!nm_platform_link_is_up (SINGLETON, ifindex)); no_error (); - g_assert (!nm_platform_link_is_connected (SINGLETON, ifindex)); no_error (); + g_assert (nm_platform_link_set_down (NM_PLATFORM_GET, ifindex)); no_error (); + g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); no_error (); + g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); no_error (); accept_signal (link_changed); /* arp/noarp */ - g_assert (!nm_platform_link_uses_arp (SINGLETON, ifindex)); - g_assert (nm_platform_link_set_arp (SINGLETON, ifindex)); - g_assert (nm_platform_link_uses_arp (SINGLETON, ifindex)); + g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex)); + g_assert (nm_platform_link_set_arp (NM_PLATFORM_GET, ifindex)); + g_assert (nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex)); accept_signal (link_changed); - g_assert (nm_platform_link_set_noarp (SINGLETON, ifindex)); - g_assert (!nm_platform_link_uses_arp (SINGLETON, ifindex)); + g_assert (nm_platform_link_set_noarp (NM_PLATFORM_GET, ifindex)); + g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex)); accept_signal (link_changed); /* Features */ - g_assert (!nm_platform_link_supports_carrier_detect (SINGLETON, ifindex)); - g_assert (nm_platform_link_supports_vlans (SINGLETON, ifindex)); + g_assert (!nm_platform_link_supports_carrier_detect (NM_PLATFORM_GET, ifindex)); + g_assert (nm_platform_link_supports_vlans (NM_PLATFORM_GET, ifindex)); /* Set MAC address */ - g_assert (nm_platform_link_set_address (SINGLETON, ifindex, mac, sizeof (mac))); - address = nm_platform_link_get_address (SINGLETON, ifindex, &addrlen); + g_assert (nm_platform_link_set_address (NM_PLATFORM_GET, ifindex, mac, sizeof (mac))); + address = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, &addrlen); g_assert (addrlen == sizeof(mac)); g_assert (!memcmp (address, mac, addrlen)); - address = nm_platform_link_get_address (SINGLETON, ifindex, NULL); + address = nm_platform_link_get_address (NM_PLATFORM_GET, ifindex, NULL); g_assert (!memcmp (address, mac, addrlen)); accept_signal (link_changed); /* Set MTU */ - g_assert (nm_platform_link_set_mtu (SINGLETON, ifindex, MTU)); + g_assert (nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, MTU)); no_error (); - g_assert_cmpint (nm_platform_link_get_mtu (SINGLETON, ifindex), ==, MTU); + g_assert_cmpint (nm_platform_link_get_mtu (NM_PLATFORM_GET, ifindex), ==, MTU); accept_signal (link_changed); /* Delete device */ - g_assert (nm_platform_link_delete (SINGLETON, ifindex)); + g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex)); no_error (); accept_signal (link_removed); /* Try to delete again */ - g_assert (!nm_platform_link_delete (SINGLETON, ifindex)); + g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, ifindex)); error (NM_PLATFORM_ERROR_NOT_FOUND); free_signal (link_added); @@ -487,16 +487,16 @@ test_external (void) run_command ("ip link add %s type %s", DEVICE_NAME, "dummy"); wait_signal (link_added); - g_assert (nm_platform_link_exists (SINGLETON, DEVICE_NAME)); - ifindex = nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME); + g_assert (nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); g_assert (ifindex > 0); - g_assert_cmpstr (nm_platform_link_get_name (SINGLETON, ifindex), ==, DEVICE_NAME); - g_assert_cmpint (nm_platform_link_get_type (SINGLETON, ifindex), ==, NM_LINK_TYPE_DUMMY); - g_assert_cmpstr (nm_platform_link_get_type_name (SINGLETON, ifindex), ==, DUMMY_TYPEDESC); + g_assert_cmpstr (nm_platform_link_get_name (NM_PLATFORM_GET, ifindex), ==, DEVICE_NAME); + g_assert_cmpint (nm_platform_link_get_type (NM_PLATFORM_GET, ifindex), ==, NM_LINK_TYPE_DUMMY); + g_assert_cmpstr (nm_platform_link_get_type_name (NM_PLATFORM_GET, ifindex), ==, DUMMY_TYPEDESC); link_changed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, link_callback, ifindex); link_removed = add_signal_ifindex (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, link_callback, ifindex); - success = nm_platform_link_get (SINGLETON, ifindex, &link); + success = nm_platform_link_get (NM_PLATFORM_GET, ifindex, &link); g_assert (success); if (!link.driver) { /* we still lack the notification via UDEV. Expect another link changed signal. */ @@ -504,17 +504,17 @@ test_external (void) } /* Up/connected/arp */ - g_assert (!nm_platform_link_is_up (SINGLETON, ifindex)); - g_assert (!nm_platform_link_is_connected (SINGLETON, ifindex)); - g_assert (!nm_platform_link_uses_arp (SINGLETON, ifindex)); + g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); + g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); + g_assert (!nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex)); run_command ("ip link set %s up", DEVICE_NAME); wait_signal (link_changed); - g_assert (nm_platform_link_is_up (SINGLETON, ifindex)); - g_assert (nm_platform_link_is_connected (SINGLETON, ifindex)); + g_assert (nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); + g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); run_command ("ip link set %s down", DEVICE_NAME); wait_signal (link_changed); - g_assert (!nm_platform_link_is_up (SINGLETON, ifindex)); - g_assert (!nm_platform_link_is_connected (SINGLETON, ifindex)); + g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); + g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); /* This test doesn't trigger a netlink event at least on * 3.8.2-206.fc18.x86_64. Disabling the waiting and checking code * because of that. @@ -532,7 +532,7 @@ test_external (void) run_command ("ip link del %s", DEVICE_NAME); wait_signal (link_removed); - g_assert (!nm_platform_link_exists (SINGLETON, DEVICE_NAME)); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); free_signal (link_added); free_signal (link_changed); @@ -548,12 +548,12 @@ init_tests (int *argc, char ***argv) void setup_tests (void) { - nm_platform_link_delete (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME)); - nm_platform_link_delete (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, SLAVE_NAME)); - nm_platform_link_delete (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, PARENT_NAME)); - g_assert (!nm_platform_link_exists (SINGLETON, DEVICE_NAME)); - g_assert (!nm_platform_link_exists (SINGLETON, SLAVE_NAME)); - g_assert (!nm_platform_link_exists (SINGLETON, PARENT_NAME)); + nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)); + nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, SLAVE_NAME)); + nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, PARENT_NAME)); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, SLAVE_NAME)); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, PARENT_NAME)); g_test_add_func ("/link/bogus", test_bogus); g_test_add_func ("/link/loopback", test_loopback); diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c index 851e5f67c6..85a119ddd0 100644 --- a/src/platform/tests/test-route.c +++ b/src/platform/tests/test-route.c @@ -53,7 +53,7 @@ ip6_route_callback (NMPlatform *platform, int ifindex, NMPlatformIP6Route *recei static void test_ip4_route_metric0 (void) { - int ifindex = nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME); + int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); SignalData *route_added = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_route_callback); SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_route_callback); SignalData *route_removed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_route_callback); @@ -67,7 +67,7 @@ test_ip4_route_metric0 (void) assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric); /* add the first route */ - g_assert (nm_platform_ip4_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, metric, mss)); + g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, metric, mss)); no_error (); accept_signal (route_added); @@ -75,7 +75,7 @@ test_ip4_route_metric0 (void) assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric); /* Deleting route with metric 0 does nothing */ - g_assert (nm_platform_ip4_route_delete (SINGLETON, ifindex, network, plen, 0)); + g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0)); no_error (); g_assert (!route_removed->received); @@ -83,7 +83,7 @@ test_ip4_route_metric0 (void) assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric); /* add the second route */ - g_assert (nm_platform_ip4_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, 0, mss)); + g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, INADDR_ANY, 0, 0, mss)); no_error (); accept_signal (route_added); @@ -91,7 +91,7 @@ test_ip4_route_metric0 (void) assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric); /* Delete route with metric 0 */ - g_assert (nm_platform_ip4_route_delete (SINGLETON, ifindex, network, plen, 0)); + g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0)); no_error (); accept_signal (route_removed); @@ -99,7 +99,7 @@ test_ip4_route_metric0 (void) assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric); /* Delete route with metric 0 again (we expect nothing to happen) */ - g_assert (nm_platform_ip4_route_delete (SINGLETON, ifindex, network, plen, 0)); + g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0)); no_error (); g_assert (!route_removed->received); @@ -107,7 +107,7 @@ test_ip4_route_metric0 (void) assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric); /* Delete the other route */ - g_assert (nm_platform_ip4_route_delete (SINGLETON, ifindex, network, plen, metric)); + g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric)); no_error (); accept_signal (route_removed); @@ -122,7 +122,7 @@ test_ip4_route_metric0 (void) static void test_ip4_route (void) { - int ifindex = nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME); + int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); SignalData *route_added = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_route_callback); SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_route_callback); SignalData *route_removed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_route_callback); @@ -139,40 +139,40 @@ test_ip4_route (void) inet_pton (AF_INET, "198.51.100.1", &gateway); /* Add route to gateway */ - g_assert (nm_platform_ip4_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 32, INADDR_ANY, 0, metric, mss)); + g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 32, INADDR_ANY, 0, metric, mss)); no_error (); accept_signal (route_added); /* Add route */ assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric); no_error (); - g_assert (nm_platform_ip4_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss)); + g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss)); no_error (); assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, metric); no_error (); accept_signal (route_added); /* Add route again */ - g_assert (nm_platform_ip4_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss)); + g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss)); no_error (); accept_signal (route_changed); /* Add default route */ assert_ip4_route_exists (FALSE, DEVICE_NAME, 0, 0, metric); no_error (); - g_assert (nm_platform_ip4_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss)); + g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss)); no_error (); assert_ip4_route_exists (TRUE, DEVICE_NAME, 0, 0, metric); no_error (); accept_signal (route_added); /* Add default route again */ - g_assert (nm_platform_ip4_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss)); + g_assert (nm_platform_ip4_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss)); no_error (); accept_signal (route_changed); /* Test route listing */ - routes = nm_platform_ip4_route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); + routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); memset (rts, 0, sizeof (rts)); rts[0].source = NM_IP_CONFIG_SOURCE_USER; rts[0].network = gateway; @@ -201,13 +201,13 @@ test_ip4_route (void) g_array_unref (routes); /* Remove route */ - g_assert (nm_platform_ip4_route_delete (SINGLETON, ifindex, network, plen, metric)); + g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric)); no_error (); assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric); accept_signal (route_removed); /* Remove route again */ - g_assert (nm_platform_ip4_route_delete (SINGLETON, ifindex, network, plen, metric)); + g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric)); no_error (); free_signal (route_added); @@ -218,7 +218,7 @@ test_ip4_route (void) static void test_ip6_route (void) { - int ifindex = nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME); + int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); SignalData *route_added = add_signal (NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip6_route_callback); SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip6_route_callback); SignalData *route_removed = add_signal (NM_PLATFORM_SIGNAL_IP6_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip6_route_callback); @@ -235,40 +235,40 @@ test_ip6_route (void) inet_pton (AF_INET6, "2001:db8:c:d:1:2:3:4", &gateway); /* Add route to gateway */ - g_assert (nm_platform_ip6_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 128, in6addr_any, metric, mss)); + g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, gateway, 128, in6addr_any, metric, mss)); no_error (); accept_signal (route_added); /* Add route */ - g_assert (!nm_platform_ip6_route_exists (SINGLETON, ifindex, network, plen, metric)); + g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric)); no_error (); - g_assert (nm_platform_ip6_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss)); + g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss)); no_error (); - g_assert (nm_platform_ip6_route_exists (SINGLETON, ifindex, network, plen, metric)); + g_assert (nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric)); no_error (); accept_signal (route_added); /* Add route again */ - g_assert (nm_platform_ip6_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss)); + g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss)); no_error (); accept_signal (route_changed); /* Add default route */ - g_assert (!nm_platform_ip6_route_exists (SINGLETON, ifindex, in6addr_any, 0, metric)); + g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, in6addr_any, 0, metric)); no_error (); - g_assert (nm_platform_ip6_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss)); + g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss)); no_error (); - g_assert (nm_platform_ip6_route_exists (SINGLETON, ifindex, in6addr_any, 0, metric)); + g_assert (nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, in6addr_any, 0, metric)); no_error (); accept_signal (route_added); /* Add default route again */ - g_assert (nm_platform_ip6_route_add (SINGLETON, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss)); + g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss)); no_error (); accept_signal (route_changed); /* Test route listing */ - routes = nm_platform_ip6_route_get_all (SINGLETON, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); + routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, ifindex, NM_PLATFORM_GET_ROUTE_MODE_ALL); memset (rts, 0, sizeof (rts)); rts[0].source = NM_IP_CONFIG_SOURCE_USER; rts[0].network = gateway; @@ -297,13 +297,13 @@ test_ip6_route (void) g_array_unref (routes); /* Remove route */ - g_assert (nm_platform_ip6_route_delete (SINGLETON, ifindex, network, plen, metric)); + g_assert (nm_platform_ip6_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric)); no_error (); - g_assert (!nm_platform_ip6_route_exists (SINGLETON, ifindex, network, plen, metric)); + g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, network, plen, metric)); accept_signal (route_removed); /* Remove route again */ - g_assert (nm_platform_ip6_route_delete (SINGLETON, ifindex, network, plen, metric)); + g_assert (nm_platform_ip6_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric)); no_error (); free_signal (route_added); @@ -322,13 +322,13 @@ setup_tests (void) { SignalData *link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME); - nm_platform_link_delete (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME)); - g_assert (!nm_platform_link_exists (SINGLETON, DEVICE_NAME)); - g_assert (nm_platform_dummy_add (SINGLETON, DEVICE_NAME)); + nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); + g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME)); wait_signal (link_added); free_signal (link_added); - g_assert (nm_platform_link_set_up (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, DEVICE_NAME))); + g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME))); g_test_add_func ("/route/ip4", test_ip4_route); g_test_add_func ("/route/ip6", test_ip6_route); diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c index d55bd7a077..17c9456e1b 100644 --- a/src/ppp-manager/nm-ppp-manager.c +++ b/src/ppp-manager/nm-ppp-manager.c @@ -546,7 +546,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager, remove_timeout_handler (manager); - config = nm_ip4_config_new (nm_platform_link_get_ifindex (SINGLETON, priv->ip_iface)); + config = nm_ip4_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface)); memset (&address, 0, sizeof (address)); address.plen = 32; @@ -651,7 +651,7 @@ impl_ppp_manager_set_ip6_config (NMPPPManager *manager, remove_timeout_handler (manager); - config = nm_ip6_config_new (nm_platform_link_get_ifindex (SINGLETON, priv->ip_iface)); + config = nm_ip6_config_new (nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface)); memset (&addr, 0, sizeof (addr)); addr.plen = 64; diff --git a/src/rdisc/nm-lndp-rdisc.c b/src/rdisc/nm-lndp-rdisc.c index 9340b9e425..a56be09edf 100644 --- a/src/rdisc/nm-lndp-rdisc.c +++ b/src/rdisc/nm-lndp-rdisc.c @@ -57,7 +57,7 @@ G_DEFINE_TYPE (NMLNDPRDisc, nm_lndp_rdisc, NM_TYPE_RDISC) static inline gint32 ipv6_sysctl_get (const char *ifname, const char *property, gint32 defval) { - return nm_platform_sysctl_get_int32 (SINGLETON, nm_utils_ip6_property_path (ifname, property), defval); + return nm_platform_sysctl_get_int32 (NM_PLATFORM_GET, nm_utils_ip6_property_path (ifname, property), defval); } NMRDisc * diff --git a/src/rdisc/tests/rdisc.c b/src/rdisc/tests/rdisc.c index 38d404cc0b..e05f34f970 100644 --- a/src/rdisc/tests/rdisc.c +++ b/src/rdisc/tests/rdisc.c @@ -60,10 +60,10 @@ main (int argc, char **argv) if (argv[0]) { ifname = argv[0]; - ifindex = nm_platform_link_get_ifindex (SINGLETON, ifname); + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname); } else { ifindex = 1; - ifname = nm_platform_link_get_name (SINGLETON, ifindex); + ifname = nm_platform_link_get_name (NM_PLATFORM_GET, ifindex); } rdisc = new (ifindex, ifname); diff --git a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c index 61c231a66d..070b623997 100644 --- a/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c +++ b/src/settings/plugins/ifcfg-rh/nm-ifcfg-connection.c @@ -160,7 +160,7 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self) if (!devtimeout) return; - if (nm_platform_link_get_ifindex (SINGLETON, ifname) != 0) + if (nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname) != 0) return; /* ONBOOT=yes, DEVICE and DEVTIMEOUT are set, but device is not present */ diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index 6ebc6043de..1081ab8f81 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -4339,11 +4339,11 @@ is_wifi_device (const char *name, shvarFile *parsed) g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (parsed != NULL, FALSE); - ifindex = nm_platform_link_get_ifindex (SINGLETON, name); + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, name); if (ifindex == 0) return FALSE; - return nm_platform_link_get_type (SINGLETON, ifindex) == NM_LINK_TYPE_WIFI; + return nm_platform_link_get_type (NM_PLATFORM_GET, ifindex) == NM_LINK_TYPE_WIFI; } static void diff --git a/src/settings/plugins/ifnet/net_parser.c b/src/settings/plugins/ifnet/net_parser.c index 011ffbc288..8f528d0f4d 100644 --- a/src/settings/plugins/ifnet/net_parser.c +++ b/src/settings/plugins/ifnet/net_parser.c @@ -174,9 +174,9 @@ init_block_by_line (gchar * buf) /* ignored connection */ conn = add_new_connection_config ("ignore", pos); } else { - int ifindex = nm_platform_link_get_ifindex (SINGLETON, pos); + int ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, pos); - if (ifindex && nm_platform_link_get_type (SINGLETON, ifindex) != NM_LINK_TYPE_WIFI) + if (ifindex && nm_platform_link_get_type (NM_PLATFORM_GET, ifindex) != NM_LINK_TYPE_WIFI) /* wired connection */ conn = add_new_connection_config ("wired", pos); else diff --git a/src/tests/test-route-manager.c b/src/tests/test-route-manager.c index 33e59e3755..4b12950fd7 100644 --- a/src/tests/test-route-manager.c +++ b/src/tests/test-route-manager.c @@ -75,7 +75,7 @@ setup_dev1_ip4 (int ifindex) /* Add some route outside of route manager. The route manager * should get rid of it upon sync. */ - nm_platform_ip4_route_add (SINGLETON, + nm_platform_ip4_route_add (NM_PLATFORM_GET, route.ifindex, NM_IP_CONFIG_SOURCE_USER, nmtst_inet4_from_string ("9.0.0.0"), @@ -141,10 +141,10 @@ update_dev0_ip4 (int ifindex) static GArray * ip4_routes (test_fixture *fixture) { - GArray *routes = nm_platform_ip4_route_get_all (SINGLETON, + GArray *routes = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, fixture->ifindex0, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT); - GArray *routes1 = nm_platform_ip4_route_get_all (SINGLETON, + GArray *routes1 = nm_platform_ip4_route_get_all (NM_PLATFORM_GET, fixture->ifindex1, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT); @@ -301,7 +301,7 @@ setup_dev0_ip6 (int ifindex) NMPlatformIP6Route *route; /* Add an address so that a route to the gateway below gets added. */ - nm_platform_ip6_address_add (SINGLETON, + nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, *nmtst_inet6_from_string ("2001:db8:8086::2"), in6addr_any, @@ -349,7 +349,7 @@ setup_dev1_ip6 (int ifindex) /* Add some route outside of route manager. The route manager * should get rid of it upon sync. */ - nm_platform_ip6_route_add (SINGLETON, + nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, *nmtst_inet6_from_string ("2001:db8:8088::"), @@ -405,7 +405,7 @@ update_dev0_ip6 (int ifindex) NMPlatformIP6Route *route; /* Add an address so that a route to the gateway below gets added. */ - nm_platform_ip6_address_add (SINGLETON, + nm_platform_ip6_address_add (NM_PLATFORM_GET, ifindex, *nmtst_inet6_from_string ("2001:db8:8086::2"), in6addr_any, @@ -448,10 +448,10 @@ update_dev0_ip6 (int ifindex) static GArray * ip6_routes (test_fixture *fixture) { - GArray *routes = nm_platform_ip6_route_get_all (SINGLETON, + GArray *routes = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, fixture->ifindex0, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT); - GArray *routes1 = nm_platform_ip6_route_get_all (SINGLETON, + GArray *routes1 = nm_platform_ip6_route_get_all (NM_PLATFORM_GET, fixture->ifindex1, NM_PLATFORM_GET_ROUTE_MODE_NO_DEFAULT); @@ -637,32 +637,32 @@ fixture_setup (test_fixture *fixture, gconstpointer user_data) NM_PLATFORM_SIGNAL_ADDED, link_callback, "nm-test-device0"); - nm_platform_link_delete (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, "nm-test-device0")); - g_assert (!nm_platform_link_exists (SINGLETON, "nm-test-device0")); - g_assert (nm_platform_dummy_add (SINGLETON, "nm-test-device0")); + nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device0")); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, "nm-test-device0")); + g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, "nm-test-device0")); wait_signal (link_added); free_signal (link_added); - fixture->ifindex0 = nm_platform_link_get_ifindex (SINGLETON, "nm-test-device0"); - g_assert (nm_platform_link_set_up (SINGLETON, fixture->ifindex0)); + fixture->ifindex0 = nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device0"); + g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, fixture->ifindex0)); link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, "nm-test-device1"); - nm_platform_link_delete (SINGLETON, nm_platform_link_get_ifindex (SINGLETON, "nm-test-device1")); - g_assert (!nm_platform_link_exists (SINGLETON, "nm-test-device1")); - g_assert (nm_platform_dummy_add (SINGLETON, "nm-test-device1")); + nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device1")); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, "nm-test-device1")); + g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, "nm-test-device1")); wait_signal (link_added); free_signal (link_added); - fixture->ifindex1 = nm_platform_link_get_ifindex (SINGLETON, "nm-test-device1"); - g_assert (nm_platform_link_set_up (SINGLETON, fixture->ifindex1)); + fixture->ifindex1 = nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device1"); + g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, fixture->ifindex1)); } static void fixture_teardown (test_fixture *fixture, gconstpointer user_data) { - nm_platform_link_delete (SINGLETON, fixture->ifindex0); - nm_platform_link_delete (SINGLETON, fixture->ifindex1); + nm_platform_link_delete (NM_PLATFORM_GET, fixture->ifindex0); + nm_platform_link_delete (NM_PLATFORM_GET, fixture->ifindex1); } void diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index 420f7a5d51..d24080452c 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -226,9 +226,9 @@ vpn_cleanup (NMVpnConnection *connection, NMDevice *parent_dev) NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection); if (priv->ip_ifindex) { - nm_platform_link_set_down (SINGLETON, priv->ip_ifindex); + nm_platform_link_set_down (NM_PLATFORM_GET, priv->ip_ifindex); nm_route_manager_route_flush (nm_route_manager_get (), priv->ip_ifindex); - nm_platform_address_flush (SINGLETON, priv->ip_ifindex); + nm_platform_address_flush (NM_PLATFORM_GET, priv->ip_ifindex); } nm_device_set_vpn4_config (parent_dev, NULL); @@ -921,7 +921,7 @@ nm_vpn_connection_apply_config (NMVpnConnection *connection) NMVpnConnectionPrivate *priv = NM_VPN_CONNECTION_GET_PRIVATE (connection); if (priv->ip_ifindex > 0) { - nm_platform_link_set_up (SINGLETON, priv->ip_ifindex); + nm_platform_link_set_up (NM_PLATFORM_GET, priv->ip_ifindex); if (priv->ip4_config) { if (!nm_ip4_config_commit (priv->ip4_config, priv->ip_ifindex, @@ -1037,7 +1037,7 @@ process_generic_config (NMVpnConnection *self, GVariant *dict) if (priv->ip_iface) { /* Grab the interface index for address/routing operations */ - priv->ip_ifindex = nm_platform_link_get_ifindex (SINGLETON, priv->ip_iface); + priv->ip_ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, priv->ip_iface); if (!priv->ip_ifindex) { nm_log_err (LOGD_VPN, "(%s): failed to look up VPN interface index", priv->ip_iface); nm_vpn_connection_config_maybe_complete (self, FALSE); |