Commit graph

30445 commits

Author SHA1 Message Date
Thomas Haller
0634dfd510
platform: avoid struct alignment issue for NMPlatformIP4Address
On m68k we get a static assertion, that NMPlatformIP4Address.address
is not at the same offset as NMPlatformIPAddress.address_ptr.

On most architectures, the bitfields fits in a gap between the fields,
but not on m68k, where integers are 2-byte aligned.
2022-05-19 16:11:34 +02:00
Thomas Haller
835554a4db
glib-aux/tests: fix and extend static assertions for NMIPAddr alignment
On m68k, integers are 2-byte aligned. Hence the assertion was wrong.

What we really want to check, is that NMIPAddr has not a smaller
alignment than in_addr_t and similar.

While at it, also assert the alignment for NMEtherAddr.
2022-05-19 16:08:01 +02:00
Thomas Haller
705e776776
glib-aux: fix static assertion for alignment of NMIPAddr for m68k
On m68k, 32-bit integers are 2-byte aligned, causing the assertion to fail.
Relax the check, it's good enough still.
2022-05-19 13:15:04 +02:00
Ana Cabral
b5829c9ac1 release: bump version to 1.39.5 (development) 2022-05-19 11:17:27 +02:00
Ana Cabral
d5b76a0a14 NEWS: update 2022-05-19 09:21:45 +02:00
Thomas Haller
fd9b7decb0
c-rbtree: re-import git-subtree for 'src/c-rbtree'
git subtree pull --prefix src/c-rbtree git@github.com:c-util/c-rbtree.git main --squash
2022-05-18 12:03:00 +02:00
Thomas Haller
4a4dbf6417 Squashed 'src/c-rbtree/' changes from 9b9713aeb9ec..eb778d39694a
eb778d39694a c-rbtree: fix alignment assertion on m64k

git-subtree-dir: src/c-rbtree
git-subtree-split: eb778d39694a0f3389f2438bbc45fb21685a047d
2022-05-18 12:02:19 +02:00
David Rheinsberg
78831d127f
c-rbtree: fix alignment assertion on m64k
We want to assert that our alignment-guarantees do not exceed the
guarantees of the system-linker or system-allocator on the target
platform. Hence, we check against max_align_t. This is a lower bound,
but not the exact check we actually want. And as it turns out, on m64k
it is too low. Add a static check against 4-byte alignment for m64k as
a workaround.

Reported-by: Michael Biebl
Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>

https://github.com/c-util/c-rbtree/issues/9
eb778d3969
2022-05-18 11:59:06 +02:00
Beniamino Galvani
9bc7278da3 device: don't require a hardware address for DHCPv6
DHCPv4 requires a hardware address, while DHCPv6 does not.

Anyway, the DHCP manager already checks that an address is available
when needed, so drop the check here.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1228
2022-05-17 18:14:11 +02:00
Thomas Haller
3e5f0a0fa2
libnm/trivial: adjust code comment
clang-format likes to indent the comment, at the location where it was.
Move it.
2022-05-17 13:10:41 +02:00
Thomas Haller
76a0696882
dhcp: merge branch 'th/dhcp-cleanup-1'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1219
2022-05-16 21:45:09 +02:00
Thomas Haller
7f943f5fa6
dhcp: merge nm_dhcp_client_start_ip4() and nm_dhcp_client_start_ip6() implementations
As almost always, there is a point in keeping IPv4 and IPv6 implementations
similar. Behave different where there is an actual difference, at the bottom
of the stack.
2022-05-16 16:37:45 +02:00
Thomas Haller
2b8aeba06d
dhcp: move code in "nm-dhcp-client.c" (2) 2022-05-16 16:37:44 +02:00
Thomas Haller
ea13cff76c
dhcp: assert that resources are freed in NMDhcpClient.dispose() 2022-05-16 16:37:44 +02:00
Thomas Haller
600467b96f
dhcp: minor cleanup in config_init() 2022-05-16 16:37:43 +02:00
Thomas Haller
f0ec297739
dhcp: use packed strv array for NMDhcpClientConfig.reject_servers
No need to do it otherwise.
2022-05-16 16:37:43 +02:00
Thomas Haller
892cde1436
dhcp: remove assertion in nm_dhcp_client_handle_event()
Technically, g_warn_if_reached() may not be an assertion, according to
glib. However, there is G_DEBUG=fatal-warnings and we want to run with
that.

So this is an assertion to us. Also, logging to stderr/stdout is not a
useful thing to the daemon. Don't do this. Especially, since it depends
on user provided (untrusted) input.
2022-05-16 16:37:42 +02:00
Thomas Haller
9097679aad
dhcp: move code in nm_dhcp_client_handle_event() 2022-05-16 16:37:42 +02:00
Thomas Haller
802f343d9f
dhcp: drop NMDhcpState enum
It's unused now.
2022-05-16 16:37:41 +02:00
Thomas Haller
97e65e4b50
dhcp: rename/refactor nm_dhcp_client_set_state() to be notifications
Optimally we want stateless, pure code. Obviously, NMDhcpClient needs to
keep state to know what it's doing. However, we should well encapsulate
the state inside NMDhcpClient, and only accept events/notifications that
mutate the internal state according to certain rules.

Having a function public set_state(self, new_state) means that other
components (subclasses of NMDhcpClient) can directly mangle the state.
That means, you no longer need to only reason about the internal state
of NMDhcpClient (and the events/notifications/state-changes that it
implements). You also need to reason that other components take part of
maintaining that internal state.

Rename nm_dhcp_client_set_state() to nm_dhcp_client_notify(). Also, add
a new enum NMDhcpClientEventType with notification/event types.

In practice, this is only renaming. But naming is important, because it
suggests the reader how to think about the code.
2022-05-16 16:37:41 +02:00
Thomas Haller
9761e38f7e
dhcp: fix handling of NM_DHCP_STATE_NOOP
The "noop" state is almost unused, however, nm_dhcp_set_state()
has a check "if (new_state >= NM_DHCP_STATE_TIMEOUT)", so the order
of the NOOP state matters.

Fix that by reordering.

Also, just return right away from NOOP.
2022-05-16 16:37:41 +02:00
Thomas Haller
f102051a29
dhcp: drop most of NMDhcpState usage from nm_dhcp_client_handle_event()
NMDhcpState is very tied to events from dhclient. But most of these
states we don't care about, and NMDhcpClient definitely should abstract
and hide them.

We should repurpose NMDhcpState to simpler state. For that, first drop
the state from nm_dhcp_client_handle_event().

This is only the first step (which arguably makes the code more
complicated, because reason_to_state() gets spread out and the logic
happens more than once). That will be addressed next.
2022-05-16 16:37:40 +02:00
Thomas Haller
70cbf3dc1e
dhcp/trivial: add comment about nm_dhcp_utils_merge_new_dhcp6_lease() 2022-05-16 16:37:40 +02:00
Thomas Haller
8d121b17b5
dhcp: move code in "nm-dhcp-client.c"
So that it makes more sense, related parts are closer together.
2022-05-16 16:34:32 +02:00
Thomas Haller
1093e66776
dhcp: minor code cleanups in "nm-dhcp-client.c" 2022-05-16 16:34:32 +02:00
Thomas Haller
c8542a5d50
dhcp: use GSource for watching child process instead of numeric source id 2022-05-16 16:34:31 +02:00
Thomas Haller
98f7081db2
dhcp: minor cleanup in maybe_add_option()
- return early to avoid nested block.
- use NM_STR_HAS_PREFIX() over g_str_has_prefix(), because that
  can be inlined and only accepts a C literal as prefix argument.
2022-05-16 16:34:31 +02:00
Thomas Haller
cb2ab420a2
dhcp: don't assert against untrusted data in maybe_add_option() 2022-05-16 16:34:31 +02:00
Thomas Haller
668d8050a5
dhcp: cleanup bytearray_variant_to_string()
- the code comment was unclear/wrong. If something comes from an environment
  variables it is *NOT* UTF-8 safe. Also, we convert all non-ASCII characters,
  not only non UTF-8 characters.

- as we already convert the string to ASCII, the check whether it's UTF-8
  is bogus.

- using GString is unnecessary.
2022-05-16 16:34:31 +02:00
Thomas Haller
9b9c07530c
dhcp: cleanup reason_to_state() in "nm-dhcp-client.c"
- use NM_IN_STRSET_ASCII_CASE().
- don't use else block after we return.
- don't accept the "iface" argument just for logging. The caller
  can do the logging, if they wish.
2022-05-16 16:32:22 +02:00
Thomas Haller
222f404928
glib-aux: add nm_g_bytes_ref() helper
g_bytes_ref() does not accept NULL. But doing so can be convenient,
add a helper for that.

Note that g_bytes_unref() does accept NULL, so there is no corresponding
helper.
2022-05-16 16:32:22 +02:00
Thomas Haller
7d1a9b898d
glib-aux/trivial: fix typo in code comment 2022-05-16 16:32:21 +02:00
Thomas Haller
a859cee560
contrib: fix /etc/motd for "nm-in-container.sh" 2022-05-16 16:32:21 +02:00
Thomas Haller
0ca6aaab32
contrib: don't use "Z" specifier for mounting base directory in "nm-in-container.sh"
It seems unnecessary, and can cause failure.
2022-05-16 16:32:21 +02:00
Thomas Haller
56e1f0d290
contrib: ignore error installing behave_html_formatter in container
Yes, this is currently broken. *sigh*. Ignore any failure.
2022-05-16 16:32:08 +02:00
Thomas Haller
a5a4aea2e6
wifi: support "802-1x.phase1-auth-flags=tls-allow-unsafe-renegotiation" flag
For details, read the linked sources.

This requires a new supplicant option, but it seems that supplicant
will silently ignore unrecognized options.

https://bugzilla.redhat.com/show_bug.cgi?id=2072070#c48
https://lists.infradead.org/pipermail/hostap/2022-May/040522.html
https://w1.fi/cgit/hostap/commit/?id=566ce69a8d0e64093309cbde80235aa522fbf84e

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1218
2022-05-16 12:09:11 +02:00
Thomas Haller
fc05880558
dhcp: merge branch 'bg/perf1-debug-dhcp'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager-ci/-/merge_requests/1042
2022-05-16 09:57:41 +02:00
Beniamino Galvani
7a3774f62d dhcp: log messages about invalid DHCP options
Log messages when invalid DHCP options are found. For example:

  <info> dhcp4 (eth0): error parsing DHCP option 6 (domain_name_servers): address 0.0.0.0 is ignored
  <info> dhcp4 (eth0): error parsing DHCP option 12 (host_name): '.example.com' is not a valid DNS domain
  <info> dhcp4 (eth0): error parsing DHCP option 26 (interface_mtu): value 60 is smaller than 68

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1225
2022-05-16 09:49:06 +02:00
Thomas Haller
e2476b1063
release: bump version to 1.39.4 (development) 2022-05-16 09:44:50 +02:00
Yuri Chornoivan
d9d72c6ea1
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1226
2022-05-16 09:00:01 +02:00
Thomas Haller
7062de9219
build/meson: use "rename" directive for installing nmcli bash completion
Otherwise, `ninja -C build uninstall` tries to delete "nmcli-completion",
when the file got renamed to "nmcli".

We depend on meson 0.47.2 already.
2022-05-13 16:15:18 +02:00
Thomas Haller
d4d001c771
build/meson: honor prefix for dbus_conf_dir
Otherwise, we will try to install "src/nm-dispatcher/nm-dispatcher.conf"
to "/usr/share/dbus-1/system.d", which is not correct, when we want a separate
prefix.
2022-05-13 15:46:55 +02:00
Thomas Haller
5704730a6c
release: bump version to 1.38.0 2022-05-13 11:13:34 +02:00
Thomas Haller
3c1e2afaa9
NEWS: update 2022-05-13 11:12:41 +02:00
Thomas Haller
921dadf158
libnm: merge branch 'th/libnm-infiniband-fixes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1223

(cherry picked from commit 3a69aa50b8)
2022-05-12 15:56:56 +02:00
Thomas Haller
3bfde56239
libnm: reject infiniband.p-key set to 0, 0x8000
Kernel does not allow this ([1], [2]).

Usually tightening the verification is a break of API. But in this case,
no user had a working configuration that is breaking. At worst, they
had a broken profile that no longer loads.

We also filter those from _infiniband_add_add_or_delete(), since [3].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/infiniband/ulp/ipoib/ipoib_main.c?id=f443e374ae131c168a065ea1748feac6b2e76613#n2394
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/infiniband/ulp/ipoib/ipoib_vlan.c?id=f443e374ae131c168a065ea1748feac6b2e76613#n116
[3] eab817d34a

(cherry picked from commit 7012b9001a)
2022-05-12 15:56:56 +02:00
Thomas Haller
d476851ee7
libnm: fix crash validating infiniband profiles for interface-name
A virtual infiniband profile (with p-key>=0) can also contain a
"connection.interface-name". But it is required to match the
f"{parent}.{p-key}" format.

However, such a profile can also set "mac_address" instead of "parent".
In that case, the validation code was crashing.

  nmcli connection add type infiniband \
     infiniband.p-key 6 \
     infiniband.mac-address 52:54:00:86:f4:eb:aa:aa:aa:aa:52:54:00:86:f4:eb:aa:aa:aa:aa \
     connection.interface-name aaaa

The crash was introduced by commit 99d898cf1f ('libnm: rework caching
of virtual-iface-name for infiniband setting'). Previously, it would not
have crashed, because we just called

  g_strdup_printf("%s.%04x", priv->parent, priv->p_key)

with a NULL string. It would still not have validated the connection
and passing NULL as string to printf is wrong. But in practice, it
would have worked mostly fine for users.

Fixes: 99d898cf1f ('libnm: rework caching of virtual-iface-name for infiniband setting')
(cherry picked from commit fd5945b408)
2022-05-12 15:56:55 +02:00
Thomas Haller
3a69aa50b8
libnm: merge branch 'th/libnm-infiniband-fixes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1223
2022-05-12 15:53:34 +02:00
Thomas Haller
7012b9001a
libnm: reject infiniband.p-key set to 0, 0x8000
Kernel does not allow this ([1], [2]).

Usually tightening the verification is a break of API. But in this case,
no user had a working configuration that is breaking. At worst, they
had a broken profile that no longer loads.

We also filter those from _infiniband_add_add_or_delete(), since [3].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/infiniband/ulp/ipoib/ipoib_main.c?id=f443e374ae131c168a065ea1748feac6b2e76613#n2394
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/infiniband/ulp/ipoib/ipoib_vlan.c?id=f443e374ae131c168a065ea1748feac6b2e76613#n116
[3] eab817d34a
2022-05-12 15:53:24 +02:00
Thomas Haller
fd5945b408
libnm: fix crash validating infiniband profiles for interface-name
A virtual infiniband profile (with p-key>=0) can also contain a
"connection.interface-name". But it is required to match the
f"{parent}.{p-key}" format.

However, such a profile can also set "mac_address" instead of "parent".
In that case, the validation code was crashing.

  nmcli connection add type infiniband \
     infiniband.p-key 6 \
     infiniband.mac-address 52:54:00:86:f4:eb:aa:aa:aa:aa:52:54:00:86:f4:eb:aa:aa:aa:aa \
     connection.interface-name aaaa

The crash was introduced by commit 99d898cf1f ('libnm: rework caching
of virtual-iface-name for infiniband setting'). Previously, it would not
have crashed, because we just called

  g_strdup_printf("%s.%04x", priv->parent, priv->p_key)

with a NULL string. It would still not have validated the connection
and passing NULL as string to printf is wrong. But in practice, it
would have worked mostly fine for users.

Fixes: 99d898cf1f ('libnm: rework caching of virtual-iface-name for infiniband setting')
2022-05-12 15:52:45 +02:00