summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-01-11 17:42:46 +0100
committerThomas Haller <thaller@redhat.com>2015-01-12 20:02:06 +0100
commit96c099de09888ea614477b021673bb5c2e38c542 (patch)
tree1ddf55f77a56c5ced69c305bec10e71c784b09ea
parent4f390e7e4d05ad2f11d127cad99c40a3096ad2b7 (diff)
downloadNetworkManager-96c099de09888ea614477b021673bb5c2e38c542.tar.gz
platform: suppress change event when deleting IPv4 route with metric 0
refresh_object() raised a spurious change event for the route we are about to delete. Suppress that by adding an internal reason flag. Fixes: 41e6c4fac1890e4302e4bfd1aa21be362cce51f2
-rw-r--r--src/platform/nm-linux-platform.c8
-rw-r--r--src/platform/nm-platform.h5
-rw-r--r--src/platform/tests/test-route.c4
3 files changed, 13 insertions, 4 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 50dfe16c78..48b5f8e16b 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -1668,6 +1668,9 @@ announce_object (NMPlatform *platform, const struct nl_object *object, NMPlatfor
{
NMPlatformIP4Route route;
+ if (reason == _NM_PLATFORM_REASON_CACHE_CHECK_INTERNAL)
+ return;
+
if (!_route_match ((struct rtnl_route *) object, AF_INET, 0, FALSE)) {
nm_log_dbg (LOGD_PLATFORM, "skip announce unmatching IP4 route %s", to_string_ip4_route ((struct rtnl_route *) object));
return;
@@ -1680,6 +1683,9 @@ announce_object (NMPlatform *platform, const struct nl_object *object, NMPlatfor
{
NMPlatformIP6Route route;
+ if (reason == _NM_PLATFORM_REASON_CACHE_CHECK_INTERNAL)
+ return;
+
if (!_route_match ((struct rtnl_route *) object, AF_INET6, 0, FALSE)) {
nm_log_dbg (LOGD_PLATFORM, "skip announce unmatching IP6 route %s", to_string_ip6_route ((struct rtnl_route *) object));
return;
@@ -3919,7 +3925,7 @@ ip4_route_delete (NMPlatform *platform, int ifindex, in_addr_t network, int plen
*
* Instead, re-fetch the route from kernel, and if that fails, there is nothing to do.
* On success, there is still a race that we might end up deleting the wrong route. */
- if (!refresh_object (platform, (struct nl_object *) route, FALSE, NM_PLATFORM_REASON_INTERNAL)) {
+ if (!refresh_object (platform, (struct nl_object *) route, FALSE, _NM_PLATFORM_REASON_CACHE_CHECK_INTERNAL)) {
rtnl_route_put ((struct rtnl_route *) route);
return TRUE;
}
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index 848f78e428..3f37ed6048 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -69,7 +69,10 @@ typedef enum {
/* Event came from the kernel. */
NM_PLATFORM_REASON_EXTERNAL,
/* Event is a result of cache checking and cleanups. */
- NM_PLATFORM_REASON_CACHE_CHECK
+ NM_PLATFORM_REASON_CACHE_CHECK,
+
+ /* Internal reason to suppress announcing change events */
+ _NM_PLATFORM_REASON_CACHE_CHECK_INTERNAL,
} NMPlatformReason;
#define __NMPlatformObject_COMMON \
diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c
index 69f5bc2e4f..fec1e38d26 100644
--- a/src/platform/tests/test-route.c
+++ b/src/platform/tests/test-route.c
@@ -55,7 +55,7 @@ test_ip4_route_metric0 (void)
{
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME);
SignalData *route_added = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_ADDED, ip4_route_callback);
- /*SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_route_callback);*/
+ SignalData *route_changed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_CHANGED, ip4_route_callback);
SignalData *route_removed = add_signal (NM_PLATFORM_SIGNAL_IP4_ROUTE_CHANGED, NM_PLATFORM_SIGNAL_REMOVED, ip4_route_callback);
in_addr_t network = nmtst_inet4_from_string ("192.0.2.5"); /* from 192.0.2.0/24 (TEST-NET-1) (rfc5737) */
int plen = 32;
@@ -115,7 +115,7 @@ test_ip4_route_metric0 (void)
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric);
free_signal (route_added);
- /*free_signal (route_changed);*/
+ free_signal (route_changed);
free_signal (route_removed);
}