Commit Graph

27030 Commits

Author SHA1 Message Date
Thomas Haller
ed8d7ae264 core: move nm_utils_generate_duid_from_machine_id() to "nm-core-utils.c" 2020-09-11 16:18:36 +02:00
Thomas Haller
b23825f457 l3cfg: add nm_l3cfg_get_combined_l3cd() function 2020-09-11 16:18:36 +02:00
Thomas Haller
d16776b5fd l3cfg: gracefully accept %NULL argument in nm_l3_config_data_lookup_objs()
This way we can safely iterate over a %NULL instance with
nm_l3_config_data_iter_obj_for_each(). This avoids a NULL check,
which in this case seems more annoying than helpful.
2020-09-11 16:18:35 +02:00
Thomas Haller
6358d10688 l3cfg: add nm_l3cfg_get_best_default_route() function
This is the best default route that we commited the last time (if any).
It may not reflect what is currently configured (in NMPlatform) and it
may not reflect the latest changes since nm_l3cfg_add_config().
2020-09-11 16:18:35 +02:00
Thomas Haller
3b8b683f8a l3cfg: add nm_l3cfg_get_pllink() helper
NML3Cfg already keeps track of the current NMPlatformLink object.
Allow accessing it directly from an NML3Cfg instance, which saves
a cache lookup from NMPlatform.
2020-09-11 16:18:34 +02:00
Thomas Haller
16e59cc37c l3cfg: support tracking the DHCP lease in NML3ConfigData 2020-09-11 16:18:34 +02:00
Thomas Haller
2fd53eb509 core: add NMDhcpLease typedef and simple accessor functions 2020-09-11 16:18:34 +02:00
Thomas Haller
348ab39f6d shared: add nm_utils_hashtable_{equal,cmp}() helper function 2020-09-11 10:45:40 +02:00
Thomas Haller
ff37c961ff shared: fix out of bounds for nm_g_array_append_new() macro
Fixes: fb6e9795b7 ('shared: add nm_g_array_append_new() helper')
2020-09-11 10:45:40 +02:00
Thomas Haller
1001dca698 device: remove unused dhcp4.root_path field 2020-09-11 10:45:36 +02:00
Thomas Haller
75ff7a6daf bond: merge branch 'th/bond-options-reapply-fix'
https://bugzilla.redhat.com/show_bug.cgi?id=1856640
https://bugzilla.redhat.com/show_bug.cgi?id=1876577

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/622
2020-09-10 22:10:45 +02:00
Thomas Haller
ef687f5c49 tui: always unset "active-slave" bond option in nmtui
"active_slave" option is a deprecated alias for "primary". nmtui can configure
the "primary" option, so whenever it configures a profile the "active_slave"
option should be unset.
2020-09-10 22:09:59 +02:00
Thomas Haller
2e2e2f92df cli: normalize profile when setting bond options "active_slave" or "primary"
"active_slave" is by now deprecated and became an alias for "primary".
If a profile specifies both properties, only "primary" is honored, without
failing validation (to not break existing behavior).
Maybe we should introduce a normalization for such cases. But normalize
might not do the right thing, if a profile currently has "primary" set,
and the user modifies it to set "active_slave" to a different value,
normalize would not know which setting was set first and remove
"active_slave" again.

In the past, nm_setting_bond_add_option() performed some simple
normalization, but this was dropped, because (such incompatible) settings
can also be created via the GObject property. Our C accessor function
should not be less flexible than other ways of creating a profile.

In the end, whenever a user (or a tool) creates a profile, the tool must
be aware of the semantics. E.g. setting an IP route without a suitable
IP address is unlike to make sense, the tool must understand what it's
doing. The same is true for the bond options. When a tool (or user) sets
the "active_slave" property, then it must clear out the redundant
information from the "primary" setting. There is no alternative to this
problem than having tools smart enough to understand what they are
doing.
2020-09-10 22:09:58 +02:00
Thomas Haller
58da09439a libnm,core: deprecate "active_slave" and alias it for "primary"
Setting "active_slave" fails unless the slave is currently present and
IFF_UP. That complicates the code, because we cannot set the property
at any time, but only under the right circumstances.

But really, "active_slave" option is something for debugging. It's not
an option which should be set by NetworkManager. The right option
instead is "primary", which will tell kernel to make the slave active,
when it is ready.

Deprecate the "active_slave" option and make it an alias for "primary".

https://bugzilla.redhat.com/show_bug.cgi?id=1856640
2020-09-10 22:09:58 +02:00
Thomas Haller
22ff4bfd18 device: cleanup code in NMDeviceBond's update_connection() 2020-09-10 22:09:58 +02:00
Thomas Haller
b5041c14f4 tui: allow configuring "primary" bond option with "balance-{alb,tlb}" 2020-09-10 22:09:58 +02:00
Thomas Haller
cb3a73af92 libnm: allow setting "primary" option with modes "tlb" and "alb" 2020-09-10 22:09:57 +02:00
Thomas Haller
f807b68376 device: inline check_changed_options() in can_reapply_change()
Code doesn't get simpler by having more functions -- if these functions
are only called once.

What actually is a problem is repeated, redundant code. Like the list of
bond options that can be reapplied. But the function didn't help to
avoid repeating the list.
2020-09-10 22:09:57 +02:00
Thomas Haller
5402943420 device: unify setting of bond options
Add a macro for the list of bond options we are going to set. By seeing
them side-by-side, it is hopefully simpler to see that all options are
specified correctly.

We see that:

- the *_SUBSET defines don't include the options that we are explicitly
  setting, that is "mode", "active_slave" and "arp_ip_target".

- OPTIONS_REAPPLY_SUBSET contains 4 options less than OPTIONS_APPLY_SUBSET:
  "ad_select", "ad_user_port_key", "lacp_rate" and "tlb_dynamic_lb".
  These are the options that are marked as BOND_OPTFLAG_IFDOWN in
  kernel.
2020-09-10 22:09:57 +02:00
Thomas Haller
0ea73cdcec device: remove duplicate option "primary" from list to reapply 2020-09-10 22:09:57 +02:00
Thomas Haller
2eea22ae95 device: allow "active_slave" and "arp_ip_target" bond option for reapply
I guess the idea was to only accept options that can be changed without
taking the interface !IFF_UP. "active_slave" is wrongly omitted from
that list.

Also, "active_slave" option doesn't really make sense for NetworkManager
to configure. Instead "primary" should be used. In the future, we should
re-map the properties and deprecate "active_slave" for "primary" ([1]).

Fixes: 746dc119a6 ('bond: let 'reapply()' reapply all supported options')

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1856640#c19

https://bugzilla.redhat.com/show_bug.cgi?id=1876577
2020-09-10 22:09:57 +02:00
Thomas Haller
0f4221da42 shared: extend NM_IN_SET()/NM_IN_STRSET() macros to support up to 30 arguments 2020-09-10 22:09:50 +02:00
Thomas Haller
3ac7929e90 clients: set "ipv[46].dns-priority=-50" during import of WireGuard profiles
WireGuard's wg-quick primarily wants to avoid DNS leaks, and thus also
our import code should generate profiles that configure exclusive DNS
servers. This is done by setting "ipv[46].dns-priority" to a negative
value.

Note that if a profile leaves the DNS priority at zero (which in many
regard is the default), then the zero translates to 50 (for VPN
profiles) and 100 (for other profiles).

Instead of setting the DNS priority to -10, set it to -50. This gives
some more room so that the user can choose priorities that are worse
than the WireGuard's one, but still negative (exclusive). Also, since
the positive range defaults to 50 and 100, let's stretch the range a
bit.

Since this only affects import and creation of new profiles, such a
change in behavior seems acceptable.
2020-09-10 11:22:48 +02:00
Beniamino Galvani
a017936223 device: fix wrongly considering ipv6.may-fail for ipv4
Fixes: 5e71f01605 ('device: merge stage3 and stage4 ip-config function for IPv4 and IPv6')
2020-09-09 11:02:57 +02:00
Thomas Haller
b867ac56a4 build/meson: enable "more_asserts" only for devel builds
more_asserts are our NetworkManager specific assertions, and the only
point of having them at all (beside g_assert(), assert() and g_return*()),
is that these assertions are disabled by default in production.

meson always enabled them by default. That is definitely wrong.

autotools enables more_asserts by default if we build a devel version
from master. I think that is bad too, because (again) having these assertions
disabled by default is the only point of having them. Anyway, mimic
the behavior of autotools, to at least disable them in release builds.
2020-09-08 18:40:57 +02:00
Jordan Petridis
391820da76 meson_options: fix suggested values for more_asserts
meson.build atm only handles, `no/all/int`

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/621
2020-09-08 18:37:45 +02:00
Valentin David
54e25f23f5 build/docs: fix generated XML syntax in tools/generate-docs-nm-settings-docs-gir.py
Class description may contains double quotes which is not valid as XML
attribute value.

[thaller@redhat.com: adjust original patch to reformat code with python black]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/620
2020-09-08 17:35:14 +02:00
Thomas Haller
2cb40f6e36 tests: ignore valgrind warning about unhandled syscalls
On Fedora rawhide (34), valgrind gives a lot of warnings like:

    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- WARNING: unhandled amd64-linux syscall: 439
    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- You may be able to write your own handler.
    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- Nevertheless we consider this a bug.  Please report
    ./src/platform/tests/test-cleanup-linux.valgrind-log:--48279-- it at http://valgrind.org/support/bug_reports.html.

Ignore them.
2020-09-07 16:50:44 +02:00
Thomas Haller
ad55cf86e8 build: fix test for valid po files (msgfmt -vc)
Otherwise, the test generates an "messages.mo" file.

Fixes: 97c1bed37e ('build: add test for valid po files (msgfmt -vc)')
2020-09-07 16:50:44 +02:00
Beniamino Galvani
ec12912908 device: enforce the absence of a master during activation
If the connection doesn't specify a master, ensure that the device is
released from any master in platform.

https://bugzilla.redhat.com/show_bug.cgi?id=1869079
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/616
2020-09-07 16:29:37 +02:00
Thomas Haller
19c8332f05 l3cfg: merge branch 'th/l3cfg-7'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/618
2020-09-07 16:11:59 +02:00
Thomas Haller
4038a8ff99 core: accept void pointer in nm_dbus_object_export() and related
NMDBusObject is an abstract type which provides the glue code for exposing
a GObject on D-Bus. We almost never use that type directly, so as it was
before, we always had to use a C cast to convince the compiler that this
is right.

Being always required to cast is not very useful, nor more typesafe.
Just use a void pointer instead.
2020-09-07 16:11:52 +02:00
Thomas Haller
47e2ff0a71 l3cfg: add nm_l3cfg_commit_type*() API for tracking the level for committing changes
NML3Cfg manages one ifindex. In the future, we may want that multiple
NMDevice and/or NMVpnConnection instances independently contribute their
NML3ConfigData to the NML3Cfg instance.

That means, at any time somebody may want to call nm_l3cfg_platform_commit()
to apply the changes. Even ACD internally may do that, when configuration
changes (e.g. an IP address passes ACD check). We thus need to know
whether we are assuming, updating or reapplying the settings.

Add API so users can register their "commit" preference.
2020-09-07 16:11:51 +02:00
Thomas Haller
4c07d34505 l3cfg: add nm_l3_config_data_has_routes_with_type_local() helper 2020-09-07 16:11:51 +02:00
Thomas Haller
c328c10227 l3cfg: more integration of NMDevice with l3cfg
Add more code that will be used later for glueing NMDevice with NML3Cfg
and NML3ConfigData. The code is not yet really used.
2020-09-07 16:11:50 +02:00
Thomas Haller
bd054bf6fd l3cfg: remove changed flag from nm_l3cfg_add_config()/nm_l3cfg_remove_config() 2020-09-07 16:11:50 +02:00
Thomas Haller
41b9d44f9b l3cfg: drop unused NM_L3_CONFIG_MERGE_FLAGS_EXTERNAL
The current approach also tracks external configuration in an NMIP[46]Config, and
we need to special handle those. In the future, we only want to track what we actually
want to configure. So this flag won't be used with NML3Cfg/NML3ConfigData.
2020-09-07 16:11:50 +02:00
Thomas Haller
38b2239146 l3cfg: add more l3cfg API that will be used next 2020-09-07 16:11:50 +02:00
Thomas Haller
e89a095673 l3cfg: add nm_l3_config_data_get_blacklisted_ip4_routes() util
We will need to prune routes that kernel adds (and we don't want).
2020-09-07 16:11:49 +02:00
Thomas Haller
0ab341b9e6 l3cfg: add nm_l3_config_data_get_domains() accessor 2020-09-07 16:11:49 +02:00
Thomas Haller
137d02a7e6 platform: add nm_platform_ip_address_get_peer_address() helper 2020-09-07 16:11:49 +02:00
Thomas Haller
97c1bed37e build: add test for valid po files (msgfmt -vc) 2020-09-07 14:56:50 +02:00
Thomas Haller
a39e1ab16e po: merge branch 'th/po-fix-fr-ja-zh_CN'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/526

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/619
2020-09-07 13:53:57 +02:00
Thomas Haller
a4f99bab1d gitlab-ci: add test for checking po files 2020-09-04 10:11:41 +02:00
Thomas Haller
60b2e7452f po: remove invalid translations from po/{fr,ja,zh_CN}.po
And `make -C po update-po` to regenerate the default.
2020-09-04 10:01:28 +02:00
Thomas Haller
9ee13a5656 po: make update-po 2020-09-04 10:01:20 +02:00
Thomas Haller
8495e8fcb3 l3cfg: merge branch 'th/l3cfg-6-acd'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/612
2020-09-03 17:50:48 +02:00
Thomas Haller
e4f04267bb l3cfg: implement IPv4 DAD/ACD (address collision detection) in NML3Cfg
Currently, NMDevice does ACD. It intercepts certain NMIP4Config
instances, and tries to perform ACD on the addresses. I think this
functionality should be handled by NML3Cfg instead.

For one, NML3Cfg sees all configurations, and can perform ACD for all
(relevant) addresses. Also, it moves logic away from NMDevice and makes
the functionality available without an NMDevice. As such, it also will
allow that independent "controllers" contribute NML3ConfigData instances
and ACD will performed for all of them (as requested).

This will be our implementation for IPv4 ACD (https://tools.ietf.org/html/rfc5227)
based on nettools' n-acd library.

The code is not actually tested yes, because NMDevice did not yet switch
over to use NML3Cfg. Once that happens, surely issues with this patch
will be found that will need fixing.
2020-09-03 11:52:39 +02:00
Thomas Haller
f81360bbbf platform: add nm_platform_ip4_address_addr_to_hash() helper
This will only have one particular use, from NNL3Cfg. However, it seems
general enough to place it in "nm-platform.h".
2020-09-03 11:39:39 +02:00
Thomas Haller
aed61588fd shared: add nm_utils_bin2hexstr_a() macro 2020-09-03 11:39:39 +02:00