Commit graph

27952 commits

Author SHA1 Message Date
Thomas Haller 9fc1bf90fa
initrd: move "src/core/initrd/" to "src/nm-initrd-generator/" 2021-03-15 17:10:53 +01:00
Thomas Haller 9d647cbcbc
initrd: don't include headers of the daemon from src/core/ 2021-03-15 17:10:53 +01:00
Thomas Haller 0033da8f61
config: add "nm-base/nm-config-base.h"
Note that we take defines from "src/core/nm-config.h" which
are GPL-2.0-or-later licensed.

libnm-base we want to include in other LGPL licensed sources,
we it must also be LGPL.

"relicense" the code that I take. I don't think it's a problem, because:

- these are only plain defines. To which extend is that even
  copyrightable?

- as far as I see, all the code was contributed by people who agreed
  to such relicensing. See RELICENSE.md file.
2021-03-15 17:10:52 +01:00
Thomas Haller 5235ea3bf4
tests: move nmtst_init_with_logging() to "libnm-glib-aux/nm-test-utils.h" 2021-03-15 17:10:52 +01:00
Thomas Haller e08a0a3a68
build/meson: fix test name for "test-dispatcher-envp" 2021-03-15 17:10:52 +01:00
Thomas Haller 2b37659c62
build/meson: don't try to buildlibnmt-newt without libnewt 2021-03-15 17:10:52 +01:00
Thomas Haller 10b4d10c9b
build: fix setting CFLAGS when building "libnm-vpn-plugin-utils-test.la"
Internally we set CPPFLAGS, because setting CFLAGS disables inheriting AM_CFLAGS --
which we use for example for "-Wno-pragmas" from the configure script.
2021-03-15 17:10:52 +01:00
Thomas Haller 0d856432b7
initrd/tests: avoid variable declaration in for loop in test_if_off()
src/core/initrd/tests/test-cmdline-reader.c: In function test_if_off:
    src/core/initrd/tests/test-cmdline-reader.c:564:5: error: for loop initial declarations are only allowed in C99 mode
        for (int i = 0; i < G_N_ELEMENTS(conn_expected); ++i) {
        ^
    src/core/initrd/tests/test-cmdline-reader.c:564:5: note: use option -std=c99 or -std=gnu99 to compile your code
2021-03-15 17:10:52 +01:00
Thomas Haller c96a21e3cf
wwan/ofono: merge branch 'pr/771'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/771
2021-03-15 13:33:20 +01:00
Bhushan Shah 0daea018c6
wwan/ofono: use gs_unref_variant instead of g_variant_unref 2021-03-15 13:32:47 +01:00
Tony Espy e4941696be
wwan/modem: do not mark connection as failed when connection drops
If the modem is connected, and registrations drops, and then is restored, the
connection isn't re-activated.

The fix was simply to change modem_state_cb to not return after setting the
state to failed, which allows nm_device_queue_recheck_available to be called,
which queues a state transition to UNAVAILABLE.
2021-03-15 13:32:47 +01:00
Tony Espy c49fe910d6
wwan/ofono: Fix ofono re-connection problems
This patch fixes two issues,

- If ofono returns InProgress, don't treat as a PREPARE_FAILURE.

- If context in question is already active, instead of trying to wait
for "Active" property to change, check the current state of context
properties, and if it is Active = true, fetch the rest of context
settings and process them

Original bug: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1565717

Co-Authored-by: Bhushan Shah <bshah@kde.org> [rebase patch to upstream,
and adjust it to newer coding style]
2021-03-15 13:32:47 +01:00
Thomas Haller 5d78d94445
libnm: merge branch 'th/lldp-neighbor-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/780
2021-03-12 18:56:53 +01:00
Thomas Haller cba3113607
libnm: guard against empty attribute names for NMLldpNeighbor
The libnm API NMLldpNeighbor does not accept "" as an attribute name.
And it does not need to, because a reasonable NetworkManager should
never expose such names.

However, we should not trust NetworkManager to be reasonable. Check that
the attribute name is not empty.
2021-03-12 18:56:43 +01:00
Thomas Haller 84d64217f8
libnm: call nm_lldp_neighbor_get_attr_value() from redundant helpers 2021-03-12 18:56:42 +01:00
Thomas Haller 626a83d025
libnm/trivial: move code
Move nm_lldp_neighbor_get_attr_value() first. The other functions are all redundant
and should possibly be deprecated.
2021-03-12 18:56:41 +01:00
Thomas Haller be40c8fdf7
libnm: for boxed type NMLldpNeighbor only ref the instance instead of deep cloning
There is no public API to modify a NMLldpNeighbor instance. They are only
created by NMDevice and afterwards immutable. There is no point to duplicate
them, when we can just take a ref.

Note that this means we must be careful if we ever add API to mutate a
NMLldpNeighbor. But immutable types are awesome, so we probably should
never do that anyway.
2021-03-12 18:56:41 +01:00
Thomas Haller ae881b7b5b
libnm: minor cleanup of NMLldpNeighbor getters 2021-03-12 18:56:40 +01:00
Thomas Haller 88e22b6832
libnm: sort attributes in nm_lldp_neighbor_get_attr_names()
A hash table gives values in undefined order. Sort them, to
get a stable order.
2021-03-12 18:56:40 +01:00
Thomas Haller f8e19f805f
libnm: make NMLldpNeighbor ref-counting thread-safe
At least ref-counting should be thread safe for our public API.

Note that NMLldpNeighbor has no public API for mutating a neighbor
instance. Especially for immutable types, it is very attractive that
ref-counting is thread-safe.

Also use slice allocator for NMLldpNeighbor structs.
2021-03-12 18:56:40 +01:00
Jonas Jelten cc7bf676eb initrd: fix auto-establishment for dhcp6 and auto6 methods
Fixes: ecc074b2f8 ('initrd: add command line parser')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/586
2021-03-12 18:31:25 +01:00
Beniamino Galvani 5af95f9d79 initrd: fix indentation
Fixes: c907fecbc5 ('initrd: fix compilation error')
2021-03-12 11:47:59 +01:00
Beniamino Galvani c907fecbc5 initrd: fix compilation error
../src/core/initrd/tests/test-cmdline-reader.c:461:36: error: unused variable 'connections' [-Werror,-Wunused-variable]
    gs_unref_hashtable GHashTable *connections = NULL;
                                   ^

Fixes: c27626a0ce ('initrd: set multi-connect=single for connections with static IP')
2021-03-12 11:02:27 +01:00
Beniamino Galvani 88aae71f22 initrd: merge branch 'bg/initrd-fixes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/779
2021-03-12 09:47:18 +01:00
Beniamino Galvani c27626a0ce initrd: set multi-connect=single for connections with static IP
We don't want to have multiple devices up with the same static IP. Set
multi-connect=single.

https://bugzilla.redhat.com/show_bug.cgi?id=1915493
2021-03-12 09:46:45 +01:00
Beniamino Galvani 389575a6b1 initrd: set the bootif MAC in existing connection with ifname
If an existing connection has an interface name set and the generator
finds a BOOTIF argument, it creates a new connection for BOOTIF.

Instead, the generator should set the MAC in the existing connection;
this sounds more correct and it is what the network-legacy module
does.

https://bugzilla.redhat.com/show_bug.cgi?id=1915493
2021-03-12 09:46:22 +01:00
Beniamino Galvani 5f73646524 initrd: fix may-fail for IPv6 2021-03-12 09:44:49 +01:00
Thomas Haller 4d609dd92f
libnm: fix exporting nm_setting_match_new() symbol 2021-03-11 19:00:34 +01:00
Thomas Haller 7b8e626529
libnm: add NM_VERSION_1_32, NM_AVAILABLE_IN_1_32, NM_DEPRECATED_IN_1_32 macros 2021-03-11 18:54:40 +01:00
Beniamino Galvani 840e54a96c devices: fail optional-802.1X connections if supplicant disappears
802-1x.optional=yes means that NM should tolerate a failure or a
timeout of the 802.1X authentication and should keep the connection
up. Even if the authentication doesn't succeed, NM keeps the
supplicant running so that it can continue trying.

If the supplicant disappears because it crashed or was killed
externally, NM should fail the connection so that it can be retried.

The current code is wrong also because after releasing the supplicant
interface, it calls wired_auth_cond_fail() which tries to connect a
signal to priv->supplicant.iface (which is NULL).

https://bugzilla.redhat.com/show_bug.cgi?id=1934291
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/776
2021-03-11 10:06:38 +01:00
Wen Liang 5e3482caec docs: improve manual page about ETHTOOL_OPTS
Signed-off-by: Wen Liang <liangwen12year@gmail.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/762
2021-03-10 14:25:51 +01:00
Beniamino Galvani 190fd9aa9f bond: restore MAC on release only when there is a cloned MAC address
Currently we unconditionally reset the MAC to the previous value after
releasing ports. This has some disadvantages:

 - by default, after the last port is removed the bond will have one
   of the previous port's address, which could conflict with the port;

 - in some cases, changing the bond MAC is not possible. For example
   when the bond is active-backup and has fail_over_mac=1|2. In such
   case the netlink call succeeds, but the address doesn't
   change; then NM would keep waiting for some time.

Don't try to restore the MAC unless the bond connection has a cloned
MAC set.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/775
2021-03-09 10:32:20 +01:00
Thomas Haller ca43239beb
logging: merge branch 'th/platform-sysctl-logging-mt'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/772
2021-03-09 09:37:57 +01:00
Thomas Haller 3c0ae1b5da
platform: make global logging cache for NMPlatform's sysctl values thread-safe
We have a cache for sysctl values, so that we can log changes and
previous values.

When resetting the log level, we prune that cache, which is done by
_nm_logging_clear_platform_logging_cache(). That function is called
by nm_logging_setup(), which is guaranteed to only happen on the main
thread.

NMPlatform in general is not thread safe (meaning, that the same NMPlatform
instance cannot be used by multiple threads at the same time). There is however
a reasonable aim that you could use different NMPlatform instances on their
own threads.

That currently doesn't work, mainly due to nm-logging which always must
be done from the main thread -- unless we would set NM_THREAD_SAFE_ON_MAIN_THREAD
in all of NMPlatform (which would be too expensive for something we
don't actually need). That means also the sysctl getter must only be
called on the main thread an all was good already.

Still, we could have NMPlatform usable from multiple thread by setting
NM_THREAD_SAFE_ON_MAIN_THREAD. As we are almost there to have the code
thread-safe, make accessing the sysctl value cache thread-safe (even if
we currently don't actually access it from multiple thread).
2021-03-08 22:29:01 +01:00
Thomas Haller 8dbfbce9f6
platform: add NM_LINUX_PLATFORM_FROM_PRIVATE() helper function 2021-03-08 22:29:01 +01:00
Thomas Haller 597ad6aa8a
logging: use NMStrBuf in _domains_to_string() 2021-03-08 22:29:01 +01:00
Thomas Haller 29e93b1738
logging: prefer stack buffer for logging message 2021-03-08 22:29:01 +01:00
Thomas Haller 45ba49f322
shared: add nm_vsprintf_buf_or_alloc() macro 2021-03-08 22:29:00 +01:00
Thomas Haller 098ac7dbc0
shared: fix behavior of NM_G_MUTEX_LOCKED()
The idea of NM_G_MUTEX_LOCKED() macro is not only to register a mutex
for unlocking (via nm_auto_unlock_g_mutex) but also to lock it at
the same time.

That is a useful helper macro. If you have to lock the mutex yourself,
it makes usage less convenient. At which point you don't need the macro
anymore and you should instead take full control and lock/unlock yourself.

Fix the macro and change behavior. The macro was not used so far, so
it's not a problem.

Fixes: dd33b3a14e ('shared: add nm_auto_unlock_g_mutex and NM_G_MUTEX_LOCKED() helper macros')
2021-03-08 22:29:00 +01:00
Thomas Haller a5829ea6d1
libnm: comment about wrong out parameter of nm_wireguard_peer_get_allowed_ip() 2021-03-08 22:24:12 +01:00
Beniamino Galvani 8df3ef5063 initrd: apply the MTU from bond= argument to the bond connection
Currently the MTU specified in:

 bond=<bondname>[:<bondslaves>:[:<options>[:<mtu>]]]

gets applied to the bond ports. Instead it should be applied to the
bond itself.

Fixes: ecc074b2f8 ('initrd: add command line parser')

https://bugzilla.redhat.com/show_bug.cgi?id=1932502
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/767
2021-03-08 10:31:51 +01:00
Thomas Haller 7ad2b8f20a
platform: merge branch 'th/platform-move'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/769
2021-03-05 11:29:09 +01:00
Thomas Haller 604b1d0331
platform: move more platform code to src/libnm-platform/ 2021-03-05 11:27:16 +01:00
Thomas Haller 06c03f3e8d
platform: drop unnecessary #include from platform code (2) 2021-03-05 11:27:16 +01:00
Thomas Haller 3b6e57961d
platform: move "platform/{wifi,wpan}/" to "src/libnm-platform/" 2021-03-05 11:27:15 +01:00
Thomas Haller f435454615
platform: move "linux/nl802154.h" to "src/linux-headers/" 2021-03-05 11:27:15 +01:00
Thomas Haller a0662c05a3
platform: drop unnecessary #include from platform code 2021-03-05 11:27:15 +01:00
Thomas Haller 901a7ecbdd
core: move NMPObjectType to "libnm-platform/nmp-base.h" 2021-03-05 11:27:15 +01:00
Thomas Haller d3585243c3
core: move creating singleton instance out of "nm-platform.c"
In core, NMPlatform is (also) a singleton instance. As we will move platform code
to libnm-platform, this singleton part makes no sense there. Move the code
to NetworkManagerUtils.c.
2021-03-05 11:27:15 +01:00
Thomas Haller 9113a672cf
platform: move nm_utils_modprobe() to libnm-platform 2021-03-05 11:27:15 +01:00