Commit graph

13823 commits

Author SHA1 Message Date
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
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
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
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
Thomas Haller
7b18e15481
platform: move nm_utils_lifetime_*() to libnm-platform 2021-03-05 11:27:15 +01:00
Thomas Haller
690105c616
platform: move nm_utils_new_{vlan,infiniband}_name() to libnm-platform 2021-03-05 11:27:15 +01:00
Thomas Haller
2d9a9d0ded
core: move NM_PLATFORM_LIFETIME_PERMANENT to libnm-platform/nmp-base.h 2021-03-05 11:27:15 +01:00
Thomas Haller
398b509931
base: move "libnm-core-intern/nm-core-types-internal.h" to libnm-base
"libnm-platform" has no dependency on libnm-core. To have the symbols
accessible, move them to libnm-base.
2021-03-05 11:27:02 +01:00
Thomas Haller
40fc7bd39a
base: move bridge defines to libnm-base/nm-base.h 2021-03-05 11:09:15 +01:00
Thomas Haller
8755538e04
glib-aux: move nm_utils_route_type{2str,_by_name}() to libnm-glib-aux 2021-03-05 11:09:15 +01:00
Thomas Haller
af0cfc559b
glib-aux: move nm_utils_ptrarray_find_first() helper to libnm-glib-aux 2021-03-05 11:09:15 +01:00
Thomas Haller
a016f24353
glib-aux: move NMIcmpv6RouterPref to libnm-glib-aux 2021-03-05 11:09:15 +01:00
Thomas Haller
3c733cc32e
glib-aux: move nm_utils_sysctl_ip_conf_*() helpers 2021-03-05 11:09:14 +01:00
Thomas Haller
2ce9cf3e20
glib-aux: move nm_utils_ip4_address_is_{zeronet,link_local}() 2021-03-05 11:09:14 +01:00
Thomas Haller
57735e1e8e
glib-aux: move nm_utils_ip[46]_address_*() helpers 2021-03-05 11:09:14 +01:00
Thomas Haller
ec22551ce9
glib-aux: move NMUtilsIPv6IfaceId struct to libnm-glib-aux 2021-03-05 11:09:14 +01:00
Thomas Haller
2ab87642f6
glib-aux: move NMLinkType to "libnm-glib-aux/nm-shared-utils.h"
It is a bit odd to do this, because usually libnm-glib-aux is not
about network related stuff. But that is not true entirely, because
it also contains NMIPAddr and other related helper funcitons.

NMLinkType is only a plain enum, there is no logic beyond it.
As such, I think it's acceptable to move it here.

There reason to do this, is that I want to move NMUtilsIPv6IfaceId and
nm_utils_get_ipv6_interface_identifier() out of src/core/, and since
that API is also trival helpers without complex state, it fits to
libnm-glib-aux. As such, we will need also NMLinkType there.
2021-03-05 11:09:14 +01:00
Thomas Haller
2b6baccff8
core: use _NM_UTILS_HWADDR_LEN_MAX instead of NM_UTILS_HWADDR_LEN_MAX 2021-03-05 11:09:14 +01:00
Thomas Haller
e691657da0
core: use _NMVlanFlags instead of NMVlanFlags 2021-03-05 11:09:14 +01:00
Thomas Haller
82e2a694d7
core: use _NM80211Mode instead of NM80211Mode 2021-03-05 11:09:13 +01:00
Thomas Haller
a5865cef1a
core: use _NMDeviceWifiCapabilities instead of NMDeviceWifiCapabilities 2021-03-05 11:09:13 +01:00
Thomas Haller
d2abd70932
core: use _NMSettingWirelessWakeOnWLan instead of NMSettingWirelessWakeOnWLan 2021-03-05 11:09:13 +01:00
Thomas Haller
8a3df8419a
libnm-base: add internal _NMVlanFlags type 2021-03-05 11:09:13 +01:00
Thomas Haller
ad91e92b25
libnm-base: add internal _NM80211Mode type 2021-03-05 11:09:13 +01:00
Thomas Haller
367be3585f
libnm-base: add internal _NMDeviceWifiCapabilities type 2021-03-05 11:09:13 +01:00
Thomas Haller
096ee5ed6e
libnm-base: add internal _NMSettingWirelessWakeOnWLan type
NMSettingWirelessWakeOnWLan is public API of libnm/libnm-core
in "src/libnm-core-public/"

We want that libnm-platform is independet of libnm-core to keep
the dependencies smaller and code better separated. Hence we
cannot use that enum there.

Duplicate NMSettingWirelessWakeOnWLan as _NMSettingWirelessWakeOnWLan
in libnm-base.
2021-03-05 11:09:13 +01:00