Commit graph

29467 commits

Author SHA1 Message Date
xiangnian 31a12ee344 example: Match more AP security
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1043
2021-12-10 16:49:51 +01:00
Beniamino Galvani 02de04287f device: fix update of the ip-iface property
Before the l3cfg rework, the ip-iface property was exported only for
interfaces with an ifindex, and only in some device states.

Restore the old behavior since it is part of the API. For example,
firewalld uses the property to tell which interfaces have a ifindex.

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

https://bugzilla.redhat.com/show_bug.cgi?id=2026024
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1042
2021-12-09 15:37:44 +01:00
Beniamino Galvani e9ca5583e5 platform: add bpf filter to ignore routes from routing daemons
Routing daemons can add a large amount of routes to the
system. Currently NM receives netlink notifications for all those
routes and exposes them on D-Bus. With many routes, the daemon becomes
increasingly slow and uses a lot of memory.

The rtm_protocol field of the route indicates the source of the
route. From /usr/include/linux/rtnetlink.h, the allowed values are:

  #define RTPROT_UNSPEC          0
  #define RTPROT_REDIRECT        1        /* Route installed by ICMP redirects;
                                             not used by current IPv4 */
  #define RTPROT_KERNEL          2        /* Route installed by kernel */
  #define RTPROT_BOOT            3        /* Route installed during boot */
  #define RTPROT_STATIC          4        /* Route installed by administrator */

  /* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
     they are just passed from user and back as is.
     It will be used by hypothetical multiple routing daemons.
     Note that protocol values should be standardized in order to
     avoid conflicts.
   */

  #define RTPROT_GATED           8        /* Apparently, GateD */
  #define RTPROT_RA              9        /* RDISC/ND router advertisements */
  #define RTPROT_MRT            10        /* Merit MRT */
  #define RTPROT_ZEBRA          11        /* Zebra */
  #define RTPROT_BIRD           12        /* BIRD */
  #define RTPROT_DNROUTED       13        /* DECnet routing daemon */
  #define RTPROT_XORP           14        /* XORP */
  #define RTPROT_NTK            15        /* Netsukuku */
  #define RTPROT_DHCP           16        /* DHCP client */
  #define RTPROT_MROUTED        17        /* Multicast daemon */
  #define RTPROT_KEEPALIVED     18        /* Keepalived daemon */
  #define RTPROT_BABEL          42        /* Babel daemon */
  #define RTPROT_OPENR          99        /* Open Routing (Open/R) Routes */
  #define RTPROT_BGP           186        /* BGP Routes */
  #define RTPROT_ISIS          187        /* ISIS Routes */
  #define RTPROT_OSPF          188        /* OSPF Routes */
  #define RTPROT_RIP           189        /* RIP Routes */
  #define RTPROT_EIGRP         192        /* EIGRP Routes */

Since NM uses only values <= RTPROT_STATIC, plus RTPROT_RA and
RTPROT_DHCP, add a BPF filter to the netlink socket to discard
notifications for other route types.

https://bugzilla.redhat.com/show_bug.cgi?id=1861527
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1038
2021-12-09 13:19:45 +01:00
Lubomir Rintel 42307a6a67 release: bump version to 1.35.2 (development) 2021-12-01 16:46:47 +01:00
Lubomir Rintel 79885656d3 initrd: don't add a connection if there's a connection dir with rd.neednet
Only create a default connection with rd.neednet if we're starting with
a totally blank slate. Otherwise it could be that the user already
included configuration in the initrd and merely wants us to activate it.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/999
2021-12-01 15:13:16 +01:00
Lubomir Rintel af1903fe3f nm-device: prefer manually configured addresses to automatic
This bumps L3_CONFIG_DATA_TYPE_MANUALIP to be the most important address
source; which is what had been the case before NetworkManager/next and
is presumably what the user expects.

It also comes into play for iBFT-booted machines, where iBFT contains a
permanent address (no lifetime data), while DHCP might lease out the
same one. In that case, expiry of the latter could potentially disrupt
connectivity to a vital storage volume.

Fixes: 14962cb414 ('merge: branch 'next''):

https://bugzilla.redhat.com/show_bug.cgi?id=2013921
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1011
2021-12-01 15:04:16 +01:00
Fernando Fernández Mancera 249ab3a5cd merge: branch 'ff/nmcli_editor_wol'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1036
2021-12-01 11:51:18 +00:00
Fernando Fernandez Mancera 624372239e nmcli: fix "remove" command to really remove the property
When using the "remove" command on nmcli edit mode it will reset the
value to the default when no property value is specified. If the
property value is specified it will remove that specific property.

Example:

```
nmcli> set ethernet.wake-on-lan phy
nmcli> print ethernet.wake-on-lan
802-3-ethernet.wake-on-lan: phy, default
nmcli> remove ethernet.wake-on-lan default
nmcli> print ethernet.wake-on-lan
802-3-ethernet.wake-on-lan: phy
nmcli> remove ethernet.wake-on-lan
nmcli> print ethernet.wake-on-lan
802-3-ethernet.wake-on-lan: default
```
2021-12-01 12:08:04 +01:00
Fernando Fernandez Mancera ec14d7df7c nmcli: introduce "add" command to edit mode
This patch introduces "add" command to nmcli edit mode. When using "add"
it will append the value to the ones already set. This is doing the same
thing than the "set" command does right now.

Example:

```
nmcli> add ipv4.addresses 192.168.1.1/24
```
2021-12-01 12:08:04 +01:00
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