Commit graph

12024 commits

Author SHA1 Message Date
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
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
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
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
Lubomir Rintel
bba4a37a59 wwan: expose the network id on the D-Bus
This is going to be useful for UIs to find out which network is the
device actually registered with.
2019-06-05 18:36:15 +02:00
Lubomir Rintel
03a91270b8 wwan: expose device id on the bus
The device id is useful to pinpoint the connection to a particular
device. However, we don't expose it anywhere and it's sort of hard to
guess.
2019-06-05 18:33:39 +02:00
Lubomir Rintel
701d663523 devices/modem-broadband: disconnect signals on dispose 2019-06-05 18:33:39 +02:00
Lubomir Rintel
393dee9c0e ethernet: don't set a hw address in a default connection
Use an ifname instead.

This also fixes creation of default wired connections for cheapo USB
ethernet adapters that come with the EEPROM footprint unpopulated.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/137/
2019-06-05 18:32:19 +02:00
Beniamino Galvani
3c54b5eb2b device: fix matching parent device by connection UUID
We must compare the UUID with the one on the *parent* device.

Also, simplify the checks to only return TRUE at the end of function.

Fixes: 27c281ac5a ('device: deduplicate match_parent()')

https://bugzilla.redhat.com/show_bug.cgi?id=1716438
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/176
2019-06-05 11:50:56 +02:00
Lubomir Rintel
5cf6cfd999 config: also save next-server in the state file
The early boot tooling gets the root-path from our state file due to a
lack of a better way to do that. However, when booting with NFS root,
the root path alone is not sufficient; the server address is communicated
via the next-server option. Save that one in the state file as well.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/168
2019-05-30 17:02:50 +02:00
Thomas Haller
9a7929bdb1 dhcp/trivial: add fixme comment about stopping clients 2019-05-29 14:48:03 +02:00
Thomas Haller
5113c5bd00 platform: avoid compiler error passing NMP_OBJECT_CAST_OBJ_WITH_IFINDEX() to nm_hash_update_vals()
Clang (3.4.2-9.el7) on CentOS 7.6 fails related to nm_hash_update_vals().

Clang seems to dislike passing certain complex arguments to typeof().
I'd prefer to fix nm_hash_update_vals() to not have this problem,
but I don't know how.

This works around the issue.
2019-05-29 09:42:40 +02:00
Thomas Haller
ad06cc78dc platform: make nm_platform_kernel_support_get() macro an inline function
clang (3.4.2-9.el7) on CentOS 7.6 fails related to nm_hash_update_vals().

I am not even quoting the error message, it's totally non-understandable.

nm_hash_update_vals() uses typeof(), and in some obscure cases, clang dislikes
when the argument itself is some complex macro. I didn't fully understand why,
but this works around it.

I would prefer to fix nm_hash_update_vals() to not have this limitation.
But I don't know how.

There is probably no downside to have this an inline function instead of
a macro.
2019-05-29 09:42:40 +02:00
Thomas Haller
15d87f2da0 ifcfg-rh: drop unused "nm-inotify-helper.h"
This code is now unused.

Also, it does not seem state of the art to me
anymore.

Drop it, it could always be resurrected if need by, but maybe
GFileMonitor could be used instead.
2019-05-29 09:31:03 +02:00
Thomas Haller
1ae5e6465f settings: drop deprecated NetworkManager.conf option "main.monitor-connection-files"
It's deprecated and off by default for a long time.

It is bad to automatically reload connection profiles. For example, ifcfg
files may consist of multiple files, there is no guarantee that we
pick up the connection when it's fully written.

Just don't do this anymore.

Users should use D-Bus API or `nmcli connection reload` or `nmcli
connection load $FILENAME` to reload profiles from disk.
2019-05-28 17:51:24 +02:00
Lubomir Rintel
e05a256724 modem: use set conn.interface upon completing the CDMA connections
There doesn't seem to be a better way to pinpoint a CDMA connection to a
device. This will have to do for now.
2019-05-28 15:03:20 +02:00
Lubomir Rintel
26aefe4660 infiniband: complete an interface name in complete_connection()
If the AddAndActivate() caller didn't explicitely a MAC address, default
to pinpointing the connection to the device by the means of an interface
name. This makes more sense than a MAC address with stable device names.
2019-05-28 15:03:20 +02:00