diff options
-rw-r--r-- | src/platform/nm-fake-platform.c | 5 | ||||
-rw-r--r-- | src/platform/nm-linux-platform.c | 38 | ||||
-rw-r--r-- | src/platform/nm-platform.c | 168 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 5 | ||||
-rw-r--r-- | src/platform/tests/platform.c | 10 | ||||
-rw-r--r-- | src/platform/tests/test-address.c | 18 | ||||
-rw-r--r-- | src/platform/tests/test-common.h | 3 | ||||
-rw-r--r-- | src/platform/tests/test-link.c | 75 | ||||
-rw-r--r-- | src/platform/tests/test-route.c | 28 |
9 files changed, 38 insertions, 312 deletions
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c index ff97d551c1..1eac40d9e2 100644 --- a/src/platform/nm-fake-platform.c +++ b/src/platform/nm-fake-platform.c @@ -160,7 +160,6 @@ link_get (NMPlatform *platform, int ifindex) return device; not_found: debug ("link not found: %d", ifindex); - platform->error = NM_PLATFORM_ERROR_NOT_FOUND; return NULL; } @@ -649,10 +648,8 @@ link_release (NMPlatform *platform, int master_idx, int slave_idx) g_return_val_if_fail (master, FALSE); g_return_val_if_fail (slave, FALSE); - if (slave->link.master != master->link.ifindex) { - platform->error = NM_PLATFORM_ERROR_NOT_SLAVE; + if (slave->link.master != master->link.ifindex) return FALSE; - } slave->link.master = 0; diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 389208604f..46fad57941 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -2477,10 +2477,8 @@ cache_lookup_link (NMPlatform *platform, int ifindex) const NMPObject *obj_cache; obj_cache = nmp_cache_lookup_link (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, ifindex); - if (!nmp_object_is_visible (obj_cache)) { - platform->error = NM_PLATFORM_ERROR_NOT_FOUND; + if (!nmp_object_is_visible (obj_cache)) return NULL; - } return obj_cache; } @@ -2718,13 +2716,11 @@ do_change_link (NMPlatform *platform, struct rtnl_link *nlo, gboolean complete_f _LOGD ("do-change-link: success changing link %d: %s (%d)", ifindex, nl_geterror (nle), -nle); break; case -NLE_OBJ_NOTFOUND: - platform->error = NM_PLATFORM_ERROR_NO_FIRMWARE; /* fall-through */ default: - if (complete_from_cache != complete_from_cache2) { - platform->error = NM_PLATFORM_ERROR_NOT_FOUND; + if (complete_from_cache != complete_from_cache2) _LOGD ("do-change-link: failure changing link %d: link does not exist in cache", ifindex); - } else + else _LOGE ("do-change-link: failure changing link %d: %s (%d)", ifindex, nl_geterror (nle), -nle); return nle == -NLE_OBJ_NOTFOUND ? NM_PLATFORM_ERROR_NO_FIRMWARE : NM_PLATFORM_ERROR_UNSPECIFIED; } @@ -2780,10 +2776,8 @@ link_delete (NMPlatform *platform, int ifindex) const NMPObject *obj; obj = nmp_cache_lookup_link (priv->cache, ifindex); - if (!obj || !obj->_link.netlink.is_in_netlink) { - platform->error = NM_PLATFORM_ERROR_NOT_FOUND; + if (!obj || !obj->_link.netlink.is_in_netlink) return FALSE; - } nmp_object_stackinit_id_link (&obj_needle, ifindex); return do_delete_object (platform, &obj_needle, NULL); @@ -2798,8 +2792,6 @@ link_get_ifindex (NMPlatform *platform, const char *ifname) obj = nmp_cache_lookup_link_full (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, 0, ifname, TRUE, NM_LINK_TYPE_NONE, NULL, NULL); - if (!obj) - platform->error = NM_PLATFORM_ERROR_NOT_FOUND; return obj ? obj->link.ifindex : 0; } @@ -2951,15 +2943,15 @@ link_set_noarp (NMPlatform *platform, int ifindex) static gboolean link_get_ipv6_token (NMPlatform *platform, int ifindex, NMUtilsIPv6IfaceId *iid) { +#if HAVE_LIBNL_INET6_TOKEN const NMPObject *obj = cache_lookup_link (platform, ifindex); - /* Always lookup @obj, because it properly sets nm_platform_get_error(). - * Otherwise, we could save this '#ifndef HAVE_LIBNL_INET6_TOKEN' */ - if (!obj || !obj->link.inet6_token.is_valid) - return FALSE; - - *iid = obj->link.inet6_token.iid; - return TRUE; + if (obj && obj->link.inet6_token.is_valid) { + *iid = obj->link.inet6_token.iid; + return TRUE; + } +#endif + return FALSE; } static const char * @@ -2991,12 +2983,12 @@ link_get_udev_device (NMPlatform *platform, int ifindex) static gboolean link_get_user_ipv6ll_enabled (NMPlatform *platform, int ifindex) { +#if HAVE_LIBNL_INET6_ADDR_GEN_MODE const NMPObject *obj = cache_lookup_link (platform, ifindex); - /* Always lookup @obj, because it properly sets nm_platform_get_error(). - * Otherwise, we could save this '#ifndef HAVE_LIBNL_INET6_ADDR_GEN_MODE' */ if (obj && obj->link.inet6_addr_gen_mode_inv) return (~obj->link.inet6_addr_gen_mode_inv) == IN6_ADDR_GEN_MODE_NONE; +#endif return FALSE; } @@ -3301,10 +3293,8 @@ slave_category (NMPlatform *platform, int slave) { int master = link_get_master (platform, slave); - if (master <= 0) { - platform->error = NM_PLATFORM_ERROR_NOT_SLAVE; + if (master <= 0) return NULL; - } switch (link_get_type (platform, master)) { case NM_LINK_TYPE_BRIDGE: diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 351c9e61ec..5316d5a2e2 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -146,39 +146,6 @@ nm_platform_try_get (void) /******************************************************************/ /** - * nm_platform_set_error: - * @self: platform instance - * @error: The error code - * - * Convenience function to falsify self->error. It can be used for example - * by functions that want to save the error, execute some operations and - * restore it. - */ -void nm_platform_set_error (NMPlatform *self, NMPlatformError error) -{ - _CHECK_SELF_VOID (self, klass); - - self->error = error; -} - -/** - * nm_platform_get_error: - * @self: platform instance - * - * Convenience function to quickly retrieve the error code of the last - * operation. - * - * Returns: Integer error code. - */ -NMPlatformError -nm_platform_get_error (NMPlatform *self) -{ - _CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG); - - return self->error; -} - -/** * nm_platform_error_to_string: * @error_code: the error code to stringify. * @@ -213,26 +180,7 @@ nm_platform_error_to_string (NMPlatformError error) } } -/** - * nm_platform_get_error_message: - * @self: platform instance - * - * Returns: Static human-readable string for the error. Don't free. - */ -const char * -nm_platform_get_error_msg (NMPlatform *self) -{ - _CHECK_SELF (self, klass, NULL); - - return nm_platform_error_to_string (self->error); -} - -static void -reset_error (NMPlatform *self) -{ - g_assert (self); - self->error = NM_PLATFORM_ERROR_SUCCESS; -} +/******************************************************************/ #define IFA_F_MANAGETEMPADDR_STR "mngtmpaddr" #define IFA_F_NOPREFIXROUTE_STR "noprefixroute" @@ -299,8 +247,6 @@ nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value) g_return_val_if_fail (value, FALSE); g_return_val_if_fail (klass->sysctl_set, FALSE); - reset_error (self); - return klass->sysctl_set (self, path, value); } @@ -351,8 +297,6 @@ nm_platform_sysctl_get (NMPlatform *self, const char *path) g_return_val_if_fail (path, NULL); g_return_val_if_fail (klass->sysctl_get, NULL); - reset_error (self); - return klass->sysctl_get (self, path); } @@ -430,7 +374,6 @@ nm_platform_link_get_all (NMPlatform *self) NMPlatformLink *item; _CHECK_SELF (self, klass, NULL); - reset_error (self); g_return_val_if_fail (klass->link_get_all, NULL); @@ -592,11 +535,8 @@ _link_add_check_existing (NMPlatform *self, const char *name, NMLinkType type, N wrong_type ? nm_link_type_to_string (type) : ""); if (out_link) *out_link = pllink; - if (wrong_type) { - nm_platform_set_error (self, NM_PLATFORM_ERROR_WRONG_TYPE); + if (wrong_type) return NM_PLATFORM_ERROR_WRONG_TYPE; - } - nm_platform_set_error (self, NM_PLATFORM_ERROR_EXISTS); return NM_PLATFORM_ERROR_EXISTS; } /* strange, nm_platform_link_get_ifindex() returned a valid ifindex, but nm_platform_link_get() failed. @@ -635,7 +575,6 @@ nm_platform_link_add (NMPlatform *self, NMPlatformError plerr; _CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG); - reset_error (self); g_return_val_if_fail (name, NM_PLATFORM_ERROR_BUG); g_return_val_if_fail (klass->link_add, NM_PLATFORM_ERROR_BUG); @@ -646,12 +585,8 @@ nm_platform_link_add (NMPlatform *self, return plerr; debug ("link: adding %s '%s'", nm_link_type_to_string (type), name); - reset_error(self); - if (!klass->link_add (self, name, type, address, address_len, out_link)) { - nm_platform_set_error (self, NM_PLATFORM_ERROR_UNSPECIFIED); + if (!klass->link_add (self, name, type, address, address_len, out_link)) return NM_PLATFORM_ERROR_UNSPECIFIED; - } - reset_error (self); return NM_PLATFORM_ERROR_SUCCESS; } @@ -685,7 +620,6 @@ nm_platform_link_exists (NMPlatform *self, const char *name) ifindex = nm_platform_link_get_ifindex (self, name); - reset_error (self); return ifindex > 0; } @@ -693,9 +627,6 @@ nm_platform_link_exists (NMPlatform *self, const char *name) * nm_platform_link_delete: * @self: platform instance * @ifindex: Interface index - * - * Delete a software interface. Sets self->error to - * NM_PLATFORM_ERROR_NOT_FOUND if ifindex not available. */ gboolean nm_platform_link_delete (NMPlatform *self, int ifindex) @@ -703,7 +634,6 @@ nm_platform_link_delete (NMPlatform *self, int ifindex) const char *name; _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (klass->link_delete, FALSE); @@ -730,17 +660,14 @@ nm_platform_link_get_ifindex (NMPlatform *self, const char *name) int ifindex; _CHECK_SELF (self, klass, 0); - reset_error (self); g_return_val_if_fail (name, 0); g_return_val_if_fail (klass->link_get_ifindex, 0); ifindex = klass->link_get_ifindex (self, name); - if (!ifindex) { + if (!ifindex) debug ("link not found: %s", name); - self->error = NM_PLATFORM_ERROR_NOT_FOUND; - } return ifindex; } @@ -759,7 +686,6 @@ nm_platform_link_get_name (NMPlatform *self, int ifindex) const char *name; _CHECK_SELF (self, klass, NULL); - reset_error (self); g_return_val_if_fail (klass->link_get_name, NULL); @@ -767,7 +693,6 @@ nm_platform_link_get_name (NMPlatform *self, int ifindex) if (!name) { debug ("link not found: %d", ifindex); - self->error = NM_PLATFORM_ERROR_NOT_FOUND; return FALSE; } @@ -786,7 +711,6 @@ NMLinkType nm_platform_link_get_type (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, NM_LINK_TYPE_NONE); - reset_error (self); g_return_val_if_fail (klass->link_get_type, NM_LINK_TYPE_NONE); @@ -806,7 +730,6 @@ const char * nm_platform_link_get_type_name (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, NULL); - reset_error (self); g_return_val_if_fail (klass->link_get_type_name, NULL); @@ -827,7 +750,6 @@ gboolean nm_platform_link_get_unmanaged (NMPlatform *self, int ifindex, gboolean *managed) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (klass->link_get_unmanaged, FALSE); @@ -873,7 +795,6 @@ gboolean nm_platform_link_refresh (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); @@ -894,7 +815,6 @@ gboolean nm_platform_link_is_up (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (klass->link_is_up, FALSE); @@ -913,7 +833,6 @@ gboolean nm_platform_link_is_connected (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (klass->link_is_connected, FALSE); @@ -932,7 +851,6 @@ gboolean nm_platform_link_uses_arp (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (klass->link_uses_arp, FALSE); @@ -956,7 +874,6 @@ gboolean nm_platform_link_get_ipv6_token (NMPlatform *self, int ifindex, NMUtilsIPv6IfaceId *iid) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (iid, FALSE); @@ -970,7 +887,6 @@ const char * nm_platform_link_get_udi (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, NULL); @@ -983,7 +899,6 @@ GObject * nm_platform_link_get_udev_device (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, NULL); @@ -1007,7 +922,6 @@ gboolean nm_platform_link_get_user_ipv6ll_enabled (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (klass->check_support_user_ipv6ll, FALSE); @@ -1032,7 +946,6 @@ gboolean nm_platform_link_set_user_ipv6ll_enabled (NMPlatform *self, int ifindex, gboolean enabled) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (klass->check_support_user_ipv6ll, FALSE); @@ -1054,7 +967,6 @@ gboolean nm_platform_link_set_address (NMPlatform *self, int ifindex, gconstpointer address, size_t length) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (address, FALSE); @@ -1078,7 +990,6 @@ gconstpointer nm_platform_link_get_address (NMPlatform *self, int ifindex, size_t *length) { _CHECK_SELF (self, klass, NULL); - reset_error (self); if (length) *length = 0; @@ -1104,7 +1015,6 @@ gboolean nm_platform_link_get_permanent_address (NMPlatform *self, int ifindex, guint8 *buf, size_t *length) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); if (length) *length = 0; @@ -1151,7 +1061,6 @@ gboolean nm_platform_link_set_up (NMPlatform *self, int ifindex, gboolean *out_no_firmware) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (klass->link_set_up, FALSE); @@ -1171,7 +1080,6 @@ gboolean nm_platform_link_set_down (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (klass->link_set_down, FALSE); @@ -1191,7 +1099,6 @@ gboolean nm_platform_link_set_arp (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (klass->link_set_arp, FALSE); @@ -1211,7 +1118,6 @@ gboolean nm_platform_link_set_noarp (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (klass->link_set_noarp, FALSE); @@ -1232,7 +1138,6 @@ gboolean nm_platform_link_set_mtu (NMPlatform *self, int ifindex, guint32 mtu) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (mtu > 0, FALSE); @@ -1253,7 +1158,6 @@ guint32 nm_platform_link_get_mtu (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, 0); - reset_error (self); g_return_val_if_fail (ifindex >= 0, 0); g_return_val_if_fail (klass->link_get_mtu, 0); @@ -1279,7 +1183,6 @@ char * nm_platform_link_get_physical_port_id (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, NULL); - reset_error (self); g_return_val_if_fail (ifindex >= 0, NULL); g_return_val_if_fail (klass->link_get_physical_port_id, NULL); @@ -1303,7 +1206,6 @@ guint nm_platform_link_get_dev_id (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, 0); - reset_error (self); g_return_val_if_fail (ifindex >= 0, 0); g_return_val_if_fail (klass->link_get_dev_id, 0); @@ -1322,7 +1224,6 @@ gboolean nm_platform_link_get_wake_on_lan (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (klass->link_get_wake_on_lan, FALSE); @@ -1350,7 +1251,6 @@ nm_platform_link_get_driver_info (NMPlatform *self, char **out_fw_version) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex >= 0, FALSE); g_return_val_if_fail (klass->link_get_driver_info, FALSE); @@ -1374,7 +1274,6 @@ gboolean nm_platform_link_enslave (NMPlatform *self, int master, int slave) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (master > 0, FALSE); g_return_val_if_fail (slave> 0, FALSE); @@ -1398,16 +1297,13 @@ gboolean nm_platform_link_release (NMPlatform *self, int master, int slave) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (master > 0, FALSE); g_return_val_if_fail (slave > 0, FALSE); g_return_val_if_fail (klass->link_release, FALSE); - if (nm_platform_link_get_master (self, slave) != master) { - self->error = NM_PLATFORM_ERROR_NOT_SLAVE; + if (nm_platform_link_get_master (self, slave) != master) return FALSE; - } debug ("link: releasing '%s' (%d) from master '%s' (%d)", nm_platform_link_get_name (self, slave), slave, @@ -1426,15 +1322,12 @@ int nm_platform_link_get_master (NMPlatform *self, int slave) { _CHECK_SELF (self, klass, 0); - reset_error (self); g_return_val_if_fail (slave >= 0, FALSE); g_return_val_if_fail (klass->link_get_master, FALSE); - if (!nm_platform_link_get_name (self, slave)) { - self->error = NM_PLATFORM_ERROR_NOT_FOUND; + if (!nm_platform_link_get_name (self, slave)) return 0; - } return klass->link_get_master (self, slave); } @@ -1507,7 +1400,6 @@ nm_platform_vlan_add (NMPlatform *self, NMPlatformError plerr; _CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG); - reset_error (self); g_return_val_if_fail (parent >= 0, NM_PLATFORM_ERROR_BUG); g_return_val_if_fail (vlanid >= 0, NM_PLATFORM_ERROR_BUG); @@ -1529,7 +1421,6 @@ gboolean nm_platform_master_set_option (NMPlatform *self, int ifindex, const char *option, const char *value) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (option, FALSE); @@ -1543,7 +1434,6 @@ char * nm_platform_master_get_option (NMPlatform *self, int ifindex, const char *option) { _CHECK_SELF (self, klass, NULL); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (option, FALSE); @@ -1556,7 +1446,6 @@ gboolean nm_platform_slave_set_option (NMPlatform *self, int ifindex, const char *option, const char *value) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (option, FALSE); @@ -1570,7 +1459,6 @@ char * nm_platform_slave_get_option (NMPlatform *self, int ifindex, const char *option) { _CHECK_SELF (self, klass, NULL); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (option, FALSE); @@ -1583,7 +1471,6 @@ gboolean nm_platform_vlan_get_info (NMPlatform *self, int ifindex, int *parent, int *vlanid) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (klass->vlan_get_info, FALSE); @@ -1602,7 +1489,6 @@ gboolean nm_platform_vlan_set_ingress_map (NMPlatform *self, int ifindex, int from, int to) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (klass->vlan_set_ingress_map, FALSE); @@ -1614,7 +1500,6 @@ gboolean nm_platform_vlan_set_egress_map (NMPlatform *self, int ifindex, int from, int to) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (klass->vlan_set_egress_map, FALSE); @@ -1630,7 +1515,6 @@ nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, N NMPlatformError plerr; _CHECK_SELF (self, klass, NM_PLATFORM_ERROR_BUG); - reset_error (self); g_return_val_if_fail (parent >= 0, NM_PLATFORM_ERROR_BUG); g_return_val_if_fail (p_key >= 0, NM_PLATFORM_ERROR_BUG); @@ -1638,10 +1522,8 @@ nm_platform_infiniband_partition_add (NMPlatform *self, int parent, int p_key, N parent_name = g_strdup (nm_platform_link_get_name (self, parent)); if ( !parent_name - || nm_platform_link_get_type (self, parent) != NM_LINK_TYPE_INFINIBAND) { - self->error = NM_PLATFORM_ERROR_WRONG_TYPE; + || nm_platform_link_get_type (self, parent) != NM_LINK_TYPE_INFINIBAND) return NM_PLATFORM_ERROR_WRONG_TYPE; - } name = g_strdup_printf ("%s.%04x", parent_name, p_key); plerr = _link_add_check_existing (self, name, NM_LINK_TYPE_INFINIBAND, out_link); @@ -1663,7 +1545,6 @@ nm_platform_infiniband_get_info (NMPlatform *self, const char **mode) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (klass->infiniband_get_info, FALSE); @@ -1675,7 +1556,6 @@ gboolean nm_platform_veth_get_properties (NMPlatform *self, int ifindex, NMPlatformVethProperties *props) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (props != NULL, FALSE); @@ -1687,7 +1567,6 @@ gboolean nm_platform_tun_get_properties (NMPlatform *self, int ifindex, NMPlatformTunProperties *props) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (props != NULL, FALSE); @@ -1699,7 +1578,6 @@ gboolean nm_platform_macvlan_get_properties (NMPlatform *self, int ifindex, NMPlatformMacvlanProperties *props) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (props != NULL, FALSE); @@ -1711,7 +1589,6 @@ gboolean nm_platform_vxlan_get_properties (NMPlatform *self, int ifindex, NMPlatformVxlanProperties *props) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (props != NULL, FALSE); @@ -1723,7 +1600,6 @@ gboolean nm_platform_gre_get_properties (NMPlatform *self, int ifindex, NMPlatformGreProperties *props) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (props != NULL, FALSE); @@ -1735,7 +1611,6 @@ gboolean nm_platform_wifi_get_capabilities (NMPlatform *self, int ifindex, NMDeviceWifiCapabilities *caps) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); @@ -1746,7 +1621,6 @@ gboolean nm_platform_wifi_get_bssid (NMPlatform *self, int ifindex, guint8 *bssid) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); @@ -1757,7 +1631,6 @@ guint32 nm_platform_wifi_get_frequency (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, 0); - reset_error (self); g_return_val_if_fail (ifindex > 0, 0); @@ -1768,7 +1641,6 @@ int nm_platform_wifi_get_quality (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, 0); - reset_error (self); g_return_val_if_fail (ifindex > 0, 0); @@ -1779,7 +1651,6 @@ guint32 nm_platform_wifi_get_rate (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, 0); - reset_error (self); g_return_val_if_fail (ifindex > 0, 0); @@ -1790,7 +1661,6 @@ NM80211Mode nm_platform_wifi_get_mode (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, NM_802_11_MODE_UNKNOWN); - reset_error (self); g_return_val_if_fail (ifindex > 0, NM_802_11_MODE_UNKNOWN); @@ -1801,7 +1671,6 @@ void nm_platform_wifi_set_mode (NMPlatform *self, int ifindex, NM80211Mode mode) { _CHECK_SELF_VOID (self, klass); - reset_error (self); g_return_if_fail (ifindex > 0); @@ -1818,7 +1687,6 @@ void nm_platform_wifi_set_powersave (NMPlatform *self, int ifindex, guint32 powersave) { _CHECK_SELF_VOID (self, klass); - reset_error (self); g_return_if_fail (ifindex > 0); @@ -1829,7 +1697,6 @@ guint32 nm_platform_wifi_find_frequency (NMPlatform *self, int ifindex, const guint32 *freqs) { _CHECK_SELF (self, klass, 0); - reset_error (self); g_return_val_if_fail (ifindex > 0, 0); g_return_val_if_fail (freqs != NULL, 0); @@ -1841,7 +1708,6 @@ void nm_platform_wifi_indicate_addressing_running (NMPlatform *self, int ifindex, gboolean running) { _CHECK_SELF_VOID (self, klass); - reset_error (self); g_return_if_fail (ifindex > 0); @@ -1852,7 +1718,6 @@ guint32 nm_platform_mesh_get_channel (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, 0); - reset_error (self); g_return_val_if_fail (ifindex > 0, 0); @@ -1863,7 +1728,6 @@ gboolean nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); @@ -1874,7 +1738,6 @@ gboolean nm_platform_mesh_set_ssid (NMPlatform *self, int ifindex, const guint8 *ssid, gsize len) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (ssid != NULL, FALSE); @@ -1912,7 +1775,6 @@ GArray * nm_platform_ip4_address_get_all (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, NULL); - reset_error (self); g_return_val_if_fail (ifindex > 0, NULL); g_return_val_if_fail (klass->ip4_address_get_all, NULL); @@ -1924,7 +1786,6 @@ GArray * nm_platform_ip6_address_get_all (NMPlatform *self, int ifindex) { _CHECK_SELF (self, klass, NULL); - reset_error (self); g_return_val_if_fail (ifindex > 0, NULL); g_return_val_if_fail (klass->ip6_address_get_all, NULL); @@ -1943,7 +1804,6 @@ nm_platform_ip4_address_add (NMPlatform *self, const char *label) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (plen > 0, FALSE); @@ -1981,7 +1841,6 @@ nm_platform_ip6_address_add (NMPlatform *self, guint flags) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (plen > 0, FALSE); @@ -2013,7 +1872,6 @@ nm_platform_ip4_address_delete (NMPlatform *self, int ifindex, in_addr_t address char str_peer[NM_UTILS_INET_ADDRSTRLEN]; _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (plen > 0, FALSE); @@ -2035,7 +1893,6 @@ nm_platform_ip6_address_delete (NMPlatform *self, int ifindex, struct in6_addr a char str_dev[TO_STRING_DEV_BUF_SIZE]; _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (ifindex > 0, FALSE); g_return_val_if_fail (plen > 0, FALSE); @@ -2051,7 +1908,6 @@ gboolean nm_platform_ip4_address_exists (NMPlatform *self, int ifindex, in_addr_t address, int plen) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (plen > 0, FALSE); g_return_val_if_fail (klass->ip4_address_exists, FALSE); @@ -2063,7 +1919,6 @@ gboolean nm_platform_ip6_address_exists (NMPlatform *self, int ifindex, struct in6_addr address, int plen) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (plen > 0, FALSE); g_return_val_if_fail (klass->ip6_address_exists, FALSE); @@ -2177,7 +2032,6 @@ gboolean nm_platform_ip4_check_reinstall_device_route (NMPlatform *self, int ifindex, const NMPlatformIP4Address *address, guint32 device_route_metric) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); if ( ifindex <= 0 || address->plen <= 0 @@ -2338,7 +2192,6 @@ GArray * nm_platform_ip4_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode) { _CHECK_SELF (self, klass, NULL); - reset_error (self); g_return_val_if_fail (ifindex >= 0, NULL); g_return_val_if_fail (klass->ip4_route_get_all, NULL); @@ -2350,7 +2203,6 @@ GArray * nm_platform_ip6_route_get_all (NMPlatform *self, int ifindex, NMPlatformGetRouteMode mode) { _CHECK_SELF (self, klass, NULL); - reset_error (self); g_return_val_if_fail (ifindex >= 0, NULL); g_return_val_if_fail (klass->ip6_route_get_all, NULL); @@ -2366,7 +2218,6 @@ nm_platform_ip4_route_add (NMPlatform *self, guint32 metric, guint32 mss) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (0 <= plen && plen <= 32, FALSE); g_return_val_if_fail (klass->ip4_route_add, FALSE); @@ -2398,7 +2249,6 @@ nm_platform_ip6_route_add (NMPlatform *self, guint32 metric, guint32 mss) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (0 <= plen && plen <= 128, FALSE); g_return_val_if_fail (klass->ip6_route_add, FALSE); @@ -2425,7 +2275,6 @@ nm_platform_ip4_route_delete (NMPlatform *self, int ifindex, in_addr_t network, char str_dev[TO_STRING_DEV_BUF_SIZE]; _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (klass->ip4_route_delete, FALSE); @@ -2441,7 +2290,6 @@ nm_platform_ip6_route_delete (NMPlatform *self, int ifindex, struct in6_addr net char str_dev[TO_STRING_DEV_BUF_SIZE]; _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (klass->ip6_route_delete, FALSE); @@ -2455,7 +2303,6 @@ gboolean nm_platform_ip4_route_exists (NMPlatform *self, int ifindex, in_addr_t network, int plen, guint32 metric) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (klass->ip4_route_exists, FALSE); @@ -2466,7 +2313,6 @@ gboolean nm_platform_ip6_route_exists (NMPlatform *self, int ifindex, struct in6_addr network, int plen, guint32 metric) { _CHECK_SELF (self, klass, FALSE); - reset_error (self); g_return_val_if_fail (klass->ip6_route_exists, FALSE); diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 57a97bcd12..afb94c1ae9 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -401,8 +401,6 @@ typedef struct { struct _NMPlatform { GObject parent; - - NMPlatformError error; }; typedef struct { @@ -590,9 +588,6 @@ nm_platform_route_scope_inv (guint8 scope) const char *nm_link_type_to_string (NMLinkType link_type); const char *nm_platform_error_to_string (NMPlatformError error); -void nm_platform_set_error (NMPlatform *self, NMPlatformError error); -NMPlatformError nm_platform_get_error (NMPlatform *self); -const char *nm_platform_get_error_msg (NMPlatform *self); gboolean nm_platform_sysctl_set (NMPlatform *self, const char *path, const char *value); char *nm_platform_sysctl_get (NMPlatform *self, const char *path); diff --git a/src/platform/tests/platform.c b/src/platform/tests/platform.c index ee48a9d7cb..fe148518c2 100644 --- a/src/platform/tests/platform.c +++ b/src/platform/tests/platform.c @@ -865,7 +865,6 @@ main (int argc, char **argv) const char *arg0 = *argv++; const command_t *command = NULL; gboolean status = TRUE; - int error; #if !GLIB_CHECK_VERSION (2, 35, 0) g_type_init (); @@ -899,12 +898,5 @@ main (int argc, char **argv) error ("\n"); } - error = nm_platform_get_error (NM_PLATFORM_GET); - if (error) { - const char *msg = nm_platform_get_error_msg (NM_PLATFORM_GET); - - error ("nm-platform: %s\n", msg); - } - - return !!error; + return EXIT_SUCCESS; } diff --git a/src/platform/tests/test-address.c b/src/platform/tests/test-address.c index 06cd3aac14..6d7a47def4 100644 --- a/src/platform/tests/test-address.c +++ b/src/platform/tests/test-address.c @@ -65,22 +65,17 @@ test_ip4_address (void) /* Add address */ g_assert (!nm_platform_ip4_address_exists (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN)); - no_error (); 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 (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 (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL)); - no_error (); accept_signals (address_changed, 0, 1); /* Test address listing */ addresses = nm_platform_ip4_address_get_all (NM_PLATFORM_GET, ifindex); g_assert (addresses); - no_error (); g_assert_cmpint (addresses->len, ==, 1); address = &g_array_index (addresses, NMPlatformIP4Address, 0); g_assert_cmpint (address->ifindex, ==, ifindex); @@ -90,13 +85,11 @@ test_ip4_address (void) /* Remove address */ g_assert (nm_platform_ip4_address_delete (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0)); - no_error (); 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 (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN, 0)); - no_error (); free_signal (address_added); free_signal (address_changed); @@ -121,22 +114,17 @@ test_ip6_address (void) /* Add address */ g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); - no_error (); 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 (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 (NM_PLATFORM_GET, ifindex, addr, in6addr_any, IP6_PLEN, lifetime, preferred, flags)); - no_error (); accept_signals (address_changed, 0, 1); /* Test address listing */ addresses = nm_platform_ip6_address_get_all (NM_PLATFORM_GET, ifindex); g_assert (addresses); - no_error (); g_assert_cmpint (addresses->len, ==, 1); address = &g_array_index (addresses, NMPlatformIP6Address, 0); g_assert_cmpint (address->ifindex, ==, ifindex); @@ -146,13 +134,11 @@ test_ip6_address (void) /* Remove address */ g_assert (nm_platform_ip6_address_delete (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); - no_error (); 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 (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); - no_error (); free_signal (address_added); free_signal (address_changed); @@ -190,12 +176,10 @@ test_ip4_address_external (void) 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 (NM_PLATFORM_GET, ifindex, addr, 0, IP4_PLEN, lifetime, preferred, NULL)); - no_error (); 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 (NM_PLATFORM_GET, ifindex, addr, IP4_PLEN)); accept_signal (address_removed);*/ @@ -229,12 +213,10 @@ 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); 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 (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 (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); - no_error (); g_assert (!nm_platform_ip6_address_exists (NM_PLATFORM_GET, ifindex, addr, IP6_PLEN)); wait_signal (address_removed);*/ diff --git a/src/platform/tests/test-common.h b/src/platform/tests/test-common.h index 5f72a1480d..4a1814f85a 100644 --- a/src/platform/tests/test-common.h +++ b/src/platform/tests/test-common.h @@ -15,9 +15,6 @@ #define debug(...) nm_log_dbg (LOGD_PLATFORM, __VA_ARGS__) -#define error(err) g_assert (nm_platform_get_error (NM_PLATFORM_GET) == err) -#define no_error() error (NM_PLATFORM_ERROR_SUCCESS) - typedef struct { int handler_id; const char *name; diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c index 40b4731b66..e09e1eb9d1 100644 --- a/src/platform/tests/test-link.c +++ b/src/platform/tests/test-link.c @@ -22,54 +22,32 @@ test_bogus(void) size_t addrlen; g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, BOGUS_NAME)); - no_error (); g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, BOGUS_IFINDEX)); - error (NM_PLATFORM_ERROR_NOT_FOUND); 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 (NM_PLATFORM_GET, BOGUS_IFINDEX)); - error (NM_PLATFORM_ERROR_NOT_FOUND); 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 (NM_PLATFORM_GET, BOGUS_IFINDEX)); - error (NM_PLATFORM_ERROR_NOT_FOUND); g_assert (!nm_platform_link_set_up (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL)); - error (NM_PLATFORM_ERROR_NOT_FOUND); 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 (NM_PLATFORM_GET, BOGUS_IFINDEX)); - error (NM_PLATFORM_ERROR_NOT_FOUND); 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 (NM_PLATFORM_GET, BOGUS_IFINDEX)); - error (NM_PLATFORM_ERROR_NOT_FOUND); 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 (NM_PLATFORM_GET, BOGUS_IFINDEX)); - error (NM_PLATFORM_ERROR_NOT_FOUND); 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 (NM_PLATFORM_GET, BOGUS_IFINDEX, NULL)); - error (NM_PLATFORM_ERROR_NOT_FOUND); 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 (NM_PLATFORM_GET, BOGUS_IFINDEX)); - error (NM_PLATFORM_ERROR_NOT_FOUND); 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 (NM_PLATFORM_GET, BOGUS_IFINDEX)); - error (NM_PLATFORM_ERROR_NOT_FOUND); 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 (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0)); - error (NM_PLATFORM_ERROR_NOT_FOUND); g_assert (!nm_platform_vlan_set_egress_map (NM_PLATFORM_GET, BOGUS_IFINDEX, 0, 0)); - error (NM_PLATFORM_ERROR_NOT_FOUND); } static void @@ -103,8 +81,6 @@ software_add (NMLinkType link_type, const char *name) /* Check that bond0 is *not* automatically created. */ if (!bond0_exists) g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, "bond0")); - - nm_platform_set_error (NM_PLATFORM_GET, plerr); return plerr == NM_PLATFORM_ERROR_SUCCESS; } case NM_LINK_TYPE_TEAM: @@ -170,8 +146,8 @@ test_slave (int master, int type, SignalData *master_changed) /* Enslave */ link_changed->ifindex = ifindex; - 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 (); + g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex)); + g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, master); accept_signals (link_changed, 1, 3); accept_signals (master_changed, 0, 1); @@ -220,7 +196,7 @@ 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 (NM_PLATFORM_GET, ifindex, NULL)); no_error (); + g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, ifindex, NULL)); g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, master)); accept_signals (link_changed, 1, 3); @@ -232,7 +208,7 @@ test_slave (int master, int type, SignalData *master_changed) * Gracefully succeed if already enslaved. */ ensure_no_signal (link_changed); - g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex)); no_error (); + g_assert (nm_platform_link_enslave (NM_PLATFORM_GET, master, ifindex)); accept_signals (link_changed, 0, 2); ensure_no_signal (master_changed); @@ -241,9 +217,7 @@ test_slave (int master, int type, SignalData *master_changed) case NM_LINK_TYPE_BRIDGE: if (nmtst_platform_is_sysfs_writable ()) { g_assert (nm_platform_slave_set_option (NM_PLATFORM_GET, ifindex, "priority", "789")); - no_error (); value = nm_platform_slave_get_option (NM_PLATFORM_GET, ifindex, "priority"); - no_error (); g_assert_cmpstr (value, ==, "789"); g_free (value); } @@ -255,7 +229,7 @@ test_slave (int master, int type, SignalData *master_changed) /* Release */ ensure_no_signal (link_changed); 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 (); + g_assert_cmpint (nm_platform_link_get_master (NM_PLATFORM_GET, ifindex), ==, 0); accept_signals (link_changed, 1, 3); if (link_type != NM_LINK_TYPE_TEAM) accept_signals (master_changed, 1, 2); @@ -267,14 +241,12 @@ test_slave (int master, int type, SignalData *master_changed) /* Release again */ ensure_no_signal (link_changed); g_assert (!nm_platform_link_release (NM_PLATFORM_GET, master, ifindex)); - error (NM_PLATFORM_ERROR_NOT_SLAVE); ensure_no_signal (master_changed); /* Remove */ ensure_no_signal (link_changed); g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex)); - no_error (); accept_signals (master_changed, 0, 1); accept_signals (link_changed, 0, 1); accept_signal (link_removed); @@ -296,7 +268,6 @@ test_software (NMLinkType link_type, const char *link_typename) /* Add */ link_added = add_signal_ifname (NM_PLATFORM_SIGNAL_LINK_CHANGED, NM_PLATFORM_SIGNAL_ADDED, link_callback, DEVICE_NAME); g_assert (software_add (link_type, DEVICE_NAME)); - no_error (); accept_signal (link_added); g_assert (nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); @@ -309,12 +280,10 @@ test_software (NMLinkType link_type, const char *link_typename) 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 (); } /* Add again */ g_assert (!software_add (link_type, DEVICE_NAME)); - error (NM_PLATFORM_ERROR_EXISTS); /* Set ARP/NOARP */ g_assert (nm_platform_link_uses_arp (NM_PLATFORM_GET, ifindex)); @@ -330,9 +299,7 @@ test_software (NMLinkType link_type, const char *link_typename) case NM_LINK_TYPE_BRIDGE: if (nmtst_platform_is_sysfs_writable ()) { g_assert (nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, "forward_delay", "789")); - no_error (); value = nm_platform_master_get_option (NM_PLATFORM_GET, ifindex, "forward_delay"); - no_error (); g_assert_cmpstr (value, ==, "789"); g_free (value); } @@ -340,9 +307,7 @@ test_software (NMLinkType link_type, const char *link_typename) case NM_LINK_TYPE_BOND: if (nmtst_platform_is_sysfs_writable ()) { g_assert (nm_platform_master_set_option (NM_PLATFORM_GET, ifindex, "mode", "active-backup")); - no_error (); 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")); g_free (value); @@ -368,17 +333,13 @@ test_software (NMLinkType link_type, const char *link_typename) /* Delete */ g_assert (nm_platform_link_delete (NM_PLATFORM_GET, ifindex)); - no_error (); - g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); no_error (); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); 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 (NM_PLATFORM_GET, ifindex)); - error (NM_PLATFORM_ERROR_NOT_FOUND); accept_signal (link_removed); /* Delete again */ 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) { @@ -436,18 +397,15 @@ test_internal (void) int ifindex; /* Check the functions for non-existent devices */ - g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); no_error (); + g_assert (!nm_platform_link_exists (NM_PLATFORM_GET, DEVICE_NAME)); 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 (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_SUCCESS); - no_error (); accept_signal (link_added); /* Try to add again */ g_assert (nm_platform_dummy_add (NM_PLATFORM_GET, DEVICE_NAME, NULL) == NM_PLATFORM_ERROR_EXISTS); - error (NM_PLATFORM_ERROR_EXISTS); /* Check device index, name and type */ ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, DEVICE_NAME); @@ -459,15 +417,15 @@ test_internal (void) 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 (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, NULL)); 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_is_up (NM_PLATFORM_GET, ifindex)); + g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); + g_assert (nm_platform_link_set_up (NM_PLATFORM_GET, ifindex, NULL)); + g_assert (nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); + g_assert (nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); accept_signal (link_changed); - 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 (); + g_assert (nm_platform_link_set_down (NM_PLATFORM_GET, ifindex)); + g_assert (!nm_platform_link_is_up (NM_PLATFORM_GET, ifindex)); + g_assert (!nm_platform_link_is_connected (NM_PLATFORM_GET, ifindex)); accept_signal (link_changed); /* arp/noarp */ @@ -494,18 +452,15 @@ test_internal (void) /* Set MTU */ g_assert (nm_platform_link_set_mtu (NM_PLATFORM_GET, ifindex, MTU)); - no_error (); 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 (NM_PLATFORM_GET, ifindex)); - no_error (); accept_signal (link_removed); /* Try to delete again */ g_assert (!nm_platform_link_delete (NM_PLATFORM_GET, ifindex)); - error (NM_PLATFORM_ERROR_NOT_FOUND); free_signal (link_added); free_signal (link_changed); diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c index 1bf18ff12a..cd4217d248 100644 --- a/src/platform/tests/test-route.c +++ b/src/platform/tests/test-route.c @@ -66,7 +66,6 @@ test_ip4_route_metric0 (void) /* add the first route */ 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); assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, 0); @@ -74,7 +73,6 @@ test_ip4_route_metric0 (void) /* Deleting route with metric 0 does nothing */ g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0)); - no_error (); ensure_no_signal (route_removed); assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, 0); @@ -82,7 +80,6 @@ test_ip4_route_metric0 (void) /* add the second route */ 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); assert_ip4_route_exists (TRUE, DEVICE_NAME, network, plen, 0); @@ -90,7 +87,6 @@ test_ip4_route_metric0 (void) /* Delete route with metric 0 */ g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0)); - no_error (); accept_signal (route_removed); assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, 0); @@ -98,7 +94,6 @@ test_ip4_route_metric0 (void) /* Delete route with metric 0 again (we expect nothing to happen) */ g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, 0)); - no_error (); ensure_no_signal (route_removed); assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, 0); @@ -106,7 +101,6 @@ test_ip4_route_metric0 (void) /* Delete the other route */ g_assert (nm_platform_ip4_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric)); - no_error (); accept_signal (route_removed); assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, 0); @@ -138,35 +132,26 @@ test_ip4_route (void) /* Add route to gateway */ 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 (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 (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, 0, metric, mss)); - no_error (); accept_signals (route_changed, 0, 1); /* Add default route */ assert_ip4_route_exists (FALSE, DEVICE_NAME, 0, 0, metric); - no_error (); 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 (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, 0, 0, gateway, 0, metric, mss)); - no_error (); accept_signals (route_changed, 0, 1); /* Test route listing */ @@ -202,13 +187,11 @@ test_ip4_route (void) /* Remove route */ 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 (NM_PLATFORM_GET, ifindex, network, plen, metric)); - no_error (); free_signal (route_added); free_signal (route_changed); @@ -236,35 +219,26 @@ test_ip6_route (void) /* Add route to gateway */ 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 (NM_PLATFORM_GET, ifindex, network, plen, metric)); - no_error (); 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 (NM_PLATFORM_GET, ifindex, network, plen, metric)); - no_error (); accept_signal (route_added); /* Add route again */ g_assert (nm_platform_ip6_route_add (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, network, plen, gateway, metric, mss)); - no_error (); accept_signals (route_changed, 0, 1); /* Add default route */ g_assert (!nm_platform_ip6_route_exists (NM_PLATFORM_GET, ifindex, in6addr_any, 0, metric)); - no_error (); 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 (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 (NM_PLATFORM_GET, ifindex, NM_IP_CONFIG_SOURCE_USER, in6addr_any, 0, gateway, metric, mss)); - no_error (); accept_signals (route_changed, 0, 1); /* Test route listing */ @@ -297,13 +271,11 @@ test_ip6_route (void) /* Remove route */ g_assert (nm_platform_ip6_route_delete (NM_PLATFORM_GET, ifindex, network, plen, metric)); - no_error (); 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 (NM_PLATFORM_GET, ifindex, network, plen, metric)); - no_error (); free_signal (route_added); free_signal (route_changed); |