Find a file
Thomas Haller dac12a8d61
platform: support IPv6 mulitpath routes and fix cache inconsistency
Add support for IPv6 multipath routes, by treating them as single-hop
routes. Otherwise, we can easily end up with an inconsistent platform
cache.

Background:
-----------

Routes are hard. We have NMPlatform which is a cache of netlink objects.
That means, we have a hash table and we cache objects based on some
identity (nmp_object_id_equal()). So those objects must have some immutable,
indistinguishable properties that determine whether an object is the
same or a different one.

For routes and routing rules, this identifying property is basically a subset
of the attributes (but not all!). That makes it very hard, because tomorrow
kernel could add an attribute that becomes part of the identity, and NetworkManager
wouldn't recognize it, resulting in cache inconsistency by wrongly
thinking two different routes are one and the same. Anyway.

The other point is that we rely on netlink events to maintain the cache.
So when we receive a RTM_NEWROUTE we add the object to the cache, and
delete it upon RTM_DELROUTE. When you do `ip route replace`, kernel
might replace a (different!) route, but only send one RTM_NEWROUTE message.
We handle that by somehow finding the route that was replaced/deleted. It's
ugly. Did I say, that routes are hard?

Also, for IPv4 routes, multipath attributes are just a part of the
routes identity. That is, you add two different routes that only differ
by their multipath list, and then kernel does as you would expect.
NetworkManager does not support IPv4 multihop routes and just ignores
them.
Also, a multipath route can have next hops on different interfaces,
which goes against our current assumption, that an NMPlatformIP4Route
has an interface (or no interface, in case of blackhole routes). That
makes it hard to meaningfully support IPv4 routes. But we probably don't
have to, because we can just pretend that such routes don't exist and
our cache stays consistent (at least, until somebody calls `ip route
replace` *sigh*).

Not so for IPv6. When you add (`ip route append`) an IPv6 route that is
identical to an existing route -- except their multipath attribute -- then it
behaves as if the existing route was modified and the result is the
merged route with more next-hops. Note that in this case kernel will
only send a RTM_NEWROUTE message with the full multipath list. If we
would treat the multipath list as part of the route's identity, this
would be as if kernel deleted one routes and created a different one (the
merged one), but only sending one notification. That's a bit similar to
what happens during `ip route replace`, but it would be nightmare to
find out which route was thereby replaced.
Likewise, when you delete a route, then kernel will "subtract" the
next-hop and sent a RTM_DELROUTE notification only about the next-hop that
was deleted. To handle that, you would have to find the full multihop
route, and replace it with the remainder after the subtraction.

NetworkManager so far ignored IPv6 routes with more than one next-hop, this
means you can start with one single-hop route (that NetworkManger sees
and has in the platform cache). Then you create a similar route (only
differing by the next-hop). Kernel will merge the routes, but not notify
NetworkManager that the single-hop route is not longer a single-hop
route. This can easily cause a cache inconsistency and subtle bugs. For
IPv6 we MUST handle multihop routes.

Kernels behavior makes little sense, if you expect that routes have an
immutable identity and want to get notifications about addition/removal.
We can however make sense by it by pretending that all IPv6 routes are
single-hop! With only the twist that a single RTM_NEWROUTE notification
might notify about multiple routes at the same time. This is what the
patch does.

The Patch
---------

Now one RTM_NEWROUTE message can contain multiple IPv6 routes
(NMPObject). That would mean that nmp_object_new_from_nl() needs to
return a list of objects. But it's not implemented that way. Instead,
we still call nmp_object_new_from_nl(), and the parsing code can
indicate that there is something more, indicating the caller to call
nmp_object_new_from_nl() again in a loop to fetch more objects.

In practice, I think all RTM_DELROUTE messages for IPv6 routes are
single-hop. Still, we implement it to handle also multi-hop messages the
same way.

Note that we just parse the netlink message again from scratch. The alternative
would be to parse the first object once, and then clone the object and
only update the next-hop. That would be more efficient, but probably
harder to understand/implement.

https://bugzilla.redhat.com/show_bug.cgi?id=1837254#c20
2022-02-16 09:59:49 +01:00
.gitlab-ci gitlab-ci: disable CentOS 8 Linux containers 2022-02-14 17:15:20 +01:00
contrib priv-helper: fix D-Bus patch to not contain forbidden character '-' 2022-02-09 18:47:14 +01:00
data priv-helper: remove D-Bus Alias for "nm-priv-helper.service" 2022-02-09 18:47:14 +01:00
docs docs: update URL for latest online documentation 2021-09-24 14:41:35 +02:00
examples examples/python: avoid Python2 "print" statement 2022-02-14 17:02:34 +01:00
introspection core: introduce device::ports property 2021-10-11 09:35:10 +02:00
m4 build: rework libreadline detection in autotools 2021-07-19 09:08:06 +02:00
man man: mention "rd.znet_ifnames" option in man nm-initrd-generator 2022-01-26 23:00:14 +01:00
po po: remove ar.po translations 2022-02-15 09:45:36 +01:00
src platform: support IPv6 mulitpath routes and fix cache inconsistency 2022-02-16 09:59:49 +01:00
tools tools: fix constructing XML by dropping broken pretty_xml() 2022-02-09 20:26:34 +01:00
vapi vapi: Update NM-1.0.metadata to include WireGuard declarations 2021-06-04 10:03:13 +02:00
.clang-format clang-format: mark FOR_EACH_DELAYED_ACTION() as a ForEachMacro 2022-01-13 15:25:17 +01:00
.dir-locals.el misc: add toplevel .dir-locals file that tells Emacs to show trailing whitespace 2013-03-08 15:15:28 +01:00
.git-blame-ignore-revs format: add ".git-blame-ignore-revs" and hint how to ignore the commit during git-blame 2020-10-27 16:00:45 +01:00
.gitignore priv-helper: fix D-Bus patch to not contain forbidden character '-' 2022-02-09 18:47:14 +01:00
.gitlab-ci.yml gitlab-ci: disable CentOS 8 Linux containers 2022-02-14 17:15:20 +01:00
.lgtm.yml lgtm.com: add configuration file for building on lgtm.com 2021-05-26 19:25:42 +02:00
.mailmap mailmap: update to add Ana 2021-07-08 22:57:45 +02:00
.triage-policies.yml gitlab-ci: use ruby:2.7 for triage pipeline 2020-03-18 17:40:59 +01:00
AUTHORS misc: update maintainers and authors 2016-04-21 13:39:03 -05:00
autogen.sh all: move "src/" directory to "src/core/" 2021-02-04 09:45:55 +01:00
ChangeLog Changelog: update references to "main" branch 2021-04-01 22:30:20 +02:00
config-extra.h.meson build: remove duplicate and unused RUNDIR define 2019-05-17 21:24:18 +02:00
config-extra.h.mk build: regenerate config-extra.h if configure was re-run with different arguments 2019-09-25 15:55:37 +02:00
config.h.meson build: allow configuring default for wifi.backend setting 2022-01-04 06:41:37 +01:00
configure.ac release: bump version to 1.37.0 (development) 2022-02-04 18:24:18 +01:00
CONTRIBUTING.md CONTRIBUTING: document style guide about naming in header files 2022-01-20 08:14:48 +01:00
COPYING COPYING: make sure we ship the relevant license texts 2019-09-10 11:10:52 +02:00
COPYING.GFDL COPYING: make sure we ship the relevant license texts 2019-09-10 11:10:52 +02:00
COPYING.LGPL COPYING: make sure we ship the relevant license texts 2019-09-10 11:10:52 +02:00
linker-script-binary.ver iface-helper/build: add linker version script 2016-10-13 21:33:33 +02:00
linker-script-devices.ver devices/build: use one linker-script-devices.ver for all device plugins 2016-10-13 21:36:06 +02:00
linker-script-settings.ver settings/build: add linker version script for settings plugins 2016-10-13 21:33:33 +02:00
lsan.suppressions tests/sanitizer: suppress leak in openssl 2020-05-14 12:03:24 +02:00
MAINTAINERS misc: update maintainers and authors 2016-04-21 13:39:03 -05:00
MAINTAINERS.md MAINTAINERS: add backports section 2021-10-14 15:40:20 +02:00
Makefile.am platform: rename "nmp-route-manager.h" to "nmp-rules-manager.h" 2022-02-09 19:13:03 +01:00
Makefile.examples examples: add "examples/python/gi/nm-up-many.py" 2021-06-11 22:48:41 +02:00
Makefile.glib all: drop emacs file variables from source files 2019-06-11 10:04:00 +02:00
Makefile.vapigen build: fix make always re-making vapigen target 2016-10-21 18:46:03 +02:00
meson.build release: bump version to 1.37.0 (development) 2022-02-04 18:24:18 +01:00
meson_options.txt build: allow configuring default for wifi.backend setting 2022-01-04 06:41:37 +01:00
NEWS NEWS: update for 1.36-rc2 2022-02-10 12:29:52 +01:00
README all: drop empty first line from sources 2019-06-11 10:15:06 +02:00
RELICENSE.md license: add Daniel to RELICENSE.md 2020-09-24 09:35:00 +02:00
TODO platform: support IPv6 mulitpath routes and fix cache inconsistency 2022-02-16 09:59:49 +01:00
valgrind.suppressions all: goodbye libnm-glib 2019-04-16 15:52:27 +02:00

******************
NetworkManager core daemon has moved to gitlab.freedesktop.org!

git clone https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
******************


Networking that Just Works
--------------------------

NetworkManager attempts to keep an active network connection available at all
times.  The point of NetworkManager is to make networking configuration and
setup as painless and automatic as possible.  NetworkManager is intended to
replace default route, replace other routes, set IP addresses, and in general
configure networking as NM sees fit (with the possibility of manual override as
necessary).  In effect, the goal of NetworkManager is to make networking Just
Work with a minimum of user hassle, but still allow customization and a high
level of manual network control.  If you have special needs, we'd like to hear
about them, but understand that NetworkManager is not intended for every
use-case.

NetworkManager will attempt to keep every network device in the system up and
active, as long as the device is available for use (has a cable plugged in,
the killswitch isn't turned on, etc).  Network connections can be set to
'autoconnect', meaning that NetworkManager will make that connection active
whenever it and the hardware is available.

"Settings services" store lists of user- or administrator-defined "connections",
which contain all the settings and parameters required to connect to a specific
network.  NetworkManager will _never_ activate a connection that is not in this
list, or that the user has not directed NetworkManager to connect to.


How it works:

The NetworkManager daemon runs as a privileged service (since it must access
and control hardware), but provides a D-Bus interface on the system bus to
allow for fine-grained control of networking.  NetworkManager does not store
connections or settings, it is only the mechanism by which those connections
are selected and activated.

To store pre-defined network connections, two separate services, the "system
settings service" and the "user settings service" store connection information
and provide these to NetworkManager, also via D-Bus.  Each settings service
can determine how and where it persistently stores the connection information;
for example, the GNOME applet stores its configuration in GConf, and the system
settings service stores its config in distro-specific formats, or in a distro-
agnostic format, depending on user/administrator preference.

A variety of other system services are used by NetworkManager to provide
network functionality: wpa_supplicant for wireless connections and 802.1x
wired connections, pppd for PPP and mobile broadband connections, DHCP clients
for dynamic IP addressing, dnsmasq for proxy nameserver and DHCP server
functionality for internet connection sharing, and avahi-autoipd for IPv4
link-local addresses.  Most communication with these daemons occurs, again,
via D-Bus.


Why doesn't my network Just Work?

Driver problems are the #1 cause of why NetworkManager sometimes fails to
connect to wireless networks.  Often, the driver simply doesn't behave in a
consistent manner, or is just plain buggy.  NetworkManager supports _only_
those drivers that are shipped with the upstream Linux kernel, because only
those drivers can be easily fixed and debugged.  ndiswrapper, vendor binary
drivers, or other out-of-tree drivers may or may not work well with
NetworkManager, precisely because they have not been vetted and improved by the
open-source community, and because problems in these drivers usually cannot
be fixed.

Sometimes, command-line tools like 'iwconfig' will work, but NetworkManager will
fail.  This is again often due to buggy drivers, because these drivers simply
aren't expecting the dynamic requests that NetworkManager and wpa_supplicant
make.  Driver bugs should be filed in the bug tracker of the distribution being
run, since often distributions customize their kernel and drivers.

Sometimes, it really is NetworkManager's fault.  If you think that's
the case, please file a bug at:

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues

Attaching NetworkManager debug logs from the journal (or wherever your
distribution directs syslog's 'daemon' facility output, as
/var/log/messages or /var/log/daemon.log) is often very helpful, and
(if you can get) a working wpa_supplicant config file helps
enormously.  See the logging section of file
contrib/fedora/rpm/NetworkManager.conf for how to enable debug logging
in NetworkManager.