Commit graph

27173 commits

Author SHA1 Message Date
Peter Hutterer 133de4ab59
gitlab CI: remove leftover comments referring to libinput
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/684
2020-11-18 08:36:13 +01:00
Thomas Haller 5ce9f0e186
man,libnm,cli: merge branch 'th/man-cli-connection-types'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/444

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/680
2020-11-17 22:21:47 +01:00
Thomas Haller 1a998153b4
man: update supported connection types in man nmcli
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/444
2020-11-17 22:19:35 +01:00
Thomas Haller ed67e01680
man: sort supported connection types in man nmcli 2020-11-17 22:19:29 +01:00
Thomas Haller d0ec501163
cli: assert that valid_parts are set for base types 2020-11-17 22:19:29 +01:00
Thomas Haller 9ebeeb6bf2
cli: fix shell completion for connection.type to show "ovs-{dpkg,patch}"
nmcli --complete-args connection add type ''

would not show "ovs-{dpdk,patch}", because the conditions about what
makes a base type are not consistent with what NMSettingConnection's
verify() does.

Fix that.
2020-11-17 22:19:29 +01:00
Thomas Haller ac7915b3ce
shared/libnm: move NMSettingPriority helpers to "shared/nm-meta-setting.h" 2020-11-17 22:19:22 +01:00
Thomas Haller 7595a8f817
ovs: merge branch 'th/ovs-external-ids-2'
https://bugzilla.redhat.com/show_bug.cgi?id=1866227

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/679
2020-11-17 19:49:43 +01:00
Thomas Haller 3a0347e821
core/ovs: for now drop cancellable from ovsdbmethod call again
Currently the cancellable is not yet used. Drop it again.

However, I think the code might be useful, so I hope to revert
this commit afterwards to use it.
2020-11-17 19:49:04 +01:00
Thomas Haller 7055539c9f
core/ovs: support setting OVS external-ids
Also support reapply. During reapply we try to preserve
keys that are added externally.

However, the current implementation does not properly use transactions
to ensure there is no race here.
2020-11-17 19:49:04 +01:00
Thomas Haller a4b13d5069
core/ovs: log external-ids of Interfaces/Ports/Bridges 2020-11-17 19:49:04 +01:00
Thomas Haller 958d7c092e
core/ovs: cleanup logging of OvsdbMethodCall
We don't need every log line repeat all the parameters
of the call. Each call should have a unique identifier
(which is NM_HASH_OBFUSCATE_PTR(call)) and only the first
message from a call contains all the details.
2020-11-17 19:49:03 +01:00
Thomas Haller c44c8e7fbc
core/ovs: allow ovsdb calls to be cancelled
In general, providing an async API also requires the
ability to cancel requests. It's not yet used, but add
a way to handle a GCancellable.
2020-11-17 19:49:03 +01:00
Thomas Haller 8b4d77a453
core/ovs: don't fail with "cancelled" reason for disconnected ovsdb
API should fail with a "cancelled" error if (and only if)
the user cancelled the operation. An error to communicate
with OVSDB or being disconnected should fail with a different
reason.
2020-11-17 19:49:03 +01:00
Thomas Haller 2983febf39
core/ovs: track pending calls in a CList instead of GArray
GArray is nice, because it is more memory efficient and encourages
local access. However, growing the array also means that all entries
get relocated, that means, we cannot pass on a pointer to a call
instance.

Next, we will add a way to cancel operations via a GCancellable.
That means, we subscribe to the cancelled signal and need to pass
on a user-data that indicates which call got cancelled. Since with
an GArray the calls can be relocated, we would anyway need an
additional allocation (just for the user data). So, we wouldn't
actually safe anything but make the code more complicated.

As often, CList works great in this use case. Use it.
2020-11-17 19:49:03 +01:00
Thomas Haller 4303618a30
core/ovs: move definitions of structs in "nm-ovsdb.c"
It's in general nicer to have all definitions of structs and enums
a the top of the source file. As enums and structs are commonly used
by functions, it's often nice to have the enums and structs defined
first, before all functions.
2020-11-17 19:49:03 +01:00
Thomas Haller c45041f1fc
examples: extend "ovs-external-ids.py" to support nmcli device modify
The python example is (also) used to test the feature. That is because
currently nmcli does not yet have support for ovs.external-ids and this
API is only accessible via D-Bus (or a tool like this example).
2020-11-17 19:49:03 +01:00
Thomas Haller afd1d58af5
libnm: return NMSetting pointer from nm_setting_ovs_external_ids_new()
After discussion ([1]), it seems this is preferred.

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/669#note_682195
2020-11-17 19:49:03 +01:00
Thomas Haller dd9c818947
shared: add NM_UTILS_ERROR_NOT_READY enum value
This is a general error code for being not ready to perform the
operation.
2020-11-17 19:49:03 +01:00
Thomas Haller eaa48caac4
shared: add nm_g_hash_table_ref()/nm_g_hash_table_unref() helpers 2020-11-17 19:49:02 +01:00
Thomas Haller 395665902b
dns: don't apply DNS configuration for external connections
External connections are devices that are configured outside of
NetworkManager. Such devices should be mostly ignored and not
be interfered with.

Note that we tend to create external connection profiles for
such devices. That happens for example if you use wg-quick to
manage a WireGuard interface outside of NetworkManager. But it
really happens for any interface.

This generated profile has no DNS configuration. Unless we use
the systemd-resolved backend, they thus don't contribute to the DNS
settings (which is fine).

However, with systemd-resolved, NetworkManager would also reset
the DNS configuration of those external interfaces. That is clearly
wrong. NetworkManager should only care about the interfaces that it
actively manages and leave others alone.

How to reproduce: use systemd-resolved and configure an interface outside
of NetworkManager. Note that `nmcli device` shows the state as
"connected (externally)". Note that `resolvectl` shows the DNS configuration
on that external interface. Do something in NetworkManager to trigger
a DNS update (e.g. SIGHUB or reactivate a profile). Note in `resolvectl`
that the external interface's DNS configuration was wiped.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/563#note_673283
2020-11-17 18:49:58 +01:00
Thomas Haller f1564caa15
dns: minor cleanup in update_dns() to use gsize for size
g_strv_length() returns a guint. That is not the right size for the length
of an array. Use the right size.
2020-11-17 16:55:15 +01:00
Thomas Haller 0e7e88cfc7
gitlab-ci: combine ubuntu/centos install scripts with their debian/fedora counterparts
Ubuntu/Debian and CentOS/Fedora are sufficiently similar that it's
better that we have only one variant of ".gitlab-ci/*-install.sh"
and "contrib/*/REQUIRED_PACKAGES".

This was already the case, however, we used to symlink
".gitlab-ci/centos-install.sh" to "fedora-install.sh". That
worked, but it didn't scale very well. For example, if we would follow
that pattern, we would also need a symlink "contrib/centos/REQUIRED_PACKAGES"
Or should "contrib/centos" symlink to "contrib/fedora"? That seems even
more wrong.

We already had the "distro.base_type" variable for that. Make use of
that also for the install script.
2020-11-17 13:28:18 +01:00
Thomas Haller bef8166893
build: add make-check step to check and generate ".gitlab-ci.yml" 2020-11-17 13:19:14 +01:00
Yuri Chornoivan 41a684f630
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/681
2020-11-17 13:13:44 +01:00
Thomas Haller f1ff6fe8b7
gitlab-ci: install correct version of ci-templates in build script
It's not clear that ci-fairy has a stable API. Instead, we pin the
version by specifying the git commit sha.

In the build script, install the pinned version.
2020-11-17 09:48:48 +01:00
Thomas Haller 539c00a8a1
gitlab-ci: automatically hash build scripts into tag for ci-templates container
ci-templates builds and caches the test containers. When the build
scripts, the ci-template or "config.yml" changes, we need to bump
the tag so that the containers get rebuild.

Partly automate this. The tag now gets generated by the template and
contains a checksum of certain build files. Thus, if you change
any build files, then `ci-fairy generate-template` would generate a
different tag. You can not miss that, because we have tests that ensure
that our ".gitlab-ci.yml" is up to date. Also, you no longer need to
manually bump the tag when a build script changes, just regenerate
".gitlab-ci.yml" with `ci-fairy generate-template`.

See also: https://gitlab.freedesktop.org/freedesktop/ci-templates/-/merge_requests/54
2020-11-17 09:40:35 +01:00
Thomas Haller 71c3291296
data: merge branch 'mikhailnov:timeout-60'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/675
2020-11-16 17:46:57 +01:00
Thomas Haller 30824b8888
NEWS: update 2020-11-16 17:46:54 +01:00
Thomas Haller f59f1a25b4
systemd: remove code comment from "NetworkManager-wait-online.service.in"
> If there is no network [1] to connect to (if network interface is down [2])
> NetworkManager will make "nm-online -s" stop [3] without waiting.

[1] we usually talk about connection profiles or devices/interfaces
[2] it would be better to say, if no suitable profile is ready to
  autoconnect.
[3] `nm-online -s` waits until NetworkManager declares "startup
complete" reached.

I find the wording of the comment not very clear or useful.
Possibly I don't understand it properly, but that is a problem
for a comment that is supposed to help.

Remove it.
2020-11-16 17:46:53 +01:00
Mikhail Novosyolov acef72c0cb
systemd: increase default timeout of NetworkManager-wait-online
We encountered the following situation:
* nm-online (NetworkManager-wait-online.service) is started
* NetworkManager tries to configure network
* the first try of using dhclient fails with timeout for some reasons
* the second try of running dhclient completes successfully (NMs tries himself)
We get a working network, but it takes more that 30 seconds.

NetworkManager-wait-online.service fails, it may be a false negative
to checkers of network being online. It will also be a false positive signal
to start mounting network (CIFS, NFS etc.) shares, for example, because
they depend from network-online.target and network-online.target will become
reached right after NetworkManager-wait-online.service fails.

So, it makes sense to increase default timeout from 30 to 60 seconds.

@thaller wrote in https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/237
that there may be cases where, for example, incorrectly set up bridges
or just network may lead to delays when booting the system.

Yes, but:
* if there is no possibility to start trying to connect the network, e.g. if all network interfaces,
  managed by NetworkManager, are DOWN, NM will not try to connect network and "nm-online -s" will
  exit with 0 without waiting (so, this will not prolong start up of workstations or servers
  when ethernet cable is just not plugged in)
* an additional potential 30 seconds delay seems to be less harmful then a false positive to start
  mounting network shares or doing abything else too eraly, when an additional wait for a few seconds
  would have prevented those things from failing.

All things considered, it seems reasonable to increase this timeout from 30 seconds to 1 minute (60 seconds).

Signed-off-by: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/675
2020-11-16 17:46:53 +01:00
Beniamino Galvani 090c360ca4 merge: branch 'bg/hostname-setting-rh1766944'
https://bugzilla.redhat.com/show_bug.cgi?id=1766944
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/669
2020-11-16 17:04:54 +01:00
Beniamino Galvani 09c8387114 policy: use the hostname setting
Rework update_system_hostname() to use the new properties from the
hostname setting.

In the default configuration where all the 3 boolean properties
hostname.{from-dhcp,from-dns,only-from-default} are true, the behavior
is the same as before.
2020-11-16 16:43:40 +01:00
Beniamino Galvani abd002642f all: add hostname setting
Add a new setting that contains properties related to how NM should
get the hostname from the connection.
2020-11-16 16:43:39 +01:00
Beniamino Galvani adf63c8875 ifcfg: reuse the same variable for different settings 2020-11-16 16:43:39 +01:00
Beniamino Galvani dc6ec6ce7b core: reverse the order of active connections in the manager
When a new active connection is created, it gets added at the
beginning of manager's list. This means that the list contains most
recently activated connections first. Since the list is doubly-linked,
it is possible to efficiently iterate in both directions, so the order
of the list is mostly a matter of convention.

I think it is preferable to have oldest active connections at the
beginning of the list; let's reverse the order.

In most places where the list is iterated, the order doesn't
matter. Where it does, use the *_prev() variant to maintain the old
iteration order.
2020-11-16 16:43:39 +01:00
Beniamino Galvani 740191f7c0 core: add nm_ip_config_get_first_address() 2020-11-16 16:43:39 +01:00
Beniamino Galvani dfd2fcde0f shared: add c-list macros to iterate backwards 2020-11-16 16:43:39 +01:00
Aleksander Morgado 5b7ce438d9
wwan: update default connection timeout to 200s
The following merge request in ModemManager introduces a more or less
common timeout value for the connection attempts in all plugin and
protocol implementations:

  https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/391

The value chosen by default for the steps that may take long to
complete in a connection attempt is 180s, and 120s for the steps in
the disconnection path.

Until now, every different plugin or protocol had a different timeout
value, all of them <= 180s, and with that change in ModemManager, the
values are now aligned for all.

Note, though, that this does not mean that a connection attempt will
take always less than 180s, as there may be multiple other steps in
addition to the one that took the maximum timeout. The value chosen
for NetworkManager is a compromise between the new defaults from MM
and what the user would expect under e.g. very low quality conditions.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/678
2020-11-16 16:04:06 +01:00
Andrew Zaborowski c1ff06e119 iwd: Fix a use after free
In connection_removed we use the id.name that was being g_freed a few
lines further down.

Fixes: bea6c40367 ('wifi/iwd: handle forgetting connection profiles')
2020-11-12 19:58:08 +01:00
Thomas Haller ab3f18b906
ppp: drop unnecessary cast for return value of g_object_new() (manually) 2020-11-12 16:08:17 +01:00
Thomas Haller a2b5e22f82
all: drop unnecessary cast for return value of g_object_new()
C casts unconditionally force the type, and as such they don't
necessarily improve type safety, but rather overcome restrictions
from the compiler when necessary.

Casting a void pointer is unnecessary (in C), it does not make the
code more readable nor more safe. In particular for g_object_new(),
which is known to return a void pointer of the right type.

Drop such casts.

  sed 's/([A-Za-z_0-9]\+ *\* *) *g_object_new/g_object_new/g' $(git grep -l g_object_new) -i
  ./contrib/scripts/nm-code-format-container.sh
2020-11-12 16:03:09 +01:00
Thomas Haller 2f83777054
core/trivial: fix clang-format code formatting 2020-11-12 15:34:59 +01:00
Andrew Zaborowski 33b9fa3a3c manager: Keep volatile/external connections while referenced by async_op_lst
If an NMSettingsConnection with the VOLATILE or EXTENRAL flags is created
and passed to nm_manager_activate_connection, it's immediately scheduled
for deletion in an idle callback and will likely be deleted before the
authorization step in nm_manager_activate_connection finishes and the
connection will be aborted.  This is because there's no
NMActiveConnection in priv->active_connection_lst_head referencing it
until _internal_activate_device().  Change
active_connection_find_by_connection to also look for connections in
priv->async_op_lst_head.

New _delete_volatile_connection_do() calls are added.  Previously it
would be called when an active connection may have been removed from
priv->active_connection_lst_head, now also call it when an active
connection may have been removed from priv->async_op_lst_head without
being added to priv->active_connection_lst_head.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/671
2020-11-12 15:04:56 +01:00
Yuri Chornoivan a68903f05a
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/676
2020-11-11 11:37:03 +01:00
Thomas Haller 8df0dee3e8
gitlab-ci: automatically run prep-container to fix hanging tests
The goal is to run most distros only manually. However, it would be nice
to avoid (manually) clicking twice to start the tests for one distro:
once for the container preparation, and once for the actual test.

Previously, the container prep part was set to manual and the actual
test automatic. It worked almost as desired, except that this leads
to the entire gitlab-ci pipeline be be in running state indefinitely.

To fix that, always run the container prep steps. If the container is
cached, this is supposed to be fast and cheap. Now only the actual tests
are marked as "manual".
2020-11-11 08:50:17 +01:00
Thomas Haller 767c83f443
gitlab-ci: add "needs" for pages test
It seems "pages" test does not get properly triggered, if only
t_fedora:33 completes. It should, because the other distros are
optional. Try to set "needs" to fix that.
2020-11-11 08:47:16 +01:00
Thomas Haller 31940037fa
device: fix _Generic() types for _NM_DEVICE_CAST() macro (2)
clang (x86_64, 3.4.2-9.el7) fails:

    ../src/devices/nm-device.c:957:9: error: controlling expression type 'typeof (*self) *const' (aka 'struct _NMDevice *const') not compatible with any generic association type
            _LOGT(LOGD_DEVICE,
            ^~~~~~~~~~~~~~~~~~
    ../shared/nm-glib-aux/nm-logging-fwd.h:162:20: note: expanded from macro '_LOGT'
    #define _LOGT(...) _NMLOG(_LOGL_TRACE, __VA_ARGS__)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/devices/nm-device-logging.h:34:81: note: expanded from macro '_NMLOG'
                const char *const    _ifname = _nm_device_get_iface(_NM_DEVICE_CAST(_self)); \
                                                                                    ^~~~~
    ../src/devices/nm-device-logging.h:14:63: note: expanded from macro '_NM_DEVICE_CAST'
        #define _NM_DEVICE_CAST(self) _NM_ENSURE_TYPE(NMDevice *, self)
                                                                  ^
    ../shared/nm-glib-aux/nm-macros-internal.h:664:53: note: expanded from macro '_NM_ENSURE_TYPE'
        #define _NM_ENSURE_TYPE(type, value) (_Generic((value), type : (value)))
                                                        ^

Fixes: cc35dc3bdf ('device: improve "nm-device-logging.h" to support a self pointer of NMDevice type')
2020-11-10 22:54:32 +01:00
Thomas Haller ebbc2c9c0d
build: fix handling NMTST_SKIP_PYTHON_BLACK for skipping make check-python-black test
Fixes: c537852231 ('build: optionally skip python black check by setting NMTST_SKIP_PYTHON_BLACK=1')
2020-11-10 20:21:03 +01:00
Thomas Haller 71eeec8c78
device: fix _Generic() types for _NM_DEVICE_CAST() macro
clang (x86_64, 3.4.2-9.el7) fails:

    ../src/devices/nm-device-6lowpan.c:161:9: error: controlling expression type 'typeof (*self) *const' (aka 'struct _NMDevice6Lowpan *const') not compatible with any generic association type
            _LOGW(LOGD_DEVICE, "could not get 6lowpan properties");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../shared/nm-glib-aux/nm-logging-fwd.h:165:20: note: expanded from macro '_LOGW'
    #define _LOGW(...) _NMLOG(_LOGL_WARN, __VA_ARGS__)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/devices/nm-device-logging.h:32:81: note: expanded from macro '_NMLOG'
                const char *const    _ifname = _nm_device_get_iface(_NM_DEVICE_CAST(_self)); \
                                                                                    ^~~~~
    ../src/devices/nm-device-logging.h:17:19: note: expanded from macro '_NM_DEVICE_CAST'
            _Generic((self), _NMLOG_DEVICE_TYPE *        \
                      ^

Fixes: cc35dc3bdf ('device: improve "nm-device-logging.h" to support a self pointer of NMDevice type')
2020-11-10 19:44:10 +01:00