diff options
author | Thomas Haller <thaller@redhat.com> | 2015-06-15 16:19:19 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-06-17 11:44:16 +0200 |
commit | d7fe907c322a3b447ebefcf2be1e3a803253f55a (patch) | |
tree | 0a4f73e594503775456565f1e279c7c2c7ada346 /src/devices | |
parent | f7fb68755c30d984aa844ecadbc2eb8715e2ecc8 (diff) | |
download | NetworkManager-d7fe907c322a3b447ebefcf2be1e3a803253f55a.tar.gz |
platform: return NMPlatformError from link-add functions
Later remove nm_platform_get_error() and signal errors via return
error codes.
Also, fix nm_platform_infiniband_partition_add() and
nm_platform_vlan_add() to check the type of the existing link
and fail with WRONG_TYPE otherwise.
Diffstat (limited to 'src/devices')
-rw-r--r-- | src/devices/nm-device-bond.c | 7 | ||||
-rw-r--r-- | src/devices/nm-device-bridge.c | 9 | ||||
-rw-r--r-- | src/devices/nm-device-infiniband.c | 7 | ||||
-rw-r--r-- | src/devices/nm-device-vlan.c | 9 | ||||
-rw-r--r-- | src/devices/team/nm-device-team.c | 7 |
5 files changed, 22 insertions, 17 deletions
diff --git a/src/devices/nm-device-bond.c b/src/devices/nm-device-bond.c index 50094189d9..7f1394248d 100644 --- a/src/devices/nm-device-bond.c +++ b/src/devices/nm-device-bond.c @@ -571,16 +571,17 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, GError **error) { const char *iface = nm_connection_get_interface_name (connection); + NMPlatformError plerr; g_assert (iface); - if ( !nm_platform_bond_add (NM_PLATFORM_GET, iface, NULL) - && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { + plerr = nm_platform_bond_add (NM_PLATFORM_GET, iface, NULL); + 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", iface, nm_connection_get_id (connection), - nm_platform_get_error_msg (NM_PLATFORM_GET)); + nm_platform_error_to_string (plerr)); return NULL; } diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c index ece01c6d6d..76b78c0122 100644 --- a/src/devices/nm-device-bridge.c +++ b/src/devices/nm-device-bridge.c @@ -498,6 +498,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, NMSettingBridge *s_bridge; const char *mac_address_str; guint8 mac_address[NM_UTILS_HWADDR_LEN_MAX]; + NMPlatformError plerr; g_assert (iface); @@ -510,17 +511,17 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, mac_address_str = NULL; } - if ( !nm_platform_bridge_add (NM_PLATFORM_GET, + plerr = nm_platform_bridge_add (NM_PLATFORM_GET, iface, mac_address_str ? mac_address : NULL, mac_address_str ? ETH_ALEN : 0, - NULL) - && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { + NULL); + 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", iface, nm_connection_get_id (connection), - nm_platform_get_error_msg (NM_PLATFORM_GET)); + nm_platform_error_to_string (plerr)); return NULL; } diff --git a/src/devices/nm-device-infiniband.c b/src/devices/nm-device-infiniband.c index e901b91a13..020dc53346 100644 --- a/src/devices/nm-device-infiniband.c +++ b/src/devices/nm-device-infiniband.c @@ -326,6 +326,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, NMSettingInfiniband *s_infiniband; int p_key, parent_ifindex; const char *iface; + NMPlatformError plerr; if (!NM_IS_DEVICE_INFINIBAND (parent)) { g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, @@ -342,13 +343,13 @@ 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 (NM_PLATFORM_GET, parent_ifindex, p_key, NULL) - && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { + plerr = nm_platform_infiniband_partition_add (NM_PLATFORM_GET, parent_ifindex, p_key, NULL); + 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", iface, nm_connection_get_id (connection), - nm_platform_get_error_msg (NM_PLATFORM_GET)); + nm_platform_error_to_string (plerr)); return NULL; } diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c index 94827e4c17..158e7de5bf 100644 --- a/src/devices/nm-device-vlan.c +++ b/src/devices/nm-device-vlan.c @@ -656,6 +656,7 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, NMDevice *device; NMSettingVlan *s_vlan; gs_free char *iface = NULL; + NMPlatformError plerr; if (!NM_IS_DEVICE (parent)) { g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CREATION_FAILED, @@ -672,18 +673,18 @@ create_virtual_device_for_connection (NMDeviceFactory *factory, nm_setting_vlan_get_id (s_vlan)); } - if ( !nm_platform_vlan_add (NM_PLATFORM_GET, + plerr = 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), - NULL) - && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { + NULL); + 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", iface, nm_connection_get_id (connection), - nm_platform_get_error_msg (NM_PLATFORM_GET)); + nm_platform_error_to_string (plerr)); return NULL; } diff --git a/src/devices/team/nm-device-team.c b/src/devices/team/nm-device-team.c index 4256bec2b4..aedeebfdb2 100644 --- a/src/devices/team/nm-device-team.c +++ b/src/devices/team/nm-device-team.c @@ -689,16 +689,17 @@ NMDevice * nm_device_team_new_for_connection (NMConnection *connection, GError **error) { const char *iface = nm_connection_get_interface_name (connection); + NMPlatformError plerr; g_assert (iface); - if ( !nm_platform_team_add (NM_PLATFORM_GET, iface, NULL) - && nm_platform_get_error (NM_PLATFORM_GET) != NM_PLATFORM_ERROR_EXISTS) { + plerr = nm_platform_team_add (NM_PLATFORM_GET, iface, NULL); + 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", iface, nm_connection_get_id (connection), - nm_platform_get_error_msg (NM_PLATFORM_GET)); + nm_platform_error_to_string (plerr)); return NULL; } |