Commit graph

23399 commits

Author SHA1 Message Date
Thomas Haller
ceaf64eee7 settings,libnm: move is-adhoc-wpa check to libnm
"nm-settings.c" is complex enough. Move this trivial helper function to libnm-core.
2019-06-13 16:10:53 +02:00
Thomas Haller
25de86abb6 manager: cleanup freeing CList in NMManager's dispose()
To unlink all elements, I find a while() loop easier to read
than c_list_for_each_*safe().
2019-06-13 16:10:53 +02:00
Thomas Haller
142c1215ee auth-chain: track auth-chains in embedded CList
NMManager and NMSettings both may have multiple authorization requests
ongoing. They need to keep track of them, at the very least to be able
to cancel them on shutdown.

Since NMAuthChain is not ref-countable, it always has only one clear
user/owner. It makes little sense otherwise. Since most callers already
want to track their NMAuthChain instances, let NMAuthChain help with that.

Embed a "parent" CList field inside NMAuthChain. This avoids requiring
an additional GSList allocation to track the element. Also, it allows to
link and append an element without iterating the list.

This ties the caller and the NMAuthChain a bit tighter together (making them
less indepdendent). Generally that is not desirable. But here it seems the
logic (of tracking the NMAuthChain) is still trivial and well separated.
It's just that NMAuthChain instances now can be linked in a CList.
2019-06-13 16:10:53 +02:00
Thomas Haller
a63714ec1d settings,keyfile: move openconnect hack from settings to keyfile reader
VPN settings (for openconnect) can only be handled by the keyfile settings
plugin.

In any case, such special casing belongs to the settings plugin and not
"nm-settings.c". The reason is that the settings plugin already has an
intimate understanding of the content of connections, it knows which fields
exist, their meaning, etc. It makes sense special handling of
openconnect is done there.

See also commit 304d0b869b ('core: openconnect migration hack').
Unfortunately it's not clear to me why/whether this is still the
right thing to do.
2019-06-13 16:10:53 +02:00
Thomas Haller
be0018382d settings: in have_connection_for_device() first skip over irrelevant connection types
nm_device_check_connection_compatible() is potentially expensive.
Check first whether the connection candidate is of a relevant type,
hoping that this check is cheaper and thus shortcuts other checks
early.
2019-06-13 16:10:53 +02:00
Thomas Haller
179134bbdc settings/trivial: move code around
"nm-settings.c" has more than 2000 LOC. Code that is related should be
grouped better so that it's easier to understand how it belongs
together.
2019-06-13 16:10:53 +02:00
Thomas Haller
ca1fe95ce0 settings: use nm_utils_g_slist_find_str() in update_specs()
NMSettings is complicated enough. We should try to move independent code out
of it, so that there is only logic that is essential there.

While at it, rework how we copy the GSList items. I don't like GSList as
a data structure, but there really is no need to allocate a new list.
Just unlink the list element and prepend it in the other list.
2019-06-13 16:10:53 +02:00
Thomas Haller
d7056d13d0 settings: drop nm_settings_plugin_initialize() and initialize on demand
As nm_settings_plugin_initialize() could not fail (it returned no value indicating
failure), there is no reason to explicitly call this. Instead just
initialize the plugin when needed.

Also, we don't need the plugin to initialize early before nm_settings_plugin_get_connections().
2019-06-13 16:10:53 +02:00
Thomas Haller
50be2f5244 settings: log settings plugin name
Instead of

  <info>  [1558284380.2045] settings: Loaded settings plugin: SettingsPluginIfcfg ("/usr/lib64/NetworkManager/1.19.2/libnm-settings-plugin-ifcfg-rh.so")

log

  <info>  [1558284380.2045] settings: Loaded settings plugin: ifcfg-rh ("/usr/lib64/NetworkManager/1.19.2/libnm-settings-plugin-ifcfg-rh.so")

Note how `man NetworkManager.conf` documents "main.plugins" configuration
option where settings plugins have names like "keyfile" and "ifcfg-rh".
It's not helpful to log the GObject type name, which is an implementation
detail.
2019-06-13 16:10:53 +02:00
Thomas Haller
18acdeeba5 settings: don't remember path of setting plugin
It was only kept to compare whether we loaded the same
plugin multiple times.

Note that load_plugins() already checks for duplicate plugin names,
so it actually could not happen that we tried to load the same file
more than once.
2019-06-13 16:10:53 +02:00
Thomas Haller
6da5ad2962 libnm: cleanup GSList/GPtrArray to/from strv conversion 2019-06-13 16:10:53 +02:00
Thomas Haller
c165c6a671 libnm: don't assert against %NULL string in nm_utils_is_uuid()
For a "is" check, it's inconvenient to assert against the parameter
being %NULL. We should accept %NULL and just say that it's not a valid
uuid.

This relaxes previous API.
2019-06-13 16:10:53 +02:00
Thomas Haller
b1f5e971f3 shared: add nm_g_variant_ref_sink() util 2019-06-13 16:10:53 +02:00
Thomas Haller
5b721ba90d shared: add nm_c_list_elem_find_first() and minor cleanups of NMCListElem API 2019-06-13 16:10:53 +02:00
Thomas Haller
8b2d115f9d shared: add nm_utils_g_slist_find_str() util 2019-06-13 16:10:53 +02:00
Thomas Haller
49c6fa2ba7 src/tests: show exit status in test failure of test_nm_utils_kill_child()
This test keeps randomly failing. Rework is, so that we see the actual
exit status in the output of the failed test.
2019-06-13 11:27:32 +02:00
Thomas Haller
a3e75f3294 CONTRIBUTING: style update
Also drop the paragraph about "autoconf mechanism". The general
guideline is self evident, while it didn't mention meson builds.
Also, a first time contributor likely won't likely be concerned about
this, as this is already advanced.
2019-06-12 07:31:00 +02:00
Thomas Haller
b323b3d62e CONTRIBUTING: comment that all new contributions must be made under LGPL-2.0+ license 2019-06-12 07:31:00 +02:00
Beniamino Galvani
b247950c6f tui: add only some options to new bond connections
Instead of adding every known option to new bond connections, only add
the ones supported by UI.

https://bugzilla.redhat.com/show_bug.cgi?id=1715720
2019-06-11 18:30:20 +02:00
Beniamino Galvani
fa0f87fef7 libnm-core: change unsupported modes for arp_ip_targets bond option
If the mode is one of '802.3ad', 'tlb' or 'alb' and the connection has
both 'arp_interval' and 'arp_ip_target' options, during normalization
we remove 'arp_interval' because unsupported in the current mode. The
connection then becomes invalid because 'arp_ip_target' requires
'arp_interval'.

Since 'arp_interval' and 'arp_ip_target' are mutually dependent, the
latter should also be unsupported for those bonding modes.

https://bugzilla.redhat.com/show_bug.cgi?id=1718173
2019-06-11 18:30:18 +02:00
Beniamino Galvani
6a3bb90ad4 cli: fix crash on autocompletion
@connections is NULL when doing autocompletion. Fixes the following:

 $ nmcli --complete-args con monitor ""
  help
  id
  uuid
  path
  filename
  ...
  Segmentation fault (core dumped)

Fixes: 4b3297271e ('cli: rework connection handling for multiple results')

https://bugzilla.redhat.com/show_bug.cgi?id=1716948
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/177
2019-06-11 16:44:06 +02:00
Beniamino Galvani
32c6c0cdaf merge: branch 'bg/ipv6-disabled'
https://bugzilla.redhat.com/show_bug.cgi?id=1643841
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/129
2019-06-11 16:28:53 +02:00
Beniamino Galvani
40afd205db core: support creating ip6-config setting with disabled method
Create the new setting with method=disabled if IPv6 is disabled in the
sysctl.
2019-06-11 16:28:16 +02:00
Beniamino Galvani
e6628fa27c ipv6: add 'disabled' method
Add a new ipv6.method value 'disabled' that completely disables IPv6
for the interface.

https://bugzilla.redhat.com/show_bug.cgi?id=1643841
2019-06-11 16:22:04 +02:00
Beniamino Galvani
5be69ba794 device: reset cached route tables when starting new activation
The values cached in the device may be stale when we start a new
activation because in a disconnected state we might have called
ip_config_merge_and_apply() which cached the main table value.
2019-06-11 15:34:59 +02:00
Thomas Haller
a4c1489507 libnm: belatedly expose nm_ethtool_optname_is_feature() in libnm
Also, plan right away to backport this symbol all the way back to
1.14.8. As such, we only need to add it once, with the right linker
version "libnm_1_14_8".

But still, the symbols first appears on a major release 1.20.0.
2019-06-11 14:58:14 +02:00
Thomas Haller
a530921f40 man: update reference for reporting bugs in man nmcli
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/188
2019-06-11 13:26:19 +02:00
Thomas Haller
91d8038a81 cli: fix default value for team.runner-min-ports
The default value is "1", not "0". Also, because "0" is not actually a
valid value as far as teamd is concerned. This fixes:

    $ nmcli connection add type team autoconnect no con-name t team.runner lacp team.runner-min-ports default
    Error: Failed to add 't' connection: team.runner-min-ports: value out or range

See "teamd.conf" manual:

    runner.min_ports (int)
        Specifies the minimum number of ports that must be active before asserting
        carrier in the master interface, value can be 1 – 255.

        Default: 1

This mistake probably happend because the teamd manual is wrong in older versions [1].

[1] f36c191da3

https://bugzilla.redhat.com/show_bug.cgi?id=1716987
2019-06-11 13:25:21 +02:00
Thomas Haller
356a159731 libnm: add nm_setting_ethtool_get_optnames() function
It's rather limiting if we have no API to ask NMSettingEthtool which
options are set.

Note that currently NMSettingEthtool only supports offload features.
In the future, it should also support other options like coalesce
or ring options. Hence, this returns all option names, not only
features.

If a caller needs to know whether the name is an option name, he/she
should call nm_ethtool_optname_is_feature().
2019-06-11 11:27:43 +02:00
Thomas Haller
1850dc4952 all: merge branch 'th/drop-emacs-file-variables'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/175
2019-06-11 10:16:35 +02:00
Thomas Haller
87a73df959 all: drop empty first line from sources
git ls-files -z -- ':(exclude)src/settings/plugins/keyfile/tests/keyfiles' | xargs -0 -n1 sed -i '1 { /^$/d }'
2019-06-11 10:15:06 +02:00
Thomas Haller
3c47285f4a all: drop vim file variables from source files
sed '1,3 { /^\(#\|--\) *vim:/d }; 1 { /^\/\* *vim:.*\*\/$/ d}' -i $(git grep -l 'vim:')
2019-06-11 10:08:07 +02:00
Thomas Haller
c0e075c902 all: drop emacs file variables from source files
We no longer add these. If you use Emacs, configure it yourself.

Also, due to our "smart-tab" usage the editor anyway does a subpar
job handling our tabs. However, on the upside every user can choose
whatever tab-width he/she prefers. If "smart-tabs" are used properly
(like we do), every tab-width will work.

No manual changes, just ran commands:

    F=($(git grep -l -e '-\*-'))
    sed '1 { /\/\* *-\*-  *[mM]ode.*\*\/$/d }'     -i "${F[@]}"
    sed '1,4 { /^\(#\|--\|dnl\) *-\*- [mM]ode/d }' -i "${F[@]}"

Check remaining lines with:

    git grep -e '-\*-'

The ultimate purpose of this is to cleanup our files and eventually use
SPDX license identifiers. For that, first get rid of the boilerplate lines.
2019-06-11 10:04:00 +02:00
Thomas Haller
d3db21ddaf examples: use '\n' line endings in "examples/C/qt/add-connection-wired.cpp"
Find with:

  git ls-files -z | xargs -0 file | grep with\ CRLF

Fix with:

  dos2unix examples/C/qt/add-connection-wired.cpp
2019-06-11 09:58:50 +02:00
Thomas Haller
c5e0e33b52 initrd/tests: increase test timeout for "initrd/test-cmdline-reader" with meson
The default timeout of 30 seconds may not be sufficient when running under valgrind
on a busy system.
2019-06-11 08:54:40 +02:00
Thomas Haller
645261b182 platform: merge branch 'th/platform-link-broadcast'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/174
2019-06-11 08:48:52 +02:00
Thomas Haller
82e87de498 platform: avoid heap allocating string buffer for printing link flags 2019-06-11 08:41:26 +02:00
Thomas Haller
10623654f9 platform: handle IFLA_BROADCAST in platform cache for links
While at it, rename the "addr" field to "l_address". The term "addr" is
used over and over. Instead we should use distinct names that make it
easier to navigate the code.
2019-06-11 08:41:26 +02:00
Thomas Haller
98ec22d4be shared: add nmtst_get_rand_uint() helper 2019-06-11 08:25:10 +02:00
Thomas Haller
d7932ee5f1 tests/trivial: rename nmtst_get_rand_int() to nmtst_get_rand_uint32()
nmtst_get_rand_int() was originally named that way, because it
calls g_rand_int(). But I think if a function returns an uint32, it
should also be named that way.

Rename.
2019-06-11 08:25:10 +02:00
Thomas Haller
7440c0c564 shared: use NM_MIN() in NM_CMP_FIELD_MEMCMP_LEN() macro
To avoid evaluating the argument more than once.
2019-06-11 08:25:10 +02:00
Thomas Haller
109b3a5bb1 dhcp: fallback to "internal" DHCP plugin if plugin does not support address family
Maybe DHCP plugins should be configurable per address family and be
re-loadable via SIGHUP. But that just adds complexity.

Nowadays we always have the "internal" DHCP plugin, which is known to
support both IPv4 and IPv6. One day, we should get rid of all plugins
and only use one implementation (that works well). The "internal" plugin
is supposed to be(come) that.

That also means, that we are not going to add more (external) DHCP
plugins and we are not going to invest work in the existing plugins
(except the "internal" plugin).

Some DHCP plugins are known to not support IPv6. If the user selects
"dhcpcd" we should just fallback to the "internal" plugin. What's the
point of letting the activation fail? Probably users shouldn't use
"dhcpcd" plugin anyway, but that's a different story. Doing such fallback
could be a problem with forward compatibility if we ever would add IPv6
support to "dhcpcd". But we won't.

Also, we are going to add "n-dhcp4" as replacement for the systemd based
code. For a time, there will be an experimental plugin "nettools" that
eventually will become the new "internal" plugin. Until that happens,
we want for IPv6 automatically fallback to systemd based "internal"
plugin. This patch will make that simple.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/173
2019-06-11 08:21:53 +02:00
Thomas Haller
fac6aea730 libnm/tests: fix team tests with "--enable-json-validation=no" 2019-06-11 08:10:03 +02:00
Thomas Haller
4e1c3f2d77 NEWS: update 2019-06-11 07:30:28 +02:00
Thomas Haller
2d6c711d64 libnm/team: fix setting setting same JSON string
When we set the same JSON config twice in a row, the second time has
indeed no effect and we can just return right away (indicating that
no attributes changed).

However, that is not true, if we are in strict validating mode and
the JSON string just happens to be the same. In this case, we still
want to switch from strict validating mode to relaxed mode. Hence,
we should not return early but continue setting the property.
2019-06-09 13:40:28 +02:00
Thomas Haller
dd3b47deed wwan: don't call _nm_modem_set_operator_code() in property setter
NM_MODEM_OPERATOR_CODE property is construct-only. Add our common
code comment to the property setter.

Construct-only setters are pretty simple. They run before the object is
constructed, hence their scope is clearer. As such, there is no need to
emit property changed notifications (also because that is already taken
care by the GObject property setter). Don't call _nm_modem_set_operator_code(),
just directly set the property.

Usually we aim to have only one place where we set state (_nm_modem_set_operator_code()).
But a construct-only property setter is trivial enough that we can affort having two
places to modify the property. In particular, because the property setter does not "modify"
the property, it merely initializes it before the object is fully
constructed.
2019-06-09 13:25:46 +02:00
Thomas Haller
5b0982034a wwan: remove unused property setter for NM_MODEM_APN
The property is read-only. The setter code is unused and unnecessary.
2019-06-09 13:25:12 +02:00
Lubomir Rintel
055e95ea26 merge: branch 'lr/modem-properties'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/139
2019-06-05 18:40:16 +02:00
Lubomir Rintel
8e270de05e libnm/modem: add APN getter 2019-06-05 18:37:17 +02:00
Lubomir Rintel
b5b8b23c4b wwan: expose the APN on the D-Bus
This is going to be useful for UIs to know which plan we're actually
using.
2019-06-05 18:36:48 +02:00