Commit Graph

23466 Commits

Author SHA1 Message Date
Thomas Haller
eed4b5253f settings: don't implement settings plugins as singletons
The settings plugins are created by NMSettings when the plugin
gets loaded. There is no need for these instances to be singletons
or to have a singleton getter.

Also, while in practice we create a settings plugin instance of
each type only once, there is nothing that would prevent creating
multiple instances. Hence, having a singleton getter is not right.

What is however useful, is to track them and block shutdown
via nm_shutdown_wait_obj_register*(). While the actual waiting
is not yet implemented, we should mark the plugin instances to
block shutdown (in the future).
2019-06-26 12:26:11 +02:00
Thomas Haller
a410873461 core: add flag to nm_shutdown_wait_obj_register_full() for freeing allcated message string
In fact, nm_shutdown_wait_obj_register*() API is still not implemented
and registering an object has no effect currently. That is, blocking
shutdown and waiting for instances to be destroyed during shutdown
is not yet implemented. Still, we already implement the API so that
components can register themself to block the shutdown. The point is
of course, that the callers already use this API, although it's not yet
implemented.

Anyway, sometimes the message string is not static. Add an option to
pass an allocated string and let the string be destroyed when no longer
needed.
2019-06-26 12:26:11 +02:00
Thomas Haller
02a0967520 libnm: fix setting error for nm_connection_update_secrets()
By convention, a function that indicates failure *MUST* set
an error.

Also, an error can only be set once.
2019-06-26 12:26:11 +02:00
Thomas Haller
d704f02119 libnm: workaround assertion failure for nmtst_connection_assert_unchanging() when disposing connection
nmtst_connection_assert_unchanging() registers to the changed signals
and asserts that they are not invoked. The purpose is that sometimes
we want to keep a reference to an NMConnection and be sure that it does
not get modified. This allows everybody to keep a reference to the very
same connection instance without cloning it -- provided they too promise
not to change it. This assert is to ensure that.

Note that NMSimpleConnection.dispose() clears the secrets and thus upon
destruction the assertion fails. At that point, the assertion is no longer
relevant, because the purpose was to ensure that no alive instances gets
modified. While destroying the instance, it's fine to modify it (nobody should
have a reference to it anymore).

This avoids the assertion failure when destroying a NMSimpleConnection with secrets
that is set with nmtst_connection_assert_unchanging().
2019-06-26 09:53:54 +02:00
Thomas Haller
b9587008fc shared: add nm_clear_error() and patch g_clear_error() to use this inlinable variant 2019-06-26 09:53:54 +02:00
Thomas Haller
03b8eb124e shared/glib: unconditionally redefine g_object_ref()/g_object_ref_sink() as typesafe macro 2019-06-26 09:53:54 +02:00
Thomas Haller
02ac5693d3 shared: add nm_utils_file_stat() util
A small convenience function to call stat(). The difference is that the
function returns an error code.
2019-06-26 09:53:54 +02:00
Thomas Haller
ec707f56c1 shared: add nm_utils_hashtable_same_keys() util 2019-06-26 09:53:54 +02:00
Thomas Haller
fcaf7994f2 shared: allow nm_c_list_move_*() API also to move from one list to another
Previously, nm_c_list_move_*() only allowed to move element inside the
same list. Relax that, it works just the same list to move the element
from one list into a different list.
2019-06-26 09:53:54 +02:00
Thomas Haller
bf6e902c90 CONTRIBUTING: update section about assertions in NetworkManager 2019-06-26 09:53:54 +02:00
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
Lubomir Rintel
a5dd31afeb contrib/checkpatch: allow empty lines within continuations
This chunk from nm-device.c is, in fact, okay:

               |<-tab->nm_assert (   !new_config
               |<-tab->           || (   new_config
               |<-tab->               && ({
               |<-tab->                    int ip_ifindex = ...
 empty line -> |
               |<-tab->                    (   ip_ifindex > 0
               |<-tab->                     && ip_ifindex == ...
               |<-tab->                  })));
2019-06-25 20:27:39 +02:00
Lubomir Rintel
da312e6220 contrib/checkpatch: be a bit stricter about whitespace
In continations (that use spaces for alignment), don't allow the number
of leading tabs to change. Previously only removal of tabs was
disallowed, but addition doesn't make sense either, as only spaces
should be used for further alignemnt.

This catches situations like this:

  |<-tab->all_work_and_no_play (makes,
  |<-tab->                      jack,
  |<-tab-><-tab->               a dull boy);
2019-06-25 20:27:39 +02:00
Lubomir Rintel
5ff19ea8d2 contrib/checkpatch: discourage g_assert*() 2019-06-25 20:27:39 +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
1ed338fe5e CONTRIBUTING: reword "novel contributions" to "new contributions"
The meaning of "novel" and "new" here is the same, but "novel" als
has a meaning related to patents. So avoid that confusion.
2019-06-24 09:27:03 +02:00
Thomas Haller
bcbc39b240 settings/ibft: merge branch 'th/drop-ibft-settings-plugin'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/186
2019-06-20 17:27:02 +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
f182d4fa20 shared/tests: add test for nm_utils_bin2hexstr_full() 2019-06-19 15:49:57 +02:00
Thomas Haller
637c785f4e shared: fix nm_utils_bin2hexstr_full() for buffers of length zero 2019-06-19 15:30:55 +02:00
Beniamino Galvani
4dce38c37f connectivity: merge branch 'bg/concheck-issue181'
Don't start connectivity check on unconfigured devices.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/181
2019-06-18 16:09:40 +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
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