Commit 96c099de authored by Thomas Haller's avatar Thomas Haller

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: 41e6c4fa
parent 4f390e7e
......@@ -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;
}
......
......@@ -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 \
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment