Commit graph

12041 commits

Author SHA1 Message Date
Beniamino Galvani
e4ce9bd7af device: set IPv6 token only when necessary
Setting the IPv6 token triggers a new router solicitation from kernel
and so we should avoid when not strictly necessary.

https://mail.gnome.org/archives/networkmanager-list/2019-May/msg00004.html
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/179
2019-06-26 09:04:00 +02:00
Thomas Haller
16dbe0a573 core: avoid plain pointer values in logging output
Logging pointer values is useful to identify the object in the logging message.
But plain pointer values also can be used to defeat ASLR and should not be logged.

Instead, print NM_HASH_OBFUSCATE_PTR() value, which is a 64 bit number based on
the pointer value and some random seed. A minor problem is that there is still the
chance of duplicates, albeit small.
2019-06-25 13:26:37 +02:00
Thomas Haller
74641be816 settings: drop ibft settings plugin
The functionality of the ibft settings plugin is now handled by
nm-initrd-generator. There is no need for it anymore, drop it.

Note that ibft called iscsiadm, which requires CAP_SYS_ADMIN to work
([1]). We really want to drop this capability, so the current solution
of a settings plugin (as it is implemented) is wrong. The solution
instead is nm-initrd-generator.

Also, on Fedora the ibft was disabled and probably on most other
distributions as well. This was only used on RHEL.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1371201#c7
2019-06-20 16:06:44 +02:00
Thomas Haller
5a416a9da1 Revert "Coerce connectivity "LIMITED" to "NONE" when device is disconnected"
NMConnectivity can now distinguish between LIMITED and NONE connectivity
and it does so based on whether IP addresses and routes are configured.

Previously, NMConnectivity would not differenciate between limited and
no connectivity, which is why NMDevice added some additional logic on top
to coerce LIMITED to NONE (if the device is not logically connected).

But note that the connectivity state (whether a network is reachable on
an interface) depends on what is configured in kernel and whether the
internet is reachable on that interface. It does not depend on the
logical device state.

On the other hand, whether the device is configured in a manner to have
connectivity depends on the logical state of the device (as NetworkManager
is configuring the device).

So, in many cases, the logical state and the connectivity state agree now,
but for the right reasons.

This reverts commit 4c4dbcb78d.
2019-06-18 15:49:09 +02:00
Thomas Haller
b626baa313 connectivity: make platform argument to nm_connectivity_check_start() optional
The platform is used to detect whether to skip the connectivity check right away.
It should be an optional argument, so one could avoid this pre-check.
2019-06-18 15:49:09 +02:00
Thomas Haller
19c957f091 connectivity: simplify passing result to idle handler 2019-06-18 15:49:09 +02:00
Thomas Haller
4001aee370 connectivity: remove unused error varialbe in _idle_cb() 2019-06-18 15:49:09 +02:00
Beniamino Galvani
91d447df19 device: don't start connectivity check on unconfigured devices
If the interface has no carrier, no addresses or no routes there is no
point in starting a connectivity check on it because it will fail.
Moreover, doing the check on a device without routes causes the
addition of a negative entry in the ARP table for each of the
addresses associated with the connectivity check host; this can lead
to poor network performances.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/181
2019-06-18 15:49:09 +02:00
Thomas Haller
5b7f6421c7 keyfile: rework selecting path name in nms_keyfile_writer_connection() and add callback to reject filenames
The previous logic seems complicated to me. I even think it is wrong.
Rework it, I think this makes sense.

Also, previously the existing path was used if the file didn't exist.
I think that is wrong. If for force a rename, then the filename must
not be used even if the file currently does not exist.

Also add an "allow_filename_cb" argument, to reject filenames that
are blacklisted.
2019-06-17 12:12:02 +02:00
Thomas Haller
71928a3e5c settings: avoid cloning the connection to maintain agent-owned secrets 2019-06-17 12:12:02 +02:00
Thomas Haller
a17453913c settings: add _nm_connection_clear_secrets_by_secret_flags() function to simplify clearing secrets 2019-06-17 12:12:02 +02:00
Thomas Haller
396b188697 settings: pass const strv plugins array to load_plugins() 2019-06-17 12:12:02 +02:00
Thomas Haller
a56fb02af6 settings: avoid emiting notify::unmanaged-specs for NMSettings if there are no changes 2019-06-17 12:12:02 +02:00
Thomas Haller
408a453bee settings: track keyfile plugin explicitly in NMSettings
The keyfile plugin is special. For one, NetworkManager will always load
it.

In the future, only this plugin should handle in-memory connections.
In-memory connections are kinda special, and we don't need general
plugins to be concerned about them. They should be handled by keyfile
plugin.

But then NMSettings needs to have a reference to the keyfile plugin
instance at hand.
2019-06-17 12:12:02 +02:00
Thomas Haller
2630ebd7b9 device: support reapplying route-table
Changing "ipv4.route-table" and "ipv6.route-table" was not allowed
during reapply.

The main difficulty for supporting that is changing the sync-mode.

With route-table 0, we don't sync all tables but only the main table.
So, when reapply changes from full-sync to no-full-sync, it's slightly
more complicated.

But it's probably not too complicated either. The change from
no-full-sync to full-sync is simple: we just start doing a full-sync.
The reverse change is slightly more complicated, because we need to
do one last full-sync, to get rid of routes that we configured on those
other tables.
2019-06-17 11:36:33 +02:00
Thomas Haller
bb3726acc2 device: use nm_platform_sysctl_ip_conf_get_rp_filter_ipv4() for warning about rp-filter 2019-06-17 11:36:33 +02:00
Thomas Haller
23c1e32456 platform: add nm_platform_sysctl_ip_conf_get_rp_filter_ipv4() 2019-06-17 11:36:33 +02:00
Thomas Haller
1fc36dc58f platform/tests: relax assertion for accepting signals in /link/software/bridge test
/link/software/bridge: NMPlatformSignalAssert: ../src/platform/tests/test-link.c:289, test_slave(): failure to accept signal [0,2] times: 'link-changed-changed' ifindex 10 (3 times received)
2019-06-16 09:35:51 +02:00
Thomas Haller
97c672665d platform/tests: relax assertion for accepting signals in /link/software/bond test
/link/software/bond: NMPlatformSignalAssert: ../src/platform/tests/test-link.c:243, test_slave(): failure to accept signal [1,2] times: link-changed-changed ifindex 13 (3 times received)
2019-06-14 14:20:08 +02:00
Alfonso Sánchez-Beato
a251712a72 core/pppd-plugin: wait to recover port settings before notifying death
pppd restores the previous settings for the serial port it uses right
before exiting. It is especially important to do so because otherwise
ModemManager is not able to recover the port as it can receive a hangup
event from the port due to CLOCAL not being restored.  However, there is
currently a race condition that produces this issue. This is because
when PHASE_DEAD is notified, pppd still has not restored the port
settings - it does that a bit later, in the die() function.

This patch delays notifying PHASE_DEAD until when the exitnotify() hook
is called by pppd: when this happens the port settings have already been
restored.

There were previously efforts to fix this in commit fe090c34b7, so
PHASE_DEAD was used instead of PHASE_DISCONNECT to notify MM that the
port was disconnected, but that still early to ensure that the port
settings are restored.

The MM traces seen when the bug is triggered are:

ModemManager[2158]: <warn>  (ttyACM1): could not re-acquire serial port lock: (5) Input/output error
ModemManager[2158]: <warn>  Couldn't load Operator Code: 'Cannot run sequence: 'Could not open serial device ttyACM1: it has been forced close'

https://mail.gnome.org/archives/networkmanager-list/2019-June/msg00014.html
2019-06-14 13:29:45 +02:00
Lubomir Rintel
ae4152120a ovs/ovsdb: add support for setting dpdk devargs option 2019-06-14 12:10:20 +02:00
Lubomir Rintel
f69dffe1e8 ovs/ovsdb: remove unused headers
Just include what is actually needed.
2019-06-14 12:02:23 +02:00
Lubomir Rintel
02950ec600 ovs/factory: fail the NMDevice if there's an error in OVSDB 2019-06-14 10:33:26 +02:00
Lubomir Rintel
e948ce7deb ovs/ovsdb: track the devices before we signal addition
This doesn't make any difference in practice, but it seems more correct.
It would cause issues if we decided to remove an interface from the
signal handler.
2019-06-14 10:33:26 +02:00
Lubomir Rintel
f2c066e104 ovs/ovsdb: signal a failure when an error column is set
When an interface (other OVS device types can not fail)  encounters an error
it indicates it by changing the error column. Watch for those changes so
that we can eventually communicate them to the OVS factory to deal with
them.
2019-06-14 10:33:26 +02:00
Lubomir Rintel
dedc0cba23 ovs/ovsdb: fix signal handler argument types 2019-06-14 10:33:08 +02:00
Lubomir Rintel
b1feebc43a ovs/ovsdb: remove the device-changes signal
It doesn't communicate anything about the nature of the change and
indeed nothing uses it.
2019-06-14 10:32:53 +02:00
Lubomir Rintel
99c7adc1e1 ovs/ovsdb: guard against OVSDB integrity issues
Don't crash in situations, where the bridge or a port has a child with
UUID we don't know. This could happen if we mess up the parsing of
messages from OVSDB, but could also theoretically happen in OVSDB sends
us bad data.
2019-06-14 10:32:53 +02:00
Thomas Haller
31382c9727 settings: remove unused NMSettingsConnection.supports_secrets() function 2019-06-13 16:10:53 +02:00
Thomas Haller
d92356c868 settings: use _nm_utils_slist_to_strv() for NMSettings:unmanaged-specs property getter
Note that now the empty list will be represented as %NULL instead of an
empty strv array.

That makes no difference in pratice. The main use of this property is as
glue for NMDBusManager to expose the property on D-Bus. Thereby it uses
g_dbus_gvalue_to_gvariant() which handles %NULL just fine.
2019-06-13 16:10:53 +02:00
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
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
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
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
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
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
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
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