Commit graph

32803 commits

Author SHA1 Message Date
Thomas Haller
a7a36cde83
cli: limit number of shown addresses/routes in nmcli overview
If you add a large number of addresses/routes, then the output of
`nmcli` is unusable. It also doesn't seem too useful.

Limit the number to show up to 10 addresses and 10 routes.

If there are more than 10 addresses, then print an 11th line with

    inet4 ... N more

Actually, if there are exactly 11 addresses, then don't waste an extra
line to print "1 more". Instead, still print the 11th address. Same for
routes.
2023-11-30 15:38:34 +01:00
Thomas Haller
39d900593b
cli: reuse NMStrBuf in ac_overview()
No need to mix GString and NMStrBuf.
2023-11-30 15:38:34 +01:00
Thomas Haller
6f53f390a2
cli: unifiy handling of IPv4/IPv6 in ac_overview()
As often, the code for IPv4/IPv6 is very similar. It's better to
treat the address family in a similar way.
2023-11-30 15:38:19 +01:00
Thomas Haller
41e3fed381
tests: improve detection of libtool in "run-nm-test.sh"
The user can set "$NMTST_LIBTOOL" to empty or the path to libtool.

If unset, we want to detect it. However, previously we would always
use "$SCRIPT_PATH/../libtool", even if that file doesn't exit. Improve
that.

For example, when running on Ubuntu with the ".gitlab-ci/debian-install.sh"
script, we don't have libtool. Entering such a container and running the
"run-nm-test.sh" script will fail as "$SCRIPT_PATH/../libtool" doesn't
exist.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1800
2023-11-30 15:36:20 +01:00
Thomas Haller
80839291f8
libnm: merge branch 'th/libnm-iptunnel-fwmark'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1797
2023-11-30 15:35:09 +01:00
Thomas Haller
05fa5ba1a9
libnm: implement missing "FwMark" property in NMDeviceIPTunnel 2023-11-30 15:32:26 +01:00
Thomas Haller
b47c94666c
libnm: mark missing "FwMark" for NMDeviceIPTunnel as ignored
This was forgotten to implement. But we cannot just forget about it.
Libnm emits a warning about unknown properties, exactly to catch such
bugs. Properties that are not implemented, must be marked to be ignored.

Next, support for this property will be added. But that introduces new
API, which cannot be backported. Hence, first fix the problem by marking
the property as ignored. This is a backportable change.

  $ LIBNM_CLIENT_DEBUG="warning" G_DEBUG=fatal-warnings nmcli
  (process:270215): nm-WARNING **: 15:22:56.125: libnm-dbus: <warn > nmclient[8094a8c217aae461]: get-managed-objects: [/org/freedesktop/NetworkManager/Devices/5]: ignore unknown property org.freedesktop.NetworkManager.Device.IPTunnel.FwMark
  Trace/breakpoint trap (core dumped)

Fixes: 351c562491 ('devices: support VTI tunnels')
2023-11-30 15:32:22 +01:00
Beniamino Galvani
0f626a5ede release: bump version to 1.45.8 (development) 2023-11-29 14:27:20 +01:00
Íñigo Huguet
02371a18b0 merge: branch 'jv/fix-doc-deps'
build/meson: fix gtkdoc dependencies

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1801
2023-11-24 07:41:08 +00:00
Jan Vaclav
ffb34d2485 build/meson: fix gtkdoc dependencies
This commit fixes the build process for the documentation that was previously
unable to build separately via meson due to a dependency issue.

Previously, trying to build the API documentation via `ninja NetworkManager-doc`
failed due to missing dependencies (for example, `nm-dbus-types.xml` was not built).
I believe this happens due to some different handling of static paths vs. custom_target
by meson in this case.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1801
Fixes: 03637ad8b5 ('build: add initial support for meson build system')
2023-11-24 07:40:44 +00:00
Íñigo Huguet
0d3fce38c2 merge: branch 'ih/readme'
Improve README and similar files, add anonymize-logs.py

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1772
2023-11-24 07:40:21 +00:00
Íñigo Huguet
5481ba1568 Add more detailed explanations for users, contributors and maintainers
README.md:

As this document is mainly for normal users, and in Gitlab it's
displayed by default, it's the main entry point to get information when
someone get into the repo, either via web or cloned.

Added explanations about how to install and use NM and how to find the
documentation for users. Added brief info about how to report issues
and ask for help, with links to CONTRIBUTING.md to get more details.

Added brief link for potential contributors to read CONTRIBUTING.md.
People not familiar with open source projects might not be aware of it.

Deleted the "moved to freedesktop" message. After 15 years, people might
know yet.

Added brief explanation about the free software license.

CONTRIBUTING.md:

Added a link to the list of all communication channels, only mailing
list and IRC were listed.

Added detailed explanation about how to report issues and attach logs.
It also references the new tool anonymize-logs.py.

Added brief guidelines about how to start contributing choosing issues
from the tracker.

Fixed some small formatting issues and added a reference to nm-in-vm,
fixing the link to nm-in-container too.

MAINTAINERS.md:

Added explanation about how to triage and properly label the issues.
This is basically based on the kind-of-workflow that we already have,
but maybe it's a good time to check that it's correct or to propose
small changes (so, please propose changes in review).
2023-11-24 07:40:08 +00:00
Íñigo Huguet
69ceee1a0b contrib: new script to anonymize logs
Script to do some anonymization to NetworkManager logs. It does
very basic stuff so it shouldn't be trusted without manually
reviewing the logs, but it can still be useful to replace lot
of potentially sensitive data.

What it masks by default:
- MAC addresses
- Public IP addresses
- Hostnames detected from `hostname` command and some known
  log messages from NM.
- Hostnames ending in some common domains such as .com or .org
- Hostnames specified via --hostname argument

What it can mask but it doesn't by default:
- Private IPs

Options like --show-macs and --hide-private-ips can override the default
behaviour.

Note that masking IP addresses can make difficult to analyze routing
problems, and trying to be smart analyzing the defined routes from the
logs or from `ip route` can lead to even worse results. Because of this,
if routing problems need to be analyzed, --show-public-ips need to be
passed.
2023-11-24 07:40:08 +00:00
Thomas Haller
0431fee765
libnm: merge branch 'th/libnm-strv-props-3'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1794
2023-11-24 08:21:07 +01:00
Thomas Haller
cf0b482f93
libnm: implement "{ipv4,ipv6}.dns-options" as direct STRV property
"nm_sett_info_propert_type_direct_strv" is the way, now STRV properties
should be implemented. Adjust the "dns-options" property..
2023-11-23 17:19:10 +01:00
Thomas Haller
9f4cd6b03f
libnm: add option for direct STRV properties to preseve/distinguish empty arrays
For most strv or string properties, we cannot distinguish between
NULL/unset/default and empty.

It would be difficult to enter in nmcli or grasp how it differs. There
are probably many bugs, where we accept empty strings, and fail to
handle them correctly.

Anyway. For most strv arrays, and empty array and NULL/unset/default are
treated the same. That means, g_object_get() tends to always return NULL
(never an empty strv array) and g_object_set() of an empty strv array
will internally leave the GArray at NULL.

For a few properties, there is a difference. See "ipv[46].dns-options".
See also "clear_emptyunset_fcn" hook in libnm-setting.

Add a way to handle such strv properties with the "direct" mechanism.
2023-11-23 17:18:32 +01:00
Thomas Haller
189bddc99b
libnm: handle empty strv array same as NULL for compare/to-dbus
For now, our "direct" strv properties cannot distinguish between
NULL/unset/default and empty.

Adjust the to-dbus() and compare() hooks to honor that.
2023-11-23 17:17:52 +01:00
Thomas Haller
563fad718c
glib-aux: refactor nm_strvarray_get_strv*() and nm_strvarray_set_strv*() helpers
Unfortunately, there are several possibilities how to handle NULL and
empty arrays. Therefore we have different variants.

Clean this up, and add a way to preserve whether the array is empty
(previous variants could not distinguish that).

Functions are also renamed, so that if you backport a user of the new
API, you'll get a compiler error if this patch is missing.

Also, nm_strvarray_get_strv_notnull() no longer takes a pointer to a
"GArray*". Previously, it used that to fake an empty strv array. Now
this returns NM_STRV_EMPTY_CC().
2023-11-23 17:17:52 +01:00
Thomas Haller
e48fc3ee3e
glib-aux: add "const" to arguments of nm_strvarray_*() helpers 2023-11-23 17:17:51 +01:00
Thomas Haller
3f8431f069
libnm: refactor "ipv6" argument of _nm_utils_dns_option_validate()
_nm_utils_dns_option_validate() allows specifying the address family,
and filters based on that. Note that all options are valid for IPv6,
but some are not valid for IPv4.

It's not obvious, that such filtering is only performed if
"option_descs" argument is provied. Otherwise, the "ipv6" argument is
ignored.

Regardless, it's also confusing to have a boolean "ipv6". When most
callers don't want a filtering based on the address family. They
actually don't want any filtering at all, as they don't pass an
"option_descs". At the same time passing a TRUE/FALSE "ipv6" is
redundant and ignored. It should be possible, to explicitly not select
an address family (as it's ignored anyway).

Instead, make the "gboolean ipv6" argument an "int addr_family".
Selecting AF_UNSPEC means clearly to accept any address family.
2023-11-23 17:17:51 +01:00
Thomas Haller
405a2fa166
libnm/tests: add more tests about dns-options in NMSettingIPConfig 2023-11-23 17:17:51 +01:00
Thomas Haller
9f1d4b650c
valgrind: add valgrind suppression for memmove() overlap
This valgrind error is raised by Ubuntu 23:10, with valgrind 1:3.21.0-0ubuntu1 and
glibc 2.38-1ubuntu6:

  ==141967== Source and destination overlap in memcpy_chk(0x1ffefffe98, 0x1ffefffe92, 8)
  ==141967==    at 0x4851042: __memcpy_chk (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==141967==    by 0x502A9CC: memmove (string_fortified.h:36)
  ==141967==    by 0x502A9CC: inet_pton6 (inet_pton.c:226)
  ==141967==    by 0x502A9CC: __inet_pton_length (inet_pton.c:56)
  ==141967==    by 0x502A9CC: inet_pton (inet_pton.c:69)
  ==141967==    by 0x114FA3: nmtst_inet6_from_string_p (nm-test-utils.h:1764)
  ==141967==    by 0x114FA3: _nmtst_assert_ip6_address (nm-test-utils.h:1856)
  ==141967==    by 0x114FA3: test_stable_privacy (test-utils.c:26)
  ==141967==    by 0x4DEC85D: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7800.0)
  ==141967==    by 0x4DEC78A: ??? (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7800.0)
  ==141967==    by 0x4DECD2A: g_test_run_suite (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7800.0)
  ==141967==    by 0x4DECE07: g_test_run (in /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7800.0)
  ==141967==    by 0x4F070CF: (below main) (libc_start_call_main.h:58)
  ==141967==
  {
     <insert_a_suppression_name_here>
     Memcheck:Overlap
     fun:__memcpy_chk
     fun:memmove
     fun:inet_pton6
     fun:__inet_pton_length
     fun:inet_pton
     fun:nmtst_inet6_from_string_p
     fun:_nmtst_assert_ip6_address
     fun:test_stable_privacy
     obj:/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7800.0
     obj:/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.7800.0
     fun:g_test_run_suite
     fun:g_test_run
     fun:(below main)
  }

This is because memmove() can call __memcpy_chk(), which triggers the
false positive in valgrind.

It probably affects other places too, but for us it's sufficient to
restrict the valgrind suppression to calls from inet_pton(). This
suppression will probably break with LTO enabled.

See-also: https://bugs.kde.org/show_bug.cgi?id=402833

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1802
2023-11-22 13:27:24 +01:00
Thomas Haller
a6e085b3e8
clang-format: rework "nm-code-format-container.sh" script
Instead of doing the broken `podman run` and `podman start` approach,
build an image ("nm-code-format:f38"), cache it, and use it to run
"nm-code-format.sh" via `podman run`. We should build and keep a
container image, not a container.

The benefit is that this allows to hand over the command line arguments
to "nm-code-format.sh". In particular the "-u" and "-F" options, which
are life savers.

This means,

  $ contrib/scripts/nm-code-format-container.sh -u

works.

Try also

  $ contrib/scripts/nm-code-format-container.sh -h

which tells you that you are running inside the container, and how to
delete/renew the container image.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1798
2023-11-22 13:25:04 +01:00
Wen Liang
21a6d7a0b6 device: change port deactivation reason upon user-request controller deactivation
When connection down is explicitly called on the controller, the port
connection should also be deactivated with the reason user-requested,
otherwise any following connection update on the controller profile
will unblock the port connection and unnessarily make the port to
autoconnet again.

Fixes: 645a1bb0ef ('core: unblock autoconnect when master profile changes')
https://gitlab.freedesktop.org/NetworkManager/NetworkManager-ci/-/merge_requests/1568
2023-11-21 20:01:12 -05:00
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