summaryrefslogtreecommitdiff
path: root/src/platform/nm-fake-platform.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-02-13 14:56:38 +0100
committerThomas Haller <thaller@redhat.com>2014-02-14 21:41:25 +0100
commit2bc90a5f2d3dabc84a6ce3a8eb6a0e2582c1c9f2 (patch)
treec1248c7c1e8370f7f1a04b1b165656a85bf58b23 /src/platform/nm-fake-platform.c
parent5f5c7284d16c5f24200bbbd40c5e9a83f84516cd (diff)
downloadNetworkManager-2bc90a5f2d3dabc84a6ce3a8eb6a0e2582c1c9f2.tar.gz
platform: do not check for _exists() before deleting addresses and routes
Before, nm_platform_ip4_address_exists(), et al. look into the cache to see whether the address/route already exists and returned an error if it did. Change the semantic of the delete functions, to return success in case of "nothing to delete". Also always try to delete the object in the kernel. The reason is, that the cache might be out of date and the caller really wants to delete it. So, to be sure, we always delete. In most cases the object is actually in the cache (because that is how the caller came to know that such an object might exist). In those cases, the lookup was not useful either, because the object was actually cached. Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'src/platform/nm-fake-platform.c')
-rw-r--r--src/platform/nm-fake-platform.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c
index 43944721cd..d0127c4733 100644
--- a/src/platform/nm-fake-platform.c
+++ b/src/platform/nm-fake-platform.c
@@ -827,7 +827,7 @@ ip4_address_delete (NMPlatform *platform, int ifindex, in_addr_t addr, int plen)
}
}
- g_assert_not_reached ();
+ return TRUE;
}
static gboolean
@@ -850,7 +850,7 @@ ip6_address_delete (NMPlatform *platform, int ifindex, struct in6_addr addr, int
}
}
- g_assert_not_reached ();
+ return TRUE;
}
static gboolean
@@ -1064,11 +1064,11 @@ ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, int plen
NMPlatformIP4Route *route = ip4_route_get (platform, ifindex, network, plen, metric);
NMPlatformIP4Route deleted_route;
- g_assert (route);
-
- memcpy (&deleted_route, route, sizeof (deleted_route));
- memset (route, 0, sizeof (*route));
- g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ROUTE_REMOVED, ifindex, &deleted_route, NM_PLATFORM_REASON_INTERNAL);
+ if (route) {
+ memcpy (&deleted_route, route, sizeof (deleted_route));
+ memset (route, 0, sizeof (*route));
+ g_signal_emit_by_name (platform, NM_PLATFORM_IP4_ROUTE_REMOVED, ifindex, &deleted_route, NM_PLATFORM_REASON_INTERNAL);
+ }
return TRUE;
}
@@ -1079,11 +1079,11 @@ ip6_route_delete (NMPlatform *platform, int ifindex, struct in6_addr network, in
NMPlatformIP6Route *route = ip6_route_get (platform, ifindex, network, plen, metric);
NMPlatformIP6Route deleted_route;
- g_assert (route);
-
- memcpy (&deleted_route, route, sizeof (deleted_route));
- memset (route, 0, sizeof (*route));
- g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ROUTE_REMOVED, ifindex, &deleted_route, NM_PLATFORM_REASON_INTERNAL);
+ if (route) {
+ memcpy (&deleted_route, route, sizeof (deleted_route));
+ memset (route, 0, sizeof (*route));
+ g_signal_emit_by_name (platform, NM_PLATFORM_IP6_ROUTE_REMOVED, ifindex, &deleted_route, NM_PLATFORM_REASON_INTERNAL);
+ }
return TRUE;
}