Commit Graph

27768 Commits

Author SHA1 Message Date
Thomas Haller
4e997d1b36 initrd/tests: cleanup redundant code in "test-cmdline-reader.c"
Add _parse(), _parse_cons() and _parse_con() helper macros. These
already perform assertions that are common in those cases, and thus
reduce a lot of boiler plate code.

Also, _parse_cons() is exactly about parsing connections. The next
time we add an out parameter to nmi_cmdline_reader_parse() we won't
have to adjust all the call sites where this parameter doesn't matter.
2021-01-20 16:55:10 +01:00
Adarsh J
e300138892 initrd: add support for rd.net.timeout.carrier
Add support for `carrier-wait-timeout` setting from kernel cmdline.

This will create a new `15-carrier-timeout.conf` file in
/run/NetworkManager/conf.d with the parameter value as specified.

The setting also inserts `match-device` to `*`, matching all devices.

NB: The parameter on kernel cmdline is specified in seconds. This is
done to be backwards compatible with with network-legacy module. However
the generated setting will automatically multiply specified value by
1000 and store timeout value in ms.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/730
2021-01-20 16:10:56 +01:00
Thomas Haller
3096d31155 shared/c-list: reimport
git subtree pull --prefix shared/c-list git@github.com:c-util/c-list.git master --squash
2021-01-20 11:07:23 +01:00
Thomas Haller
efebd9dca4 Squashed 'shared/c-list/' changes from ac7c83139821..96455db9f04a
96455db9f04a c-list: remove redundant check from c_list_is_linked()

git-subtree-dir: shared/c-list
git-subtree-split: 96455db9f04a6c9101a00957161551aea700b6aa
2021-01-20 11:07:14 +01:00
Thomas Haller
761a1452d9 shared/n-dhcp4: reimport
git subtree pull --prefix shared/n-dhcp4 git@github.com:nettools/n-dhcp4.git master --squash
2021-01-20 11:02:24 +01:00
Thomas Haller
c4938e4552 Squashed 'shared/n-dhcp4/' changes from 8c91e9ae8999..f459d85fdef6
f459d85fdef6 packed: use c_errno() in packet_sendto_udp() to avoid compiler warning
d52768da6acd client-lease: add n_dhcp4_client_lease_get_server_identifier()

git-subtree-dir: shared/n-dhcp4
git-subtree-split: f459d85fdef6954b4f4b103e211fb9e175b12bac
2021-01-20 11:01:41 +01:00
Thomas Haller
eb99fbea77 libnm/doc: consistently write "Since:" tag for enum values 2021-01-20 09:16:21 +01:00
Thomas Haller
6af73f9d17 Revert "n-dhcp4: work around compiler warning in n_dhcp4_socket_packet_send()"
We have now a different solution using c_errno() in packet_sendto_udp().

This reverts commit 4686e9baef.
2021-01-19 19:54:31 +01:00
Thomas Haller
5bdc36b392 n-dhcp4: use c_errno() in packet_sendto_udp() to avoid compiler warning
With LTO enabled, the compiler might think that "len" in n_dhcp4_socket_packet_send()
might be uninitialized. That is even a correct assumption, as the compiler does not
understand the API of sendmsg() and that sendmsg() is supposed to set a positive errno.

Work around by using c_errno() in packet_sendto_udp().

    shared/n-dhcp4/src/n-dhcp4-c-connection.c: In function n_dhcp4_c_connection_send_request:
    shared/n-dhcp4/src/n-dhcp4-socket.c:368:19: error: len may be used uninitialized in this function [-Werror=maybe-uninitialized]
             } else if (len != n_buf) {
                       ^
    shared/n-dhcp4/src/n-dhcp4-socket.c:351:23: note: len was declared here
             size_t n_buf, len;
                           ^
2021-01-19 19:53:37 +01:00
Thomas Haller
d649a1f9cc veth: merge branch 'th/veth-fixes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/726
2021-01-19 18:46:00 +01:00
Thomas Haller
a824f56441 device: if a device is not IFF_UP assume that is has carrier
A device that is not IFF_UP does not have carrier. So we don't
know the real state before we bring it up.

On the other hand, during `nmcli connection up` we check whether the
device is available. So we are blocked. The solution is to optimistically
assume that the device has carrier if it is down. We may fail later.

  $ nmcli connection add type veth con-name vv0 autoconnect no ifname vv0 peer vv1 ipv4.method shared ipv6.method shared
  $ nmcli connection up vv0
  $ nmcli device connect vv1
  Error: Failed to add/activate new connection: Connection 'vv1' is not available on device vv1 because device has no carrier
2021-01-19 16:41:50 +01:00
Thomas Haller
7c05ff1632 device: fix complete-connection for veth devices
Otherwise,

    $ nmcli device connect veth0

fails with

    Error: Failed to add/activate new connection: veth.peer: property is not specified

In complete_connection(), we should by default complete ethernet
connections, unless the caller already indicated to want a veth
profile.

Fixes: cd0cf9229d ('veth: add support to configure veth interfaces')
2021-01-19 16:41:45 +01:00
Thomas Haller
bcb63affdd release: bump version to 1.29.9 (development) 2021-01-19 15:50:23 +01:00
Beniamino Galvani
e2d04e18d5 device: fix stale pointer in nm_device_get_hostname_from_dns_lookup()
Fixes: 09c8387114 ('policy: use the hostname setting')

https://bugzilla.redhat.com/show_bug.cgi?id=1917713
2021-01-19 11:13:38 +01:00
Beniamino Galvani
4367785007 hostname: merge branch 'bg/hostname-from-any'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/729
2021-01-18 16:30:24 +01:00
Beniamino Galvani
92c494f290 all: change default value of hostname.only-from-default to false
Currently, is retrieved by default only from the device with the
default route. This is done so that in presence of multiple
connections the choice is deterministic.

However, this limitation seems confusing for users, that expect to get
an hostname even for non-default devices. Change the default and allow
any device to obtain the hostname.

Note that when there is a default route, NM still prefers that device
and so the behavior doesn't change.

The only change in behavior is that when there is no default route and
the machine doesn't have a static hostname, NM will try to get
hostname from DHCP or reverse DNS.

https://bugzilla.redhat.com/show_bug.cgi?id=1766944
2021-01-18 16:29:55 +01:00
Beniamino Galvani
af55a86a82 policy: prefer device with default route to determine the hostname
In case two devices have the same hostname-priority, prefer the one
with the best default route. In this way, even if
hostname.only-from-default is set to FALSE globally, the behavior is
similar to the past when there is a device with the default route.

Previously, NMPolicy considered only the hostname-priority and the
activation order to build the DeviceHostnameInfo list. Now it has to
consider also the presence of the default route, which depends on the
address family. Therefore, now there is a DeviceHostnameInfo for each
[device,address_family] combination.
2021-01-18 16:24:53 +01:00
Thomas Haller
6ce0c064ac examples: add comment about scanning to "python/dbus/show-bssids.py" example
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/630
2021-01-18 13:26:12 +01:00
Thomas Haller
eafa96c06a contrib/spec: let NetworkManager-wifi depend on wireless-regdb/crda
Based-on-patch-by: Peter Robinson <pbrobinson@gmail.com>

https://src.fedoraproject.org/rpms/NetworkManager/pull-request/7
2021-01-18 12:22:07 +01:00
Beniamino Galvani
c243e003d6 build: add missing dependency of nm-base for config-extra.h in Makefile.am
Fix the following build error:

 In file included from shared/nm-base/nm-ethtool-base.c:6:
 ./shared/nm-default.h:87:10: fatal error: config-extra.h: No such file or directory
    87 | #include "config-extra.h"
       |          ^~~~~~~~~~~~~~~~

Fixes: e5d2a05ad5 ('libnm: add "shared/nm-base/nm-base.h"')
2021-01-18 09:57:18 +01:00
Thomas Haller
e6b5f54d6d wifi: log WPS flag of access point 2021-01-18 09:28:59 +01:00
Thomas Haller
1d04770002 wifi: fix caching ap-flags for supplicant-interface
Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/631
2021-01-18 09:27:32 +01:00
Thomas Haller
a326c30110 contrib/rpm: fix packaging "/usr/share/man/man8/nm-cloud-setup.8.gz" in "NetworkManager"
nm-cloud-setup is provided by sub-package "NetworkManager-cloud-setup",
which also has the manual page. The main package "NetworkManager" should
not also contain the manual page.
2021-01-15 17:51:20 +01:00
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