Commit graph

30536 commits

Author SHA1 Message Date
Thomas Haller
eb25c9ecd2
dns/resolved: use nm_utils_hash_to_array_with_buffer() in NMDnsSystemdResolved's update()
We copy the content of the hash table to an array, so that we can sort
the entries and they have a defined order.

We are not only interested in the keys, but the keys and the values.
Hence, use nm_utils_hash_to_array_with_buffer() which gives both at
the same time.
2022-04-15 09:04:29 +02:00
Thomas Haller
51cec67253
dns/resolved: sort dirty interfaces to prune in "nm-dns-systemd-resolved.c"
When we do something where the order makes a visible difference,
we should do it in a consistent way, that does not depend on arbitray
things. Sort the ifindexes from dirty_interfaces hash table.
2022-04-15 09:04:29 +02:00
Thomas Haller
39b68d72d3
dns/resolved: add const to parameters in "nm-dns-systemd-resolved.c" 2022-04-15 09:04:29 +02:00
Thomas Haller
4564adfb53
dns/resolved: minor cleanups in "nm-dns-systemd-resolved.c" 2022-04-15 09:04:29 +02:00
Thomas Haller
a60b971003
dns: add update-pending property to NMDnsManager 2022-04-15 09:04:29 +02:00
Thomas Haller
b7ca08e971
dns: add "update-pending" state to NMDnsPlugin
Theoretically, this should be a GObject property, and not a signal.
But then I'd  also have to implement the get_property() function,
which is more hazzle than necessary. A signal will do nicely.
2022-04-15 09:04:29 +02:00
Thomas Haller
f68230fbe9
dns: call nm_dns_plugin_stop() also for NMDnsSystemdResolved instance
Currently NMDnsSystemdResolved does not implement "stop()". That is
about to change. Make sure to call stop before unreferencing the
instance.
2022-04-15 09:04:29 +02:00
Thomas Haller
0001a2fd0c
dns: fix NMDnsPluginPrivate and drop unused fields
NM_DNS_PLUGIN_GET_PRIVATE() macro was broken. Also NMDnsPluginPrivate
contained unused fields. Fix that.

The private data is unused at the moment, but will be used next.
Hence it is fixed and not removed.
2022-04-15 09:04:28 +02:00
Thomas Haller
068ca09d16
dns: obfuscate pointer value for NMDnsPlugin logging 2022-04-15 09:04:28 +02:00
Thomas Haller
f7b41fc18c
dns: avoid printing pointer value for NMDnsManager logging statements
We avoid printing raw pointer values. Also, in this case this is a
singleton, and we only create one instance of this type.

Note that we would still have printed the pointer instance while
constructing the instances, before setting it as singleton.

Just drop this.
2022-04-15 09:04:28 +02:00
Thomas Haller
bd95a5c0ec
dns: register NMDnsPlugin instance as wait-obj for shutdown
nm_shutdown_wait_obj_register_object() today has no practical effect.
In the future it will block shutdown until the object gets destroyed.
We will want that NMDnsPlugin gets wrapped up during shut down, before
quitting.
2022-04-15 09:04:28 +02:00
Thomas Haller
de926723f0
glib-aux: add nm_utils_hash_to_array() helper
We effectively already have this function, with the name
nm_utils_named_values_from_strdict(). Which is a decent name,
if you have a strdict. But it seems odd to use for other dictionaries.

Instead, add a variant with a different name. Naming is important,
and just to have the better name, the function is effectively duplicated.
2022-04-15 09:04:28 +02:00
Thomas Haller
78aad6cf51
glib-aux: add "name_ptr" union field to NMUtilsNamedValue
NMUtilsNamedValue is a key-value tuple, usually the key is a string
(hence the name "Named").

But this struct is also useful for keys that are not strings.
Add another "name_ptr" union field to access the key that way.

The alternative would be to add another struct, which serves
a very similar purpose though.
2022-04-14 21:31:36 +02:00
Thomas Haller
e05f439ff4
dhcp: merge branch 'th/systemd-no-dhcp4'
https://bugzilla.redhat.com/show_bug.cgi?id=2073067

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1188
2022-04-14 21:22:49 +02:00
Thomas Haller
6150a495c9
dhcp/systemd: drop dhcp4 client (and related files)
This code is now unused.
2022-04-14 14:51:03 +02:00
Thomas Haller
54119d4105
dhcp: drop internal systemd DHCPv4 client
This is long replaced by nettools' n-dhcp4 client.
Drop it.

We still require NMDhcpSystemd for the DHCPv6 client.

Note that "[main].dhcp=systemd" now falls back to the internal client.
But this option was undocumented and internal anyway.
2022-04-14 14:51:02 +02:00
Thomas Haller
b1575e814f
dhcp: don't use systemd's dhcp_lease_load() in nettools' n-dhcp4 ip4_start() 2022-04-14 14:51:02 +02:00
Thomas Haller
c44b49db6f
glib-aux: add nm_parse_env_file() helpers for parsing systemd's env-files
We write lease files for internal DHCP client ("systemd" and "nettools")
in a systemd-specific format. We want to drop systemd code, so we need
to have our own parsing code.

Granted, nettools only writes a single "ADDRESS=" line, so parsing that
would be easy. On the other hand, systemd's parser is not complicated
either (in particular, if we can steal their implementation). Also, it's
a commonly used format in systemd, so having the parser would allow us
to parse similar formats.

Also, we could opt to choose that format, where it makes sense.
2022-04-14 14:51:02 +02:00
Thomas Haller
7df494bc9a
glib-aux: add nm_ascii_is_{whitespace,newline}() helper 2022-04-14 14:51:02 +02:00
Thomas Haller
4b9ea28cd4
tests: improve nmtst_assert_strv() helper macro 2022-04-14 14:51:01 +02:00
Thomas Haller
c20e3a72e2
release: bump version to 1.39.1 (development) 2022-04-14 13:42:16 +02:00
Thomas Haller
6bada7fb9e
contrib/rpm: reorder variable in spec file and set rpm_version
On recent Fedora and RHEL we no longer have differing "rpm_version"
and "real_version". So usually "rpm_version" is just the same as
"real_version".

Update the template spec file to reflect that. For the "build_clean.sh"
script, we anyway always set them both to "__VERSION__".
2022-04-14 12:47:07 +02:00
Thomas Haller
fb5a1fa05e
release: bump version to 1.37.91 (1.38-rc2) (development) 2022-04-14 12:20:36 +02:00
Thomas Haller
6ee8c8de6e
NEWS: update 2022-04-14 12:02:56 +02:00
Thomas Haller
335afba2e6
c-stdaux: re-import git-subtree for 'src/c-stdaux'
git subtree pull --prefix src/c-stdaux git@github.com:c-util/c-stdaux.git main --squash
2022-04-13 12:49:59 +02:00
Thomas Haller
e5b6639624 Squashed 'src/c-stdaux/' changes from 9582a563c25e..f20e1cf2dfb1
f20e1cf2dfb1 build: verify cflags do not contain spaces
5333735eeb74 build: export cflags via declare_dependency()
d050374b1c1a build: export basic CFLAGS

git-subtree-dir: src/c-stdaux
git-subtree-split: f20e1cf2dfb177e77cc946331ed2d2a83169d8b9
2022-04-13 12:49:04 +02:00
Beniamino Galvani
7438218210
n-dhcp4/connection: dynamically allocate the receive buffer
Each connection object includes a 64KiB scratch buffer used for
receiving packets. When many instances of the client are created,
those buffers use a significant amount of memory. For example, 500
clients take ~30MiB of memory constantly reserved only for those
buffers.

Since the buffer is used only in the function and is never passed
outside, a stack allocation would suffice; however, it's not wise to
do such large allocations on the stack; dynamically allocate it.

https://github.com/nettools/n-dhcp4/issues/26
https://github.com/nettools/n-dhcp4/pull/27

64513e31c0
(cherry picked from commit a5a5654f18)
2022-04-13 11:05:12 +02:00
Thomas Haller
a0c92bb9a4
c-stdaux: re-import git-subtree for 'src/c-stdaux'
git subtree pull --prefix src/c-stdaux git@github.com:c-util/c-stdaux.git main --squash
2022-04-13 11:03:41 +02:00
Thomas Haller
5da47deadd Squashed 'src/c-stdaux/' changes from 8652c488b8f1..9582a563c25e
9582a563c25e build: update dependency handling
c1cda3600991 test: remove possible wrong warning in possible unused variable

git-subtree-dir: src/c-stdaux
git-subtree-split: 9582a563c25e75896794a7b32e4d6b0f0bdfa19a
2022-04-13 11:01:09 +02:00
Thomas Haller
2fff437955
n-dhcp4: re-import git-subtree for 'src/n-dhcp4'
git subtree pull --prefix src/n-dhcp4 git@github.com:nettools/n-dhcp4.git master --squash
2022-04-13 10:57:58 +02:00
Thomas Haller
aba56902d1 Squashed 'src/n-dhcp4/' changes from 281f431756e3..64513e31c01a
64513e31c01a connection: dynamically allocate the receive buffer
2b55ae2f0bda merge branch 'bengal:lease-boot-file'
d0f13d174b1a lease: add an accessor for the file name
0c64aedd80bf lease: fix n_dhcp4_client_lease_get_server_identifier()
745ca63afb44 lease: fix typo
b9d907d32ec0 Make n_dhcp4_client_lease_get_basetime publicly visible

git-subtree-dir: src/n-dhcp4
git-subtree-split: 64513e31c01a88db54c89321f89bcc85da27ffc5
2022-04-13 10:57:10 +02:00
Beniamino Galvani
a5a5654f18
n-dhcp4/connection: dynamically allocate the receive buffer
Each connection object includes a 64KiB scratch buffer used for
receiving packets. When many instances of the client are created,
those buffers use a significant amount of memory. For example, 500
clients take ~30MiB of memory constantly reserved only for those
buffers.

Since the buffer is used only in the function and is never passed
outside, a stack allocation would suffice; however, it's not wise to
do such large allocations on the stack; dynamically allocate it.

https://github.com/nettools/n-dhcp4/issues/26
https://github.com/nettools/n-dhcp4/pull/27

64513e31c0
2022-04-13 10:56:50 +02:00
Thomas Haller
0c6d242dc0
dhcp/dhclient: fix setting "src" attribute for certain routes
Fixes: 2dc7a3d9f9 ('dhcp: set "src" for DHCPv4 routes')
(cherry picked from commit 197e73ac7c)
2022-04-13 10:49:04 +02:00
Thomas Haller
197e73ac7c
dhcp/dhclient: fix setting "src" attribute for certain routes
Fixes: 2dc7a3d9f9 ('dhcp: set "src" for DHCPv4 routes')
2022-04-13 10:43:27 +02:00
Thomas Haller
8e5f60dfd3
dhcp/nettools: reword code comment in dhcp4_event_cb()
Also drop the "FIXME" tag. There is nothing to fix here.
2022-04-13 10:27:50 +02:00
Thomas Haller
24dab91a66
glib-aux/trivial: add code comment to nm_str_buf_get_str_unsafe() 2022-04-13 09:25:06 +02:00
Thomas Haller
2c5bacd416
std-aux: add NM_UTILS_GET_NEXT_REALLOC_SIZE_488 define 2022-04-13 09:23:28 +02:00
Thomas Haller
cb98616e02
ndisc/tests: relex check in test_dns_solicit_loop()
Dunno why this happens. Just silence it.

  nm:ERROR:../src/core/ndisc/tests/test-ndisc-fake.c:649:test_dns_solicit_loop: assertion failed (data.counter == 3): (2 == 3)
2022-04-12 18:45:29 +02:00
谢致邦 (XIE Zhibang)
a0988868ba
supplicant: Disable WPA3 transition mode when PMF is set to disabled
According to WPA3_Specification_v3.0 section 2.3, when operating in
WPA3-Personal transition mode an AP:

- shall set MFPC to 1, MFPR to 0.

Therefore, do not operate in WPA3-Personal transition mode when PMF is set to
disabled. This also provides a way to be compatible with some devices that are
not fully compatible with WPA3-Personal transition mode.

Signed-off-by: 谢致邦 (XIE Zhibang) <Yeking@Red54.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1186
(cherry picked from commit b6eb237a27)
2022-04-11 18:56:51 +02:00
谢致邦 (XIE Zhibang)
b6eb237a27
supplicant: Disable WPA3 transition mode when PMF is set to disabled
According to WPA3_Specification_v3.0 section 2.3, when operating in
WPA3-Personal transition mode an AP:

- shall set MFPC to 1, MFPR to 0.

Therefore, do not operate in WPA3-Personal transition mode when PMF is set to
disabled. This also provides a way to be compatible with some devices that are
not fully compatible with WPA3-Personal transition mode.

Signed-off-by: 谢致邦 (XIE Zhibang) <Yeking@Red54.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1186
2022-04-11 18:55:49 +02:00
Thomas Haller
4c67970e4c
platform: log skipped addresses in nm_platform_ip_address_sync()
This is generally useful. Don't only log with more logging.
2022-04-11 11:47:48 +02:00
Thomas Haller
7f427ac4e6
platform: ensure the platform cache is up to date during nm_platform_ip_address_sync()
Since commit 528a63d9cc ('platform: avoid unnecessary configuration of
IP address in nm_platform_ip_address_sync()'), we no longer configure the
IP address if it is in the platform cache. But the cache might not be
up to date. Process any pending netlink events.

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

Fixes: 528a63d9cc ('platform: avoid unnecessary configuration of IP address in nm_platform_ip_address_sync()')
2022-04-11 11:44:02 +02:00
Thomas Haller
0f2708f86a
NEWS: update 2022-04-08 17:53:21 +02:00
Thomas Haller
14052c847c
platform: merge branch 'th/platform-address-order' (part 1)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1168

(cherry picked from commit 8b95693985)
2022-04-08 16:27:02 +02:00
Thomas Haller
0bdb2e97d9
platform: track IPv4 subnets with prefix length in nm_platform_ip_address_sync()
The entire point of the dance in nm_platform_ip_address_sync() is to ensure that
conflicting IPv4 addresses are in their right order, that is, they have
the right primary/secondary flag.

Kernel only sets secondary flags for addresses that are in the same
subnet, and we also only care about the relative order of addresses
that are in the same subnet. In particular, because we rely on kernel's
"secondary" flag to implement this.

But kernel only treads addresses as secondary, if they share the exact
same subnet. For example, 192.168.0.5/24 and 192.168.0.6/25 would not
be treated as primary/secondary but just as unrelated addresses, even if
the address cleared of it's host part is the same.

This means, we must not only hash the network part of the addresses, but
also the prefix length. Implement that, by tracking the full NMPObject.

(cherry picked from commit 619dc2fcab)
2022-04-08 16:27:00 +02:00
Thomas Haller
a8e96e3c4b
platform: move known_subnets variable to inner scope in nm_platform_ip_address_sync()
(cherry picked from commit e1431b43a2)
2022-04-08 16:27:00 +02:00
Thomas Haller
41b56cb2b9
platform: fix undefined behavior for pointer comparison in ip4_addr_subnets_is_plain_address()
Fixes: 2f68a50041 ('platform: fix the order of addition of primary and secondary IPv4 addresses')
(cherry picked from commit 40f22e69c8)
2022-04-08 16:26:59 +02:00
Thomas Haller
8736cc8618
platform: fix returning error from nm_platform_ip_address_sync()
None of the callers really handle the return value of nm_platform_ip_address_sync()
or whether the function encountered problems. What would they anyway do
about that?

For IPv4 we were already ignoring errors to add addresses, but for IPv6 we
aborted. That seems wrong. As the caller does not really handle errors,
I think we should follow through and add all addresses in case of error.

Still, also collect a overall "success" of the function and return it.

(cherry picked from commit cedaa191d4)
2022-04-08 16:26:59 +02:00
Thomas Haller
4c3197b377
platform: fix address order in nm_platform_ip_address_sync()
In the past, nm_platform_ip_address_sync() only had the @known_addresses
argument. We would figure out which addresses to delete and which to preserve,
based on what addresses were known. That means, @known_addresses must have contained
all the addresses we wanted to preserve, even the external ones. That approach
was inherently racy.

Instead, nowadays we have the addresses we want to configure (@known_addresses)
and the addresses we want to delete (@prune_addresses). This started to change in
commit dadfc3abd5 ('platform: allow injecting the list of addresses to prune'),
but only commit 58287cbcc0 ('core: rework IP configuration in NetworkManager using
layer 3 configuration') actually changed to pass separate @prune_addresses argument.

However, the order of IP addresses matters and there is no sensible kernel API
to configure the order (short of adding them in the right order), we still need
to look at all the addresses, check their order, and possibly delete some.
That is, we need to handle addresses we want to delete (@prune_addresses)
but still look at all addresses in platform (@plat_addresses) to check
their order.

Now, first handle @prune_addresses. That's simple. These are just the
addresses we want to delete. Second, get the list of all addresses in
platform (@plat_addresses) and check the order.

Note that if there is an external address that interferes with our
desired order, we will leave it untouched. Thus, such external addresses
might prevent us from getting the order as desired. But that's just
how it is. Don't add addresses outside of NetworkManager to avoid that.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
(cherry picked from commit 80f8e23992)
2022-04-08 16:26:58 +02:00
Thomas Haller
0fc40735ab
platform: add nm_platform_ip_address_delete() helper
(cherry picked from commit a60a262574)
2022-04-08 16:26:58 +02:00