Commit graph

19065 commits

Author SHA1 Message Date
Thomas Haller
f13b97a9e4 keyfile: reject team properties in parser
We don't properly coordinate reading the team properties from keyfile.
They must be ignored, at least for now.

(cherry picked from commit 1b8ae83967)
2017-12-08 11:32:41 +01:00
Francesco Giudici
f092cc0f94 merge: branch 'fg/team_abstraction_tests_and_fixes_rh1398925'
https://bugzilla.redhat.com/show_bug.cgi?id=1398925

(cherry picked from commit 4d1796b2c7)
2017-12-08 04:00:09 +01:00
Francesco Giudici
78d10c9d18 libnm-core: add test cases for NMSettingTeamPort
(cherry picked from commit b5f0d61d03)
2017-12-08 04:00:09 +01:00
Francesco Giudici
7abcede5bb libnm-core: add test cases for NMSettingTeam
(cherry picked from commit 1248969342)
2017-12-08 04:00:09 +01:00
Francesco Giudici
ace038539a gitignore: ignore libnm-core/tests/test-setting
We now have merged in libnm-core/tests/test-setting test file the test
files for 8021x, bond and dcb... add the new test file to .gitignore and
remove the old ones.

(cherry picked from commit 540b7b3dfd)
2017-12-08 04:00:09 +01:00
Lubomir Rintel
bb3fc9769b libnm-core: merge the settings tests into a single one
Thomas likes this more and who am I to argue.

(cherry picked from commit 9bb30f86ec)
2017-12-08 04:00:09 +01:00
Francesco Giudici
bc92380a76 libnm-core: team: skip writing in the keyfile all the exposed properties
Their values are already saved in the team.config and team-port.config
properties, from which they are synced.

(cherry picked from commit bb4c95e168)
2017-12-08 04:00:09 +01:00
Francesco Giudici
4525b7e208 libnm-core: team: change tx-hash APIs idx type from int to guint
(cherry picked from commit 4c7a841823)
2017-12-08 04:00:09 +01:00
Francesco Giudici
5d79b6cc42 libnm-core: team: rework defaults management on runner properties
till now when no explicit value was set on a property, the default value
for that property was returned, also if the property was not applicable
to the selected runner.
Fix this, showing default values for properties only when relevant and
showing instead -1 or null when the property is not relevant for the
selected runner.
Moreover, reset all the properties but the link-watchers when the team.runner
is changed: this is required to clean up the properties unrelated to the
new runner and start with the runner-specific defaults.

(cherry picked from commit a5642fd93a)
2017-12-08 04:00:08 +01:00
Francesco Giudici
07a49b30af libnm-core: team: use the correct name for teamd property 'balancing_interval'
the teamd 'runner.tx_balancer.balancing_interval' property was wrongly
set and searched as 'runner.tx_balancer.interval'. Fixed.

Fixes: fc3b7d61e2
(cherry picked from commit ed2a1a153b)
2017-12-08 04:00:08 +01:00
Francesco Giudici
dd18259c63 libnm-core: json: share code to load defaults in team(-port).config
Move code from _nm_utils_team_config_get to the brand new
_json_team_add_defaults function without any change.
Then remove the duplicated code from _nm_utils_team_config_equal and
leverage the new function. Here the only functional change is that
the defaults for "notify_peers" and "mcast_rejoin" for the
"activebackup" runner are added (the only case in which their default
values are different than 0).

(cherry picked from commit fdd41852ee)
2017-12-08 04:00:08 +01:00
Francesco Giudici
a2357fea43 libnm-core: trivial: just move static json functions
(cherry picked from commit f0ae71e7d6)
2017-12-08 04:00:08 +01:00
Francesco Giudici
ad1be3a472 libnm-core: trivial: move json key deletion code to a separate function
(cherry picked from commit 8648aa576e)
2017-12-08 04:00:08 +01:00
Francesco Giudici
e8eb416675 libnm-core: use proper writer for team-port link-watchers
(cherry picked from commit 16c9435c5b)
2017-12-08 04:00:08 +01:00
Francesco Giudici
07b1e80803 cli: add support to TeamPort link watchers
(cherry picked from commit c5228b8a83)
2017-12-08 04:00:08 +01:00
Francesco Giudici
704f0acb77 libnm-core: team-port: expose the new link-watchers property
It will allow explicit configuration of link-watchers in the team port
configuration.

(cherry picked from commit f094837d73)
2017-12-08 04:00:08 +01:00
Francesco Giudici
10745107f2 libnm-core: add keyfile writer for team link watcher
Allow tests to dump the content of the property when getting a failure.

(cherry picked from commit 0d8fcc39ab)
2017-12-08 04:00:08 +01:00
Francesco Giudici
62876cee9a libnm-core: synchronize team.link_watchers when team.config is set.
(cherry picked from commit 363a2cfe95)
2017-12-08 04:00:07 +01:00
Francesco Giudici
a1c25edfe8 libnm-core: synchronize team.config when team.link_watchers is set.
(cherry picked from commit e59878ce19)
2017-12-08 04:00:07 +01:00
Francesco Giudici
2eacf89f38 cli: add support to Team link watchers
(cherry picked from commit 4657390d45)
2017-12-08 04:00:07 +01:00
Francesco Giudici
466f8e0dd5 libnm-core: team: expose the new link-watchers property
It will allow explicit configuration of link-watchers in the team
configuration.

(cherry picked from commit ca816ae10e)
2017-12-08 04:00:07 +01:00
Francesco Giudici
574d70b2eb libnm-core: add backend for GVariant de/serialization of link_watchers.
(cherry picked from commit ba4ce843fa)
2017-12-08 04:00:07 +01:00
Francesco Giudici
e9d5836937 libnm-core: team: add NMTeamLinkWatcher boxed type
Team allows to specify multiple link watchers for each link.
Define a link watcher object in order to allow to specify multiple ones
for each Team configuration.

(cherry picked from commit 72f6d08714)
2017-12-08 03:59:59 +01:00
Francesco Giudici
000e02f56a ifcfg-rh: tests: align json team configuration format to jansson one
(cherry picked from commit 53821a4b13)
2017-12-08 02:18:01 +01:00
Francesco Giudici
5cbe512fd3 libnm-core: preserve keys order in team.config with old jansson libs
When jansson lib version is < 2.8 the order of the keys of json objects
is not preserved automatically. In particular, when loading the json
string, parsing it and dumping it back to a string the key order will be
lost if the now deprecated JSON_PRESERVE_ORDER flag is not set.
Add the flag: will do nothing on recent jansson versions but will fix
behavior for legacy ones.

(cherry picked from commit 5e6f7de4be)
2017-12-08 02:16:52 +01:00
Francesco Giudici
f5e358eb46 merge: branch 'fg/team_abstraction_rh1398925'
https://bugzilla.redhat.com/show_bug.cgi?id=1398925

(cherry picked from commit 9022b14478)
2017-12-08 02:10:27 +01:00
Francesco Giudici
921635d3ae libnm-core: enforce team and team-port defaults
Rework a bit the way default values are check, set and aligned.

(cherry picked from commit 3e34e404b4)
2017-12-08 02:10:27 +01:00
Francesco Giudici
5b9f4202d6 cli: add team-port properties
(cherry picked from commit 81527f1a09)
2017-12-08 02:10:27 +01:00
Francesco Giudici
8b171fd8ae libnm-core: enforce team-port config and properties alignment
Ensure .config is aligned when an explicit team-port is set and vice
versa

(cherry picked from commit ec60e01d39)
2017-12-08 02:10:26 +01:00
Francesco Giudici
7d9553da50 libnm-core: add explicit team properties to NMSettingTeamPort
(cherry picked from commit 1c99d379eb)
2017-12-08 02:10:22 +01:00
Francesco Giudici
316a6ea3be cli: add team properties
(cherry picked from commit e1220c933f)
2017-12-08 02:08:57 +01:00
Francesco Giudici
4926ca42e7 libnm-core: enforce team config and properties alignment
Ensure .config is aligned when an explicit team property is set and vice versa.

(cherry picked from commit fc3b7d61e2)
2017-12-08 02:08:57 +01:00
Francesco Giudici
b42ad17e2d libnm-core: add explicit team properties to NMSettingTeam
(cherry picked from commit 9715969b77)
2017-12-08 02:08:49 +01:00
Francesco Giudici
6812997c38 libnm-core: add inline functions to update team json config
Add functions and structure to simplify json config and team property
enforcement. These will be used in both NMSettingTeam and
NMSettingTeamPort.

(cherry picked from commit b4c9bcd49f)
2017-12-08 01:59:46 +01:00
Francesco Giudici
4831edaa78 libnm-core: add functions to align team json config to exposed properties
(cherry picked from commit dadf710ee3)
2017-12-08 01:59:41 +01:00
Beniamino Galvani
b2a9e2f326 ifcfg-rh: use separate variables for DNS searches
DNS searches from the ipv4 and ipv6 settings were joined and written
to the same ifcfg-rh "DOMAIN" variable and so the connection read back
from disk was different from the one written.

Instead, introduce a separate variable for ipv6 searches; to preserve
backwards compatibility, still read the "DOMAIN" variable for ipv6
when ipv4 is disabled so that we don't lose DNS searches on upgrade.

https://bugzilla.redhat.com/show_bug.cgi?id=1517794
(cherry picked from commit a9b5079324)
2017-12-07 10:00:22 +01:00
Francesco Giudici
55321009df ifcfg-rh: initialize watch descriptors to -1
This is now required as we instance inotify-helper only on need:
we have to init them to the unset value, otherwise...

	Thread 1 "NetworkManager" received signal SIGSEGV, Segmentation fault.
	nm_inotify_helper_remove_watch (self=0x0, wd=0) at src/settings/plugins/ifcfg-rh/nm-inotify-helper.c:100
	100		if (priv->ifd < 0)
	(gdb) backtrace
	#0  0x00007fffe35da6c0 in nm_inotify_helper_remove_watch (self=0x0, wd=0) at src/settings/plugins/ifcfg-rh/nm-inotify-helper.c:100
	#1  0x00007fffe35d45b1 in nm_inotify_helper_clear_watch (wd=0x7fffdc008628, helper=<optimized out>) at src/settings/plugins/ifcfg-rh/nm-inotify-helper.h:53
	#2  0x00007fffe35d45b1 in path_watch_stop (self=0x7fffdc0085f0) at src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c:223
	#3  0x00007fffe35d467c in filename_changed (object=0x7fffdc0085f0, pspec=<optimized out>, user_data=<optimized out>) at src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c:242
	#4  0x00007ffff61b230d in g_closure_invoke () at /lib64/libgobject-2.0.so.0
	#5  0x00007ffff61c498e in signal_emit_unlocked_R () at /lib64/libgobject-2.0.so.0
	#6  0x00007ffff61cd1a5 in g_signal_emit_valist () at /lib64/libgobject-2.0.so.0
	#7  0x00007ffff61cdb0f in g_signal_emit () at /lib64/libgobject-2.0.so.0
	#8  0x00007ffff61b6594 in g_object_dispatch_properties_changed () at /lib64/libgobject-2.0.so.0
	#9  0x00007ffff61b5f3e in g_object_notify_queue_thaw () at /lib64/libgobject-2.0.so.0
	#10 0x00007ffff61b7776 in g_object_new_internal () at /lib64/libgobject-2.0.so.0
	#11 0x00007ffff61b924d in g_object_new_valist () at /lib64/libgobject-2.0.so.0
	#12 0x00007ffff61b9691 in g_object_new () at /lib64/libgobject-2.0.so.0
	#13 0x00007fffe35d5018 in nm_ifcfg_connection_new (source=source@entry=0x0, full_path=full_path@entry=0x555555a9a590 "/etc/sysconfig/network-scripts/ifcfg-team3", error=error@entry=0x7fffffffdc30, out_ignore_error=out_ignore_error@entry=0x7fffffffdc2c) at src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-connection.c:429
	#14 0x00007fffe35d5e96 in update_connection (self=self@entry=0x555555a59ea0, source=source@entry=0x0, full_path=0x555555a9a590 "/etc/sysconfig/network-scripts/ifcfg-team3", connection=connection@entry=0x0, protect_existing_connection=protect_existing_connection@entry=0, protected_connections=protected_connections@entry=Python Exception <class 'gdb.error'> There is no member named keys.:
	0x555555a9fc00, error=0x0) at src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c:218
	#15 0x00007fffe35d7073 in read_connections (plugin=plugin@entry=0x555555a59ea0) at src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c:545
	#16 0x00007fffe35d72f1 in get_connections (config=0x555555a59ea0) at src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c:581
	#17 0x00005555556bb513 in load_connections (self=0x555555a1a920) at src/settings/nm-settings.c:239
	#18 0x00005555556bb513 in nm_settings_start (self=0x555555a1a920, error=<optimized out>) at src/settings/nm-settings.c:1800
	#19 0x00005555555ada1f in nm_manager_start (self=0x555555a490c0, error=<optimized out>) at src/nm-manager.c:5262
	#20 0x00005555555851ae in main (argc=<optimized out>, argv=<optimized out>) at src/main.c:417

Fixes: 31f2a46639
(cherry picked from commit 993a726c4a)
2017-12-07 06:53:12 +01:00
Thomas Haller
42fb6976aa all: merge fixing pointers casts for g_object_ref()
See related bug https://bugzilla.gnome.org/show_bug.cgi?id=790697

https://mail.gnome.org/archives/desktop-devel-list/2012-July/msg00100.html

(cherry picked from commit cdbe1ad715)
2017-12-06 10:50:12 +01:00
Thomas Haller
85b1c11b8f shared: propagate type for g_object_ref()
See related bug https://bugzilla.gnome.org/show_bug.cgi?id=790697

(cherry picked from commit 7ca601d529)
2017-12-06 10:44:45 +01:00
Thomas Haller
ceeeb51e1d all: use cast macros instead of C cast
When building with assertions, they nm_assert() for the
type. Otherwise, they are identical to a C cast.

Also, where possible, don't cast at all, but adjust
the type instead.

Also, there were a few missing casts.

(cherry picked from commit 7661ad64ba)
2017-12-06 10:44:44 +01:00
Colin Walters
4bd3069b68 tree-wide: cast after g_object_ref() for proposed GLib patch
This fixes the build with related bug https://bugzilla.gnome.org/show_bug.cgi?id=790697

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00005.html
(cherry picked from commit 3f6bef47f3)
2017-12-06 10:44:44 +01:00
Thomas Haller
ad7f1d18a0 core: merge branch 'th/user-block-autoconnect-rh1401515'
https://bugzilla.redhat.com/show_bug.cgi?id=1401515

(cherry picked from commit 632e693251)
2017-12-06 09:40:43 +01:00
Thomas Haller
a0a4722432 settings: support setting a connection as volatile via Update2()
Extend the Update2 flags to allow marking a connection as volatile.
Making a connection as volatile means that the connection stays alive
as long as an active connection references it.

It is correct that Update2() returns before the connection is actually
deleted. It might take an arbitrary long time until the volatile
mechanism cleans up the connection.

Also add two more IN_MEMORY flags: "detached" and "only".

The existing NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY would not detach nor
delete the possible file on disk. That is, the mode only changes what NM
thinks is the current content of the connection profile. It would not delete
the file on disk nor would it detach the profile in-memory from the file.
As such, later persisting the connection again to disk would overwrite
the file, and deleting the profile, would delete the file.

Now add two new IN_MEMORY modes.

NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_DETACH is like making the connection
in-memory only, but forgetting that there might be any profile on disk.
That means, a later Delete() would not delete the file. Similarly, a
later Update2() that persists the connection again, would not overwrite
the existing file on disk, instead it would choose a new file name.

On the other hand, NM_SETTINGS_UPDATE2_FLAG_IN_MEMORY_ONLY would delete
a potential file from disk right away.

It's clear that "volatile" only makes sense with either "in-memory-detached"
or "in-memory-only". That is, the file on disk should be deleted right away
(before the in-memory part is garbage collected) or the file on disk should
be forgotten.

(cherry picked from commit 35dc6421de)
2017-12-06 09:35:43 +01:00
Thomas Haller
9834c39b73 settings: delete volatile connection and support setting the volatile flag
Previously, we would only set a connection as volatile before
adding it to manager. As we never would set it volatile last on,
there was no need to handle deletion.

Now support that. Watch the volatile flag, and if the connection
has currently not active connection that keeps it alive, delete
it in an idle handler.

(cherry picked from commit cfced599ca)
2017-12-06 09:35:43 +01:00
Thomas Haller
e36b647c4b shared/trivial: fix type on comment
(cherry picked from commit 011a609bd4)
2017-12-06 09:35:43 +01:00
Thomas Haller
4c432ec6a6 manager/trivial: reorder declarations at beginning of file
First, define structs. Then forward declare functions. Reorder code
to have a certain order that is also used by other files (or should
be).

(cherry picked from commit 4c84f74326)
2017-12-06 09:35:43 +01:00
Thomas Haller
446c86f4be settings: let invisible connection not autoconnect according to is_blocked() function
Previously, NMPolicy would explicitly check whether the connection is not visible,
to skip autoconnect.

We have nm_settings_connection_autoconnect_is_blocked() function, that can do that.
The advantage is, that at various places we call nm_settings_connection_autoconnect_is_blocked()
to determine whether autoconnect is blocked. By declaring invisible connections
as blocked from autoconnect as well, we short-cut various autoconnection attempts,
that previoulsy only failed later during auto_activate_device().

(cherry picked from commit ccc93639a0)
2017-12-06 09:35:43 +01:00
Thomas Haller
ab24d5356c settings: remove accessor functions to connection flags
The accessor functions just look whether a certain flag is set. As these
functions have a different name then the flags, this is more confusing
then helpful. For example, if you want to know where the NM_GENERATED
flag matters, you had to know to grep for nm_settings_connection_get_nm_generated()
in addition to NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED.

The accessor function hid that the property was implemented as
a connection flag. For example, it was not immediately obvious
that nm_settings_connection_get_nm_generated() is the same
as having the NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED flag
set.

Drop them.

(cherry picked from commit 545e3111c8)
2017-12-06 09:35:43 +01:00
Thomas Haller
e3d81c167c settings: refactor setting connection flags
It seems more idiomatic to have a mask+value argument, instead
of setting all flags at once. At least, other setters work this
way, so change it for consistency.

(cherry picked from commit 4549bd07a1)
2017-12-06 09:35:43 +01:00
Thomas Haller
1c071d388c settings: track visible state as regular connection flags
We already need to re-emit the notify::flags signal.
It's cumbersome to do this for boolean properties, so
re-use the flags to also track the visibility state.

(cherry picked from commit 0e1abe5ef3)
2017-12-06 09:35:43 +01:00