Commit graph

30830 commits

Author SHA1 Message Date
Thomas Haller
a5cbd700d3
mptcp: merge branch 'th/mptcp-2'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1315
2022-08-09 08:06:11 +02:00
Thomas Haller
f64dff6939
all: drop various NMMptcpFlags
The default behavior might be sufficient. Drop those flags for now,
and figure out a good solution when we have an actual use-case.
2022-08-09 08:02:56 +02:00
Thomas Haller
eb083eece5
all: add NMMptcpFlags and connection.mptcp-flags property 2022-08-09 08:02:54 +02:00
Thomas Haller
5374c403d2
platfrom: handle MPTCP addresses with NMPGlobalTracker
When we configure MPTCP addresses, we usually do so per interface
(ifindex). That is, because each interface (via NMDevice and NML3Cfg)
decides how to configure MPTCP, and then we always add MTCP addresses
for this certain ifindex.

With that, we could have a purely interface-specific view and not a
global sync method. However, there are two problems:

The minor problem is that we don't cache the endpoints (because we don't
get notifications). We can only get a dump of all endpoints. It seems
odd to have a mptcp-addr-sync method that is per-ifindex, when it needs
to dump all addresses.

The much more important reason is that the number of endpoints that we
can configure in kernel is very limited. So we need to make a choice
which endpoints to configure, and for that we need to holistic view that
NMPGlobalTracker has.
2022-08-09 08:02:52 +02:00
Thomas Haller
ce635c4339
platform: add dump/update function for MPTCP addresses
Since the generic netlink API does (currently) not support notifications
about changes of the MPTCP addresses, we won't get notifications when
they change, and it seems wrong to put such things in the NMPlatform
cache.

We can just get the list of endpoints by polling, so add a function
nm_platform_mptcp_addrs_dump() for that.

Also, add nm_platform_mptcp_addr_update() which can add/remove/update
MPTCP addresses.
2022-08-09 08:02:50 +02:00
Thomas Haller
ec64559caa
platform: add hash functions for NMPlatformMptcpAddr instances
We already have two hash functions for MPTCP addresses:
nmp_object_id_hash*() which compares the identity of objects
and nm_platform_mptcp_addr_hash*(), which compares all fields.

There is also a need to hash only the address. Add it. Will be used
next.
2022-08-09 08:02:49 +02:00
Thomas Haller
3a8864a585
platform: delete conflicting route/rule during nmp_global_tracker_sync()
The ID of an object does not entail all properties/attributes.
During sync, if we already have an object with the same ID configured,
it may still differ in other aspects.

Handle those cases, by deleting such routes/rules before adding the
desired object.
2022-08-09 08:02:47 +02:00
Thomas Haller
370147cf9d
platform: drop unnecessary NMPlatformMptcpAddr.in_kernel flag
Since we don't get netlink notifications when the MPTCP endpoints
change, we don't cache them. And since we don't cache them,
there is less need to mark whether they were received from kernel
or created internally.
2022-08-09 08:02:46 +02:00
Thomas Haller
e1c18e9ed2
platform: adjust identity for MPTCP addr objects
It's not very clear what the best identity is.

For example, in kernel you cannot add two MPTCP addresses that only differ by
ifindex. Thus (as far as kernel is concerned), the ifindex is not part of the
identity. Still, as we will have an interface centric view, this will be
useful for us.

On the other hand, to kernel is the "id" a second primary key, along
side "addr:port". However, to us it's not useful to consider that as
part of nmp_object_id_equal(), because usually kernel will pick an "id"
for us, and when we track objects that we are about to add, they don't
have an "id" yet.

So, adjust nmp_object_id_equal(). However -- somewhat unusual -- let it
deviate from kernel's understanding of what defines an MPTCP address.
2022-08-09 08:02:45 +02:00
Thomas Haller
d92053fc6e
platform: fix nm_platform_mptcp_addr_cmp() to compare port
Fixes: 1a0c8772b0 ('platform: add NMPlatformMptcpAddr object')
2022-08-09 08:02:43 +02:00
Thomas Haller
8bdd416972
platform: use nlmsg_parse_error() in _netlink_recv_handle() 2022-08-09 08:02:42 +02:00
Thomas Haller
92fe4c383e
platform: use NLA_NEST_END() macro in _wireguard_create_change_nlmsgs() 2022-08-09 08:02:42 +02:00
Thomas Haller
413c1e3fa0
platform/netlink: add NLA_NEST_END() helper macro
It's upper case like NLA_PUT(), which also does a goto nla_put_failure;
on error. Otherwise, the upper case naming is a bit odd.
2022-08-09 08:02:41 +02:00
Thomas Haller
494b3d82c1
platform/netlink: add nlmsg_parse_error() helper 2022-08-09 08:02:40 +02:00
Thomas Haller
6e7d8f0335
platform/netlink: add nlmsg_undata() helper 2022-08-09 08:02:39 +02:00
Thomas Haller
c74c783c28
platform/netlink: make callback parameters to nl_recvmsg() const 2022-08-09 08:02:38 +02:00
Thomas Haller
6e5dae732a
nmcli: improve handling nicks for enum values
For enum type properties, we support to specify a list of
aliases.

- the getter uses a separate list from the setter. The idea
  is that some of these aliases are only for showing, but not
  for setting. Add a special marker GOBJECT_ENUM_VALUE_INFOS_GET_FROM_SETTER
  which indicates that the value information from the setter
  should also be used by the getter.

- extend _values_fcn_gobject_enum() to also return the nicks from
  the setter for bash completion. After all, they can be set too.
2022-08-09 08:02:38 +02:00
Thomas Haller
f4b128c63b
device: fix reapply for lldp/mdns/llmnr/dns-over-tls settings
When only one of those connection.{lldp,mdns,llmnr,dns-over-tls}
settings changes, we still need to do a full restart of the IP
configuration to reapply the changes.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
2022-08-09 08:02:37 +02:00
Thomas Haller
13d334cdbb
glib-aux,platform: add comments to nm_platform_ip_address_get_scope()/nm_utils_ip_is_site_local()
About site-local IPv6 addresses (unique local addresses, ULA).
2022-08-09 08:02:37 +02:00
Thomas Haller
8f67a80537
glib-aux: add nm_utils_ip6_is_ula() helper 2022-08-09 08:02:36 +02:00
Thomas Haller
e0fc8a11d5
glib-aux: add nm_g_hash_table_contains_any() helper 2022-08-09 08:02:36 +02:00
Thomas Haller
49ddb96d4e
std-aux: add nm_utils_addr_family_to_size_untrusted() helper 2022-08-09 08:02:36 +02:00
Thomas Haller
0a26320c09
contrib: update bash history in nm-in-container.sh 2022-08-08 20:45:18 +02:00
Thomas Haller
338672394f
platform: fix compilation for new bond options
CentOS 7's headers don't yet contains IFLA_BOND_PEER_NOTIF_DELAY.
Define it ourselves.

Fixes: f900f7bc2c ('platform: add netlink support for bond link')
2022-08-08 14:27:21 +02:00
Thomas Haller
3e47d370af
contrib: merge branch 'th/in-container-inplace'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1326
2022-08-08 11:55:32 +02:00
Thomas Haller
341c46de84
contrib: improve motd for nm-in-container.sh script
Leave a hint about core-dumps.

Also, now we have `contrib/fedora/rpm/configure-for-system.sh` script,
which can configure the build in a way similar to what we get
when doing an RPM build.

That means, inside "contrib/scripts/nm-in-container.sh" we
can just type `make install`, and it will replace the pre-installed
NetworkManager.

The main advantage is that it becomes convenient to run NetworkManager
as a systemd service. Previously, the suggested was to to install
NetworkManager inside another prefix, and run it in the terminal.

Running NetworkManager as systemd service is also necessary for NM-ci,
which restarts the NetworkManager service, and you couldn't run a test,
if you just started NetworkManager in a terminal.

Previously, you had to build a complete RPM, which takes a lot of time.
2022-08-08 11:54:27 +02:00
Thomas Haller
d966c2ac4c
contrib: install "qt-devel" in nm-in-container.sh script
Yes, it's a large dependency. But on your outer host you
probably configured NetworkManager with QT enabled (for the
example scripts). We want to compile the same work tree inside
the container. So install qt-devel.
2022-08-08 11:54:27 +02:00
Thomas Haller
f2bd67b386
contrib/rpm: add "configure-for-system.sh" script to configure build
This will use the same option as when we do an RPM build.
The purpose is that you could type `make install` with such
a build, and it would replace the files that you'd get by installing
the NetworkManager RPMs.

Of course, you would not want to do that on your work station, but it
will be useful in a container, where we don't mind messing up the
installation.
2022-08-08 11:54:27 +02:00
Thomas Haller
4e4135842e
contrib/rpm: cleanup spec file to unify version comparisons
- always check fedora||rhel and not rhel||fedora.
- consistently use >= instead of >.
2022-08-08 11:54:27 +02:00
Thomas Haller
1e6e15cd80
contrib/rpm: prefer --with-$OPTION=yes|no over --with/--without and --enable/--disable
autotools accepts both --with-$OPTION/--without-$OPTION and
--with-$OPTION=yes|no. Consistently use the latter.

The advantage is that whether it's enabled becomes an argument, so in a
script you could do

  "--with-$OPTION=$VALUE"

Same for enable/disable option.
2022-08-08 11:54:27 +02:00
Thomas Haller
8efc0319ce
build/meson: force overwriting files in "meson-post-install.sh"
Repeated `ninja -C build install` should succeed. But they did not:

  Running custom install script '/data/src/NetworkManager/tools/meson-post-install.sh /usr/share /usr/bin /etc/NetworkManager /usr/lib/NetworkManager /var/lib/NetworkManager /usr/share/man /etc 1 1 1 1'
  --- stdout ---

  --- stderr ---
  ln: failed to create symbolic link '/usr/lib/NetworkManager/dispatcher.d/90-nm-cloud-setup.sh': File exists
2022-08-08 11:54:26 +02:00
Thomas Haller
c14e61ac96
build: wrap lines in Makefile.am for "vapi/libnm.vapi" 2022-08-08 09:30:53 +02:00
Lubomir Rintel
5cf96c4db2
bridge: fix reapply of vlan_filtering and default_pvid
Fixes: 8e8fed433f ('bridge: add reapply support')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1327
2022-08-06 21:08:51 +02:00
Thomas Haller
cf141f3e7a
glib-aux: merge branch 'th/random-utils'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1323
2022-08-05 19:36:23 +02:00
Thomas Haller
67a5cf7675
core: block to get good random bytes for "/var/lib/NetworkManager/secret_key"
_host_id_read() is the only place where we really care to have good
random numbers, because that is the secret key that we persist to disk.

Previously, we tried only nm_random_get_bytes_full(), which is a best
effort to get strong random numbers. If it fails to generate those,
it would simply remember the generated key in memory and proceed, but not
persist it to disk.

nm_random_get_bytes_full() does not block waiting for good numbers.

Change that. Now, first call nm_random_get_crypto_bytes(), which would
block and try hard to get good random numbers. Only if that fails,
fallback to nm_random_get_bytes_full() as before. The difference is of
course only in early boot, when we might not yet have entropy. In that
case, I think it's better for NetworkManager to block.
2022-08-05 19:29:35 +02:00
Thomas Haller
d20343c9d0
glib-aux: rework random number utils
Heavily inspired by systemd ([1]).

We now also have nm_random_get_bytes{,_full}() and
nm_random_get_crypto_bytes(), like systemd's random_bytes()
and crypto_random_bytes(), respectively.

Differences:

- instead of systemd's random_bytes(), our nm_random_get_bytes_full()
  also estimates whether the output is of high quality. The caller
  may find that interesting. Due to that, we will first try to call
  getrandom(GRND_NONBLOCK) before getrandom(GRND_INSECURE). That is
  reversed from systemd's random_bytes(), because we want to find
  out whether we can get good random numbers. In most cases, kernel
  should have entropy already, and it makes no difference.

Otherwise, heavily rework the code. It should be easy to understand
and correct.

There is also a major bugfix here. Previously, if getrandom() failed
with ENOSYS and we fell back to /dev/urandom, we would assume that we
have high quality random numbers. That assumption is not warranted.
Now instead poll on /dev/random to find out.

[1] a268e7f402/src/basic/random-util.c (L81)
2022-08-05 19:29:34 +02:00
Thomas Haller
e80fc43f2a
glib-aux: add assertions to nm_utils_fd_wait_for_event() 2022-08-05 16:10:39 +02:00
Thomas Haller
d5b31a05e6
glib-aux: add nm_str_buf_append_printfv()
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1321
2022-08-05 16:07:46 +02:00
Fernando Fernandez Mancera
fba856f204 merge: branch 'ff/bond_netlink'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1227
2022-08-04 12:05:52 +02:00
Fernando Fernandez Mancera
e064eb9d13 bond: use netlink to set bond options
Use the netlink platform implementation for setting the bond link
options.
2022-08-04 11:18:36 +02:00
Fernando Fernandez Mancera
32870d8233 libnm-utils: convert string bond opts to int
NMPlatform code for bond netlink support will use the numeric values,
therefore we need functions to convert all the string values to int.
2022-08-04 11:18:36 +02:00
Fernando Fernandez Mancera
f900f7bc2c platform: add netlink support for bond link
sysfs is deprecated and kernel people will not add new bond options to
sysfs. Netlink is a stable API and therefore is the right method to
communicate with kernel in order to set the link options.
2022-08-04 11:18:36 +02:00
Fernando Fernandez Mancera
cd31559ded utils: introduce nm_ether_addr_from_string() helper 2022-08-04 11:18:36 +02:00
Thomas Haller
483d287590
glib-aux: use unsigned long literals in NM_HASH_COMBINE_BOOLS() macro
To avoid the ambiguity for which integer type is used.
2022-08-04 11:05:33 +02:00
Thomas Haller
77af18c67b
platform/netlink: cleanup NLA_PUT() macro
Add parentheses around macro arguments.

Yes, it's not technically necessary when using macro arguments are
surrounded by commas. Still do it, for consistency and for not having
special exceptions to the rule.
2022-08-04 10:39:25 +02:00
Georg Müller
1d614dbded
crypto: support EC private keys
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1324
2022-08-04 09:46:06 +02:00
avery
ebdf3bd376
nmcli-completion: fix support for embedded quote characters
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/455

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1325

Fixes: 9d2290135c ('cli: make nmcli do its own command completion')
2022-08-04 08:59:01 +02:00
Lubomir Rintel
3ce3451040 Revert "contrib/rpm: enable -Werror on --with debug instead of --with test"
This reverts commit cac11c736d.
It went in accidentally.
2022-08-02 18:03:45 +02:00
Lubomir Rintel
5b7f8f3f70 device: wait for carrier even if it wasn't us who brought the device IFF_UP
The devices generally need to be IFF_UP and wait a little before the
carrier detection is reliable. Some devices, actually need to wait
more than a little -- r8169 needs up to 5 seconds.

For this reason, we delay startup complete while the carrier is down
after we bring the device up. We do this so that we don't reject
activations due to carrier down until we're sure it's really down.
This works well as long as it's us who brought the device up.

If we're restarting the daemon, the device is going to be already up
when we start up the daemon for the second time. There's, however, a
slim chance that the device was brought down and up very shortly before
the restart and therefore the carrier reporting is still not reliable.
As a matter of fact, we bring the devices down and back up on some
occassions, such as when enslaving to a team device.

Therefore, the following events in quick succession cause trouble:

  # nmcli con up team-slave-eth0
  [20099.205355] Generic FE-GE Realtek PHY r8169-0-300:00: attached PHY driver (mii_bus:phy_addr=r8169-0-300:00, irq=MAC)
  [20099.365641] nm-team: Port device eth0 added
  [20099.370728] r8169 0000:03:00.0 eth0: Link is Down
  [20099.436631] nm-team: Port device eth0 removed
  [20099.463422] Generic FE-GE Realtek PHY r8169-0-300:00: attached PHY driver (mii_bus:phy_addr=r8169-0-300:00, irq=MAC)
  [20099.628505] r8169 0000:03:00.0 eth0: Link is Down
  [20099.669425] Generic FE-GE Realtek PHY r8169-0-300:00: attached PHY driver (mii_bus:phy_addr=r8169-0-300:00, irq=MAC)
  [20099.833457] r8169 0000:03:00.0 eth0: Link is Down
  [20099.838471] nm-team: Port device eth0 added

The device has been brought down, enslaved and brought up.
"Link is Down" indicates carrier not being detected.

  Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
  # systemctl restart NetworkManager

Now NM sees the device being up, but carrier down.

  # nmcli con up testeth0
  Error: Connection activation failed: No suitable device found for this connection (...).

Activation failed, because eth0 carrier still appears down.

  # [20102.943464] r8169 0000:03:00.0 eth0: Link is Up - 1Gbps/Full - flow control rx/tx

Now it's up, but the party is already over. Shiet.

Let's wait whenever the device reaches unavailable state, whether we
bring it up at that point or not.

Fixes-test: @restart_L2_only_lacp

https://bugzilla.redhat.com/show_bug.cgi?id=2092361
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1316
2022-08-02 15:06:35 +02:00
Lubomir Rintel
cac11c736d contrib/rpm: enable -Werror on --with debug instead of --with test
The test bcond is used to make test suite failure terminate the %check
phase. That should generally be done for distro builds.

What the distro builds shouldn't do is terminate the build on compiler
warnings, because they're fairly likely to appear on toolchain updates
without indicating actual bugs.

However, currently that's precisely what do we do now.

Let's use -Werror on debug builds instead. They are intentionally made
more prone to fail (e.g. trip more runtime assertions) because failures
can be more rapidly addressed and don't affect distro builds.
2022-08-02 15:06:13 +02:00