Commit graph

27544 commits

Author SHA1 Message Date
Tom Stellard
d19a13e4b1
contrib/rpm: use make macros
https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro

https://src.fedoraproject.org/rpms/NetworkManager/pull-request/4

8f93680134
2021-01-15 17:25:19 +01:00
Thomas Haller
fef16c3f54
all: merge branch 'th/shared-nm-platform'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/716
2021-01-15 12:23:48 +01:00
Thomas Haller
a288de4b3d
shared: add "shared/README.md" 2021-01-15 12:17:15 +01:00
Thomas Haller
9901aeef2c
platform: move "nm-platform-utils.[hc]" to "shared/nm-platform" library
By now it has no further dependencies on libnm-core or NetworkManager core.
Make it part of "shared/nm-platform" library.
2021-01-15 11:32:53 +01:00
Thomas Haller
c0bc296a51
platform: use NMOptionBool instead of NMTernary
NMTernary is a dependency for libnm-core. Avoid it.
2021-01-15 11:32:49 +01:00
Thomas Haller
0dc5ea2412
shared: add NMOptionBool as alternative to NMTernary
NMTernary is part of libnm's public API. It thus cannot be used by code
without libnm/libnm-core dependency.

Add another enum with the same purpose.

The name "NMTernary" is already taken, and we should not use some macro
trickery to use (effectively) different types under the same name.
Another possible name would be "NMTern", but for no strong reasons
we choose NMOptionBool. The naming reminds of rust's std::option::Option.
2021-01-15 11:32:46 +01:00
Thomas Haller
d2464c260f
core: move NMIPConfigSource from "src/nm-types.h" to "shared/nm-base" 2021-01-15 11:32:43 +01:00
Thomas Haller
874bd8994e
libnm,shared: move nm-ethtool helper to "libnm-base"
We want to use this by "shared/nm-platform", which should have
no dependency on "libnm-core".

Move "libnm-core/nm-ethtool-utils.h" to "libnm/nm-ethtool-utils.h" so
that it is only used by libnm. This file contains the defines for
the option names.

Also, symlink "libnm/nm-ethtool-utils.h" as "shared/nm-base/nm-ethtool-utils-base.h".
We want to use the same defines also internally. Since they are both
public API (must be in libnm) and should be in "shared/nm-base", this
is the way.
2021-01-15 11:32:41 +01:00
Thomas Haller
19242f56d7
libnm: split ethtool option names to a new header "libnm-core/nm-ethtool-utils.h"
We want to use these defines for option names also in "shared/nm-base"
(and in turn in "shared/nm-platform), which cannot include "libnm-core".

However, they are also public API of libnm.

To get this done, in a first step, move these defines to a new header
"libnm-core/nm-ethtool-utils.h".

Since now the name "nm-ethtool-utils.h" is taken, also rename
nm-libnm-core-intern files.
2021-01-15 11:32:39 +01:00
Thomas Haller
9a5a95e0fa
platform: remove unnecessary includes from "nm-platform-utils.c" 2021-01-15 11:32:38 +01:00
Thomas Haller
90881953ed
platform: move nm_platform_link_duplex_type_to_string() to "nm-platform-utils.c"
There should be a clear hierarchie of dependency. That is,
"nm-platform.h" may use "nm-platform-utils.h", but not the
other way around.

Move nm_platform_link_duplex_type_to_string().
2021-01-15 11:32:36 +01:00
Thomas Haller
84d67d3a4f
shared: add duplicate for NM_UTILS_HWADDR_LEN_MAX to "nm-base/nm-base.h"
We will need this in "shared/nm-platform", but we don't want
to include "libnm-core/nm-utils.h" for that.
2021-01-15 11:32:35 +01:00
Thomas Haller
126681a965
platform: move types from "nm-platform-utils.h" to nmp-base.h"
Thereby, also no longer include "nm-platform.h" and "nm-setting-wired.h"
in "nm-platform-utils.h".
2021-01-15 11:32:34 +01:00
Thomas Haller
2bb5c8b13b
platform: add duplicate of NMSettingWiredWakeOnLan to nm-base for platform
Currently src/platform depends on libnm-core. libnm-core is large
optimally we have a better separation between our code. That means
libnm-core does not depend on platform and vice versa.

However, nm-platform re-uses some enums from libnm-core for internal code.
To avoid that dependency, add _NMSettingWiredWakeOnLan as a duplicate to
nm-base/nm-base.h. nm-base can both be used by libnm-core, nm-platform
and src/platform.

The only problem is that NMSettingWiredWakeOnLan is also part of public
API of libnm. It means, we must duplicate the enum. But with several
static assertions in unit tests I think that is not a problem to do.
2021-01-15 11:32:33 +01:00
Thomas Haller
e5d2a05ad5
libnm: add "shared/nm-base/nm-base.h"
Our dependencies are complicated.

Currently "src/platform" uses parts of libnm-core and is relatively
strongly entangled with core. It would be nice to have that part
clearly independent from "src" and from "libnm-core".

Also, "src/platform/nm-platform-utils.h" uses NMEthtoolID enum, which
previously was defined in "libnm-core/nm-libnm-core-intern/nm-ethtool-utils.h".

Move that to a new place "shared/nm-base/nm-base.h".

Note that we have "libnm-core/nm-libnm-core-intern", which is
libnm/core related code which uses and is used by libnm-core.
There is a need for a library which is used by libnm-core, but
does not depend on libnm-core itself. Here comes "shared/nm-base".

Yes, many libraries. But the goal is to entangle the dependencies
and have a clear hierarchy of includes. And to have "shared/nm-platform"
independent of libnm-core.
2021-01-15 11:32:32 +01:00
Thomas Haller
31dca65e04
shared,platform: move "nmp-netns.[hc]" to shared/nm-platform 2021-01-15 11:32:31 +01:00
Thomas Haller
24c634bf57
core/logging: move "nm-logging.c" to shared/nm-log-core/libnm-log-core library
We want to move platform code to "shared/nm-platform". However, platform
code uses the logging infrastructure from the daemon, there is thus
an odd circular dependency.

Solve that by moving the "src/nm-logging.[hc]" to a new helper library
in "shared/nm-log-core".
2021-01-15 11:32:31 +01:00
Thomas Haller
c6e1327495
core: move NM_MANAGER_ERROR to shared/nm-glib-aux
"src/nm-logging.c" should be independent of libnm-core. It almost
is, except the error domain and code.

Move NM_MANAGER_ERROR to "nm-glib-aux/nm-shared-utils.h" so that
"nm-logging.c" is independent of libnm-core.
2021-01-15 11:32:30 +01:00
Thomas Haller
186f2da2fc
shared,platform: add "shared/nm-platform" library
NetworkManager core is huge. We should try to split out
parts that are independent.

Platform code is already mostly independent. But due to having it
under "src/", there is no strict separation/layering which determines
the parts that can work independently. So, while the code is mostly
independent (in practice), that is not obvious from looking at the
source tree. It thus still contributes to cognitive load.

Add a shared library "shared/nm-platform", which should have no
dependencies on libnm-core or NetworkManager core.

In a first step, move the netlink code there. More should follow.
2021-01-15 11:32:30 +01:00
Thomas Haller
05008faf6e
build/meson: add libnm_systemd_core_dep dependency 2021-01-15 11:32:29 +01:00
Thomas Haller
63e070b180
build/meson: cleanup build of test-systemd executable 2021-01-15 11:32:29 +01:00
Thomas Haller
fd2e626b40
build: add missing dependency for config-extra.h in Makefile.am 2021-01-15 11:32:29 +01:00
Thomas Haller
27f57be076
build: add missing linking with systemd-journald library
These programs use sd_journal_sendv(), they thus need to link against
systemd library.
2021-01-15 11:32:28 +01:00
Thomas Haller
43d4810179
shared: move nm_utils_ifname_cpy() to "shared/nm-glib-aux" 2021-01-15 11:32:28 +01:00
Thomas Haller
6aa6da2b08
shared: add _nm_utils_hwaddr_aton_exact()
This is the same as libnm's nm_utils_hwaddr_aton(), which however
is public API.

We want to use this function also without libnm(-core). Hence add
the helper to "shared/nm-glib-aux".
2021-01-15 11:32:28 +01:00
Thomas Haller
cda8badc57
shared/c-siphash: reimport
git subtree pull --prefix shared/c-stdaux git@github.com:c-util/c-stdaux.git master --squash
2021-01-15 11:19:04 +01:00
Thomas Haller
e97c791684 Squashed 'shared/c-stdaux/' changes from ffa3dcc36533..346623b40eb8
346623b40eb8 c-stdaux: guard __builtin_choose_expr() from Coverity

git-subtree-dir: shared/c-stdaux
git-subtree-split: 346623b40eb8137cae7568a69ee42253ff098ff7
2021-01-15 11:18:21 +01:00
Thomas Haller
18cd6ef832
shared/c-siphash: reimport
git subtree pull --prefix shared/c-siphash git@github.com:c-util/c-siphash.git master --squash
2021-01-15 11:17:32 +01:00
Thomas Haller
a275cfe43b Squashed 'shared/c-siphash/' changes from d8b3a7a8f40e..4918c33b65d0
4918c33b65d0 build: update submodules

git-subtree-dir: shared/c-siphash
git-subtree-split: 4918c33b65d01a9478faface8b4c89f91c390092
2021-01-15 11:17:17 +01:00
Thomas Haller
3f6a2588cd
shared/c-rbtree: reimport
git subtree pull --prefix shared/c-rbtree git@github.com:c-util/c-rbtree.git master --squash
2021-01-15 11:16:25 +01:00
Thomas Haller
afdcf971bd Squashed 'shared/c-rbtree/' changes from 3162c5c04574..a3b1f80548d1
a3b1f80548d1 build: update submodules

git-subtree-dir: shared/c-rbtree
git-subtree-split: a3b1f80548d1c736208c55e9251c49ada649dd62
2021-01-15 11:14:16 +01:00
Thomas Haller
d86b5d07a9
shared: merge branch 'th/enum-from-str-fix-signed'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/728
2021-01-15 09:39:32 +01:00
Thomas Haller
726a82c79d
shared: fix _nm_utils_enum_from_str_full() for negative enum values
Enums can also be negative (contrary to Flags). Fix the parsing.

  $ nmcli connection modify "$PROFILE" connection.llmnr -1
  Error: failed to modify connection.llmnr: invalid option '-1', use one of [default,no,resolve,yes].
2021-01-15 09:36:30 +01:00
Thomas Haller
88a7ec8b14
shared: avoid heap allocation in _nm_utils_enum_from_str_full()
In the vast majority of cases is the string for _nm_utils_enum_from_str_full()
short. As we duplicate it for stripping, prefer to clone it on the stack
with nm_strdup_maybe_a().
2021-01-15 09:36:30 +01:00
Thomas Haller
e884ef39ed
shared: add nm_strdup_maybe_a() helper macro 2021-01-15 09:36:30 +01:00
Jonathan Lebon
a1d9a79228
contrib/rpm: don't trigger udev if socket doesn't exist
On rpm-ostree systems, we don't want scriptlets to affect the running
system because a major part of the value is "background updates".
Scriptlets are run in a containerized environment where e.g. udev is not
available.

Add a check for the udev socket before triggering it to handle this.
This also helps the container use case.

This doesn't break rpm-ostree strictly, because it uses `|| :`, but it
still spams error messages during the compose. I kept the `|| :` to be
safe, but it's likely fine to remove them now.

See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1352154
See-also: https://src.fedoraproject.org/rpms/udisks2/pull-request/3
See-also: https://github.com/coreos/fedora-coreos-tracker/issues/703

https://src.fedoraproject.org/rpms/NetworkManager/pull-request/6
2021-01-14 22:46:35 +01:00
Thomas Haller
9ba8c32dac
contrib/rpm: add "BuildRequires: make" to SPEC file
https://fedoraproject.org/wiki/Changes/Remove_make_from_BuildRoot
2021-01-14 22:17:34 +01:00
Beniamino Galvani
07ee187cb5 initrd: fix leak in test
Fixes: 6069ef4b8b ('initrd: accept a zero-byte prefix for BOOTIF')
2021-01-14 21:48:16 +01:00
Beniamino Galvani
6069ef4b8b initrd: accept a zero-byte prefix for BOOTIF
The BOOTIF MAC address can be prefixed with a hardware address
type. Typically it is 01 (for ethernet), but the legacy network module
accepts (and strips) any byte value.

It seems wrong to take any address type without validation. In
addition to "01", also accept a zero type which, according to the
bugzilla below, is used in some configurations to mean "undefined".

While at it, also accept ':' as separator for the first byte.

https://bugzilla.redhat.com/show_bug.cgi?id=1904099
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/713
2021-01-14 19:14:01 +01:00
Thomas Haller
584e8f92f5
release: bump version to 1.29.8 (development) 2021-01-14 18:56:21 +01:00
Thomas Haller
55c5c57d1e
devices/tests: improve assert for ioctl() in _test_recv_fixture_setup()
This assert sometimes fails during copr builds. But the way
the assert was, it was hard to see what the actual problem
was.

Restructure the assert (again) to get the errno in the
test logs.
2021-01-14 18:24:38 +01:00
Yuri Chornoivan
b2ff18692f
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/727
2021-01-14 18:09:24 +01:00
Thomas Haller
010ad9eeb8
ndisc: merge branch 'th/ndisc-dns-lifetimes'
https://bugzilla.redhat.com/show_bug.cgi?id=1874743

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/725
2021-01-14 13:08:26 +01:00
Thomas Haller
68528f7af5
ndisc: don't artificially extend the lifetime of DNSSL/RDNSS options
RFCs actually expect to honor the lifetime. See for example [1].

This is just not right, and totally arbitrary. It was added
when our libndp based implementation was added, but unclear
why this was done (beyond the code comment).

[1] page 204, v6LC.2.2.25: Processing Router Advertisement DNS (Host
    only) at https://ipv6ready.org/docs/Core_Conformance_5_0_0.pdf
2021-01-14 11:48:52 +01:00
Thomas Haller
872f265859
ndisc: fix encoding DNS Search List Option in RA
The format is different than what was implemented.

Read [1] or see systemd's implementation ([2]).

[1] https://tools.ietf.org/html/rfc8106#section-5.2
[2] 65ab27211c/src/libsystemd-network/sd-radv.c (L791)

Fixes: 6387856602 ('ndisc/lndp: add ability to announce the managed IPv6 configuration')
2021-01-14 11:48:51 +01:00
Thomas Haller
8d9662e16f
ndisc: minor cleanup in send_ra()
- use size_t variable for memory sizes and guint for iterating
  over GArray.
2021-01-14 10:38:52 +01:00
Thomas Haller
e3c464b56c
ndisc: pack structs for lndp options
There is no actual change in behavior, because "struct nd_opt_hdr"
as two uint8_t, so in practice this struct was always packed already.

But make it explicit, because it's clear that we use these structs
to set the binary message and they need a well defined (packed) memory
layout.
2021-01-14 10:38:52 +01:00
Thomas Haller
96d7ddc865
ndisc: add comment and static assert for struct sizes for ndisc packet layout
Obviously, there is no change in behavior. It's just an assertion.
2021-01-14 10:38:52 +01:00
Thomas Haller
5a213541ea
shared: add nm_str_buf_append_{dirty,c_len}() helpers 2021-01-14 10:38:52 +01:00
Thomas Haller
cc8706f815
wireguard: delay activation while resolving DNS names for WireGuard peers to avoid race
The endpoints of WireGuard peers can be configured as DNS name, which
NetworkManager will resolve.

Since activating a profile might affect now names get resolved, we must
first resolve names before completing the activation of the WireGuard
device (and before reconfiguring DNS accordingly).

For example, if you configure exclusive DNS resolution via the WireGuard
device, and if the peer needs to be resolved via DNS, then resolving the
peer name must happen before the reconfiguration of DNS. Otherwise the
new DNS configuration will be broken due to being unable to reach the
WireGuard peer.

Fix that by waiting.

There is still an unfixed problem. If resolving any peers fails,
activation silently proceeds -- again possibly breaking the network
setup. Of course, NetworkManager will repeatedly try to re-resolve
the name, but that may never succeed if DNS would be resolved via
the VPN itself.

That is different from `wg set` which resolves hostnames and fails.
Consequently `wg-quick up` would also fail. But these are both one shot
applications, they are not around and basically let the user handle the
error (by reading the log and invoking the command again). NetworkManager
can do something different and proceed activation (as it will also
periodically re-resolve the hostnames again). Note that it's also valid
to activate a WireGuard device without any peers (and to modify the
activated device later with Reapply()). As such, having no peers (or
being unable to resolve a hostname) may be a valid configuration.

I think we should add an option/flag that when enabled will cause
the activation to fail of names cannot be resolved.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/535
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/616

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/721
2021-01-14 10:23:45 +01:00