Commit graph

27645 commits

Author SHA1 Message Date
Thomas Haller
ac1a9e03e4
all: move "src/" directory to "src/core/"
Currently "src/" mostly contains the source code of the daemon.
I say mostly, because that is not true, there are also the device,
settings, wwan, ppp plugins, the initrd generator, the pppd and dhcp
helper, and probably more.

Also we have source code under libnm-core/, libnm/, clients/, and
shared/ directories. That is all confusing.

We should have one "src" directory, that contains subdirectories. Those
subdirectories should contain individual parts (libraries or
applications), that possibly have dependencies on other subdirectories.
There should be a flat hierarchy of directories under src/, which
contains individual modules.

As the name "src/" is already taken, that prevents any sensible
restructuring of the code.

As a first step, move "src/" to "src/core/". This gives space to
reorganize the code better by moving individual components into "src/".

For inspiration, look at systemd's "src/" directory.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/743
2021-02-04 09:45:55 +01:00
Thomas Haller
97ed143e04
udev/trivial: rename nm_udev_client_unref() to nm_udev_client_destory()
NMUdevClient does not actually implement ref-counting, because it's not
used. Still, the destroy function was named nm_udev_client_unref(),
because theoretically then we could later, as the need arises, make
the type ref-counted. Then unref function already had the right name.

However, NMUdevClient also has a callback function that emits monitor
events. Again for simplicity, this callback function cannot be reset, it
can only be set once (in the constructor) and can also not be unset nor
disabled.

When the user of NMUdevClient is done with the instance and calls
"unref", then it must be sure that the callback is no longer invoked
afterwards. In practice that is already the case, but "unref" makes it
sound as if somebody else could also still hold a reference -- in which
case the user would have to first unset/disable the callback.

Rename the function to "destroy()", so that it's clear that the instance
is gone afterwards and that the callback will not be invoked anymore.
2021-02-03 14:58:00 +01:00
Thomas Haller
41a28ca9c3
all/udev: use NM_MAKE_STRV() for arguments of nm_udev_client_new() 2021-02-03 14:46:55 +01:00
Beniamino Galvani
fc2844e263
device: group boolean fields together 2021-02-03 13:46:30 +01:00
Thomas Haller
684019d6f1
cloud-setup: add Documentation link to "nm-cloud-setup.service" 2021-02-02 18:13:02 +01:00
Thomas Haller
150c18130e
cloud-setup: add comment to "nm-cloud-setup.service" about drop-in files 2021-02-02 18:09:27 +01:00
Thomas Haller
a3d686a0ee
man: clarify use of systemctl edit in man nm-cloud-setup 2021-02-02 17:50:58 +01:00
Thomas Haller
81369ac83c
libnm/docs: hook up new nm-keyfile API in libnm documentation (fix)
Fixes: 25d64c861c ('libnm/docs: hook up new nm-keyfile API in libnm documentation')
2021-02-02 16:14:04 +01:00
Thomas Haller
25d64c861c
libnm/docs: hook up new nm-keyfile API in libnm documentation 2021-02-02 14:44:56 +01:00
Thomas Haller
1ccbae6e4e
contrib/rpm: add "enabled=true" key to "20-connectivity-{fedora,redhat}.conf"
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/649
2021-02-02 14:02:31 +01:00
Frederic Martinsons
38331fc02c
tests: add a dbus test function to change delay of active connection state change
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/740
2021-02-02 10:42:33 +01:00
Antonio Cardace
5a7df5deee
bond: merge branch 'ac/bond_change_mode_fix'
https://bugzilla.redhat.com/show_bug.cgi?id=1870691
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/731

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2021-02-02 10:41:28 +01:00
Antonio Cardace
136081957d
device: fix bond-slave creation race-condition
In some cases the enslavement event of a device gets
processed by nm-platform before the master NMDevice is
created, in such cases the enslavement information is simply
lost by NM, to prevent this let NMDevice connect to the
'device-ifindex-changed' signal to be notified of when its master
NMDevice appears so that eventually the NMDevices will be consistent
with the kernel network state.

https://bugzilla.redhat.com/show_bug.cgi?id=1870691

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2021-02-02 09:51:58 +01:00
Antonio Cardace
374cc96126
core: add 'device-ifindex-changed' signal
NMManager now emits a 'device-ifindex-changed' whenever
a device ifindex gets changed.

https://bugzilla.redhat.com/show_bug.cgi?id=1870691

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2021-02-02 09:51:58 +01:00
Antonio Cardace
84dc705159
device: add 'master_ifindex' field to NMDevice
https://bugzilla.redhat.com/show_bug.cgi?id=1870691

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2021-02-02 09:51:58 +01:00
Antonio Cardace
d2d74f99a9
bond: release slaves prior to changing mode
Bonds need to release all enslaved devices when
the bond mode is to be changed.

Also release slaves when they're external interfaces as
it means the master it's now managed by NetworkManager.

https://bugzilla.redhat.com/show_bug.cgi?id=1870691

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2021-02-02 09:51:57 +01:00
Antonio Cardace
a4d37612c8
device: take over unmanaged devices when explicitely deactivated
https://bugzilla.redhat.com/show_bug.cgi?id=1870691

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2021-02-02 09:51:57 +01:00
Antonio Cardace
91766a6910
device: make devices 'external' when going to 'unmanaged' state
This is the default state for new devices hence they should
return back to this state when unmanaged.

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2021-02-02 09:51:57 +01:00
Antonio Cardace
6ddfee3751
device: make 'nm_device_master_release_slaves' internal API
https://bugzilla.redhat.com/show_bug.cgi?id=1870691

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2021-02-02 09:51:57 +01:00
Beniamino Galvani
3f4765f30e merge: branch 'bg/macsec-display-ckn'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/739
2021-02-01 18:05:41 +01:00
Beniamino Galvani
c42de1c5b6 supplicant: display the MACsec CKN as hex string
The CKN can contain non-ASCII or NULL bytes. Display the original hex
string from configuration instead.
2021-02-01 18:05:29 +01:00
Beniamino Galvani
18fe100926 supplicant: rename 'hidden' argument
Sometimes the option can't be displayed as is because it contains NULL
or non-ascii characters. Rename the 'hidden' argument of
nm_supplicant_config_add_option_with_type() to 'display_value' so that
callers can pass a preferred string representation of the value.
2021-02-01 18:05:29 +01:00
Beniamino Galvani
2757da7eac device: check ifindex before changing ethernet link settings
During the call to deactivate(), the device can already have lost the
ifindex. Add a check for that to prevent assertion:

 ((src/platform/nm-platform.c:3306)): assertion 'g_return_val_if_fail(ifindex > 0, FALSE)' failed

 0   g_logv (libglib-2.0.so.0 + 0x5bf67)
 1   g_log (libglib-2.0.so.0 + 0x5c223)
 2   _nm_g_return_if_fail_warning.lto_priv.0 (NetworkManager + 0x4c69f)
 3   nm_platform_ethtool_set_link_settings (NetworkManager + 0x183418)
 4   deactivate.lto_priv.1 (NetworkManager + 0x27dfd1)
 5   nm_device_cleanup (NetworkManager + 0x25b047)
 6   _set_state_full (NetworkManager + 0x24f4d8)
 7   nm_device_unrealize (NetworkManager + 0x259e63)
 8   _platform_link_cb_idle (NetworkManager + 0x27097f)
 9   g_idle_dispatch (libglib-2.0.so.0 + 0x5305b)
 10  g_main_context_dispatch (libglib-2.0.so.0 + 0x53f8f)
 11  g_main_context_iterate.constprop.0 (libglib-2.0.so.0 + 0xa74d8)
 12  g_main_loop_run (libglib-2.0.so.0 + 0x53673)
 13  main (NetworkManager + 0x4bdba)
 14  __libc_start_main (libc.so.6 + 0x27b75)
 15  _start (NetworkManager + 0x4c3ee)

https://bugzilla.redhat.com/show_bug.cgi?id=1923062
2021-02-01 15:29:55 +01:00
Thomas Haller
087a3b4955
libnm: fix NMVpnConnectionStateReason for glib-mkenums
The previous form was confusing glib-mkenums parser. Simplify
it.

Fixes: 5022e3b8ee ('libnm: revert coercing NMVpnConnectionStateReason to NMActiveConnectionStateReason')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/646
2021-02-01 09:31:00 +01:00
Thomas Haller
484b699c78
tools/tests: add usage to "tools/run-nm-test.sh"
Also support specifying the test name after "--".
2021-01-29 08:43:11 +01:00
Thomas Haller
7e32c3efda
gitlab-ci: generate new container images for tests
- the python-black version on Fedora 33 was updated, and this formats
  our python code differently. The black version that is used by our
  gitlab-ci is the authoritative version that should be used. Update
  it by regenerating the containers.

- especially Fedora:rawhide and Debian:sid often introduce changes that
  will cause a break of our build. Update the containers to test latest
  versions.
2021-01-28 14:50:39 +01:00
Thomas Haller
7869aacf61
gitlab-ci: skip valgrind on Debian/sid with glib2.0 (2.66.4-2)
See-also: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1902#note_1018573
2021-01-28 14:50:32 +01:00
Thomas Haller
d446cde260
examples/python: some style update to avoid changes in black code formatting
Fedora 33's version of python-black is the authoritative version we
use for formatting -- note that formatting may look different depending
on the black version.

Recently, the package was updated to 20.8~b1-1.fc33, which treats
these lines different.

Work around that by adjusting the code so that both older and current
versions of python black behave the same.
2021-01-28 10:25:25 +01:00
Thomas Haller
b98ec9bc58
build/meson: fix linking of core plugins to not include static helper libraries
We have many static helper libraries, like libnm-glib-aux or libnm-core.
These can be statically linked in any end-binary as internal API. However, they
must only be linked once.

Also, we have various plugins (device, settings, ppp, wwan) which are
dlopened by NetworkManager. They should use the symbols from
NetworkManager core. It is important that they do not link with the
static libraries already, because also NetworkManager core links with
it, so these symbols will be duplicate.

As the symbols are internal, you might think that it is not a real
problem to duplicate them. However, there are also global variables,
like the hash tables for NMRefStr or the seed for NMHash. These global
variables must be only be used once, and hence also these symbols must
no be duplicated.

Fix that by adding a new dependency that is for the core plugins. This
dependency only has "include_directories" but not "link_with".
2021-01-28 09:31:13 +01:00
Thomas Haller
98ae351134
build/meson: cleanup meson files of core 2021-01-28 09:28:25 +01:00
Thomas Haller
90622e782b
build/meson: rename "daemon_nm_default_dep" to "core_default_dep"
Naming for us is hard, because everything is an "nm". However, let's
standardize on the term "core" for the daemon, and not "daemon".

Eventually I would like to move the daemon from "src/" to "src/core/",
rename the dep in anticipation of that.
2021-01-28 08:46:29 +01:00
Thomas Haller
947a8b7bad
build: merge branch 'th/meson-cleanup' 2021-01-28 08:31:12 +01:00
Thomas Haller
a482461cb4
build/meson: cleanup "src/meson.build" 2021-01-27 21:47:53 +01:00
Thomas Haller
3abae51080
build/meson: drop special timeout for libnm test
A timeout for tests should not be reached anyway. It's only
a fail-safe for not running indefinitely (and for meson not killing
the test too early). We don't need to run test-libnm with a shorter
timeout.
2021-01-27 21:32:28 +01:00
Thomas Haller
5d85d7c849
shared: split redefining g_return* warning out of "nm-default.h"
It's confusing enough. Let's keep "nm-default.h" simpler.
Especially due to the nesting of #if, which clang-format wants
to indent.
2021-01-27 21:30:20 +01:00
Thomas Haller
be9ed624a9
build/meson: cleanup "libnm/tests/meson.build" 2021-01-27 21:30:19 +01:00
Thomas Haller
beb29ffb3c
build: rename static "liblibnm" to "libnm-static"
This is basically all of libnm as a static-library. The name
liblibnm isn't great. Arguably, we do have quite a lot of
libnmxyz, so finding a good name is hard. But libnm-static seems
a better name. Rename.
2021-01-27 21:25:46 +01:00
Thomas Haller
e795b297c9
build/meson: cleanup "libnm/meson.build" 2021-01-27 21:20:35 +01:00
Thomas Haller
15d97f1b6f
build/meson: cleanup "libnm-core/tests/meson.build" 2021-01-27 21:20:35 +01:00
Thomas Haller
095dce489c
build/meson: cleanup "libnm-core/meson.build" 2021-01-27 21:13:42 +01:00
Thomas Haller
bd302341ef
build/meson: rename "libnm_utils_base" to "libnm_glib_aux"
It's the better name.
2021-01-27 21:02:40 +01:00
Thomas Haller
9d5d5d5bf0
build/meson: cleanup "shared/meson.build"
Drop some "helper" variables that are only used once. These variables
spread out what is defined, and only make the meson file more complicated
to follow.
2021-01-27 20:56:40 +01:00
Beniamino Galvani
05745cf079 release: bump version to 1.29.10 (development) 2021-01-27 18:31:03 +01:00
Antonio Cardace
157a06d27b bond: introduce new 'vlan+srcmac' xmit_hash_policy option
Kernel patch introducing this option:
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=7b8fc0103bb5

https://bugzilla.redhat.com/show_bug.cgi?id=1915457

Signed-off-by: Antonio Cardace <acardace@redhat.com>
2021-01-27 17:10:17 +01:00
Beniamino Galvani
0a05e39e0b ovs: merge branch 'bg/ovs-cleanup-pt2'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/734
2021-01-27 16:12:47 +01:00
Beniamino Galvani
e2b4417570 core: unblock OVS interfaces when the ovsdb is ready
OVS system interfaces can start to connect even before the ovsdb is
ready. However, the connection attempt is doomed to fail and the
NMSettingsConnection gets blocked with reason FAILED.

Unblock them once the ovsdb is ready.

Ideally, NMPolicy should subscribe to the NMOvsdb::ready signal,
however NMOvsdb is in a plugin, so it's easier if NMOvsdb directly
calls a function of the core.
2021-01-27 16:12:42 +01:00
Beniamino Galvani
c3cb177b7d ovs: set OVS interfaces as available only after ovs-ready signal
Don't allow OVS interfaces to connect until the NMOvsdb signals it's
ready. Otherwise, connection attemps can race with the initial OVS
cleanup.
2021-01-27 16:12:42 +01:00
Beniamino Galvani
6d195f7a3f ovs: improve disconnecting devices after removal from ovsdb
Sometimes during boot the device starts an activation with reason
'assumed', then the ovs interfaces gets removed from the ovsdb. At
this point the device has an active-connection associated; it has the
activate_stage1_device_prepare() activation source scheduled, but it
is still in disconnected state.

Currently the factory doesn't recognizes that the device is activating
and allows the device to proceed even if the interface was removed
from the ovsdb. Fix this by checking the presence of an
active-connection instead.
2021-01-27 16:12:42 +01:00
Beniamino Galvani
31d0a9524d ovs: clean up interfaces from ovsdb at startup
During shutdown, NM always tries to remove from ovsdb all bridges,
ports, interfaces that it previously added. Currently NM doesn't run
the main loop during shutdown and so it's not possible to perform
asynchronous operations. In particular, the NMOvsdb singleton is
disposed in a destructor where it's not possible to send out all the
queued deletions.

The result is that NM deletes only one OVS interface, keeping the
others. This needs to be fixed, but requires a rework of the shutdown
procedure that involves many parts of NM.

Even when a better shutdown procedure will be implemented, we should
support an unclean shutdown caused by e.g. a kernel panic or a NM
crash. In these cases, the interfaces added by NM would still linger
in the ovsdb.

Delete all those interface at NM startup. If there are connections
profiles for them, NM will create them again.

Also, NMOvsdb now emits a NM_OVSDB_READY signal and provides a
nm_ovsdb_is_ready() to allow other parts of the daemon to order
actions after the initial OVS cleanup.

https://bugzilla.redhat.com/show_bug.cgi?id=1861296
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/700
2021-01-27 16:12:42 +01:00
Beniamino Galvani
a30d744657 ovs: change reason for deactivation-on-removal
The interface was removed, so NM_DEVICE_STATE_REASON_REMOVED sounds
more correct.
2021-01-27 16:12:42 +01:00