Commit graph

31062 commits

Author SHA1 Message Date
Thomas Haller
a80bb943b1
contrib: add entries to bash_history for nm-in-container.sh script 2022-09-28 18:35:48 +02:00
Thomas Haller
1fa9db0705
contrib: add entries to bash_history for nm-in-container.sh script 2022-09-28 17:51:15 +02:00
Thomas Haller
af85961ea1
all: merge branch 'th/array-find-bsearch'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1397
2022-09-28 13:32:02 +02:00
Thomas Haller
efcc030752
std-aux/trivial: fix typo in code comment 2022-09-28 13:30:45 +02:00
Thomas Haller
f786b05479
glib-aux: swap arguments for nm_array_find_bsearch()
Have "len" before "elem_size". That is consistent with g_qsort_with_data()
and bsearch(), and is also what I would expect.

Note that the previous commit just renamed the function. If a user
of the new, changed API gets backported to an older branch, we will
get a compilation error and note that the arguments need to be adjusted.
2022-09-28 13:30:44 +02:00
Thomas Haller
2953ebccba
glib-aux: rename nm_utils_array_find_binary_search() to nm_array_bsearch()
The "nm_utils_" prefix is just too verbose. Drop it.
Also, Posix has a bsearch function. As this function
is similar, rename it.

Note that currently the arguments are provided in differnt
order from bsearch(). That will be partly addressed next.
That is the main reason for the rename. The next commit
will swap the arguments, so do a rename first to get a compilation
error when backporting a patch that uses the changed API.
2022-09-28 13:30:43 +02:00
Thomas Haller
1c067fe4c6
cli: merge branch 'th/cli-select-by-uuid'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1393
2022-09-28 13:29:07 +02:00
Thomas Haller
046e36b4fd
nmcli: allow selecting profiles by partial UUID
For convenience, allow also to match the UUID by prefix -- if the
"uuid" selector is used.

Note that still, there must be only one candidate found. The "uuid"
selector guarantees to find a unique connection.

  $ nmcli -f connection.uuid,connection.id connection show uuid eb43d80c
2022-09-28 13:27:14 +02:00
Thomas Haller
baf9b38650
nmcli: ensure profiles matching by "uuid","path" selector are unique
The "connection.uuid" and the D-Bus path are supposed to be unique on
D-Bus. Anything else indicates to a bug somewhere.

Still, with `nmcli connection $operation [uuid|path] $arg ...` ensure
that the result is always unique.

In practice, this should make no difference. In the case of an
unexpected duplicate, it seems better to fail and uphold the
guarantee that these selectors give unique results.

Also, next we will accept matching prefixes of the UUID. While partial
match will then be supported, it should still be unique. That is, the
"uuid" specifier should always only yield one result. While this patch
should make not difference in practice today (albeit enforcing something
that should be valid), it will make a difference then.
2022-09-28 13:27:14 +02:00
Beniamino Galvani
9819738607 Revert "device: restart DHCP when the MAC changes"
The commit causes problems with bridges. When a new port is attached
the MAC of the bridge possibly changes and if we restart DHCP the
bridge will get a different IP address.

Revert the change until a better solution to the original problem is
found.

This reverts commit 905adabdba.

https://bugzilla.redhat.com/show_bug.cgi?id=2124443
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1401
2022-09-28 11:31:09 +02:00
Beniamino Galvani
683239166b nmtui: merge branch 'bg/nmtui-8021x'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1314
2022-09-28 09:14:05 +02:00
Beniamino Galvani
48b7ab5636 NEWS: update 2022-09-28 09:09:09 +02:00
Beniamino Galvani
9b396f7cc8 nmtui: add MACsec support 2022-09-28 09:09:09 +02:00
Beniamino Galvani
e45f4b6b9e nmtui: ethernet: support wired 802.1X authentication 2022-09-28 09:09:09 +02:00
Beniamino Galvani
4af8010f02 nmtui: wifi: support WPA Enterprise 2022-09-28 09:09:09 +02:00
Beniamino Galvani
7b067be580 nmtui: introduce Nmt8021xFields
Introduce a new widget to edit 802.1X settings.
2022-09-28 09:09:09 +02:00
Beniamino Galvani
81be1923bc nmtui: add secret-flags support to NmtPasswordFields
The existing option ALWAYS_ASK is never used. Add a more generic
option SHOW_SECRET_FLAGS to display a popup for choosing the secret
flags.
2022-09-28 09:09:09 +02:00
Beniamino Galvani
7f5f2eefca nmtui: add NOT_EMPTY flag to NmtPasswordFields
Add a new flag to return a NULL string when the password is
empty. This is needed when creating the binding to some properties
that don't accept an empty value.
2022-09-28 09:09:09 +02:00
Beniamino Galvani
729d00249e newt: fix validity evaluation for stacks
The default implementation of child_validity_changed() for containers
checks that every child widget is valid. For stacks, the validity
should be determined only by the active child.
2022-09-28 09:09:09 +02:00
Beniamino Galvani
2d7970dd50 nmtui: fix property getter/setter in NmtPasswordFields
The 'show_password' widget is created in _init(), which is before
properties are accessed. We can assume it's always present.
2022-09-28 09:09:09 +02:00
Vojtech Bubela
c32823d5e9
wpa_supplicant: add tls_disable_time_checks flag to phase 1 auth flags
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/978

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1378
2022-09-28 08:53:55 +02:00
Fernando Fernandez Mancera
3871c670ab bond: fix arp_all_target option when arp_interval is disabled
The bond option arp_all_target can be set even if arp_interval is
disabled.

https://bugzilla.redhat.com/show_bug.cgi?id=2123311

Fixes: e064eb9d13 ('bond: use netlink to set bond options')
2022-09-27 13:52:22 +02:00
Yuri Chornoivan
f54c85ef8c
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1391
2022-09-27 08:07:03 +02:00
Beniamino Galvani
e1b8ab90de merge: branch 'bg/rh2101317'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1374
2022-09-26 16:17:45 +02:00
Beniamino Galvani
ed29863645 manager: fix syntax
Remove the commas and use compound literals.
2022-09-26 16:16:42 +02:00
Beniamino Galvani
952f6a3787 core: accept unmanaged parent if it's unrealized
find_parent_device_for_connection() must return a parent device even
if it's unrealized. In fact, callers already handle the unrealized
case; in specific:

 - _internal_activate_device() will try to autoactivate a connection
   on the unrealized parent to realize it;

 - system_create_virtual_device()'s goal is to create a NMDevice
   object, so it doesn't matter whether the parent is realized or not.

Relax the condition about managed-ness, since any unrealized
device is also unmanaged.

This change fixes the following scenario, where all profiles have
autoconnect=no and autoconnect-slaves=yes:

                   vrf0
       -------------^----------------
       |            |               |
       |         bridge0        bond0.4000
       |                            .
     bond0    <......................
    ---^---
    |     |
  veth0  veth1

    ----> = controller
    ....> = VLAN parent

When profiles are added, unrealized devices are created for bond0 and
bridge0, but not for bond0.4000 becase its parent is unrealized. Then
the autoconnect-slaves machinery for vrf0 tries to activate all ports
but fails for bond0.4000 because it can't find a device for it.

https://bugzilla.redhat.com/show_bug.cgi?id=2101317
2022-09-26 16:16:42 +02:00
Thomas Haller
ee0f3f6242
glib-aux: add nm_strv_contains() helper 2022-09-23 15:55:06 +02:00
Thomas Haller
2f8bb7c86a
contrib: handle non-existing files with nm-code-format.sh -u
"-u" calls `git diff -name-only $UPSTREAM` to get a list of files.
However, if $UPSTREAM contains a file that doesn't exist in the current
checkout, we get a non-existing file name and clang-format will fail.

Avoid that, by filtering only files that exist.

Also, pass "--no-renames" option to git-diff.
2022-09-23 15:32:28 +02:00
Thomas Haller
dbd2df3d13
all: use nm_hash_vals()/nm_hash_val() where it's shorter 2022-09-23 15:21:09 +02:00
Thomas Haller
43c3e2b683
glib-aux: add nm_hash_vals() and adjust implementation of nm_hash_update_val(),nm_hash_val()
nm_hash_update_vals() has variadic arguments and accepts (in principle) any
number of arguments. It works by copying the value to a packed struct on
the stack.

nm_hash_update_val() is essentially the same, but accepts only one
argument. Implement nm_hash_update_val() in terms of
nm_hash_update_vals().

Also, add nm_hash_vals(), and adjust nm_hash_val() to be implemented that way.

Maybe we should drop combine the val/vals variants into one, and not
have two variants. We only keep them because both are currently in use.
Also, we have nm_hash_update_valp(), which is useful but can only take one
argument. For naming consistency of nm_hash_update_val(), nm_hash_update_valp()
and nm_hash_update_vals() they are all kept.
2022-09-23 15:18:39 +02:00
Fernando Fernandez Mancera
5a87683b14 policy: fix disposal of devices list
When disposing NMPolicy all the devices in the devices hash-table should
be unregistered and removed from the hash-table.

Fixes: 7e3d090acb ('policy: refactor tracking of registered devices')
2022-09-23 14:46:24 +02:00
Thomas Haller
f094977a86
platform: merge branch 'th/platform-obj-rename-pt1'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1384
2022-09-23 11:45:13 +02:00
Thomas Haller
c43fe3d33d
platform: move NMPlatformIP[46]Address to "nmp-plobj.c"
Later, we should move all such objects. And we should rename
the API to have a unique prefix, like "NMPPlObjIP[4]Address".

This is just a first step that introduces more inconsistencies than it
solves. It will get better afterwards.
2022-09-23 11:43:36 +02:00
Thomas Haller
4366dc6582
platform: add "nmp-base.c" source
"nmp-base.h" really should only contain simple defines like enum types
or #define. As such, it almost does not need a source file.

However, the enum-to-string methods for the enums of "nmp-base.h" need a
place. Add "nmp-base.c" for that.
2022-09-23 11:43:35 +02:00
Thomas Haller
aea053db38
platform: add "nmp-plobj.[hc]"
Our naming in libnm-platform is bad.

We have NMPlatform, which is a cache of objects. Consequently we have
platform methods like nm_platform_get_link().

We also have various other types that share the NMPlatform prefix, like
NMPlatformIP4Address. For those we have nm_platform_ip4_address_to_string().

"methods" of a type should have the same prefix as the type,
and we should not have types that share the same prefix.

Also, "NMPlatformIP4Address" is a long name, and inconsistent with the
strongly related NMPObjectIP4Address.

Add new files to move and rename parts of the platform API.
2022-09-23 11:43:34 +02:00
Thomas Haller
231671fd02
all: add src/nm-compat-headers for patching included system headers
We already have src/linux-headers, where we have complete copies of linux
user space headers. Of course that exists, because we want to use certain
features and don't depend on the installed kernel headers. Which works
well, because kernel user space API is stable, and we anyway want to
support compiling against a newer kernel and run against an older (e.g.
in a container). So having our copy of newer kernel headers is merely
as if we compiled against as newer kernel.

Add "src/nm-compat-headers" which has a similar purpose, but a different
approach. Instead of replacing the included header entirely, include
the system header and patch it with #define.

Use this for "linux/if_addr.h". Of course, the approach here is that we
no longer include <linux/if_addr.h> directly, but instead include
"nm-compat-headers/linux/if_addr.h".
2022-09-23 11:43:33 +02:00
Thomas Haller
dd2e1bc1cd
platform: simplify ifindex-to-string helper
This changes a few places where we might have looked up the ifname in
NMPlatform to only print the ifindex. Since the ifindex is the real identifier,
and the logfile is already full of lines that associate the ifname with the ifindex,
this is fine.
2022-09-23 11:43:33 +02:00
Thomas Haller
a8931585be
platform,glib-aux: move and rename nm_platform_ip4_broadcast_address_create() 2022-09-23 11:43:33 +02:00
Thomas Haller
cc36baa5c7
glib-aux: add nm_str_truncate() helper 2022-09-23 11:43:27 +02:00
Thomas Haller
d1fd6eb53b
libnm: fix API break in "nm-utils.h" for NM_UTILS_INET_ADDRSTRLEN
This is part of public API, and was wrongly renamed during some internal
refactoring.

Reported-by: Eivind Næss <eivnaes@yahoo.com>

Fixes: 08eff4c46e ('glib-aux: rename IP address related helpers from "nm-inet-utils.h"')
2022-09-22 08:24:38 +02:00
Beniamino Galvani
23ce9cff99 libnm-core: allow empty slave-type with a NMSettingBondPort
It is allowed to have a connection with empty connection.slave-type
and a NMSettingBondPort; the property will be set automatically during
normalization if a master is set, otherwise the setting will be removed.

With this change, it becomes possible to remove a port from a bond
from nmcli, turning it into a non-slave connection. Before, this used
to fail with:

  $ nmcli connection add type ethernet ifname test con-name test+ connection.master bond0 connection.slave-type bond
  $ nmcli connection modify test+ connection.master '' connection.slave-type ''
  Error: Failed to modify connection 'test+': connection.slave-type: A connection with a 'bond-port' setting must have the slave-type set to 'bond'

https://bugzilla.redhat.com/show_bug.cgi?id=2126262
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1382

Fixes: 9958510f28 ('bond: add support of queue_id of bond port')
2022-09-21 13:24:14 +02:00
Thomas Haller
6e0ede9d65
contrib: add "nm-code-format.sh -u" parameter
Reformatting the entire source tree takes quite long. For fast
development it's useful to only check the files that changes on the
current checkout.

For that there was already the "-F|--fast" option, but that only
compared the files that changed compared to HEAD^.

What actually would be useful is to check the files that changed on the
current branch, compared to some upstream commit. Add "-u|--upstream"
option to specify the upstream commit (usually "main").

As a special twist,

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

is the same as

  ./contrib/scripts/nm-code-format.sh -u main
2022-09-21 10:22:32 +02:00
Thomas Haller
a939324a78
firewall: merge branch 'th/firewall-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1379
2022-09-21 10:10:02 +02:00
Thomas Haller
b74e2cbfaa
firewall: move logging stdin argument to nft call 2022-09-21 10:08:52 +02:00
Thomas Haller
cfeecbedff
firewall: expose nm_firewall_nft_call() in header file 2022-09-21 10:08:52 +02:00
Thomas Haller
0a0c197916
firewall-utils: move _append() macro to be used by other places 2022-09-21 10:08:51 +02:00
Thomas Haller
dc66fb7d04
firewall/trivial: rename nm_firewall_config_apply() to nm_firewall_config_apply_sync()
Sync/blocking methods are ugly. Their name should highlight this.
Also, we may have an async variant, so we will need the "good" name
for apply() and apply_finish().
2022-09-21 10:08:35 +02:00
Thomas Haller
7362ad6266
firewall: more renaming and splitting _fw_nft_set_shared()
Blocking calls are ugly. Rename those to have a "_sync()" suffix.
Also, split from _fw_nft_set_shared() the part that constructs the
stdin for nft.
2022-09-19 18:51:39 +02:00
Thomas Haller
7ad3fb1956
firewall/trivial: rename nm_firewall_config_new() to nm_firewall_config_new_shared() 2022-09-19 18:51:38 +02:00
Thomas Haller
e185f7966d
firewall/trivial: rename "shared"/"add" argument in firewall utils to "up" 2022-09-19 18:51:37 +02:00