NetworkManager/shared/nm-utils
Thomas Haller cdd8c65799 platform: fix cache to use kernel's notion for equality of routes
Until now, NetworkManager's platform cache for routes used the quadruple
network/plen,metric,ifindex for equaliy. That is not kernel's
understanding of how routes behave. For example, with `ip route append`
you can add two IPv4 routes that only differ by their gateway. To
the previous form of platform cache, these two routes would wrongly
look identical, as the cache could not contain both routes. This also
easily leads to cache-inconsistencies.

Now that we have NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID, fix the route's
compare operator to match kernel's.

Well, not entirely. Kernel understands more properties for routes then
NetworkManager. Some of these properties may also be part of the ID according
to kernel. To NetworkManager such routes would still look identical as
they only differ in a property that is not understood. This can still
cause cache-inconsistencies. The only fix here is to add support for
all these properties in NetworkManager as well. However, it's less serious,
because with this commit we support several of the more important properties.
See also the related bug rh#1337855 for kernel.

Another difficulty is that `ip route replace` and `ip route change`
changes an existing route. The replaced route has the same
NM_PLATFORM_IP_ROUTE_CMP_TYPE_WEAK_ID, but differ in the actual
NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID:

    # ip -d -4 route show dev v
    # ip monitor route &
    # ip route add 192.168.5.0/24 dev v
    192.168.5.0/24 dev v scope link
    # ip route change 192.168.5.0/24 dev v scope 10
    192.168.5.0/24 dev v scope 10
    # ip -d -4 route show dev v
    unicast 192.168.5.0/24 proto boot scope 10

Note that we only got one RTM_NEWROUTE message, although from NMPCache's
point of view, a new route (with a particular ID) was added and another
route (with a different ID) was deleted. The cumbersome workaround is,
to keep an ordered list of the routes, and figure out which route was
replaced in response to an RTM_NEWROUTE. In absence of bugs, this should
work fine. However, as we only rely on events, we might wrongly
introduce a cache-inconsistancy as well. See the related bug rh#1337860.

Also drop nm_platform_ip4_route_get() and the like. The ID of routes
is complex, so it makes little sense to look up a route directly.
2017-08-12 16:04:28 +02:00
..
c-list-util.c c-list: add c_list_sort() 2017-07-25 06:42:14 +02:00
c-list-util.h c-list: add c_list_sort() 2017-07-25 06:42:14 +02:00
c-list.h shared: update c-list 2017-07-05 14:22:10 +02:00
gsystem-local-alloc.h shared: move shared files to subdirectory "shared/nm-utils/" 2016-06-16 10:45:53 +02:00
nm-dedup-multi.c shared: add nm_dedup_multi_entry_reorder() function 2017-08-12 16:02:11 +02:00
nm-dedup-multi.h platform: fix cache to use kernel's notion for equality of routes 2017-08-12 16:04:28 +02:00
nm-enum-utils.c shared: cast from/to argument to unsigned for GFlags in _nm_utils_enum_get_values() 2017-04-27 18:01:58 +02:00
nm-enum-utils.h libnm: move public nm_utils_enum_*() functions back to libnm-core 2017-04-05 18:38:31 +02:00
nm-glib.h all: use "static inline" keywords instead of "inline static" 2017-02-23 15:28:27 +01:00
nm-macros-internal.h platform: refactor NMPObject cast macros using _Generic() 2017-07-05 22:17:42 +02:00
nm-obj.h all: add base object type in "nm-obj.h" 2017-07-05 14:22:10 +02:00
nm-shared-utils.c shared: add nm_utils_str_utf8safe_*() API to sanitize UTF-8 strings 2017-05-19 09:46:08 +02:00
nm-shared-utils.h shared: cleanup NM_CMP_*() macros 2017-07-31 15:13:31 +02:00
nm-test-utils.h test: redirect glib logging to stdout 2017-08-12 16:02:11 +02:00
nm-udev-utils.c libnm: don't cunescape \x00 encoding in nm_udev_utils_property_decode() 2017-05-19 09:46:08 +02:00
nm-udev-utils.h udev: add and use nm_udev_utils_property_decode() function 2017-03-22 12:41:06 +01:00
nm-vpn-editor-plugin-call.h shared: include "gsystem-local-alloc.h" from "nm-glib.h" 2016-06-16 10:45:54 +02:00
nm-vpn-plugin-macros.h shared: add nm_utils_syslog_coerce_from_nm() util 2016-09-19 15:35:33 +02:00
nm-vpn-plugin-utils.c shared: add "nm-utils/nm-vpn-plugin-utils.h" 2016-06-16 10:45:54 +02:00
nm-vpn-plugin-utils.h shared: add "nm-utils/nm-vpn-plugin-utils.h" 2016-06-16 10:45:54 +02:00
unaligned.h shared: add unaligned.h 2016-10-14 11:16:13 +02:00