Commit Graph

32742 Commits

Author SHA1 Message Date
Thomas Haller
559d071f8d std-aux: remove NM_CONST_MAX()
We now can use either NM_MAX() or NM_MAX_CONST() instead. Drop this.
2023-11-15 09:32:20 +01:00
Thomas Haller
ca4401e327 all: use NM_MAX() instead of NM_CONST_MAX()
NM_CONST_MAX() is going to be replaced by NM_MAX() (or, in cases where
NM_MAX() cannot be used, by NM_MAX_CONST()). Replace usage.
2023-11-15 09:32:19 +01:00
Thomas Haller
5acd30ca44 all: use NM_MIN_CONST()/NM_MAX_CONST() instead of MIN()/MAX()
glib's MIN()/MAX() will be replaced by NM_MIN()/NM_MAX().
There are however a few places where NM_MIN()/NM_MAX() cannot
be used.

Adjust those places to use NM_MIN_CONST()/NM_MAX_CONST() instead.
2023-11-15 09:32:19 +01:00
Thomas Haller
fa500e5540 glib-aux: let NM_MIN()/NM_MAX() return a compile time constant
Glib's MIN()/MAX() should not be used, in favor of NM_MIN()/NM_MAX().
That's because the NM variants

- evaluate arguments only once
- have a static assertion that the signedness of the arguments matches

However, previously those macros never evaluated to a compile time
constant. Unlike the glib variants, which do so when the arguments are
compile time constants. That is sometimes important when using the
macros in a context that requires a constant.

Extend NM_MIN()/NM_MAX() to be a compile time constant, when possible.

Note that there are still a few places where NM_MIN()/NM_MAX() cannot be
used due to the expression statement. For those cases, there is
NM_MIN_CONST()/NM_MAX_CONST().
2023-11-15 09:32:19 +01:00
Thomas Haller
6f4a60b6f2 all: ensure same signedness of arguments to MIN()/MAX()
Comparing integers of different signedness gives often unexpected
results. Adjust usages of MIN()/MAX() to ensure that the arguments agree
in signedness.
2023-11-15 09:32:18 +01:00
Thomas Haller
5671d73fb5 std-aux: don't use G_STATIC_ASSERT() in "nm-std-aux.h"
libnm-std-aux must not have any glib dependencies. That's why it has
NM_STATIC_ASSERT().
2023-11-15 09:32:08 +01:00
Thomas Haller
c04c955407 nm-in-container: fix mount command in "_nm-in-container-setup.sh"
On Fedora 39, mount now requires the dummy device argument.
It was wrong to omit it, altough it worked previously.

Fix the mount command line.
2023-11-15 09:28:58 +01:00
Íñigo Huguet
539d6f436a gen-metadata-nm-settings-nmcli: fix some printf warnings on 32 bit platforms
The specifiers %ld and %lu are not correct for 64 bit integers on 32 bit
platforms, triggering a warning. Use instead the GLib constants to
correctly define them.

Fixes: 925d4df801 ('man nm-settings-nmcli: add "Valid values" field')
Fixes: 5c6ae44e00 ('man nm-settings-nmcli: add "Special values" field')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1790
2023-11-14 19:14:12 +01:00
Thomas Haller
451d0bf954 all: merge branch 'th/nm-hash-seed'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1783
2023-11-14 19:12:27 +01:00
Thomas Haller
4f62600e21 all: use NM_HASH_SEED_16() macro 2023-11-14 14:15:42 +01:00
Thomas Haller
27ae71b504 core: generate fixed fallback timestamp in _host_id_read_timestamp()
nm_hash_siphash42() uses a randomized seed like nm_hash*(). In this case,
we want to always generate the same fake timestamp, based on the host-id.

In practice, it doesn't really matter, because this is only the fallback
path for something gone horribly wrong already.
2023-11-14 14:15:42 +01:00
Thomas Haller
0d6885c087 glib-aux: add NM_HASH_SEED_16_U64() macro
c_siphash_init() requires a 16 bytes array. That is cumbersome to use.
We have NM_HASH_SEED_16() macro for helping with that. It's still
cumbersome.

Most of the time, the caller just wants to pick an arbitrarily chosen,
fixed number. Add NM_HASH_SEED_16_U64() which takes a number and gives
a 16 seed array. The argument is in host endianness, but the resulting
seed array has it encoded in big endianness, to be architecture
independent.
2023-11-14 14:15:42 +01:00
Thomas Haller
832065b6e6 libnm/docs: fix generated documentation
Fixes: 82e2eeeb2a ('libnm/docs: clarify default `ipv4.dhcp-client-id` generated by nettools/internal DHCP plugin')
2023-11-14 12:51:22 +01:00
Thomas Haller
82e2eeeb2a libnm/docs: clarify default ipv4.dhcp-client-id generated by nettools/internal DHCP plugin 2023-11-14 11:29:05 +01:00
Thomas Haller
8dcadafec0 core: merge branch 'th/getpwuid-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1771
2023-11-14 10:35:51 +01:00
Thomas Haller
a7de74018e libnm: use nm_getpwuid() in _permissions_user_allowed()
No need to clone the string again. Use nm_getpwuid() directly and avoid
an additional clone.
2023-11-14 10:35:12 +01:00
Thomas Haller
5a7d1ec208 glib-aux: add nm_getpwuid() helper
Calling getpwuid_r() is cumbersome, because it has a separate passwd and
string buffer, and you shall retry, when the buffer is too small.

Extract nm_getpwuid() for that. This one always allocates a suitable
buffer, that the caller can free.

This will allow callers to get the full passwd struct. It will also
allow callers to avoid the additional strdup() of nm_utils_uid_to_name(),
when we don't need a clone of the string.
2023-11-14 10:35:12 +01:00
Thomas Haller
b2b2823c53 core: avoid getpwuid() unless necessary in permission check
Most profiles don't have "connection.permissions" set. Avoid resolving the
UID to the name via getpwuid() (in nm_auth_is_subject_in_acl()), until we
know that we require it.
2023-11-14 10:35:12 +01:00
Thomas Haller
f19c854905 glib-aux/tests: add test for nm_utils_uid_to_name() 2023-11-14 10:35:12 +01:00
Thomas Haller
2d2f9e0be4 gitlab,python: merge branch 'th/gitlab-ci-no-el7'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1782
2023-11-14 10:30:03 +01:00
Thomas Haller
eb5b78c4bf all: drop support for building with Python2
Now that we no longer test on CentOS7, we also have no more tests that
build using Python2.

Note that build with Python2 is currently broken already (which would be
fixable).

Drop Python2 too.

Existing Python scripts still use a common subset of Python2 and
Python3. They can be improved to use Python3 features in the future.
2023-11-14 10:29:48 +01:00
Thomas Haller
c5fd65aba4 gitlab-ci: drop centos:7 tests
CentOS7 uses gcc-4.8, which have various problems and working around
them is getting more cumbersome.

Also, CentOS7 is ancient by now. It's time. Drop it.
2023-11-14 10:29:48 +01:00
Thomas Haller
7871e160ed gitlab-ci: enable tests on Fedora 40
We don't use "rawhide", because we explicitly enable Fedora versions by
their release number (and "rawhide" is just an alias).

However, by now "rawhide" is Fedora 40. Enable it.
2023-11-14 10:29:48 +01:00
Thomas Haller
93257caa91 connectivity: use GSource pointer for curl_timer instead of numeric source-id
I think GSource* is preferable, because it's more type-safe than the
guint numbers. Also, g_source_remove() only works with
g_main_context_default(), while g_source_detach() of a GSource pointer
works with any GMainContext (so it's more general, even if we in this
case only have sources attached to g_main_context_default()).

Handling GSource* pointers is possibly also faster, since it saves one
extra g_main_context_find_source_by_id() -- on the other hand, tracking
the pointer costs 8 bytes while tracking the guint only costs 4 bytes.
Whether it's faster is unproven, but possibly it is. In any case it's
not an argument against using pointers.

Anyway. Update another usage of source-ids to use GSource pointers.
This is also the pattern that "checkpatch.pl" suggests.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1774
2023-11-14 10:28:11 +01:00
Beniamino Galvani
8d2e510065 merge: branch 'jv/ipv6-acd-logging'
device: add IPv6 ACD logging for ac6/manual configuration

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1787
2023-11-14 07:57:40 +00:00
Jan Vaclav
94643d7e43 ndisc: remove redundant DAD logging
The log message here is not needed anymore, as the conflict is
already logged by nm-device.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1787
2023-11-14 07:55:22 +00:00
Jan Vaclav
856cbbd663 device: add IPv6 ACD logging for ac6/manual configuration
Adds logging for ACD when IPv6 addresses are configured manually or via AC6.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1787
2023-11-14 07:55:22 +00:00
Beniamino Galvani
7447c1c202 dns: add options to control automatic addition of edns0 and trust-ad
Options "edns0" and "trust-ad" are automatically added when using
caching plugins such as dnsmasq and systemd-resolved. In some cases,
those options can break resolution due to non-conforming resolvers,
and there is no way to disable them.

Introduce new options "_no-add-edns0" and "_no-add-trust-ad" to
prevent the automatic addition of "edns0" and "trust-ad". The initial
underscore indicates that the option is internal and is not written
into resolv.conf.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1393
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1751
2023-11-14 08:34:58 +01:00
Beniamino Galvani
f9c9cbbf2f merge: branch 'jv/strv-checked'
create nm_strvarray_get_idxnull_or_greturn macro, use in libnm api

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1765
2023-11-09 10:30:56 +00:00
Jan Vaclav
383bd0ff4a libnm: use checked strvarray getter in api functions
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1765
2023-11-09 10:26:42 +00:00
Jan Vaclav
1f3779fceb glib-aux: create nm_strvarray_get_idxnull_or_greturn macro
This commit adds a getter macro which checks the bounds of a
StrvArray when getting elements, while allowing access at `len` - returning NULL.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1765
2023-11-09 10:26:42 +00:00
Thomas Haller
cd84dae191 libnm: fix unused variables in non-debug mode in _nm_setting_class_commit()
CC       src/libnm-core-impl/libnm_core_impl_la-nm-setting.lo
    src/libnm-core-impl/nm-setting.c: In function '_nm_setting_class_commit':
    src/libnm-core-impl/nm-setting.c:339:41: error: unused variable 'i' [-Werror=unused-variable]
      339 |     guint                               i;
          |                                         ^
    src/libnm-core-impl/nm-setting.c: At top level:
    src/libnm-core-impl/nm-setting.c:168:1: error: '_nm_sett_info_property_find_in_array' defined but not used [-Werror=unused-function]
      168 | _nm_sett_info_property_find_in_array(const NMSettInfoProperty *properties,
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors

Fixes: 2dd5b065a8 ('libnm: drop special casing G_TYPE_STRV from _nm_setting_class_commit()')
2023-11-09 10:10:32 +01:00
Thomas Haller
6c5c5a73bd libnm: merge branch 'th/libnm-strv-props'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1775
2023-11-08 09:39:35 +01:00
Thomas Haller
bdbd3890e3 libnm: add assertions to unreachable code in _nm_setting_property_{get,set}_property_direct() 2023-11-08 09:17:17 +01:00
Thomas Haller
11ee08e78a libnm: simplify assertions in _property_infos_sort_cmp_setting_connection()
What we sort is very static, the names of properties in
NMSettingConnection. We know that the list contains no two identical
names. There were already assertions for that, just rework them a bit to
make the code clearer.
2023-11-08 09:17:16 +01:00
Thomas Haller
eb3b2d9ef6 libnm: initialize "name" in _nm_properties_override_gobj()
Previously, _nm_setting_class_commit() required that the "name" of a
NMSettInfoProperty is unset, when the property also has a "param_spec".
_nm_setting_class_commit() would then as first iterate over all
properties, and set the name.

In practice, all callers only initialize NMSettInfoProperty via
_nm_properties_override_gobj(). Now, let _nm_properties_override_gobj()
set the "name" right away.

Now _nm_setting_class_commit() will instead assert that the name is always
set, and that the caller takes care of that. That means, we have less to
do in _nm_setting_class_commit() (assertions aside).
2023-11-08 09:17:16 +01:00
Thomas Haller
43febd92ff libnm: drop unnecessary cleanup of direct strv properties
Direct properties are automatically cleaned up by the base class
(_finalize_direct()). No need to duplicate that. The point of
the direct property implementation is to free us from this repeated
cumbersome steps (and forgetting this step without a direct property
would not be only unnecessary, but erroneous).
2023-11-08 09:17:15 +01:00
Thomas Haller
2dd5b065a8 libnm: drop special casing G_TYPE_STRV from _nm_setting_class_commit()
There are no such properties left. They now all use
_nm_setting_property_define_gprop_strv_oldstyle() and the
properties_override array already contains the properties.

This simplifies _nm_setting_class_commit() and moves logic away.

Note that most of the code in _nm_setting_class_commit() is only asserts
for consistency.

Since "properties_override" now contains all properties, it doesn't
really "override" any default and the name is bad. Anyway.
2023-11-08 09:17:15 +01:00
Thomas Haller
7113c0c67e libnm: use _nm_setting_property_define_gprop_strv_oldstyle()
Use _nm_setting_property_define_gprop_strv_oldstyle() for all existing
(remaining) G_TYPE_STRV properties.

The benefit is that the properties_override array already lists the
property, and we don't need special hacks in _nm_setting_class_commit()
to initialize those properties.

Also, this style is discouraged. We can now easier find all properties
that should be reworked.
2023-11-08 09:17:14 +01:00
Thomas Haller
907970d08b libnm: add _nm_setting_property_define_gprop_strv_oldstyle() define
This will be used for adding G_TYPE_STRV properties. This is a legacy
approach, new properties should use _nm_setting_property_define_direct_strv(),
which is more efficient and where the meta-data knows more about the
strv property.

Will be used next.
2023-11-08 09:17:14 +01:00
Thomas Haller
aa63748379 libnm: reuse static property type for strv properties 2023-11-08 09:17:14 +01:00
Thomas Haller
4a9c32063f libnm: reserve size for properties_override array
For settings with many properties, pre-allocate a larger buffer via
_nm_sett_info_property_override_create_array_sized().

The buffer is larger than needed, so when we add more properties it
still works. In any case, GArray will grow automatically, so getting
this wrong is not fatal (just suboptimal).
2023-11-08 09:17:14 +01:00
Thomas Haller
53b532ffba libnm: rework creating property info for "name"
The goal is to have the properties_overrides already pre-populated with
all properties. Then we will be able to drop special cases from
_nm_setting_class_commit().
2023-11-08 09:17:04 +01:00
Beniamino Galvani
85bcf2d99f test-client: fix warnings about invalid escape sequences
In Python 3.12 a backslash-character pair that is not a valid escape
sequence generates a SyntaxWarning [1]:

    src/tests/client/test-client.py:2161: SyntaxWarning: invalid escape sequence '\?'
    nmc.pexp.expect("Do you want to provide them\? \(yes/no\) \[yes]")

Use raw strings to avoid that.

[1] https://docs.python.org/3/whatsnew/3.12.html

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1785
2023-11-07 09:58:39 +01:00
Íñigo Huguet
f6998c8daa merge: branch 'ih/spdx'
contrib/rpm: libnm: migrate to SPDX license

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1781
2023-11-07 07:20:41 +00:00
Íñigo Huguet
1560052dcc contrib/rpm: libnm: migrate to SPDX license
The license identifier was updated for the main package, but not for
libnm which overrides it to LGPL 2.1 or later. Update it too.

Fixes: 8c5aec7a1b ('contrib/rpm: migrate to SPDX license')
2023-11-07 07:20:04 +00:00
Beniamino Galvani
a8b23db4d6 merge: branch 'feature-ethtool-eee'
ethtool: introduce EEE support

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1777
2023-11-06 08:38:18 +00:00
Johannes Zink
3165d9a2de ethtool: introduce EEE support
Some Applications require to explicitly enable or disable EEE.
Therefore introduce EEE (Energy Efficient Ethernet) support with:

 * ethtool.eee on/off

Unit test case included.

Signed-off-by: Johannes Zink <j.zink@pengutronix.de>
2023-11-03 15:41:21 +00:00
Íñigo Huguet
3842418512 Remove reference to deleted file in Makefile.am
The file NetworkManager-wait-online-systemd-pre200.service.in has been
removed but was still referenced in Makefile.am. Remove it from there.

Fixes: 886cd58658 ('build: assume we have at least systemd v200')
2023-11-03 08:37:44 +01:00
Íñigo Huguet
d7088fdf90 merge: branch 'systemd'
dispatcher: show man page in .service file / drop support for pre-v200 systemd

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1769
2023-11-03 07:21:27 +00:00