Commit graph

31078 commits

Author SHA1 Message Date
Lubomir Rintel
455dbfce6e device: assert we're not waiting on a nil master
If we're notified of a master appearing, make sure there's actually an
ifindex we're waiting for.

Triger an assertion failure if that is not the case, cause that's pretty
messed up.
2022-09-30 23:21:14 +02:00
Lubomir Rintel
bf60fd5acc device: fix recheck slave logic
Since commit a1de6810df ('device: don't ignore external slave removals')
we don't leave device_recheck_slave_status() on un-eslaving (that is
plink->master = 0) early enough.

This results in hooking of NM_MANAGER_DEVICE_IFINDEX_CHANGED even
when we're not actually waiting for any master device to come up,
accompanied by a messed up log entry:

  device[3fa7cfc200be4e84] (portXc): enslaved to unknown device 0 (??)

We also log nonsense when we see any device's link being removed:

  device[a9a4b65bde851bcf] (br0): ifindex: set ifindex 0 (old-l3cfg: 05c6a4409f84d9d2)
  device[45d34e95fb71cce0] (portXa): master br0 with ifindex 0 appeared

We don't do further damage afterwards, so this is purely a cosmetic
annoyance.
2022-09-30 23:21:14 +02:00
Lubomir Rintel
a49aede4b8 checkpoint: move a log message a little lower
It's happier there.
2022-09-30 23:21:14 +02:00
Thomas Haller
c5beec90a8
core: merge branch 'th/mlag-bonding-slb' (part 2)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1385
2022-09-29 14:43:36 +02:00
Thomas Haller
e796a67d6c
firewall: introduce helper function for add/flush/delete nft table command 2022-09-29 14:41:59 +02:00
Thomas Haller
02feefb1df
firewall: fail from nm_firewall_nft_call() on non-zero exit code 2022-09-29 14:41:59 +02:00
Thomas Haller
607a9544cb
device: allow resetting the devip state via nm_device_devip_set_state()
There is no reason to disallow resetting the state.
2022-09-29 14:41:58 +02:00
Thomas Haller
a5f125f8cb
glib-aux: add NM_UTILS_ERROR_COMMAND_FAILED error code 2022-09-29 14:41:58 +02:00
Thomas Haller
95e6ebec66
glib-aux: add nm_utils_get_process_exit_status_desc_buf() helper 2022-09-29 14:41:58 +02:00
Thomas Haller
cd2f8945c9
device: merge branch 'th/mlag-bonding-slb' (part 1)
Small spin-off from merge request with minor cleanups.
Merge early.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1385
2022-09-29 14:40:24 +02:00
Thomas Haller
45eab7b2d8
core: obfuscate pointer value in logging in "nm-active-connection.c" 2022-09-29 14:40:12 +02:00
Thomas Haller
0d764715dd
device: downgrade warning level for logging in nm_device_queue_state()
This is something that does happen.

Is that a bug? If so, this should not be a warning message but an
assertion failure. If it's not a bug, then this does not warrant warning
level, because the user wouldn't know what to do about this and it's
something that occasionally happens.

Granted, the state handling in NMDevice is complex, that it's unclear
whether this indicates a problem or not. In any case, having a warning
does only confuse the user.
2022-09-29 14:40:11 +02:00
Thomas Haller
cf942832c3
device: simplify resource management in nm_device_master_release_slave() 2022-09-29 14:40:11 +02:00
Fernando Fernandez Mancera
07e0ab48d1 veth: drop iface peer check during create_and_realize()
When fetching the parent device, if the system is slow, NetworkManager
can hit a race condition where the property is still NULL. In that case,
NetworkManager should create the veth link.

Checking that the peer device exists, it is type NM_DEVICE_TYPE_VETH and
it have a parent device is enough to know that we can skip the link
creation.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1399

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

Fixes: 4655b7c308 ('veth: fix veth activation on booting')
2022-09-29 10:29:28 +02:00
Thomas Haller
520411623d
glib-aux: fix nm_str_buf_finalize() for cloning buffer
NMStrBuf can also contains NUL characters. We thus cannot use g_strndup(),
which uses strncpy() and truncates at the first NUL.

Fixes: 13d25f9d0b ('glib-aux: add support for starting with stack-allocated buffer in NMStrBuf')
2022-09-29 08:21:00 +02:00
Thomas Haller
786bb9d048
NEWS: update 2022-09-28 21:37:00 +02:00
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