Commit graph

591 commits

Author SHA1 Message Date
Thomas Haller
aeb2426e88
libnm: change default value for "dcb.app-fcoe-mode" property
String properties in libnm's NMSetting really should have NULL as a
default value. The only property that didn't, was "dcb.app-fcoe-mode".

Change the default so that it is also NULL.

Changing a default value is an API change, but in this case probably no
issue. For one, DCB is little used. But also, it's not clear who would
care and notice the change. Also, because previously verify() would reject
a NULL value as invalid. That means, there are no existing, valid profiles
that have this value set to NULL.  We just make NULL the default, and
define that it means the same as "fabric".

Note that when we convert integer properties to D-Bus/GVariant, we often
omit the default value. For string properties, they are serialized as
"s" variant type. As such, NULL cannot be expressed as "s" type, so we
represent NULL by omitting the property. That makes especially sense if
the default value is also NULL. Otherwise, it's rather odd. We change
that, and we will now always express non-NULL value on D-Bus and let
NULL be encoded by omitting the property.
2021-11-04 20:25:18 +01:00
Thomas Haller
38d81cfa89
ifcfg: always read/write KEY_DCB_APP_FCOE_MODE key
The settings plugin is not supposed to normalize the profile. It should
read/write what is, and let NMConnection handle what is valid and what
needs normalization.
2021-11-04 20:25:18 +01:00
Thomas Haller
572ce7b7a7
glib-aux/trivial: rename GBytes helper API
Give a consistent name.

A bit odd are now the names nm_g_bytes_hash() and nm_g_bytes_equal()
as they go together with nm_pg_bytes_hash()/nm_pg_bytes_equal().
But here the problem is more with the naming of "nm_p*_{equal,hash}()"
functions, which probably should be renamed to "nm_*_ptr_{equal,hash}()".
2021-11-04 20:25:18 +01:00
Thomas Haller
ea7ce48c00
trivial: fix code style
Fixes: de6d069dce ('ndisc: send router solicitations before expiry')
2021-11-04 20:23:07 +01:00
Harald van Dijk
58bfcffd59 core: support linking with LLD 13
LLD 13 adds -z start-stop-gc and makes it the default, resulting in:

    CCLD     src/core/NetworkManager-all-sym
  ld.lld: error: undefined symbol: __stop_connection_defaults
  >>> referenced by nm-config.c:0 (src/core/nm-config.c:0)
  >>>               libNetworkManager_la-nm-config.o:(read_config) in archive src/core/.libs/libNetworkManager.a
  >>> referenced by nm-config-data.c:1598 (src/core/nm-config-data.c:1598)
  >>>               libNetworkManager_la-nm-config-data.o:(nm_config_data_get_connection_default) in archive src/core/.libs/libNetworkManager.a
  >>> referenced by nm-config-data.c:0 (src/core/nm-config-data.c:0)
  >>>               libNetworkManager_la-nm-config-data.o:(nm_config_data_get_connection_default) in archive src/core/.libs/libNetworkManager.a

  ld.lld: error: undefined symbol: __start_connection_defaults
  >>> referenced by nm-config.c:0 (src/core/nm-config.c:0)
  >>>               libNetworkManager_la-nm-config.o:(read_config) in archive src/core/.libs/libNetworkManager.a
  >>> referenced by nm-config.c:0 (src/core/nm-config.c:0)
  >>>               libNetworkManager_la-nm-config.o:(read_config) in archive src/core/.libs/libNetworkManager.a
  >>> referenced by nm-config.c:0 (src/core/nm-config.c:0)
  >>>               libNetworkManager_la-nm-config.o:(read_config) in archive src/core/.libs/libNetworkManager.a
  >>> referenced 2 more times
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

Add __attribute__((__retain__)) to prevent GC of the connection
defaults.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1008
2021-11-02 12:42:51 +01:00
Lubomir Rintel
73ac6dfb8a policy: send ip configs to the DNS manager earlier
Don't wait until the device is ACTIVATED -- pass them as soon as they're
valid. They should be applied at the moment the device enters ACTIVATED
state.

https://bugzilla.redhat.com/show_bug.cgi?id=2006677
2021-11-02 12:42:51 +01:00
Lubomir Rintel
5ec8ee47b4 Revert "core: make ActiveConnection emit StateChanged a bit later"
Thomas thinks this is a bad idea and probably is right:
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1000#note_1122853

This reverts commit 4ae846b9c6.
2021-11-02 12:42:51 +01:00
Lubomir Rintel
c6dc7a7ea7 Revert "core: make Device emit StateChanged a bit later"
Thomas thinks this is a bad idea and probably is right:
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1000#note_1122853

This reverts commit c75b7dd893.
2021-11-02 12:42:51 +01:00
Jonas Kümmerlin
de6d069dce ndisc: send router solicitations before expiry
There are routers out in the wild which won't send unsolicited
router advertisements.

In the past, these setups still worked because NetworkManager
used to send router solicitations whenever the half-life of
dns servers and dns domains expired, but this has been changed
in commit 03c6d8280c ('ndisc: don't call solicit_routers()
from clean_dns_*() functions').

We will now schedule router solicitation to be started again
about one minute before advertised entities expire.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/997
2021-11-02 10:32:14 +01:00
Beniamino Galvani
d8186b1253 core: better handle sd-resolved errors when resolving hostnames
If NM tries to resolve a link-local address, systemd-resolved returns
error "org.freedesktop.resolve1.NoNameServers" because those addresses
can only be resolved via other protocols like LLMNR or mDNS.

Previously NM would fall back to spawning the helper, which would ask
again to systemd-resolved via /etc/resolv.conf. In this way, a
synthetic result (or one obtained not from DNS) would be returned.

We must avoid non-DNS results. When systemd-resolved returns an error
that is not a D-Bus one (as MethodNotFound) but is a
"org.fd.resolve1.*" [1], we can assume that systemd-resolved is
running properly and we shall never fall back to spawning the helper.

[1] https://www.freedesktop.org/wiki/Software/systemd/resolved/#commonerrors

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/833
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1006
2021-10-29 16:43:27 +02:00
Lubomir Rintel
4ae846b9c6 core: make ActiveConnection emit StateChanged a bit later
We need to make sure StateChanged goes on the D-Bus only after the
policy is done dealing with the state change internally.

This is done so that we can be sure the DNS changes are committed at the
time "nmcli c up" returns.

https://bugzilla.redhat.com/show_bug.cgi?id=2006677
2021-10-28 13:21:15 +02:00
Lubomir Rintel
c75b7dd893 core: make Device emit StateChanged a bit later
We need to make sure StateChanged goes on the D-Bus only after the
policy is done dealing with the state change internally.

This is done so that we can be sure the DNS changes are committed at the
time "nmcli c up" returns.

https://bugzilla.redhat.com/show_bug.cgi?id=2006677
2021-10-27 15:53:16 +02:00
Fernando Fernandez Mancera
ff9b64c923 core: reload config for active devices
When NetworkManager is reloaded the config from active devices is not
being reloaded properly.

Related: https://bugzilla.redhat.com/1852445

Fixes: 121c58f0c4 ('core: set number of SR-IOV VFs asynchronously')

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-18 09:53:15 +02:00
Thomas Haller
30fa9949e5
l3cfg: fix "maybe-uninitialized" warning in _l3_commit_ndisc_params() 2021-10-17 14:59:31 +02:00
Thomas Haller
5c48c5d5d6
l3cfg: set IPv6 sysctls during NML3Cfg commit 2021-10-17 10:41:32 +02:00
Thomas Haller
4b270448e4
l3cfg: add addr_family parameter to nm_l3cfg_check_ready()
We have "ipv[46].may-fail", which are per-address family. This works
together with nm_l3cfg_check_ready(), where we check whether an
NML3ConfigData is ready. We need to have that check also per-address
family.
2021-10-17 10:41:31 +02:00
Robin Ebert
a2f6cde3eb
core: Save whether SetLinkDNSOverTLS is supported 2021-10-15 10:01:13 +02:00
Robin Ebert
b652202829
ifcfg-rh: add support for connection.dns-over-tls 2021-10-15 10:00:53 +02:00
Robin Ebert
1a98cf1669
core: add support for connection.dns-over-tls 2021-10-15 10:00:31 +02:00
Beniamino Galvani
21782d1fdb core: fix signal emission for device ports
The MASTER property must be emitted on the port; while PORTS and
SLAVES on the controller.

Fixes: 9d2ed74e74 ('core: introduce device::ports property')
2021-10-13 09:38:41 +02:00
Thomas Haller
e81c2baf70
wwan: drop workaround to use GTE DNS servers for PPP
Drop a workaround added by commit a8ca7f537d ('ppp: work around PPP
bug that returns bogus nameservers'), in 2009.

Also drop the second workaround (`if (!num ...`), which was introduced
by commit 294a5e3153 ('modem: substitute known-good nameservers if PPP
doesn't return any (lp:434477)').

I hope this doesn't break something, but it really doesn't seem right in
2021.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/988
2021-10-12 13:24:26 +02:00
Thomas Haller
07d570766f
l3cfg: various fixes and improvments (e.g. add pre-commit hook)
- add "pre-commit" signal.

- fix assertion in nm_l3_config_data_get_ip6_privacy().

- set IPv6 privacy in _init_from_connection_ip() from profile.

- fix leaking "os_zombie_lst" in _obj_state_data_free().

- remove wrong assertion about VRF.

- fix _routes_temporary_not_available_update() to honor only the
  requested object type. Otherwise, we always prune unrelated objects
  too.
2021-10-12 09:37:02 +02:00
Thomas Haller
8b575f7553
l3cfg: add nm_l3cfg_commit_type_clear() helper 2021-10-12 09:18:15 +02:00
Thomas Haller
e0e58fd5bc
dns: fix format string for printing size_t in send_updates()
This in particular breaks i386 builds.

Fixes: 6f663b8f8e ('dns: log about what NMDnsSystemdResolved is doing')
2021-10-11 20:44:52 +02:00
Thomas Haller
544c223557
l3cfg: keep NML3Cfg alive while having a commit scheduled
We might want to schedule a last update and unref the NML3Cfg instance.
We need to make sure that the last update gets processed. Do that by
taking a reference while an idle source is pending.
2021-10-11 13:54:29 +02:00
Fernando Fernandez Mancera
9d2ed74e74 core: introduce device::ports property
The property `PROP_PORTS` should be of type g_param_spec_variant() with
variant 'ao'. This way the variant can be cached.

The deprecated property 'device::slaves' in
'src/core/devices/nm-device.c' must have the same getter-implementation,
returning the same GVariant instance.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-11 09:35:10 +02:00
Thomas Haller
06d448245b
systemd: merge branch systemd into main 2021-10-08 18:04:37 +02:00
Thomas Haller
098a963e42
core: simplify nm_dbus_utils_g_value_set_object_path() 2021-10-07 08:10:05 +02:00
Thomas Haller
c1305dc801
core: in NMNetns use GSource for idle dispatch of platform signal 2021-10-07 08:10:05 +02:00
Thomas Haller
0ee3100ba1
l3cfg: fix nm_l3_config_data_new_clone() for different ifindex 2021-10-04 15:40:15 +02:00
Thomas Haller
25ec8f4451
l3cfg: fix assertion failure in _obj_state_zombie_lst_get_prune_lists()
"nm_assert(_self->priv.p->combined_l3cd_commited)" might fail during deactivate.
At that point the combined/commited config is NULL, but we still have zombies.
2021-09-30 15:10:19 +02:00
Beniamino Galvani
fcfaf78c91
l3cfg: fix dns options in _init_from_connection_ip() 2021-09-30 15:10:18 +02:00
Thomas Haller
5efd3134e4
l3cfg: accept NULL NML3ConfigData for several getters
We often want to be pedantic about not accepting %NULL for getters (or ref,
unref, etc). Often that is also inconvenient, so we would need to write:

  if (l3cd)
      strv = nm_l3_config_data_get_nameservers(l3cd, addr_family, &len);
  else
      len = 0;

(and, make sure that strv does not trigger a maybe-uninitialized warning).

Being pedanic here is more cumbersome than helpful. Accept NULL to return
the sensible default.

Also add nm_l3_config_data_get_dns_priority_or_default() helper which maps
NULL or a missing value to zero. This is also only for convenience for certain
callers.
2021-09-30 15:10:18 +02:00
Thomas Haller
17fd1e4708
l3cfg/trivial: explain commit-type in code comments 2021-09-29 09:26:43 +02:00
Beniamino Galvani
8a06d66d0e
l3cfg: fix nm_l3cfg_commit_type_register() to set commit_type and add debug logging
Co-authored-by: Thomas Haller <thaller@redhat.com>
2021-09-28 22:18:13 +02:00
Thomas Haller
78c716cfaf
l3cfg: track "never-default" in NML3Cfg 2021-09-28 13:20:28 +02:00
Thomas Haller
c9a833c910
l3cfg: drop nm_l3cfg_property_emit_register() API
The idea was that NMIPConfig would register itself with the property (like "address-data")
and then NML3Cfg would emit the property changed notification.

However, we can already achive that via the regular notification, in particular
by listening to NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE notification.

Also, NML3Cfg does not really understand the details when the property should
be emitted. For example, many routes not not exposed via "route-data" property,
and changes to those should not trigger a notification.

Drop the unused API.
2021-09-27 10:09:50 +02:00
Thomas Haller
e47dd2ee22
l3cfg: configure dependent routes when creating combined config 2021-09-27 07:55:32 +02:00
Thomas Haller
ed1536c890
l3cfg: fix assertion failure in _l3_hook_add_obj_cb()
With nm_l3cfg_get_combined_l3cd(), we can get the commited or
the combined (next) l3cd. The commits is easy, it's cached already.

However, the combined needs to be computed first, if there were any
changes. For that we call _l3cfg_update_combined_config(), which then
also calls nm_l3_config_data_merge().

But in non-commit mode, _l3cfg_update_combined_config() doesn't call
_l3_acd_data_add_all(), so in _l3_hook_add_obj_cb() the ACD data may
not be as expected. This can previously hit an assertion.
2021-09-25 10:10:17 +02:00
Thomas Haller
d68fa91199
platform/tests: fix assertion failure in NMTstpAcdDefender
Seems we can get a DOWN event during unit tests. I don't really
understand why, but let's ignore it.

  [...]
  #4  0x000055e365777786 in _l3_acd_nacd_event (fd=<optimized out>, condition=<optimized out>, user_data=0x55e367566270) at src/core/platform/tests/test-common.c:2703
  #5  0x00007f4399c224cf in g_main_dispatch (context=0x55e36755fce0) at ../glib/gmain.c:3337
  #6  g_main_context_dispatch (context=0x55e36755fce0) at ../glib/gmain.c:4055
  #7  0x00007f4399c764f8 in g_main_context_iterate.constprop.0 (context=context@entry=0x55e36755fce0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>)
      at ../glib/gmain.c:4131
  #8  0x00007f4399c1fc03 in g_main_context_iteration (context=0x55e36755fce0, context@entry=0x0, may_block=may_block@entry=1) at ../glib/gmain.c:4196
  #9  0x000055e365770719 in test_l3_ipv6ll (test_data=<optimized out>) at src/core/tests/test-l3cfg.c:1024
2021-09-25 10:10:17 +02:00
Thomas Haller
a446e490f9
l3cfg: mediate commit_type with nm_l3cfg_commit_on_idle_schedule()
We have nm_l3cfg_commit(), however that is synchronous and triggers an
avalanche of side effects. So it should be avoided if a component is
not aware of the current circumstances in which it gets called (most of them).

The alternative is nm_l3cfg_commit_on_idle_schedule(), but previously
that only supported the auto type.

Two changes:

- add a commit_type parameter to nm_l3cfg_commit_on_idle_schedule().
  This allows to explicitly select a type for the next commit.
  Previously, if the caller wanted for example to trigger a reapply
  once, they had to register a handle, trigger the commit and unregister
  the handle again. This basically allows to specify an ad-hoc commit
  type that is only used once.

- if an explicit commit type is requested, then still always combine
  it with auto. That means, we always use the "maximum" of what is
  requested and what is registered.
2021-09-24 21:48:39 +02:00
Thomas Haller
ddfd1e8ddf
device: minor cleanup in reapply_cb() 2021-09-24 18:03:05 +02:00
Thomas Haller
70a077e4d8
l3cfg: add nm_l3cfg_check_ready() helper 2021-09-23 21:17:43 +02:00
Thomas Haller
145950d0c2
l3cfg/trivial: add code comment about NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE 2021-09-23 11:06:28 +02:00
Thomas Haller
a1b6896b14
trivial: update fixme comment
The proper tag is "l3cfg" not "next". Currently "next" branch and l3cfg rework
is the same, but in the future we might have other "next" branches, while "l3cfg"
is the tag to indicate this effort.
2021-09-23 10:55:12 +02:00
Thomas Haller
e8a63b0ab5
device: use proper define NM_SETTING_IP6_CONFIG_METHOD_SHARED in addrconf6_start() 2021-09-23 10:31:59 +02:00
Thomas Haller
642c160e59
core: use nm_clear_g_free() instead of g_clear_pointer() 2021-09-22 17:25:31 +02:00
Thomas Haller
d6ab4d24cf
l3cfg/trivial: rename parameter in nm_l3cfg_remove_config() 2021-09-21 09:12:23 +02:00
Thomas Haller
79d4b67681
l3cfg: add nm_l3_config_data_lookup_address_4() helper 2021-09-21 09:11:54 +02:00
Thomas Haller
b1ad3f1ba5
l3cfg: return any IPv4/IPv6 route from nm_l3_config_data_get_best_default_route() 2021-09-21 08:36:14 +02:00