Commit graph

29458 commits

Author SHA1 Message Date
Nacho Barrientos
906dbb280d systemd: byte order to host before using the lifetime
I've seen this in `NetworkManager-1.34.0-0.3.el8.x86_64` (latest in CentOS
Stream 8 at the time of writing this message) which does not use the latest
Systemd but probably the code base is the same (see
51f93e00a2).

Before the patch:

```
libsystemd: eth0: DHCPv6 client: T1 expires in 34y 3w 6d 45min 31s
libsystemd: eth0: DHCPv6 client: T2 expires in 54y 5month 3w 3d 23h 20min 35s
```

After the patch:

```
libsystemd: eth0: DHCPv6 client: T1 expires in 3d 7h 58min 3s
libsystemd: eth0: DHCPv6 client: T2 expires in 5d 2h 26min 50s
```

same box (x86_64 system) and same DHCPv6 server.

This regression has likely been introduced by 8a8955507af363c31297bbc5df79852db4ad39d6.

See-also: https://github.com/systemd/systemd/pull/21558

https://bugzilla.redhat.com/show_bug.cgi?id=2027267
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/863
2021-11-30 11:42:40 +01:00
流浪猫
7f517e09d0 po: update and fix Simplified Chinese translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1021
2021-11-30 10:55:49 +01:00
Beniamino Galvani
7f8c8078a1 dhcp: accept IPv4-address options longer than expected
Some DHCP servers send duplicate options, and we concatenate them
according to RFC 3396 section 7. Therefore, it's possible that a
option carrying a IPv4 address has a length > 4.

See also commit 1cbf9d22a5 ('n-dhcp4: accept options that are longer
than requested') which did something similar in the nettools client.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/848
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1034
2021-11-29 10:44:17 +01:00
Beniamino Galvani
9a76b07f74 l3cfg: fix assertion failure
Fix the following assertion failure:

  src/core/nm-l3cfg.c:2636:_l3_acd_data_state_change: assertion failed: (!acd_data->nacd_probe)

When AcdData enters state NM_L3_ACD_ADDR_STATE_READY, the duplicate
address detection procedure completed successfully but the address is
not configured yet on the interface. In the READY state we don't clear
the probe because the same probe can be reused also for defending the
address. Change the assertion.

https://bugzilla.redhat.com/show_bug.cgi?id=2026288
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1035
2021-11-29 10:38:15 +01:00
Beniamino Galvani
6a68008e44 merge: branch 'th/clang-format-13'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1020
2021-11-29 10:32:36 +01:00
Thomas Haller
081510ed94 gitlab-ci: use Fedora 35 as default build target 2021-11-29 09:31:09 +00:00
Thomas Haller
615221a99c format: reformat source tree with clang-format 13.0
We use clang-format for automatic formatting of our source files.
Since clang-format is actively maintained software, the actual
formatting depends on the used version of clang-format. That is
unfortunate and painful, but really unavoidable unless clang-format
would be strictly bug-compatible.

So the version that we must use is from the current Fedora release, which
is also tested by our gitlab-ci. Previously, we were using Fedora 34 with
clang-tools-extra-12.0.1-1.fc34.x86_64.

As Fedora 35 comes along, we need to update our formatting as Fedora 35
comes with version "13.0.0~rc1-1.fc35".
An alternative would be to freeze on version 12, but that has different
problems (like, it's cumbersome to rebuild clang 12 on Fedora 35 and it
would be cumbersome for our developers which are on Fedora 35 to use a
clang that they cannot easily install).

The (differently painful) solution is to reformat from time to time, as we
switch to a new Fedora (and thus clang) version.
Usually we would expect that such a reformatting brings minor changes.
But this time, the changes are huge. That is mentioned in the release
notes [1] as

  Makes PointerAligment: Right working with AlignConsecutiveDeclarations. (Fixes https://llvm.org/PR27353)

[1] https://releases.llvm.org/13.0.0/tools/clang/docs/ReleaseNotes.html#clang-format
2021-11-29 09:31:09 +00:00
Fernando Fernandez Mancera
e44cdc7981 ovsdb: deactivate removed device if does not have a master
When using OVS link aggregation ports, NetworkManager ovsdb is removing
the ports when cleaning it up. If that happens, it should deactivate the
device even if it does not have controller or the state is not
assume/external.

An interface that is port of the OVS bonding can be activated before the
ovsdb clean up, if it is not deactivated then NetworkManager will finish
with a wrong configuration. The 'ovsdb_device_removed()' is already
checking that the device is "ovs-interface" with subtype "system".
2021-11-28 20:34:38 +01:00
Fernando Fernandez Mancera
4549995052 bridge: allow ageing_time option to be zero
If the user wants to disable MAC ageing on the bridge, they need to set
ageing_time to zero.

https://bugzilla.redhat.com/show_bug.cgi?id=1871950
2021-11-26 10:20:01 +01:00
Thomas Haller
5e0764cf8e
nm-sudo: reorder sections in nm-sudo.service unit file
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/938#note_1163013
2021-11-19 11:42:10 +01:00
Thomas Haller
867bef5fe7
man: clarify "configure-and-quit" option in NetworkManager.conf 2021-11-19 11:39:50 +01:00
Thomas Haller
a2b26e26d9
NEWS: update 2021-11-19 11:16:01 +01:00
Thomas Haller
2cd1a22a78
NEWS: drop unstable warning for 1.34 2021-11-19 11:12:50 +01:00
Thomas Haller
b0ac01a06e
NEWS: fix trailing whitespace and use full stop for news entries 2021-11-19 11:12:03 +01:00
Ana Cabral
77d7b8287c release: bump version to 1.35.1 (development) 2021-11-18 18:01:49 +01:00
Beniamino Galvani
4495aa7a4d device: remove an unused variable
Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
2021-11-18 16:55:20 +01:00
Beniamino Galvani
4f52907beb NEWS: update 2021-11-18 16:51:19 +01:00
Beniamino Galvani
14962cb414 merge: branch 'next'
This is a refactor of IP configuration done by NM to make it more
independent from NMDevice.

See these files for more information:
src/core/README.l3cfg.md
src/core/README.next.ip-config.md

https://bugzilla.redhat.com/show_bug.cgi?id=1868254
2021-11-18 16:28:08 +01:00
Beniamino Galvani
2838b1c5e8 core: track force-commit flag for l3cd and platform objects
Problem: if l3cfg commits an address and routes from DHCP, when the
address expires those objects are removed automatically. NM tracks the
objects as missing as if the user removed them. This is to prevent
l3cfg to committing them again. If the lease if renewed, l3cfg should
be allowed to commit those objects again.

Introduce a l3cd flag to indicate that it should be force-committed
once, and propagate this flag to platform objects. In this way, l3cfg
can avoid committing again objects that are removed externally, but it
can commit them when the l3cd changes.

Fixes-test: @bridge_down_to_l2_only
2021-11-18 16:21:35 +01:00
Beniamino Galvani
7f03b0c9ef l3cfg: consider a externally-removed address as ACD-ready
If an address is removed externally, it should be considered ready
from ACD point of view. In this way it can be commit again (for
example, if the DHCP lease is renewed).
2021-11-18 16:21:35 +01:00
Beniamino Galvani
c5f26a546b l3cfg: fix handling of removed addresses
If the address appears after being removed, start defending it instead
of throwing an assertion.
2021-11-18 16:21:34 +01:00
Ana Cabral
fcfa598fc2 device: fix route metric penalty assignment
When a route has the connectivity check enabled and does not have
full connectivity, it should have its route metric penalized,
this way this route will not be preferred over others.

Fixes-test: @per_device_connectivity_check
2021-11-18 16:21:34 +01:00
Wen Liang
8995d44a0b core: compare the DNS configurations before updating DNS
DNS manager always sets `priv->config_changed = TRUE` and overwrites
the "resolv.conf" file. To fix it, compare the new configuration with
the old configuration, if there is no change, skipping the update.

Fixes-test: @ipv4_ignore_resolveconf_with_ignore_auto_dns
Fixes-test: @ipv4_ignore_resolveconf_with_ignore_auto_dns_var1

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1023
2021-11-18 16:21:34 +01:00
Fernando Fernandez Mancera
b85a9cd9df device: set ip_state to PENDING when cleaning up from reapply
When doing a reapply the ip_state must be set as PENDING, if not the
ipdhcp_state won't be extended to ip_state.

In addition, if one of the IP configuration is ready and the other may
fail, then we should consider it ready. The other ip state does not
matter at all, it can be none too.

Fixes-test: @nmcli_device_reapply_routes
2021-11-18 16:21:34 +01:00
Beniamino Galvani
6ac95047ca dhcp: remove old timeout code
There is already the 'no_lease_timeout'.
2021-11-18 16:21:34 +01:00
Beniamino Galvani
bce13b0b2f dhcp: schedule a timeout when starting the client
'no_lease_timeout' is the timeout to get the initial lease and to
renew it once it was lost. It should be scheduled when the client is
started.

Fixes-test: @dhcp4_outages_in_various_situation
2021-11-18 16:21:34 +01:00
Fernando Fernandez Mancera
6b4123db1c l3cfg: do not add dependent routes for non-default routes
When the route is not a default route 0.0.0.0/0, NetworkManager should
not add dependent routes.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-11-18 16:21:34 +01:00
Wen Liang
81ac02ae75 core: clear sticky update flag when unmanaging a device
Sticky update flag forces a commit at UPDATE level after unmanaging
a device. As a result, all the link local addresses will be removed.
To prevent the commit after unmanaging a device, clear sticky update
flag.

Signed-off-by: Wen Liang <liangwen12year@gmail.com>
2021-11-18 16:21:34 +01:00
Beniamino Galvani
655896f75b device: set ipv6 privacy in the the ipmanual l3cd
In this way, the ipv6 privacy setting is committed as soon as the
connection goes up.

Fixes-test: @ipv6_ip6-default_privacy
2021-11-18 16:21:34 +01:00
Beniamino Galvani
3a0eb586b8 device: don't reset addrgenmode for assumed devices
If we reset the addrgenmode, IPv6 addresses are lost.
2021-11-18 16:21:33 +01:00
Beniamino Galvani
cd65351d29 device: fix _dev_addrgenmode6_set()
If addrgenmode=0 is already set, the function should still toggle
disable_ipv6 if needed, to stop the generation of temporary addresses.

Also, it should store the last set value into 'previous_mode_val'.

Fixes-test: @ipv6_keep_external_routes
2021-11-18 16:21:33 +01:00
Beniamino Galvani
bd7b5aa707 device: don't disable IPv6 when NM is managing IPv6
If NM set addrgenmode=none, it's because it manages the IPv6 in user
space. In such case it should never disable IPv6.
2021-11-18 16:21:33 +01:00
Beniamino Galvani
a319193333 device: fix optional 802.1X authentication
If the authentication is optional, we are going to re-enter stage2. Set
the "ready" variable so that we can return success immediately and
skip to stage3.
2021-11-18 16:21:33 +01:00
Beniamino Galvani
de5e1eb9e5 device: don't fail immediately on DHCP expiry
If we had a lease and it expired, don't fail immediately. The client
will try to obtain a new lease and it will send a NO_LEASE_TIMEOUT
event once it fails. Only at that time we should fail.
2021-11-18 16:21:33 +01:00
Fernando Fernandez Mancera
e9bd8b3dac device: fix wrong assignment in ip_state_other comparison
Fixes: 0b05c5adb4b0 ('device: fail when a addr family fails and the other is disabled')
2021-11-18 16:21:33 +01:00
Beniamino Galvani
70676b3d0a l3cfg: set ipv6 token
Fixes-test: @ipv6_token
2021-11-18 16:21:33 +01:00
Beniamino Galvani
d2fc0984a1 l3cd: add ipv6 token 2021-11-18 16:21:33 +01:00
Thomas Haller
682d2c842a core: drop redundant "gateway" variable for NMIPConfig
The "gateway" variable was redundant to best_default_route. It was
somewhat convenient to have, because the best_default_route pointer
might change, but the next hop might still be the same. So it was easy
to track whether it changes.

But it's also redundant information. By relying on best_default_route
alone we have all the information we need.
2021-11-18 16:21:32 +01:00
Thomas Haller
7faeda8351 platform: accept %NULL route as parameter to nm_platform_ip_route_get_gateway()
It's sometimes convenient to accept %NULL and have a "maybe type" like
behavior to propagate the %NULL input of the getter.
2021-11-18 16:21:32 +01:00
Beniamino Galvani
bcf31a9b29 device: fix assertion failure on master carrier change
Fix the following assertion failure:

 "nm_assert(NM_DEVICE_GET_PRIVATE(self)->act_request.obj);"

  0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
  1  __GI_abort () at abort.c:79
  2  g_assertion_message () at gtestutils.c:2533
  3  g_assertion_message_expr () at gtestutils.c:2556
  4  activation_source_invoke_or_schedule (self=0x55b543884610 [NMDeviceBridge], func=0x55b542e8c940 <activate_stage3_ip_config>, do_sync=0) at src/core/devices/nm-device.c:8854
  5  nm_device_set_carrier (self=0x55b543884610 [NMDeviceBridge], carrier=1) at src/core/devices/nm-device.c:6217
  6  device_link_changed (user_data=user_data@entry=0x55b543884610) at src/core/devices/nm-device.c:6479
  7  g_idle_dispatch (source=0x55b5438577d0, callback=0x55b542e95980 <device_link_changed>, user_data=0x55b543884610) at gmain.c:5579
  8  g_main_dispatch (context=0x55b543719bc0) at gmain.c:3193
  9  g_main_context_dispatch (context=context@entry=0x55b543719bc0) at gmain.c:3873
  10 g_main_context_iterate (context=0x55b543719bc0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3946
2021-11-18 16:21:32 +01:00
Beniamino Galvani
cc3ec40513 device: fail when a addr family fails and the other is disabled
Fixes-test: @ipv4_method_shared_with_already_running_dnsmasq
2021-11-18 16:21:32 +01:00
Beniamino Galvani
8f8e912e3b core: also export 0.0.0.0 as gateway in IP configuration
The IP configuration exported over D-Bus for a device has a "gateway"
property. If the device has a default route without a gateway, before
the L3 rework the gateway used to be exported as "0.0.0.0". That seems
useful to indicate that the device has a default route, but without
a next hop. Restore that behavior.

Fixes-test: @preserve_route_to_generic_device
2021-11-18 16:21:32 +01:00
Beniamino Galvani
c4238620d3 glib-aux: accept NULL addresses in nm_ip_addr_equal()
nm_ether_addr_equal() already accepts NULL addresses and makes a
distinction between NULL and a zero address.

Introduce a similar behavior for nm_ip_addr_equal(), as it's useful in
some cases.
2021-11-18 16:21:32 +01:00
Beniamino Galvani
9380d3c715 device: fix waiting for IPv6 autoconf addresses
When NM is restarted and the previous connection gets assumed,
addresses are already configured; in such case we don't need to wait.
2021-11-18 16:21:32 +01:00
Beniamino Galvani
a2d96a5c2e vlan: preserve external IP changes on parent MAC update
When the parent MAC is updated, a VLAN device also updates its MAC and
then performs a new commit to restore IP configuration. This should
not remove addresses added externally. Change the commit type to
UPDATE.

Fixes-test: @static_route_persists_mac_change
2021-11-18 16:21:32 +01:00
Beniamino Galvani
96850933bb core: ignore external routes when generating connections 2021-11-18 16:21:32 +01:00
Beniamino Galvani
d8d6ecf37a l3cfg: remove event down source on finalize 2021-11-18 16:21:32 +01:00
Beniamino Galvani
8fb8e334b8 device: wait that IPv6 autoconf addresses become non-tentative
Fixes-test: @ipv6_preserve_cached_routes
2021-11-18 16:21:32 +01:00
Beniamino Galvani
98da62642b device: enable IPv6 in ip6_managed_setup()
IPv6 must be enabled when the device enters the DISCONNECTED state.
2021-11-18 16:21:31 +01:00
Beniamino Galvani
b86388bef3 core: avoid stale entries in the DNS manager
When a virtual interface is removed externally, the device is
unrealized and the ifindex is cleared; this also detaches the existing
l3cfg from the device. At this point the l3cd entry for the device
lingers forever in the DNS manager.

Emit a last L3CD_CHANGED so that the old entry gets removed.

Fixes-test: @disconnect_from_pppoe
2021-11-18 16:21:31 +01:00