summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-12-15 13:25:53 +0100
committerThomas Haller <thaller@redhat.com>2015-12-16 20:14:16 +0100
commitf87f7af3001ee34c2363092fb098acf3f3b9de3b (patch)
treef144e2cf3959d0cc21cb0c823f4b59c668fbb53e
parent9a06eb8bd19863379c6cfb2c459a3bfb7d1054dc (diff)
downloadNetworkManager-f87f7af3001ee34c2363092fb098acf3f3b9de3b.tar.gz
platform: change meaning of return value for delete-function
When deleting an object, we allow failure to delete a non-existing object. Thus, the only thing we care about is whether the object is no longer present after deletion. Adjust the return values to reflect that.
-rw-r--r--src/platform/nm-linux-platform.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index ddb027275b..0dffb09e70 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -3720,6 +3720,7 @@ do_add_addrroute (NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *
static gboolean
do_delete_object (NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *nlmsg)
{
+ NMLinuxPlatformPrivate *priv = NM_LINUX_PLATFORM_GET_PRIVATE (platform);
WaitForNlResponseResult seq_result = WAIT_FOR_NL_RESPONSE_RESULT_UNKNOWN;
int nle;
char s_buf[256];
@@ -3734,7 +3735,7 @@ do_delete_object (NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *
NMP_OBJECT_GET_CLASS (obj_id)->obj_type_name,
nmp_object_to_string (obj_id, NMP_OBJECT_TO_STRING_ID, NULL, 0),
nl_geterror (nle), -nle);
- return FALSE;
+ goto out;
}
delayed_action_handle_all (platform, FALSE);
@@ -3762,15 +3763,14 @@ do_delete_object (NMPlatform *platform, const NMPObject *obj_id, struct nl_msg *
wait_for_nl_response_to_string (seq_result, s_buf, sizeof (s_buf)),
log_detail);
- if (nmp_cache_lookup_obj (NM_LINUX_PLATFORM_GET_PRIVATE (platform)->cache, obj_id)) {
- /* such an object still exists in the cache. To be sure, refetch it (and
- * hope it's gone) */
- do_request_one_type (platform, NMP_OBJECT_GET_TYPE (obj_id));
- }
+out:
+ if (!nmp_cache_lookup_obj (priv->cache, obj_id))
+ return TRUE;
- /* The return value doesn't say, whether the object is in the platform cache after adding
- * it. Instead the return value says, whether the netlink request succeeded. */
- return success;
+ /* such an object still exists in the cache. To be sure, refetch it (and
+ * hope it's gone) */
+ do_request_one_type (platform, NMP_OBJECT_GET_TYPE (obj_id));
+ return !!nmp_cache_lookup_obj (priv->cache, obj_id);
}
static NMPlatformError
@@ -5176,6 +5176,8 @@ ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, int plen,
NM_PLATFORM_LIFETIME_PERMANENT,
NM_PLATFORM_LIFETIME_PERMANENT,
NULL);
+ if (!nlmsg)
+ g_return_val_if_reached (FALSE);
nmp_object_stackinit_id_ip4_address (&obj_id, ifindex, addr, plen, peer_address);
return do_delete_object (platform, &obj_id, nlmsg);
@@ -5199,6 +5201,8 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int
NM_PLATFORM_LIFETIME_PERMANENT,
NM_PLATFORM_LIFETIME_PERMANENT,
NULL);
+ if (!nlmsg)
+ g_return_val_if_reached (FALSE);
nmp_object_stackinit_id_ip6_address (&obj_id, ifindex, &addr, plen);
return do_delete_object (platform, &obj_id, nlmsg);