summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2023-01-03 20:19:12 +0100
committerThomas Haller <thaller@redhat.com>2023-01-19 08:56:21 +0100
commit4ec2123aa22ca7bb960b05dbd082f2472b19becb (patch)
treeca533501ede9db3c177c4b731eec42da34457cce
parent854f2cc1fcd63162029c8ae2907e560ced90bcab (diff)
platform: parse routes of any type to handle replace
When you issue ip route replace broadcast 1.2.3.4/32 dev eth0 then this route may well replace a (unicast) route that we have in the cache. Previously, we would right away ignore such messages in _new_from_nl_route(), which means we miss the fact that a route gets replaced. Instead, we need to parse the message at least so far, that we can detect and handle the replace.
-rw-r--r--src/libnm-platform/nm-linux-platform.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c
index aea08e54f7..067eaf5463 100644
--- a/src/libnm-platform/nm-linux-platform.c
+++ b/src/libnm-platform/nm-linux-platform.c
@@ -3787,15 +3787,6 @@ _new_from_nl_route(const struct nlmsghdr *nlh, gboolean id_only, ParseNlmsgIter
else
return NULL;
- if (!NM_IN_SET(rtm->rtm_type,
- RTN_UNICAST,
- RTN_LOCAL,
- RTN_BLACKHOLE,
- RTN_UNREACHABLE,
- RTN_PROHIBIT,
- RTN_THROW))
- return NULL;
-
if (nlmsg_parse_arr(nlh, sizeof(struct rtmsg), tb, policy) < 0)
return NULL;
@@ -5331,6 +5322,17 @@ ip_route_is_alive(const NMPlatformIPRoute *route)
return FALSE;
}
+ if (!NM_IN_SET(nm_platform_route_type_uncoerce(route->type_coerced),
+ RTN_UNICAST,
+ RTN_LOCAL,
+ RTN_BLACKHOLE,
+ RTN_UNREACHABLE,
+ RTN_PROHIBIT,
+ RTN_THROW)) {
+ /* Certain route types are ignored and not placed into the cache. */
+ return FALSE;
+ }
+
return TRUE;
}