Commit graph

32779 commits

Author SHA1 Message Date
Fernando Fernandez Mancera 084beb0818 contrib/rpm: fix reference to "22-wifi-mac-addr.conf" 2023-11-21 13:03:24 +01:00
Thomas Haller 1d241f5295
contrib: fix invalid escape sequence in "find-backports"
Fixes: 57cfa5daf9 ('contrib: add "find-backports" script')
2023-11-20 17:14:47 +01:00
Thomas Haller 1054d3bce0
nm-in-container: set TERM=xterm in bashrc
Otherwise, TERM is set to "dump", which breaks a lot of uses of the
pager.
2023-11-20 16:40:10 +01:00
Thomas Haller 84ede1c380
nm-in-container: bind mount additional directories
- If ".git/nm-in-container-host" exists, bind mount all of "/" to
  "/Host".

- also honor all ".git/nm-data-link-*" files for additional
  directories to bind mount.

- as before, honor ".git/NetworkManager-ci" symlink.

Note that directories also get symlinked from "/". Like
"/NetworkManager-ci" which symlinks links to the bind mount location.
2023-11-20 16:00:14 +01:00
Thomas Haller c9742cec2a
libnm/doc: fix typo documenting NMCheckpointCreateFlags
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1429
2023-11-20 15:27:28 +01:00
Thomas Haller 087ae7df3c
wifi: merge branch 'th/fedora-wifi-mac-addr-rand'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1789
2023-11-17 12:52:14 +01:00
Thomas Haller ea8dbd7a6d
contrib/rpm: add "22-wifi-mac-addr.conf" to F40+
Install a configuration snippet on Fedora 40+, that sets the default for
"wifi.cloned-mac-address" to "stable-ssid" (otherwise, the built-in default
is "preserve").

This will mean, that on Wi-Fi profiles that don't explicitly override
the property "wifi.cloned-mac-address", a stable address is generated.
The benefit is, that Fedora will randomize the MAC address by default.

Note that this also affects all pre-existing Wi-Fi profiles, that don't
explicitly configure the property in the profile. Depending on how you
see it, this is desirable. Randomization should be done, unless the user
opts-out (not the other way around).

Note that setting "wifi.cloned-mac-address=stable-ssid" is similar to
setting a stable ID "${NETWORK_SSID}" and "wifi.cloned-mac-address=stable".
The difference is that the latter also affects other properties, like

  - "ipv6.addr-gen-mode=stable-privacy"
  - "{ethernet,wifi}.cloned-mac-address=stable"
  - "ipv4.dhcp-client-id=stable"
  - "ipv6.dhcp-duid=stable-{llt,ll,uuid}"
  - "{ipv4,ipv6}.iaid=stable"

Especially with "ipv6.addr-gen-mode=stable", changing the stable ID
would mean that also all IPv6 addresses change. We want to avoid that by
only changing the cloned-mac-address to "stable-ssid".

This means, after upgrade to F40, different MAC addresses will be used
on most users' Wi-Fi. This means, DHCP might hand out different IP
addresses, sessions might expire, and configuration that depended on the
previous MAC address will be affected.

https://pagure.io/fedora-workstation/issue/350
2023-11-17 12:48:37 +01:00
Thomas Haller d210923c0f
wifi: add "wifi.cloned-mac-address=stable-ssid"
Add a new "stable-ssid" mode that generates the MAC address based on the
Wi-Fi's SSID.

Note that this gives the same MAC address as setting

    connection.stable-id="${NETWORK_SSID}"
    wifi.cloned-mac-address="stable"

The difference is that changing the stable ID of a profile also affects
"ipv6.addr-gen-mode=stable-privacy" and other settings.
2023-11-16 13:07:54 +01:00
Thomas Haller 587f5afb5a
all: differentiate NM_CLONED_MAC_IS_SPECIAL() for wired/wireless
Will be used next, when we support "stable-ssid" for
"wifi.cloned-mac-address" property.
2023-11-16 13:07:53 +01:00
Thomas Haller 901a1b096b
core: support "${NETWORK_SSID}" for connection.stable-id
For Wi-Fi profiles, this will encode the SSID in the stable-id.
For other profiles, this encodes the connection UUID (but the SSID and
the UUID will always result in distinct stable IDs).

Also escape the SSID, so that the generated stable-id is always valid
UTF-8.
2023-11-16 13:07:53 +01:00
Íñigo Huguet 83a1ce39b0 release: bump version to 1.45.7 (development) 2023-11-16 11:37:32 +01:00
Thomas Haller d57a47adec
libnm: merge branch 'th/libnm-strv-props-2'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1788
2023-11-16 08:33:47 +01:00
Thomas Haller 8079e8969d
libnm: implement "ipv4.dhcp-reject-servers" as direct-strv property 2023-11-15 17:59:28 +01:00
Thomas Haller 4cd58207c1
libnm: implement "ipv4.dns-search" as direct-strv property 2023-11-15 17:59:27 +01:00
Thomas Haller eed4a21fa3
libnm: use nm_strvarray_*() helpers for strv properties
We have many properties, and we aim that they have a small set of
"types". The purpose is that we can treat similar properties (with the
same type) alike.

One type are "direct" strv properties. Those still require some
C functions, like get-length(), clear(), add(), get-at-index().
The implementation of those functions should also be similar, so that
strv properties behave similar.

For that, make use of helper functions, so that little duplicate logic
is there.

Use some new nm_strvarray_*() functions, and unify/cleanup some code.
All related to strv properties in NMSetting classes.
2023-11-15 17:59:27 +01:00
Thomas Haller 3435bc3011
libnm: move NMValueStrv definition in header 2023-11-15 17:59:26 +01:00
Thomas Haller 7b5e8381f0
glib-aux: assert against NULL arguments for nm_strvarray_add() 2023-11-15 17:59:26 +01:00
Thomas Haller 2d8c4cfe05
glib-aux: add nm_strvarray_add_take() helper 2023-11-15 17:59:26 +01:00
Thomas Haller 60375218d1
glib-aux: add nm_strvarray_remove_index() helper 2023-11-15 17:59:25 +01:00
Thomas Haller 6c83f7bd67
glib-aux: add nm_strvarray_ensure_and_add() helper 2023-11-15 17:59:25 +01:00
Thomas Haller 73947cdfd0
glib-aux: add nm_strvarray_clear() helper 2023-11-15 17:59:25 +01:00
Thomas Haller 7ab9a2b69f
glib-aux: add nm_strvarray_contains() helper 2023-11-15 17:58:04 +01:00
Thomas Haller 9f9a89d778
glib-aux: cleanup assertions for GArray element size in nm_strvarray helpers
The check "sizeof(const char *const *) ==
g_array_get_element_size((GArray *) strv)" is wrong, but probably
harmless, because most likely on our supported architectures all pointer
sizes are the same size.

Also, just use `sizeof(char *)` instead of `sizeof(const char *)`. Not
that it matters, but the GArray holds pointers of `char *`.

Also, consistently place the "sizeof()" on the left side of the
comparison.
2023-11-15 17:57:57 +01:00
Thomas Haller 339f99c08e
gitlab-ci: drop builds for CentOS 8 (8.1.1911, 8.2.2004, 8.3.2011)
CentOS Linux 8 is long gone. We were only running tests on this old
build environment, to see how we fare in such environment.

The test was broken for 4+ months. Instead of fixing it, disable it.

It's partly caused by RHEL8, as it is somewhat cumbersome to even build
on CentOS 8. That's because some devel packages (like libteam-devel) are
not installable. As workaround for that, we re-build such packages in a
copr ([1]). The problem is, that we only have one copr build for e.g.
CentOS 8. If we rebuild against latest CentOS 8 Stream, then libteam is
build against newer dependencies, which are not installable on CentOS
Linux 8.1.1911 (etc). We would have to build libteam in a way, that
does not drag newer dependencies that are missing on CentOS Linux 8.

For example, trying to use copr [1] on CentOS Linux 8 and installing
"teamd" gives:

  Error:
   Problem: package teamd-devel-1.31-4.el8.x86_64 requires teamd = 1.31-4.el8, but none of the providers can be installed
    - conflicting requests
    - nothing provides libjansson.so.4(libjansson.so.4)(64bit) needed by teamd-1.31-4.el8.x86_64

This could be hacked around, for example by having libteamd-devel not
depend on any teamd package. Instead, just drop it. It's gone.

Arguable, CentOS 8 Stream should be reasonably close (in terms of
versions of gcc, glibc, glib) so we don't miss too much.

[1] https://copr.fedorainfracloud.org/coprs/nmstate/nm-build-deps/

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1793
2023-11-15 10:52:53 +01:00
Thomas Haller 1c187166c2
nm-in-container: install ausearch/audit package
This is now required by NM-ci. Install it.
2023-11-15 10:41:11 +01:00
Thomas Haller cce8106a37
libnm: fix broken assertion in _permissions_user_allowed()
Fixes: b2b2823c53 ('core: avoid getpwuid() unless necessary in permission check')
2023-11-15 10:41:11 +01:00
Thomas Haller 36629ae710
libnm: rename "ethtool.eee" property to "ethtool.eee-enabled"
There are various properties related to EEE, that we might want to add
support for in the future (for example, "ethtool.eee-advertise").

Don't use up the base name "eee", instead make it "eee-enabled". All
properties should have different prefixes, and "ethtool.eee" would be a
prefix of "ethtool.eee-advertise".

Also, the #define is already called NM_ETHTOOL_OPTNAME_EEE_ENABLED. This
also should be consistent.

Rename.

Fixes: 3165d9a2de ('ethtool: introduce EEE support')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1792
2023-11-15 09:36:29 +01:00
Thomas Haller b853a3021c
cli: merge branch 'th/cli-sort-connected-externally'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1784
2023-11-15 09:35:13 +01:00
Thomas Haller 38ad9e5211
cli: sort nmcli device output by active-connection first
Previously, we first sort by the device's state, then by the active
connection's state. Contrast to `nmcli connection`, which first sorts
by the active connection's state.

It means, the sort order is somewhat different. Fix that.

In most cases, that shouldn't make a difference, because the
device's state and the active-connection's state should
correspond. However, it matters as we now treat external activations
different, and that is tied to the active connection.
2023-11-15 09:34:47 +01:00
Thomas Haller a5f9f2fbfc
cli: sort external connections later in nmcli connection|device
EXTERNAL connections are special. Sort them later. This affects output
of `nmcli connection` and `nmcli device`.
2023-11-15 09:34:47 +01:00
Thomas Haller 8ccd1f7bfe
cli: refactor active_connection_get_state_ord()
Additional logic will be added, that makes the switch() approach
more cumbersome. Use a sorted array instead to find the priority.
2023-11-15 09:34:46 +01:00
Thomas Haller 8e1330964d
cli: fix sorting of active connections
CMP() is a confusing pattern. Sure enough, the sort order was wrong, for
example, `nmcli connection` would show

    $ nmcli -f STATE,UUID,DEVICE c
    STATE       UUID                                  DEVICE
    activating  3098c902-c59c-45f4-9e5a-e4cdb79cfe1b  nm-bond
    activated   e4fc23ac-54ab-4b1a-932a-ebed12c96d9b  eth1

("activating" shown before "activated").

With `nmcli device`, we sort with compare_devices(). This first sorts by
device state (with "connected" being sorted first). Only when the device
state is equal, we fallback to nmc_active_connection_cmp().  So with
`nmcli device` we usually get "connected" devices first, and we don't
really notice that there is a problem with nmc_active_connection_cmp().

On the other hand, `nmcli connection` likes to sort first via
nmc_active_connection_cmp(), which gets it wrong. Profiles in
"activating" state are sorted first. That's inconsistent with `nmcli
device`, but it's also not what is intended.

Fix that.

Note the change in the test output. Both eth1 and eth0 are connected to
to the same profile, but one "eth0" the active-connection's state is
DEACTIVATING, while on "eth1" it's ACTIVATED (but both device's states
are "CONNECTED"). That's why "eth1" is now sorted first (as desired).

Fixes: a1b25a47b0 ('cli: rework printing of `nmcli connection` for multiple active connections')
2023-11-15 09:34:46 +01:00
Thomas Haller ca5fb29b7e
client/tests: add checks to "test-client.py"
- test for "-order" option with `nmcli connection show`.

- test for order of activated devices. Optimally, the devices
  should be in activating vs. activated state. I fail to do that,
  the mock implementation is cumbersome to use. It still seems useful
  to have this (maybe it could be improved).
2023-11-15 09:34:45 +01:00
Thomas Haller 1bf97d8b2f
all: merge branch 'th/minmax'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1778
2023-11-15 09:33:31 +01:00
Thomas Haller 21c979eb17
glib: undef MIN()/MAX() to make it unusable (use NM variants)
NM variants:

- evaluate arguments only once
- have a static assertion that the signedness of the argument agrees.

Like MIN()/MAX(), NM_MIN()/NM_MAX() now also evaluate to a constant
expression, if the arguments are already constant. That means, the only
reason why MIN()/MAX() was preferable over NM_MIN()/NM_MAX() is no
longer relevant. Except there are a few places where NM_MIN()/NM_MAX()
cannot be used. In those places use NM_MIN_CONST()/NM_MAX_CONST().
2023-11-15 09:32:22 +01:00
Thomas Haller bee14cf47c
all: use NM_MAX() instead of MAX() 2023-11-15 09:32:21 +01:00
Thomas Haller b4dd83975e
all: use NM_MIN() instead of MIN() 2023-11-15 09:32:20 +01:00
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