Commit graph

23441 commits

Author SHA1 Message Date
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
Lubomir Rintel
11d59de600 build/autotools: generate "config-extra.h" via makefile "config-extra.h.mk"
When the code that generates "config-extra.h" changes, we want to regenerate
the file. Move that code to a separate makefile so we can add a
dependency.

Otherwise, we'd had to depend on "Makefile", which itself is generated by
Makefile.am.

Also, depend on "config.h" to regenerate it when ./configure runs and
touches that header. This may not cover all cases where ./configure's
configuration changes and a regeneration would be due. But such is life.

Also, most components depend on this header, so let various .dirstamp
files depend on it, so we are sure to build this first. That because,
autotools generates dependencies for header files automatically, but
that requires that the header file exist. Such automatic dependencies
don't work out-of-the-box for generated headers.

Co-authored-by: Thomas Haller <thaller@redhat.com>
2019-06-17 17:42:09 +02:00
Thomas Haller
721f238946 build/autotools: depend "config-extra.h" on "config.h"
"config-extra.h" is really just like "config.h", except it works around some
limitations of autoconf.

If we depend on "Makefile", any changes to "Makefile.am" will cause a full
rebuild. We want to avoid that.

Instead, depend on "config.h". That one only changes when configure runs
again. And that's the better dependancy, because "config-extra.h" is
generated based on informations generated by configure (despite being
generated by "Makefile").
2019-06-17 13:00:37 +02:00
Thomas Haller
7ed1fc817f Revert "build: only update config-extra.h if it changes"
Not touching "config-extra.h" means that the target is rebuild every
time (because the timestampt does not get updated). On the other hand,
touching it will cause a full rebuild (which we often want to avoid).

The right solution is instead to depend on "config.h", which will be
done next.

This reverts commit 14271d84a0.
2019-06-17 12:54:04 +02:00
Thomas Haller
57431d872c settings: merge branch 'th/various-settings-cleanup-2'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/184
2019-06-17 12:12:17 +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
1de36fad51 libnm: add NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED serialization flag
At various places we only want to serialize agent-owned secrets. Without this
flag, we need to clone the setting first, then drop the secrets, then serialize
to D-Bus. Add a serialization flag to avoid that.

The name ("with") and the meaning of the flag is chosen in a way, that
there could be multiple such flags (NM_CONNECTION_SERIALIZE_WITH_SECRETS_NOT_REQUIRED),
and specifying at least one of them, would have the meaning to whitelist
flags of this kind. Specifying non of these "with" flags would have the
meaning of specifying *all*. Currently there is only one kind, so the name
and meaning is slightly counter intuitive.
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
45013bfbff libnm: cleanup _nm_connection_ensure_normalized() and split nm_connection_normalize()
- in _nm_connection_ensure_normalized() allow also to only check that
  the UUID is as expected, without really resetting it.

- split the normalization part out of nm_connection_normalize() and
  reuse it in _nm_connection_ensure_normalized(). As we already verified
  the connnection, we know that normalization is due and don't need to
  verify again.
2019-06-17 12:12:02 +02:00
Thomas Haller
1cc4a8b6a9 shared: add nm_utils_g_slist_strlist_cmp() util
Usually we avoid GSList, because I think it's not a great data type.
Anyway, our match-specs are just a GSList of strings, so we need some
API to handle them.
2019-06-17 12:12:02 +02:00
Thomas Haller
3d0dba20b5 core: merge branch 'th/reapply-route-table'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/183
2019-06-17 12:11:07 +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
Lubomir Rintel
7d3a957c98 release: bump version to 1.19.4-dev 2019-06-14 16:44:35 +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
2653458a3e merge: branch 'lr/ovs-dpdk'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/181
2019-06-14 12:10:55 +02:00
Lubomir Rintel
bd119981a1 clients: add ovs-dpdk interface support 2019-06-14 12:10:20 +02:00
Lubomir Rintel
ae4152120a ovs/ovsdb: add support for setting dpdk devargs option 2019-06-14 12:10:20 +02:00
Lubomir Rintel
b93643ed85 core/ovs-interface: add support for dpdk type 2019-06-14 12:10:20 +02:00
Lubomir Rintel
a26abc797c libnm-core: add ovs-dpdk setting 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
f5e82796be core/ovs-interface: fix type documentation 2019-06-14 12:02:23 +02:00
Lubomir Rintel
d0f0d778f3 merge: branch 'lr/ovs-failures'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/182
2019-06-14 11:35:46 +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
Lubomir Rintel
14271d84a0 build: only update config-extra.h if it changes
This is to avoid updating config-extra.h timestamp very time one touches
Makefile.am, because it has a large dependency chain and makes
debugging of the Makefile inconvenient.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/180
2019-06-14 09:21:24 +02:00
Thomas Haller
a646be6509 settings: merge branch 'th/various-settings-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/172
2019-06-13 16:11:15 +02:00
Thomas Haller
954906e3d1 libnm: add _nm_connection_ensure_normalized() helper 2019-06-13 16:10:53 +02:00
Thomas Haller
1a398421ff libnm: add nmtst_connection_assert_unchanging() helper 2019-06-13 16:10: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