From eef388990f134fd30045807860055ef22afbbd5c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 9 Dec 2015 16:14:49 +0100 Subject: [PATCH] platform/trivial: rename link related functions Link related functions should have a "nm_platform_link" prefix. Rename. Naming is a subjective matter and one might argue that omitting the "link" part from the name is shorter and even preferred. However, I think functions related to links should have a common prefix as the underlyings are strongly related. --- src/devices/nm-device-bond.c | 3 +- src/devices/nm-device-bridge.c | 10 ++-- src/devices/nm-device-infiniband.c | 4 +- src/devices/nm-device-tun.c | 18 +++---- src/devices/nm-device-veth.c | 2 +- src/devices/nm-device-vlan.c | 12 ++--- src/devices/team/nm-device-team.c | 2 +- src/platform/nm-linux-platform.c | 2 +- src/platform/nm-platform.c | 66 +++++++++++++------------ src/platform/nm-platform.h | 36 ++++++++------ src/platform/tests/test-address.c | 2 +- src/platform/tests/test-cleanup.c | 2 +- src/platform/tests/test-link.c | 78 +++++++++++++++--------------- src/platform/tests/test-route.c | 2 +- src/tests/test-route-manager.c | 4 +- 15 files changed, 128 insertions(+), 115 deletions(-) diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 72ded91f7d..33f0ad159f 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -455,9 +455,8 @@ create_and_realize (NMDevice *device, NMPlatformError plerr; g_assert (iface); - g_assert (out_plink); - plerr = nm_platform_bond_add (NM_PLATFORM_GET, iface, out_plink); + plerr = nm_platform_link_bond_add (NM_PLATFORM_GET, iface, out_plink); if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "Failed to create bond interface '%s' for '%s': %s", diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index 298a799024..187fee0356 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -400,11 +400,11 @@ create_and_realize (NMDevice *device, } } - plerr = nm_platform_bridge_add (NM_PLATFORM_GET, - iface, - hwaddr ? mac_address : NULL, - hwaddr ? ETH_ALEN : 0, - out_plink); + plerr = nm_platform_link_bridge_add (NM_PLATFORM_GET, + iface, + hwaddr ? mac_address : NULL, + hwaddr ? ETH_ALEN : 0, + out_plink); if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "Failed to create bridge interface '%s' for '%s': %s", diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index 792bdcd053..50e1feb06d 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -226,7 +226,7 @@ update_connection (NMDevice *device, NMConnection *connection) ifindex = nm_device_get_ifindex (device); if (ifindex > 0) { - if (!nm_platform_infiniband_get_properties (NM_PLATFORM_GET, ifindex, NULL, NULL, &transport_mode)) + if (!nm_platform_link_infiniband_get_properties (NM_PLATFORM_GET, ifindex, NULL, NULL, &transport_mode)) transport_mode = "datagram"; } g_object_set (G_OBJECT (s_infiniband), NM_SETTING_INFINIBAND_TRANSPORT_MODE, transport_mode, NULL); @@ -268,7 +268,7 @@ create_and_realize (NMDevice *device, return FALSE; } - plerr = nm_platform_infiniband_partition_add (NM_PLATFORM_GET, parent_ifindex, p_key, out_plink); + plerr = nm_platform_link_infiniband_add (NM_PLATFORM_GET, parent_ifindex, p_key, out_plink); if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "Failed to create InfiniBand P_Key interface '%s' for '%s': %s", diff --git a/src/devices/nm-device-tun.c b/src/devices/nm-device-tun.c index 469d93cc1d..3501ddb466 100644 --- a/src/devices/nm-device-tun.c +++ b/src/devices/nm-device-tun.c @@ -68,7 +68,7 @@ reload_tun_properties (NMDeviceTun *self) ifindex = nm_device_get_ifindex (NM_DEVICE (self)); if (ifindex > 0) { - if (!nm_platform_tun_get_properties (NM_PLATFORM_GET, ifindex, &props)) { + if (!nm_platform_link_tun_get_properties (NM_PLATFORM_GET, ifindex, &props)) { _LOGD (LOGD_DEVICE, "tun-properties: cannot loading tun properties from platform for ifindex %d", ifindex); ifindex = 0; } else if (g_strcmp0 (priv->mode, props.mode) != 0) { @@ -162,7 +162,7 @@ update_connection (NMDevice *device, NMConnection *connection) nm_connection_add_setting (connection, (NMSetting *) s_tun); } - if (!nm_platform_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) { + if (!nm_platform_link_tun_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &props)) { _LOGW (LOGD_HW, "failed to get TUN interface info while updating connection."); return; } @@ -213,13 +213,13 @@ create_and_realize (NMDevice *device, user = _nm_utils_ascii_str_to_int64 (nm_setting_tun_get_owner (s_tun), 10, 0, G_MAXINT32, -1); group = _nm_utils_ascii_str_to_int64 (nm_setting_tun_get_group (s_tun), 10, 0, G_MAXINT32, -1); - plerr = nm_platform_tun_add (NM_PLATFORM_GET, iface, - nm_setting_tun_get_mode (s_tun) == NM_SETTING_TUN_MODE_TAP, - user, group, - nm_setting_tun_get_pi (s_tun), - nm_setting_tun_get_vnet_hdr (s_tun), - nm_setting_tun_get_multi_queue (s_tun), - out_plink); + plerr = nm_platform_link_tun_add (NM_PLATFORM_GET, iface, + nm_setting_tun_get_mode (s_tun) == NM_SETTING_TUN_MODE_TAP, + user, group, + nm_setting_tun_get_pi (s_tun), + nm_setting_tun_get_vnet_hdr (s_tun), + nm_setting_tun_get_multi_queue (s_tun), + out_plink); if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "Failed to create TUN/TAP interface '%s' for '%s': %s", diff --git a/src/devices/nm-device-veth.c b/src/devices/nm-device-veth.c index 07187205fb..986c93d8f9 100644 --- a/src/devices/nm-device-veth.c +++ b/src/devices/nm-device-veth.c @@ -81,7 +81,7 @@ get_peer (NMDeviceVeth *self) if (priv->ever_had_peer) return priv->peer; - if (!nm_platform_veth_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &peer_ifindex)) { + if (!nm_platform_link_veth_get_properties (NM_PLATFORM_GET, nm_device_get_ifindex (device), &peer_ifindex)) { _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 4e5da03207..401ef4fd3e 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -232,12 +232,12 @@ create_and_realize (NMDevice *device, vlan_id = nm_setting_vlan_get_id (s_vlan); - plerr = nm_platform_vlan_add (NM_PLATFORM_GET, - iface, - parent_ifindex, - vlan_id, - nm_setting_vlan_get_flags (s_vlan), - out_plink); + plerr = nm_platform_link_vlan_add (NM_PLATFORM_GET, + iface, + parent_ifindex, + vlan_id, + nm_setting_vlan_get_flags (s_vlan), + out_plink); if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "Failed to create VLAN interface '%s' for '%s': %s", diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 74803225d8..827a4efad9 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -679,7 +679,7 @@ create_and_realize (NMDevice *device, const char *iface = nm_device_get_iface (device); NMPlatformError plerr; - plerr = nm_platform_team_add (NM_PLATFORM_GET, iface, out_plink); + plerr = nm_platform_link_team_add (NM_PLATFORM_GET, iface, out_plink); if (plerr != NM_PLATFORM_ERROR_SUCCESS && plerr != NM_PLATFORM_ERROR_EXISTS) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, "Failed to create team master interface '%s' for '%s': %s", diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 17ccee41b0..d7a4536bb4 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -618,7 +618,7 @@ _linktype_get_type (NMPlatform *platform, NMPlatformTunProperties props; if ( platform - && nm_platform_tun_get_properties_ifname (platform, ifname, &props)) { + && nm_platform_link_tun_get_properties_ifname (platform, ifname, &props)) { if (!g_strcmp0 (props.mode, "tap")) return NM_LINK_TYPE_TAP; if (!g_strcmp0 (props.mode, "tun")) diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index cf58e9b252..46cc505404 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -642,7 +642,7 @@ nm_platform_link_add (NMPlatform *self, } /** - * nm_platform_dummy_add: + * nm_platform_link_dummy_add: * @self: platform instance * @name: New interface name * @out_link: on success, the link object @@ -650,7 +650,7 @@ nm_platform_link_add (NMPlatform *self, * Create a software ethernet-like interface */ NMPlatformError -nm_platform_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link) +nm_platform_link_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link) { return nm_platform_link_add (self, name, NM_LINK_TYPE_DUMMY, NULL, 0, out_link); } @@ -1476,7 +1476,7 @@ nm_platform_link_get_lnk_vxlan (NMPlatform *self, int ifindex, const NMPlatformL /*****************************************************************************/ /** - * nm_platform_bridge_add: + * nm_platform_link_bridge_add: * @self: platform instance * @name: New interface name * @address: (allow-none): set the mac address of the new bridge @@ -1486,17 +1486,17 @@ nm_platform_link_get_lnk_vxlan (NMPlatform *self, int ifindex, const NMPlatformL * Create a software bridge. */ NMPlatformError -nm_platform_bridge_add (NMPlatform *self, - const char *name, - const void *address, - size_t address_len, - const NMPlatformLink **out_link) +nm_platform_link_bridge_add (NMPlatform *self, + const char *name, + const void *address, + size_t address_len, + const NMPlatformLink **out_link) { return nm_platform_link_add (self, name, NM_LINK_TYPE_BRIDGE, address, address_len, out_link); } /** - * nm_platform_bond_add: + * nm_platform_link_bond_add: * @self: platform instance * @name: New interface name * @out_link: on success, the link object @@ -1504,13 +1504,13 @@ nm_platform_bridge_add (NMPlatform *self, * Create a software bonding device. */ NMPlatformError -nm_platform_bond_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link) +nm_platform_link_bond_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link) { return nm_platform_link_add (self, name, NM_LINK_TYPE_BOND, NULL, 0, out_link); } /** - * nm_platform_team_add: + * nm_platform_link_team_add: * @self: platform instance * @name: New interface name * @out_link: on success, the link object @@ -1518,13 +1518,13 @@ nm_platform_bond_add (NMPlatform *self, const char *name, const NMPlatformLink * * Create a software teaming device. */ NMPlatformError -nm_platform_team_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link) +nm_platform_link_team_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link) { return nm_platform_link_add (self, name, NM_LINK_TYPE_TEAM, NULL, 0, out_link); } /** - * nm_platform_vlan_add: + * nm_platform_link_vlan_add: * @self: platform instance * @name: New interface name * @vlanid: VLAN identifier @@ -1534,7 +1534,7 @@ nm_platform_team_add (NMPlatform *self, const char *name, const NMPlatformLink * * Create a software VLAN device. */ NMPlatformError -nm_platform_vlan_add (NMPlatform *self, +nm_platform_link_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, @@ -1594,7 +1594,7 @@ nm_platform_link_vxlan_add (NMPlatform *self, } /** - * nm_platform_tun_add: + * nm_platform_link_tun_add: * @self: platform instance * @name: new interface name * @tap: whether the interface is a TAP @@ -1608,9 +1608,15 @@ nm_platform_link_vxlan_add (NMPlatform *self, * Create a TUN or TAP interface. */ NMPlatformError -nm_platform_tun_add (NMPlatform *self, const char *name, gboolean tap, - gint64 owner, gint64 group, gboolean pi, gboolean vnet_hdr, - gboolean multi_queue, const NMPlatformLink **out_link) +nm_platform_link_tun_add (NMPlatform *self, + const char *name, + gboolean tap, + gint64 owner, + gint64 group, + gboolean pi, + gboolean vnet_hdr, + gboolean multi_queue, + const NMPlatformLink **out_link) { NMPlatformError plerr; @@ -1747,7 +1753,7 @@ nm_platform_link_vlan_change (NMPlatform *self, } gboolean -nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to) +nm_platform_link_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to) { NMVlanQosMapping map = { .from = from, @@ -1758,7 +1764,7 @@ nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int t } gboolean -nm_platform_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to) +nm_platform_link_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to) { NMVlanQosMapping map = { .from = from, @@ -1808,7 +1814,7 @@ nm_platform_link_gre_add (NMPlatform *self, } NMPlatformError -nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, const NMPlatformLink **out_link) +nm_platform_link_infiniband_add (NMPlatform *self, int parent, int p_key, const NMPlatformLink **out_link) { gs_free char *parent_name = NULL; gs_free char *name = NULL; @@ -1838,11 +1844,11 @@ nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, c } gboolean -nm_platform_infiniband_get_properties (NMPlatform *self, - int ifindex, - int *out_parent, - int *out_p_key, - const char **out_mode) +nm_platform_link_infiniband_get_properties (NMPlatform *self, + int ifindex, + int *out_parent, + int *out_p_key, + const char **out_mode) { const NMPlatformLnkInfiniband *plnk; const NMPlatformLink *plink; @@ -2063,7 +2069,7 @@ nm_platform_link_sit_add (NMPlatform *self, } gboolean -nm_platform_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex) +nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex) { const NMPlatformLink *plink; int peer_ifindex; @@ -2093,7 +2099,7 @@ nm_platform_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_if } gboolean -nm_platform_tun_get_properties_ifname (NMPlatform *self, const char *ifname, NMPlatformTunProperties *props) +nm_platform_link_tun_get_properties_ifname (NMPlatform *self, const char *ifname, NMPlatformTunProperties *props) { char *path, *val; gboolean success = TRUE; @@ -2154,14 +2160,14 @@ nm_platform_tun_get_properties_ifname (NMPlatform *self, const char *ifname, NMP } gboolean -nm_platform_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *props) +nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *props) { _CHECK_SELF (self, klass, FALSE); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (props != NULL, FALSE); - return nm_platform_tun_get_properties_ifname (self, nm_platform_link_get_name (self, ifindex), props); + return nm_platform_link_tun_get_properties_ifname (self, nm_platform_link_get_name (self, ifindex), props); } gboolean diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 46d1312226..5d9b31bf84 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -700,10 +700,10 @@ const NMPlatformLink *nm_platform_link_get_by_ifname (NMPlatform *self, const ch const NMPlatformLink *nm_platform_link_get_by_address (NMPlatform *self, gconstpointer address, size_t length); GArray *nm_platform_link_get_all (NMPlatform *self); -NMPlatformError nm_platform_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link); -NMPlatformError nm_platform_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len, const NMPlatformLink **out_link); -NMPlatformError nm_platform_bond_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link); -NMPlatformError nm_platform_team_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link); +NMPlatformError nm_platform_link_dummy_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link); +NMPlatformError nm_platform_link_bridge_add (NMPlatform *self, const char *name, const void *address, size_t address_len, const NMPlatformLink **out_link); +NMPlatformError nm_platform_link_bond_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link); +NMPlatformError nm_platform_link_team_add (NMPlatform *self, const char *name, const NMPlatformLink **out_link); gboolean nm_platform_link_delete (NMPlatform *self, int ifindex); /* convienience methods to lookup the link and access fields of NMPlatformLink. */ @@ -756,6 +756,7 @@ gboolean nm_platform_link_supports_vlans (NMPlatform *self, int ifindex); gboolean nm_platform_link_enslave (NMPlatform *self, int master, int slave); gboolean nm_platform_link_release (NMPlatform *self, int master, int slave); + gboolean nm_platform_master_set_option (NMPlatform *self, int ifindex, const char *option, const char *value); char *nm_platform_master_get_option (NMPlatform *self, int ifindex, const char *option); gboolean nm_platform_slave_set_option (NMPlatform *self, int ifindex, const char *option, const char *value); @@ -773,9 +774,9 @@ const NMPlatformLnkSit *nm_platform_link_get_lnk_sit (NMPlatform *self, int ifin const NMPlatformLnkVlan *nm_platform_link_get_lnk_vlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); const NMPlatformLnkVxlan *nm_platform_link_get_lnk_vxlan (NMPlatform *self, int ifindex, const NMPlatformLink **out_link); -NMPlatformError nm_platform_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags, const NMPlatformLink **out_link); -gboolean nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to); -gboolean nm_platform_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to); +NMPlatformError nm_platform_link_vlan_add (NMPlatform *self, const char *name, int parent, int vlanid, guint32 vlanflags, const NMPlatformLink **out_link); +gboolean nm_platform_link_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to); +gboolean nm_platform_link_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to); gboolean nm_platform_link_vlan_change (NMPlatform *self, int ifindex, NMVlanFlags flags_mask, @@ -789,16 +790,23 @@ gboolean nm_platform_link_vlan_change (NMPlatform *self, NMPlatformError nm_platform_link_vxlan_add (NMPlatform *self, const char *name, NMPlatformLnkVxlan *props, const NMPlatformLink **out_link); -NMPlatformError nm_platform_tun_add (NMPlatform *self, const char *name, gboolean tap, gint64 owner, gint64 group, gboolean pi, - gboolean vnet_hdr, gboolean multi_queue, const NMPlatformLink **out_link); +NMPlatformError nm_platform_link_tun_add (NMPlatform *self, + const char *name, + gboolean tap, + gint64 owner, + gint64 group, + gboolean pi, + gboolean vnet_hdr, + gboolean multi_queue, + const NMPlatformLink **out_link); -NMPlatformError nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, const NMPlatformLink **out_link); -gboolean nm_platform_infiniband_get_properties (NMPlatform *self, int ifindex, int *parent, int *p_key, const char **mode); +NMPlatformError nm_platform_link_infiniband_add (NMPlatform *self, int parent, int p_key, const NMPlatformLink **out_link); +gboolean nm_platform_link_infiniband_get_properties (NMPlatform *self, int ifindex, int *parent, int *p_key, const char **mode); -gboolean nm_platform_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex); -gboolean nm_platform_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *properties); +gboolean nm_platform_link_veth_get_properties (NMPlatform *self, int ifindex, int *out_peer_ifindex); +gboolean nm_platform_link_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *properties); -gboolean nm_platform_tun_get_properties_ifname (NMPlatform *platform, const char *ifname, NMPlatformTunProperties *props); +gboolean nm_platform_link_tun_get_properties_ifname (NMPlatform *platform, const char *ifname, NMPlatformTunProperties *props); gboolean nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps); gboolean nm_platform_wifi_get_bssid (NMPlatform *self, int ifindex, guint8 *bssid); diff --git a/src/platform/tests/test-address.c b/src/platform/tests/test-address.c index fdf24c7997..68bf2fd70e 100644 --- a/src/platform/tests/test-address.c +++ b/src/platform/tests/test-address.c @@ -354,7 +354,7 @@ _g_test_run (gconstpointer user_data) nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)); g_assert (!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, DEVICE_NAME)); - g_assert_cmpint (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL), ==, NM_PLATFORM_ERROR_SUCCESS); + g_assert_cmpint (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL), ==, NM_PLATFORM_ERROR_SUCCESS); ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); g_assert_cmpint (ifindex, >, 0); diff --git a/src/platform/tests/test-cleanup.c b/src/platform/tests/test-cleanup.c index 94ce05491d..9e624a028a 100644 --- a/src/platform/tests/test-cleanup.c +++ b/src/platform/tests/test-cleanup.c @@ -35,7 +35,7 @@ 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 (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS); + g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS); accept_signal (link_added); free_signal (link_added); g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME), NULL)); diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index 8fb00f5bd6..0cee24cd8d 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -61,8 +61,8 @@ test_bogus(void) g_assert (!nm_platform_link_supports_vlans (NM_PLATFORM_GET, BOGUS_IFINDEX)); g_assert (!nm_platform_link_get_lnk_vlan (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL)); - g_assert (!nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0)); - g_assert (!nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0)); + g_assert (!nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0)); + g_assert (!nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0)); } static void @@ -83,15 +83,15 @@ software_add (NMLinkType link_type, const char *name) { switch (link_type) { case NM_LINK_TYPE_DUMMY: - return nm_platform_dummy_add (NM_PLATFORM_GET, name, NULL) == NM_PLATFORM_ERROR_SUCCESS; + return nm_platform_link_dummy_add (NM_PLATFORM_GET, name, NULL) == NM_PLATFORM_ERROR_SUCCESS; case NM_LINK_TYPE_BRIDGE: - return nm_platform_bridge_add (NM_PLATFORM_GET, name, NULL, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS; + return nm_platform_link_bridge_add (NM_PLATFORM_GET, name, NULL, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS; case NM_LINK_TYPE_BOND: { gboolean bond0_exists = !!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, "bond0"); NMPlatformError plerr; - plerr = nm_platform_bond_add (NM_PLATFORM_GET, name, NULL); + plerr = nm_platform_link_bond_add (NM_PLATFORM_GET, name, NULL); /* Check that bond0 is *not* automatically created. */ if (!bond0_exists) @@ -99,14 +99,14 @@ software_add (NMLinkType link_type, const char *name) return plerr == NM_PLATFORM_ERROR_SUCCESS; } case NM_LINK_TYPE_TEAM: - return nm_platform_team_add (NM_PLATFORM_GET, name, NULL) == NM_PLATFORM_ERROR_SUCCESS; + return nm_platform_link_team_add (NM_PLATFORM_GET, name, NULL) == NM_PLATFORM_ERROR_SUCCESS; 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 (NM_PLATFORM_GET, PARENT_NAME, NULL, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS) + if (nm_platform_link_bridge_add (NM_PLATFORM_GET, PARENT_NAME, NULL, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS) accept_signal (parent_added); free_signal (parent_added); @@ -123,7 +123,7 @@ software_add (NMLinkType link_type, const char *name) accept_signal (parent_changed); free_signal (parent_changed); - return nm_platform_vlan_add (NM_PLATFORM_GET, name, parent_ifindex, VLAN_ID, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS; + return nm_platform_link_vlan_add (NM_PLATFORM_GET, name, parent_ifindex, VLAN_ID, 0, NULL) == NM_PLATFORM_ERROR_SUCCESS; } } default: @@ -466,7 +466,7 @@ test_bridge_addr (void) nm_utils_hwaddr_aton ("de:ad:be:ef:00:11", addr, sizeof (addr)); - g_assert_cmpint (nm_platform_bridge_add (NM_PLATFORM_GET, DEVICE_NAME, addr, sizeof (addr), &plink), ==, NM_PLATFORM_ERROR_SUCCESS); + g_assert_cmpint (nm_platform_link_bridge_add (NM_PLATFORM_GET, DEVICE_NAME, addr, sizeof (addr), &plink), ==, NM_PLATFORM_ERROR_SUCCESS); g_assert (plink); link = *plink; g_assert_cmpstr (link.name, ==, DEVICE_NAME); @@ -518,11 +518,11 @@ test_internal (void) g_assert (!nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)); /* Add device */ - g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS); + g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS); accept_signal (link_added); /* Try to add again */ - g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_EXISTS); + g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_EXISTS); /* Check device index, name and type */ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); @@ -1092,58 +1092,58 @@ test_vlan_set_xgress (void) /* ingress-qos-map */ - g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 4, 5)); + g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 4, 5)); _assert_ingress_qos_mappings (ifindex, 1, 4, 5); - g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 3, 7)); + g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 3, 7)); _assert_ingress_qos_mappings (ifindex, 2, 3, 7, 4, 5); - g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 3, 8)); + g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 3, 8)); _assert_ingress_qos_mappings (ifindex, 2, 3, 8, 4, 5); - g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, 4)); + g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, 4)); _assert_ingress_qos_mappings (ifindex, 3, 0, 4, 3, 8, 4, 5); - g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, G_MAXUINT32)); + g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, G_MAXUINT32)); _assert_ingress_qos_mappings (ifindex, 3, 0, G_MAXUINT32, 3, 8, 4, 5); - g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, G_MAXUINT32 - 1)); + g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, G_MAXUINT32 - 1)); _assert_ingress_qos_mappings (ifindex, 3, 0, G_MAXUINT32 - 1, 3, 8, 4, 5); - g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, 5)); + g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, 5)); _assert_ingress_qos_mappings (ifindex, 3, 0, 5, 3, 8, 4, 5); - g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, 5)); + g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 0, 5)); _assert_ingress_qos_mappings (ifindex, 3, 0, 5, 3, 8, 4, 5); /* Set invalid values: */ - g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 8, 3)); + g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 8, 3)); _assert_ingress_qos_mappings (ifindex, 3, 0, 5, 3, 8, 4, 5); - g_assert (nm_platform_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 9, 4)); + g_assert (nm_platform_link_vlan_set_ingress_map (NM_PLATFORM_GET, ifindex, 9, 4)); _assert_ingress_qos_mappings (ifindex, 3, 0, 5, 3, 8, @@ -1151,36 +1151,36 @@ test_vlan_set_xgress (void) /* egress-qos-map */ - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 7, 3)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 7, 3)); _assert_egress_qos_mappings (ifindex, 1, 7, 3); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 8, 4)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 8, 4)); _assert_egress_qos_mappings (ifindex, 2, 7, 3, 8, 4); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 0, 4)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 0, 4)); _assert_egress_qos_mappings (ifindex, 3, 0, 4, 7, 3, 8, 4); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 1, 4)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 1, 4)); _assert_egress_qos_mappings (ifindex, 4, 0, 4, 1, 4, 7, 3, 8, 4); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 1, 5)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 1, 5)); _assert_egress_qos_mappings (ifindex, 4, 0, 4, 1, 5, 7, 3, 8, 4); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 9, 5)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 9, 5)); _assert_egress_qos_mappings (ifindex, 5, 0, 4, 1, 5, @@ -1188,7 +1188,7 @@ test_vlan_set_xgress (void) 8, 4, 9, 5); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 8, 5)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 8, 5)); _assert_egress_qos_mappings (ifindex, 5, 0, 4, 1, 5, @@ -1196,27 +1196,27 @@ test_vlan_set_xgress (void) 8, 5, 9, 5); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 8, 0)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 8, 0)); _assert_egress_qos_mappings (ifindex, 4, 0, 4, 1, 5, 7, 3, 9, 5); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 0, 0)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 0, 0)); _assert_egress_qos_mappings (ifindex, 3, 1, 5, 7, 3, 9, 5); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 100, 4)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 100, 4)); _assert_egress_qos_mappings (ifindex, 4, 1, 5, 7, 3, 9, 5, 100, 4); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, G_MAXUINT32, 4)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, G_MAXUINT32, 4)); _assert_egress_qos_mappings (ifindex, 5, 1, 5, 7, 3, @@ -1224,7 +1224,7 @@ test_vlan_set_xgress (void) 100, 4, G_MAXUINT32, 4); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, G_MAXUINT32, 8)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, G_MAXUINT32, 8)); _assert_egress_qos_mappings (ifindex, 5, 1, 5, 7, 3, @@ -1232,20 +1232,20 @@ test_vlan_set_xgress (void) 100, 4, G_MAXUINT32, 4); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, G_MAXUINT32, 0)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, G_MAXUINT32, 0)); _assert_egress_qos_mappings (ifindex, 4, 1, 5, 7, 3, 9, 5, 100, 4); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 100, 0)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 100, 0)); _assert_egress_qos_mappings (ifindex, 3, 1, 5, 7, 3, 9, 5); - g_assert (nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 1, 0)); + g_assert (nm_platform_link_vlan_set_egress_map (NM_PLATFORM_GET, ifindex, 1, 0)); _assert_egress_qos_mappings (ifindex, 2, 7, 3, 9, 5); @@ -1559,11 +1559,11 @@ test_nl_bugs_veth (void) ifindex_veth0 = nmtstp_assert_wait_for_link (IFACE_VETH0, NM_LINK_TYPE_VETH, 100)->ifindex; ifindex_veth1 = nmtstp_assert_wait_for_link (IFACE_VETH1, NM_LINK_TYPE_VETH, 100)->ifindex; - /* assert that nm_platform_veth_get_properties() returns the expected peer ifindexes. */ - g_assert (nm_platform_veth_get_properties (NM_PLATFORM_GET, ifindex_veth0, &i)); + /* assert that nm_platform_link_veth_get_properties() returns the expected peer ifindexes. */ + g_assert (nm_platform_link_veth_get_properties (NM_PLATFORM_GET, ifindex_veth0, &i)); g_assert_cmpint (i, ==, ifindex_veth1); - g_assert (nm_platform_veth_get_properties (NM_PLATFORM_GET, ifindex_veth1, &i)); + g_assert (nm_platform_link_veth_get_properties (NM_PLATFORM_GET, ifindex_veth1, &i)); g_assert_cmpint (i, ==, ifindex_veth0); /* assert that NMPlatformLink.parent is the peer-ifindex. */ diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c index 0ceac56374..f7611f97dc 100644 --- a/src/platform/tests/test-route.c +++ b/src/platform/tests/test-route.c @@ -295,7 +295,7 @@ setup_tests (void) nm_platform_link_delete (NM_PLATFORM_GET, nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME)); g_assert (!nm_platform_link_get_by_ifname (NM_PLATFORM_GET, DEVICE_NAME)); - g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS); + g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS); accept_signal (link_added); free_signal (link_added); diff --git a/src/tests/test-route-manager.c b/src/tests/test-route-manager.c index eba7d9ef77..347c122c36 100644 --- a/src/tests/test-route-manager.c +++ b/src/tests/test-route-manager.c @@ -876,7 +876,7 @@ fixture_setup (test_fixture *fixture, gconstpointer user_data) "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_get_by_ifname (NM_PLATFORM_GET, "nm-test-device0")); - g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, "nm-test-device0", NULL) == NM_PLATFORM_ERROR_SUCCESS); + g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, "nm-test-device0", NULL) == NM_PLATFORM_ERROR_SUCCESS); accept_signal (link_added); free_signal (link_added); fixture->ifindex0 = nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device0"); @@ -888,7 +888,7 @@ fixture_setup (test_fixture *fixture, gconstpointer user_data) "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_get_by_ifname (NM_PLATFORM_GET, "nm-test-device1")); - g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, "nm-test-device1", NULL) == NM_PLATFORM_ERROR_SUCCESS); + g_assert (nm_platform_link_dummy_add (NM_PLATFORM_GET, "nm-test-device1", NULL) == NM_PLATFORM_ERROR_SUCCESS); accept_signal (link_added); free_signal (link_added); fixture->ifindex1 = nm_platform_link_get_ifindex (NM_PLATFORM_GET, "nm-test-device1");