Commit graph

26461 commits

Author SHA1 Message Date
Thomas Haller
b5c563329a
l3cfg: notify NML3Cfg about NMPlatform changes in an idle handler
We need to react to platform changes. Also, we usually want to delay the
reaction to an idle handler.

Instead of subscribing each NML3Cfg instance itself to platform changes,
let only NMNetns do that. The goal is of course that each platform event
only needs to notify the NML3Cfg instance, which collects the events and
schedules them on the idle handler.
2020-07-23 15:29:25 +02:00
Thomas Haller
ea1f0fc0a6
device: let NMDevice track a NML3Cfg instance for each ifindex 2020-07-23 15:29:25 +02:00
Thomas Haller
88d057978d
core: add "nm-l3cfg.[hc]" 2020-07-23 15:29:24 +02:00
Thomas Haller
d32074e2b6
device: simplify device_ip_link_changed() for setting ip_iface
_ip_iface_update() only had one caller. The code is simpler to
understand by inlining it.

Also, it is relevant where and how we set ip_iface_ and ip_ifindex_
fields. Keep the places few and easily understandable.
2020-07-23 15:29:24 +02:00
Thomas Haller
5c273efb36
core: use nm_utils_parse_inaddr_prefix_bin() in nm_utils_ip_route_attribute_to_platform()
We already have an implementation for parsing an address/plen string.
Use it.
2020-07-23 15:29:24 +02:00
Thomas Haller
4127c88ad2
core: move _nm_ip_config_merge_route_attributes() to "NetworkManagerUtils.c"
and rename to nm_utils_ip_route_attribute_to_platform(). The function is independent
from NMIP4Config. We also will use it outside of NMIP4Config. Also, "NetworkManagerUtils.c"
already has similar functions that parse libnm structures to internal structures.
2020-07-23 15:29:24 +02:00
Thomas Haller
348d721b3f
core: use nmp_object_ip_route_is_best_defaut_route() in NMIP4Config 2020-07-23 15:29:24 +02:00
Thomas Haller
3f771c55ac
core: use nmp_object_ref_set() instead of _nm_ip_config_best_default_route_set()
_nm_ip_config_best_default_route_set() doesn't really do anything
special. Use the generic helper function for the same job.

Also because NMIP4Config in the current form will be replaced by
something else, and this code needs to change.
2020-07-23 15:29:24 +02:00
Thomas Haller
84d93315d8
platform: add nmp_object_ip_route_is_best_defaut_route() helper 2020-07-23 15:29:24 +02:00
Thomas Haller
d4b7a3c27e
platform: add nmp_object_ref_set() helper 2020-07-23 15:29:24 +02:00
Thomas Haller
04be1dbd80
platform: add NMP_OBJECT_GET_ADDR_FAMILY() helper 2020-07-23 15:29:23 +02:00
Thomas Haller
bc3439d14f
platform: add nmp_object_link_get_ifname() helper 2020-07-23 15:29:23 +02:00
Thomas Haller
fb6e9795b7
shared: add nm_g_array_append_new() helper 2020-07-23 15:29:23 +02:00
Thomas Haller
99296d4c6c
shared: add nm_strv_ptrarray_ensure() and nm_strv_ptrarray_find_first() helpers 2020-07-23 15:29:23 +02:00
Thomas Haller
7ae8100d7a
shared: add NM_IS_IPv4() macro
This is of course trivial. However, we use this macro at several places
as and index into an array of length 2, to lookup either the IPv4 or
IPv6 element. As such, this MUST return 0 or 1. This promise is what the
macro should convey.
2020-07-23 15:29:23 +02:00
Thomas Haller
56a0aa06ac
shared: move addr-family helpers to "nm-std-aux.h"
Handling address families is something we do all over the place.
Move some simple helper code to "nm-std-aux.h".
2020-07-23 15:29:23 +02:00
Thomas Haller
97770bc7a8
shared: add nm_g_object_ref_set_take() helper macro 2020-07-23 15:29:23 +02:00
Thomas Haller
ace515e697
shared: add nm_hash_obfuscated_ptr_str() helper 2020-07-23 15:29:23 +02:00
Thomas Haller
1e870c675d
shared: avoid heap allocation for temporary string in nm_utils_parse_inaddr_prefix_bin() 2020-07-23 15:29:22 +02:00
Thomas Haller
e9b84221de
device: emit rx-bytes/tx-bytes change notification together
This also groups the PropertiesChanged signal on D-Bus.
2020-07-23 15:29:22 +02:00
Thomas Haller
abce548222
shared: don't freeze in nm_gobject_notify_together() unless necessary
nm_gobject_notify_together() is supposed to emit one or more property changed
notifications, but with freezing (and thawing) the notifications.

Also, we want to allow the user to pass PROP_0, for skipping emitions.
The point is code like

  nm_gobject_notify_together (obj,
                              PROP_FOO,
                              bar_changed ? PROP_BAR : PROP_0);

Optimize the code to only freeze/thaw the notifications, if we are
actually notifying more than one properties.
2020-07-23 15:29:19 +02:00
Beniamino Galvani
e6acf64859 libnm-core: support 'clsact' qdisc
The 'clsact' qdisc is similar to 'ingress' but supports both ingress
and egress [1]. It uses the same handle as 'ingress' and has two child
classes :fff2 (ingress) and :fff3 (egress) on which filters can be
attached.

With clsact, for example, it becomes possible to do port mirroring
with a single qdisc:

  nmcli connection modify mirror +tc.qdisc "clsact"
  nmcli connection modify mirror +tc.tfilter
    "parent ffff:fff3 matchall action mirred egress mirror dev dummy1"
  nmcli connection modify mirror +tc.tfilter
    "parent ffff:fff2 matchall action mirred egress mirror dev dummy1"

instead of two (ingress + i.e. prio). We don't support yet the
symbolic names 'ingress' and 'egress' for :fff2 and :fff3 in the
filter.

See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1436535

[1] https://lwn.net/Articles/671458/
2020-07-23 14:12:02 +02:00
Thomas Haller
2a1bac6b8a
core: fix selecting of best-default-route to consider only unicast routes
Fixes: 5d0d13f570 ('platform: add support for local routes')
2020-07-21 18:13:45 +02:00
Thomas Haller
5035687a7b
core: only expose "type unicast" routes on D-Bus
Currently, we would not mark non-unicast routes with their type, so they
would wrongly appear as unicast routes in the D-Bus API.

That is wrong. For now, just hide them.

Fixes: 5d0d13f570 ('platform: add support for local routes')
2020-07-21 13:52:26 +02:00
Charlie Getzen
e7d2ea95ba
man: update nmcli.xml wording
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/582
2020-07-21 09:14:16 +02:00
Beniamino Galvani
116c49fceb merge: branch 'bg/sleep-unmanaged-rh1855563'
https://bugzilla.redhat.com/show_bug.cgi?id=1855563
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/580
2020-07-21 09:01:09 +02:00
Beniamino Galvani
725fed01cf policy: block connection from autoconnect in case of failed dependency
A connection that fails due to dependency-failed is not able to
reconnect until the master connection activates again; when this
happens, the master clears the blocked reason for all its slaves in
activate_slave_connections() and tries to reconnect them. For this to
work, the slave should be marked as blocked when it fails with
dependency-failed.
2020-07-21 09:00:53 +02:00
Beniamino Galvani
fe2d93980b manager: fix race condition when resuming from sleep
If the device state change (to disconnected or unmanaged) triggered by
a sleep event happens after the wake, the devices becomes wrongly
unmanaged and it's necessary to manually manage it again, or restart
NM.

During the wake event we should disconnect the device_sleep_cb()
callback for all devices because we don't want to react to state
changes anymore; in particular we don't need to detect when the device
becomes disconnected to unmanage it.
2020-07-21 09:00:52 +02:00
Thomas Haller
e73bd2cf5f
cloud-setup: always replace addresses, routes and rules in _nmc_mangle_connection()
If the list of addresses, routes and rules is empty, we still want to mangle
the applied connection, to also have an empty list.

nm-cloud-setup has certain expectations. For example, that the static addresses,
routes and rules of the active connection is entirely under the control of the
tool. For example, so it usually replaces the lists entirely. It also should do
that, if the new list is empty.

Maybe, one day there could be more complex merging strategies, where the user could
also add static addresses, routes, or rules to the profile, and nm-cloud-setup
would preserve them. However, that is not implemented, nor is it clear how exactly
that would work.
2020-07-20 19:02:57 +02:00
Thomas Haller
6f29ed9f3f
device: fix setting %NULL iface in nm_device_update_from_platform_link()
Fixes: f004e7b1a7 ('device: mark ifindex/iface fields of NMDevicePrivate as const')
2020-07-20 16:11:48 +02:00
Thomas Haller
cb4fb0ac06
core: use nm_streq*() instead of strcmp() in "nm-device.c" and "nm-manager.c" 2020-07-20 13:55:22 +02:00
Thomas Haller
f004e7b1a7
device: mark ifindex/iface fields of NMDevicePrivate as const
"nm-device.c" is large and complicated. It's hard to find relevant places
that modify the ifindex,ip_ifindex,iface,ip_iface fields.

Mark them as const, to make that easier.
2020-07-19 12:38:17 +02:00
Thomas Haller
3f140afdfc
all: add trailing semicolon to NM_DEFINE_SINGLETON_REGISTER() 2020-07-19 12:15:41 +02:00
Thomas Haller
ba42189bb9
all: add trailing semicolon to NM_UTILS_LOOKUP_DEFINE()/NM_GOBJECT_PROPERTIES_DEFINE*() 2020-07-19 12:12:58 +02:00
Thomas Haller
b17e3cf707
all: add trailing semicolon to NM_AUTO_DEFINE_FCN_*() uses 2020-07-19 12:01:56 +02:00
Thomas Haller
8bd2673484
shared: add _NM_DUMMY_STRUCT_FOR_TRAILING_SEMICOLON define
Will be used next.
2020-07-19 11:37:23 +02:00
Thomas Haller
e4877b9ca2
shared: make nm_utils_strdup_reset() self-assignment safe
There is no need to write code that has such trivial flaws.

  val = g_strdup ("aaaa");
  nm_utils_strdup_reset (&val, &val[1]);
2020-07-19 11:31:17 +02:00
Beniamino Galvani
74a36168bb po: RHEL 8.3 translations - fr,ja,zh-CN 2020-07-17 15:59:09 +02:00
Beniamino Galvani
0911d2a4ee core: fix check on master active-connection failure
The previous check was never satisfied, as the device is assigned to
the active-connection and realized early. Instead, check the
master_ready flag, which tells if the master is ready and, therefore,
if the slave has already been added to the master.

Before this commit, in some cases a device didn't detect that the
master failed and kept waiting forever.

https://bugzilla.redhat.com/show_bug.cgi?id=1845018
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/568
2020-07-17 08:56:28 +02:00
Thomas Haller
3e475e5cd1
contrib/rpm: prefer keyfile settings plugin from Fedora 33 and newer
This change is for Fedora 33 and newer. For now, also enable it for RHEL
9 and newer, but it must still be decided whether that will be done
there as well.

https://mail.gnome.org/archives/networkmanager-list/2020-May/msg00002.html
https://fedoraproject.org/wiki/Changes/NetworkManager_keyfile_instead_of_ifcfg_rh
https://lists.fedoraproject.org/archives/list/devel-announce@lists.fedoraproject.org/thread/OLOU27DAON2TYGTAVZ35GZE2BEIN42U3/
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/OLOU27DAON2TYGTAVZ35GZE2BEIN42U3/
https://pagure.io/fesco/issue/2432

https://bugzilla.redhat.com/show_bug.cgi?id=1857391
2020-07-16 12:28:03 +02:00
Beniamino Galvani
26e97fcd0d team: perform cleanup immediately when connecting to teamd fails
When NM fails to connect to teamd during an activation, it sets the
device state to FAILED. Eventually the device will become DISCONNECTED
and will call the ->deactivate() method that will perform the cleanup
of timers, teamd process and teamdctl instance.

However, in this way, when the device is DISCONNECTED timers are still
armed and can be triggered in the wrong state. Instead, perform the
cleanup immediately on failure.

https://bugzilla.redhat.com/show_bug.cgi?id=1856723
2020-07-16 09:36:26 +02:00
Thomas Haller
e2fba6c4b3
libnm: trace log the call and the completion event for D-Bus methods 2020-07-15 12:39:50 +02:00
Thomas Haller
16d5dff596
libnm: support "stdout" flag for LIBNM_CLIENT_DEBUG for logging to stdout
Trace logging from libnm is verbose. So, by default we print trace
messages to stderr. However, that means that messages printed to stdout
are not in sync with the trace logging.

That means, if the libnm application prints messages to stdout, and
you'd like to correlate them with trace messages, it is difficult.

Add an option to allow printing trace messages to stdout.

  $ LIBNM_CLIENT_DEBUG=trace,stdout nmcli

Possibly redirecting stderr to stdout might also work around the
ordering issue. However, it's not entirely clear how buffering of
the file streams affects this.
2020-07-15 11:53:20 +02:00
Thomas Haller
39264bdb13
libnm: add trace logging for D-Bus calls
libnm-dbus: <trace> [394618.09943] nmclient[97de7f355f14dfa9]: call D-Bus method on :1.17: /org/freedesktop/NetworkManager/Settings/17, org.freedesktop.NetworkManager.Settings.Connection.GetSettings -> (a{sa{sv}}) (())
2020-07-15 11:20:47 +02:00
Antonio Cardace
1b1a764445
core: merge branch 'ac/vrf_local_route_fix'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/579
2020-07-15 11:00:28 +02:00
Antonio Cardace
d342af1925
core: fix generation of dependent local routes for VRFs
When using VRF devices we must pre-generate dependent local
routes in the VRF's table otherwise they will be incorrectly added
to the local table instead.

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

Fixes: a199cd2a7d ('core: add dependent local routes configured by kernel')
2020-07-15 10:57:49 +02:00
Thomas Haller
f0a39b517e
bond: avoid setting "active_slave" option without interface enslaved
Kernel will reject setting "active_slave", if the interface is not enslaved or not
up. We already handle that by setting the option whenever we enslave an interface.
However, we also must not set it initially, otherwise we get an ugly error log message:

    NetworkManager[939]: <debug> [1594709143.7459] platform-linux: sysctl: setting net:/sys/class/net/bond99/bonding/active_slave to eth1 (current value is )
    NetworkManager[939]: <error> [1594709143.7459] platform-linux: sysctl: failed to set bonding/active_slave to eth1: (22) Invalid argument
    NetworkManager[939]: <warn>  [1594709143.7460] device (bond99): failed to set bonding attribute active_slave to eth1
    ...
    kernel: bond99: (slave eth1): Device is not bonding slave
    kernel: bond99: option active_slave: invalid value (eth1)

See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1856640

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/577
2020-07-14 19:13:39 +02:00
Sayed Shah
e3cd3b73ed
cloud-setup: don't require delimiter in 'nmcs_utils_hwaddr_normalize'
Azure gives MAC address without delimiter. So, make the normalize function
more liberal so that it can accept this format.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/576
2020-07-14 19:10:29 +02:00
Thomas Haller
aa4cb0e5eb
contrib: improve code comments to release.sh scripts 2020-07-13 23:54:34 +02:00
Thomas Haller
7b14686ae2
release: bump version to 1.27.1 (development) 2020-07-13 23:40:48 +02:00