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: 41e6c4fac1
This commit is contained in:
Thomas Haller
2015-01-11 17:42:46 +01:00
parent 4f390e7e4d
commit 96c099de09
3 changed files with 13 additions and 4 deletions

View File

@@ -1668,6 +1668,9 @@ announce_object (NMPlatform *platform, const struct nl_object *object, NMPlatfor
{ {
NMPlatformIP4Route route; NMPlatformIP4Route route;
if (reason == _NM_PLATFORM_REASON_CACHE_CHECK_INTERNAL)
return;
if (!_route_match ((struct rtnl_route *) object, AF_INET, 0, FALSE)) { 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)); nm_log_dbg (LOGD_PLATFORM, "skip announce unmatching IP4 route %s", to_string_ip4_route ((struct rtnl_route *) object));
return; return;
@@ -1680,6 +1683,9 @@ announce_object (NMPlatform *platform, const struct nl_object *object, NMPlatfor
{ {
NMPlatformIP6Route route; NMPlatformIP6Route route;
if (reason == _NM_PLATFORM_REASON_CACHE_CHECK_INTERNAL)
return;
if (!_route_match ((struct rtnl_route *) object, AF_INET6, 0, FALSE)) { 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)); nm_log_dbg (LOGD_PLATFORM, "skip announce unmatching IP6 route %s", to_string_ip6_route ((struct rtnl_route *) object));
return; 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. * 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. */ * 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); rtnl_route_put ((struct rtnl_route *) route);
return TRUE; return TRUE;
} }

View File

@@ -69,7 +69,10 @@ typedef enum {
/* Event came from the kernel. */ /* Event came from the kernel. */
NM_PLATFORM_REASON_EXTERNAL, NM_PLATFORM_REASON_EXTERNAL,
/* Event is a result of cache checking and cleanups. */ /* 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; } NMPlatformReason;
#define __NMPlatformObject_COMMON \ #define __NMPlatformObject_COMMON \

View File

@@ -55,7 +55,7 @@ test_ip4_route_metric0 (void)
{ {
int ifindex = nm_platform_link_get_ifindex (DEVICE_NAME); 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_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); 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) */ 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; int plen = 32;
@@ -115,7 +115,7 @@ test_ip4_route_metric0 (void)
assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric); assert_ip4_route_exists (FALSE, DEVICE_NAME, network, plen, metric);
free_signal (route_added); free_signal (route_added);
/*free_signal (route_changed);*/ free_signal (route_changed);
free_signal (route_removed); free_signal (route_removed);
} }