Commit graph

30141 commits

Author SHA1 Message Date
Thomas Haller
257221d198
core: change the priority order in static "ipv6.addresses"
The order of addresses matters. For "ipv4.addresses", the list
contains the primary address first. For "ipv6.addresses", the
order was reverted. This was also documented behavior.

The previous patch just changed behavior with respect to relative order
of static IPv6 addresses and autoconf6/DHCPv6. As we seem in the mood
for changing behavior, here is another one.

Now the addresses are interpreted in an order consistent with IPv4 and
how one might expect: preferred addresses first.

(cherry picked from commit 3d6b6aa317)
2022-05-03 12:18:35 +02:00
Thomas Haller
171d70bbf7
core: change order/priority of static IPv6 addresses relative to autoconf6/DHCPv6
The order of addresses can matter for source address selection.
This is described in RFC 6724 section 5, but if the rules don't
determine a clear winner, the order matters.

Change the relative order of IPv6 addresses. Previously, we would prefer
autoconf6, over DHCPv6, over manual addresses. Now that got reverted
to make more sense and be consistent with IPv4.
Also, if we had multiple autoconf6 addresses (received at different
moments in time), then previously a newly received address would be
added with highest priority. Now, the older address will be preferred
and that order will be enforced (this can be a problem, see (*) below).

For IPv4, it's all simple and sensible. When we add addresses in kernel
via netlink, the first address (of a subnet) becomes the primary.
Note that we only control the order of addresses of the same subnet.
The addresses in ipv4.addresses" are sorted with primary address first.
In the same way is the order for addresses in NML3ConfigData and for
@known_addresses in nm_platform_ip_address_sync(), all primary-first.
Also, manual addresses are sorted with higher priority compared to DHCPv4
addresses (at least since NetworkManager 1.36). That means the way how we
merge NML3ConfigData makes sense (nm_l3_config_data_merge()) because we first
merge the static configuration, then the DHCPv4 configuration, where we just
append the lower priority DHCPv4 addresses.

For IPv6, the address priority is messed up. On netlink/kernel, the last added
address becomes the preferred one (we thus need to add them in the order of
lowest priority first). Consequently and historically, the IPv6 addresses in
@known_addresses parameter to nm_platform_ip_address_sync() were
lowest priority first. And so they were tracked in NML3ConfigData
and in the profile ("ipv6.addresses"). That is confusing.
Also, we usually want to merge NML3ConfigData with different priorities
(e.g. static configuration from the profile before autoconf6/DHCPv6),
as we do with IPv4. However, since internally IPv6 addresses are tracked in
reverse order, it means later NML3ConfigData would be appended and get effectively
a higher priority. That means, autoconf6 addresses were preferred over DHCPv6 and
over manual "ipv6.addresses", respectively. That seems undesirable and inconsistent
with IPv4. Change that. This is a change in behavior.

Note that changing the order of addresses means to remove and re-add
them in the right (inverse) order, with lease important first. This
means, when we add a new address with lower priority, we need to remove
all higher priority addresses temporarily, before readding them. That
is a problem(*).

Note that in the profile, "ipv6.addresses" is still tracked in reverse
order. This did not change, but might change later.

(cherry picked from commit 4a548423b9)
2022-05-03 12:18:33 +02:00
Thomas Haller
f3a84483f7
platform: merge branch 'th/platform-address-order' (part 2)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1168

(cherry picked from commit 0119d56dca)
2022-05-03 12:18:30 +02:00
Thomas Haller
0180a9fca5
glib-aux: add assertions for valid prefix length
(cherry picked from commit 9ce4a16523)
2022-05-03 12:18:28 +02:00
Thomas Haller
fee1d627e9
glib-aux/tests: avoid invalid prefix length in test_platform_ip_address_pretty_sort_cmp()
Next we are going to assert that the prefix length is valid.
The test needs to have valid prefix lengths too. Adjust.

(cherry picked from commit a850e438a7)
2022-05-03 12:18:26 +02:00
Thomas Haller
fb6e912810
glib-aux: use uint32 type for prefix length parameter
Of course, the prefix length cannot be larger than 32 or 128.
But as C does implicit conversions, a buggy prefix length can
lead to a (wrongly) valid prefix length.

Make the type uint32, to prevent that (at least for common cases,
unless you pass a huge 64 bit integer).

(cherry picked from commit 0cf9db42d4)
2022-05-03 12:18:24 +02:00
Thomas Haller
e5fa1a30c2
glib-aux: move nm_utils_ip4_address_clear_host_address() to header so it can be inlined
(cherry picked from commit b5a06dedd4)
2022-05-03 12:18:22 +02:00
Thomas Haller
04d982e278
glib-aux: move ip address utils in "nm-shared-utils.h" header
Some were duplicated. Drop those.

Some function were in an order where they required forward declarations.
Reorder.

(cherry picked from commit d7990b359b)
2022-05-03 12:18:20 +02:00
Thomas Haller
09832c5639
platform: use nm_utils_ip4_address_clear_host_address()
We have this util function, presumably because it's good to have it.
Use it.

(cherry picked from commit 3a545fd041)
2022-05-03 12:18:18 +02:00
Thomas Haller
57065cc50d
platform: guard logging statements with check whether logging is enabled
(cherry picked from commit 4fc25d523a)
2022-05-03 12:18:17 +02:00
Thomas Haller
3b56f33aa2
glib-aux: assert that nm_utils_to_string_buffer_init() does not use the global buffer
For convenience, most to-string methods call nm_utils_to_string_buffer_init().
This allows to omit the string buffer and use a global (thread-local)
buffer.

That "convenience" seems error prone. Start drop it.

Start by adding a g_return_if_reached() assertion to catch the cases
that use it.

(cherry picked from commit 27752bfd5b)
2022-05-03 12:18:15 +02:00
Thomas Haller
14b920d3cf
all: avoid using global string buffer for to-string methods
These string functions allow to omit the string buffer. This is for
convenience, to use a global (thread-local) buffer. I think that is
error prone and we should drop that "convenience" feature.

At various places, pass a stack allocated buffer.

(cherry picked from commit b87afac8e8)
2022-05-03 12:18:13 +02:00
Thomas Haller
c21034f494
all: use "NM_UTILS_TO_STRING_BUFFER_SIZE" macro
(cherry picked from commit 02a8d21e4e)
2022-05-03 12:18:12 +02:00
Thomas Haller
e13c2426c8
all: add "NM_UTILS_TO_STRING_BUFFER_SIZE" macro
I want to get rid of "_nm_utils_to_string_buffer" (or at least, limit
and control its use). Currently it's used all over the place only
to get the size of it. Add a define instead.

(cherry picked from commit 36e709c021)
2022-05-03 12:18:11 +02:00
Thomas Haller
429540a6b7
platform: avoid unnecessary configuration of IP address in nm_platform_ip_address_sync()
We call sync many times. Often there is nothing to update. Check the
cache first, before (re) adding it.

Note that many addresses have a limited lifetime, that is, a lifetime
that keeps counting down with seconds granularity. For those (common)
cases we will only avoid the call to kernel if there are two syncs
within less than a second.

(cherry picked from commit 528a63d9cc)
2022-05-03 12:18:10 +02:00
Thomas Haller
aa764f5fcc
platform: add nm_platform_ip_address_get() helper
(cherry picked from commit a815212214)
2022-05-03 12:18:09 +02:00
Thomas Haller
07c4b3ec71
platform: avoid duplicated code in _nmp_object_stackinit_from_type()
(cherry picked from commit 3bd5d2bca9)
2022-05-03 12:18:09 +02:00
Thomas Haller
e38dac5226
platform: rename local variable in nm_platform_ip_address_sync()
(cherry picked from commit 31299473cd)
2022-05-03 12:18:08 +02:00
Thomas Haller
1f05866821
platform: make "idx" argument in _addr_array_clean_expired() mandatory
There is only one caller of _addr_array_clean_expired(), and it always
provides the "idx" pointer.

(cherry picked from commit de9f174d51)
2022-05-03 12:18:08 +02:00
Thomas Haller
2e6d45cb4e
platform: add ascending/descending functions for ip6_address_scope_cmp*()
It seems easier to read, than passing a boolean parameter.

(cherry picked from commit 305f11069f)
2022-05-03 12:18:07 +02:00
Thomas Haller
e9d3ba66df
platform: allocate result array when needed in nm_platform_ip_{address,route}_get_prune_list()
It is rather unlikely, that we call this function with no existing
routes/addresses. Hence, usually this does not safe an allocation
of the GPtrArray.

However, it's slightly less code and makes more sense this way
(instead of checking afterwards, whether the array is empty and
destroy it).

(cherry picked from commit 6bc9b73c55)
2022-05-03 12:18:07 +02:00
Thomas Haller
d361bfc945
platform: add logging statements to nm_platform_ip_address_sync() for printf() debugging
The code is disabled at compile time. It's only useful for printf
debugging to modify the source to get more logging.

(cherry picked from commit fcb4033a81)
2022-05-03 12:18:07 +02:00
Thomas Haller
032757a02d
trivial: fix code format
(cherry picked from commit 0ddc664526)
2022-05-03 10:28:52 +02:00
Fernando Fernandez Mancera
a494c00901 l3cfg: drop NM_L3_CFG_COMMIT_TYPE_ASSUME and assume_config_once
ASSUME is causing more troubles than benefits it provides. This patch is
dropping NM_L3_CFG_COMMIT_TYPE_ASSUME and assume_config_once. NM3LCfg
will commit as if the sys-iface-state is MANAGED.

This patch is part of the effort to remove ASSUME from NetworkManager.
After ASSUME is dropped when starting NetworkManager it will take full
control of the interface, re-configuring it. The interface will be
managed from the start instead of assumed and then managed.

This will solve the situations where an interface is half-up and then a
restart happens. When NetworkManager is back it won't add the missing
addresses (which is what assume does) so the interface will fail during
the activation and will require a full activation.

https://bugzilla.redhat.com/show_bug.cgi?id=2050216
https://bugzilla.redhat.com/show_bug.cgi?id=2077605
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1196
(cherry picked from commit bf5927b978)
2022-04-28 12:03:46 +02:00
Thomas Haller
ea6625ce97 platform: add semantic comparison for IP addresses and add "nm_platform_vtable_address"
We already have a comparison of NMPlatformIPXAddress with the modes
"full" and "id". The former is needed to fully compare two addresses,
the latter as identity for tracking addresses in the cache.

In NetworkManager we also use the NMPlatformIP[46]Address structure to
track the addresses we want to configure. When we add them in kernel,
we will later see them in the platform cache. However, some fields
will be slightly different. For example, "addr_source" address will
always be "kernel", because that one is not a field we configure in
kernel. Also, the "n_ifa_flags" probably differ (getting "permanent"
and "secondary" flags).

Add a compare function that can ignore such differences.

Also add nm_platform_vtable_address for accessing the IPv4 and IPv6
methods generically (based on an "IS_IPv4" variable).

(cherry picked from commit ef1b60c061)
2022-04-28 12:03:41 +02:00
Thomas Haller
3a98ecfa0e platform: make NMPlatformVTableAddress struct smaller and pack NMPObjectType
(cherry picked from commit 7c92663f8d)
2022-04-28 12:03:35 +02:00
Thomas Haller
9e40474c71 platform: make "now" timestamp an in/out parameter to nmp_utils_lifetime_get()
nmp_utils_lifetime_get() calculates the lifetime of addresses,
and it bases the result on a "now" timestamp.

If you have two addresses and calculate their expiry, then we want to
base it on top of the same "now" timestamp, meaning, we should
only call nm_utils_get_monotonic_timestamp_sec() once. This is also a
performance optimization. But much more importantly, when we make a
comparison at a certain moment, we need that all sides have the same
understanding of the current timestamp.

But nmp_utils_lifetime_get() does not always require the now timestamp.
And the caller doesn't know, whether it will need it (short of knowing
how nmp_utils_lifetime_get() is implemented). So, make the now parameter
an in/out argument. If we pass in an already valid now timestamp, use
that. Otherwise, fetch the current time and also return it.

(cherry picked from commit deb37401e9)
2022-04-28 12:03:30 +02:00
Thomas Haller
66237888e7 glib-aux: add nm_utils_get_monotonic_timestamp_sec_cached() helper
(cherry picked from commit 3f4586532f)
2022-04-28 12:03:25 +02:00
Thomas Haller
352e8bb865
device: set MTU after attaching bond port
When attaching a bond port, kernel will reset the MTU of the port ([1],
[2]). Configuring a different MTU on the port seems not a sensible
thing for the user to do.

Still, before commit e67ddd826f ('device: commit MTU during stage2')
we would first attach the bond port before setting the MTU. That
changed, and now the MTU set by kernel wins.

Btw, this change in behavior happens because we attach the port in
stage3 (ip-config), which seems an ugly thing to do.

Anyway, fix this by setting the MTU after attaching the ports, but still
in stage3.

It is probably not sensible for the user to configure a different MTU.
Still, if the user requested it by configuration, we should apply it.
Note that NetworkManager has some logic to constrain the MTU based on
the parent/child and controller/port. In many regards however, NetworkManager
does not fully understand or enforce the correct MTU and relies on the
user to configure it correctly. After all, if the user misconfigures the
MTU, the setup will have problems anyway (and in many cases neither
kernel nor NetworkManager could know that the configuration is wrong).

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/bonding/bond_main.c?h=v5.17#n3603
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/bonding/bond_main.c?h=v5.17#n4372

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

Fixes: e67ddd826f ('device: commit MTU during stage2')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1199
(cherry picked from commit 6804c2ba04)
2022-04-27 12:59:34 +02:00
Lubomir Rintel
3b06ee7c4e configure.ac: fix a syntax error
Fixes this error:

  checking whether more special flags are required for pthreads... no
  checking for PTHREAD_PRIO_INHERIT... yes
  ./configure: line 30294: ,as_fn_error: command not found
  checking for a Python interpreter with version >= 3... python
  checking for python... /usr/bin/python

Fixes: 3affccf29b ('tests: fix undefined references to pthread')
(cherry picked from commit a8284b1d3b)
2022-04-21 09:58:56 +02:00
Thomas Haller
29fe4035c1
settings: fix assertion failure in NMSettings' _startup_complete_check()
This probably has no bad effects when building without more-asserts.

  #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
  #1  0x00007f7ead0564a3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
  #2  0x00007f7ead009d06 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
  #3  0x00007f7eacfdc7d3 in __GI_abort () at abort.c:79
  #4  0x00007f7ead1fed4c in g_assertion_message (domain=<optimized out>, file=<optimized out>, line=<optimized out>, func=<optimized out>, message=<optimized out>) at ../glib/gtestutils.c:3065
  #5  0x00007f7ead25f98f in g_assertion_message_expr (domain=0x560964f8b7e9 "nm", file=0x560964f83da8 "src/core/settings/nm-settings.c", line=640, func=0x56096504a390 <__func__.44.lto_priv.1> "_startup_complete_check", expr=<optimized out>) at ../glib/gtestutils.c:3091
  #6  0x0000560964ed710e in _startup_complete_check (self=0x560966d1d030, now_msec=<optimized out>) at src/core/settings/nm-settings.c:640
  #7  0x0000560964ed7d9b in _startup_complete_notify_connection (self=0x560966d1d030, sett_conn=<optimized out>, forget=<optimized out>) at src/core/settings/nm-settings.c:704
  #8  0x0000560964edd070 in _connection_changed_delete (self=0x560966d1d030, storage=<optimized out>, sett_conn=0x560966cedbc0, allow_add_to_no_auto_default=<optimized out>) at src/core/settings/nm-settings.c:1244
  #9  0x0000560964edd948 in _connection_changed_process_one (update_reason=(NM_SETTINGS_CONNECTION_UPDATE_REASON_IGNORE_PERSIST_FAILURE | NM_SETTINGS_CONNECTION_UPDATE_REASON_CLEAR_SYSTEM_SECRETS | NM_SETTINGS_CONNECTION_UPDATE_REASON_UPDATE_NON_SECRET | unknown: 0x5400), override_sett_flags=0, sett_mask=NM_SETTINGS_CONNECTION_INT_FLAGS_NONE, sett_flags=1725440360, allow_add_to_no_auto_default=0, sett_conn_entry=0x560966d1d030, self=<optimized out>) at src/core/settings/nm-settings.c:1294
  #10 _connection_changed_process_all_dirty (self=<optimized out>, allow_add_to_no_auto_default=<optimized out>, sett_flags=<optimized out>, sett_mask=<optimized out>, override_sett_flags=<optimized out>, update_reason=<optimized out>) at src/core/settings/nm-settings.c:1335
  #11 0x0000560964eeb8ec in nm_settings_delete_connection (allow_add_to_no_auto_default=648659760, sett_conn=<optimized out>, self=0x560966d1d030) at src/core/settings/nm-settings.c:2457
  #12 nm_settings_connection_delete (self=<optimized out>, allow_add_to_no_auto_default=648659760) at src/core/settings/nm-settings-connection.c:637
  #13 0x0000560964eebebd in delete_auth_cb (self=0x560966cedbc0, context=0x7f7e9c0170a0, subject=0x560966cc5ed0, error=0x0, data=<optimized out>) at src/core/settings/nm-settings-connection.c:1877
  #14 0x0000560964ec9778 in pk_auth_cb (auth_manager=<optimized out>, auth_call_id=<optimized out>, is_authorized=1, is_challenge=<optimized out>, auth_error=<optimized out>, user_data=0x560966e16980) at src/core/settings/nm-settings-connection.c:1262
  #15 0x0000560964db9a28 in _call_id_invoke_callback (error=0x0, is_challenge=0, is_authorized=1, call_id=0x560966ddeb00) at src/core/nm-auth-manager.c:180
  #16 _call_on_idle (user_data=user_data@entry=0x560966ddeb00) at src/core/nm-auth-manager.c:284
  #17 0x00007f7ead23111b in g_idle_dispatch (source=0x560966e50190, callback=0x560964db9900 <_call_on_idle>, user_data=0x560966ddeb00) at ../glib/gmain.c:5848
  #18 0x00007f7ead234d4f in g_main_dispatch (context=0x560966cd1e20) at ../glib/gmain.c:3337
  #19 g_main_context_dispatch (context=0x560966cd1e20) at ../glib/gmain.c:4055
  #20 0x00007f7ead289608 in g_main_context_iterate.constprop.0 (context=0x560966cd1e20, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4131
  #21 0x00007f7ead234463 in g_main_loop_run (loop=0x560966caf010) at ../glib/gmain.c:4329
  #22 0x0000560964cb7515 in main (argc=<optimized out>, argv=<optimized out>) at src/core/main.c:509

Fixes: 3df662f534 ('settings: rework wait-device-timeout handling and consider device compatibility')
(cherry picked from commit 9046975a81)
2022-04-20 14:16:12 +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
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
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
谢致邦 (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
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
Thomas Haller
c1682b2556
connectivity: handle "NoNameServers" resolved error and don't callback to system resolver
No need to try further. The verdict is clear.

From the log:

  <debug> [1649424031.1507] connectivity: (wlan0,IPv4,427) can't resolve a name via systemd-resolved: GDBus.Error:org.freedesktop.resolve1.NoNameServers: No appropriate name servers or networks for name found
  <debug> [1649424031.1507] connectivity: (wlan0,IPv4,427) start request to 'http://fedoraproject.org/static/hotspot.txt' (try resolving 'fedoraproject.org' using system resolver)

(cherry picked from commit 5b779c1ab7)
2022-04-08 15:50:35 +02:00
Thomas Haller
64e65d35b3
connectivity: don't clear "concheck.resolve_cancellable" early in systemd_resolved_resolve_cb()
This can lead to a crash. The code might continue to call
system_resolver_resolve(), then it has no more cancellable.
That means, if the task gets cancelled, then the callback
will still return and result in a crash.

There is no need to cancel or clear the cancellable during
normal operation. It will be cleaned up at the end.

This leads to an assertion error (or possibly crash):

  ...
  #6  0x00005584ff461e67 in system_resolver_resolve_cb (source_object=<optimized out>, res=0x5585016b9190, user_data=user_data@entry=0x558501667800) at src/core/nm-connectivity.c:798
  #7  0x00007f348a02419a in g_task_return_now (task=0x5585016b9190) at ../gio/gtask.c:1219
  #8  0x00007f348a0241dd in complete_in_idle_cb (task=task@entry=0x5585016b9190) at ../gio/gtask.c:1233
  #9  0x00007f3489e263eb in g_idle_dispatch (source=0x7f3464001070, callback=0x7f348a0241d0 <complete_in_idle_cb>, user_data=0x5585016b9190) at ../glib/gmain.c:5897
  ...

Fixes: 57d226d3f0 ('connectivity: resolve hostname ourselves to avoid blocking libcurl')
(cherry picked from commit 62b1f9766a)
2022-04-08 15:50:34 +02:00
Beniamino Galvani
a66e054bd6 wifi: disable FT in AP mode
Currently wpa_supplicant doesn't support FT in AP mode. FT-PSK and
FT-EAP are simply not negotiated with the STA. FT-SAE gets negotiated
but then the key derivation is not supported, leading to a
authentication failure.

Even if support for FT in AP mode is introduced in wpa_supplicant in
the future, it will require additional parameters as the nas
identifier and the mobility domain, which are currently not provided
by NM.

Disable all FT key-mgmts in AP mode since they are useless and cause
issues (FT-SAE).

See-also: https://mail.gnome.org/archives/networkmanager-list/2022-March/msg00016.html
See-also: http://lists.infradead.org/pipermail/hostap/2022-April/040352.html

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1184
(cherry picked from commit 82980f7791)
2022-04-08 15:31:44 +02:00
Thomas Haller
2ed877049b
build/autotools: avoid compiler warning generating "NM-1.0.gir"
We passed on the CFLAGS, but they also contain

  "-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40"

which causes compiler warnings:

    GISCAN   src/libnm-client-impl/NM-1.0.gir
  /data/src/NetworkManager/tmp-introspect_17ddrdb/NM-1.0.c: In function ‘dump_object_type’:
  /data/src/NetworkManager/tmp-introspect_17ddrdb/NM-1.0.c:251:13: warning: Not available before 2.70
    251 |   if (G_TYPE_IS_FINAL (type))
        |             ^~~~~~~~~~~~~~~~~
  /data/src/NetworkManager/tmp-introspect_17ddrdb/NM-1.0.c: In function ‘dump_fundamental_type’:
  /data/src/NetworkManager/tmp-introspect_17ddrdb/NM-1.0.c:369:13: warning: Not available before 2.70
    369 |   if (G_TYPE_IS_FINAL (type))
        |             ^~~~~~~~~~~~~~~~~

Filter them out.

See-also: https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/331
(cherry picked from commit 1234e5583a)
2022-04-07 11:56:18 +02:00
Thomas Haller
10b9e07bfc
dhcp: set "src" for DHCPv4 routes
Let's set the "src" (RTA_PREFSRC) of DHCP routes.
This helps with source address selection.

This can matter if the interface also has static addresses
configured.

Systemd-networkd also does this ([1], [2]).

[1] ac2dce5f36
[2] 5b89bff55f/src/network/networkd-dhcp4.c (L395)

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1173
(cherry picked from commit 2dc7a3d9f9)
2022-04-07 10:22:53 +02:00
Thomas Haller
35f27f4511
release: bump version to 1.37.90 (1.38-rc1) 2022-04-06 18:39:01 +02:00
Thomas Haller
8e76b08e1c
NEWS: update 2022-04-06 18:28:06 +02:00