Commit graph

23049 commits

Author SHA1 Message Date
Thomas Haller
df769c8dfd ifcfg-rh: support serializaing all possible values for ethernet.s390-options (OPTIONS)
While the keys of s390-options are from a well-behaving set of names
(that is enforced by nm_connection_verify()), the values are arbitrary
strings.

Our settings plugin must be able to express all values of a connection,
hence we need to support escapes.
2019-04-25 09:26:35 +02:00
Thomas Haller
0a8f11639a libnm: refactor implementation of "ethernet.s390-options" property
- the previous implementation of nm_setting_wired_get_s390_option()
  returned the elements in an arbitrary order (because it just iterated
  idx times over the unsorted hash table).

- the API for "s390-options" suggests both accessing by index and by
  name. Storing the options in a hash-table is not optimal for lookup
  by index. It also requires us to sort the elements over and over
  again.
  Use instead a sorted array. Note that add/remove of course requires to
  move the elements (and has thus O(n)).

- "s390-options" are very seldomly set. We shouldn't pay the price in every
  NMSettingWired to allocate a GHashTable and deal with it.

- don't assert in nm_setting_wired_add_s390_option() and
  nm_setting_wired_remove_s390_option() that the key is valid.
  ifcfg-rh reader understandably does not want to implement additional
  logic to pre-validate the key, so any invalid keys would trigger an
  assertion failure. We have verify() for this purpose.
2019-04-25 09:22:51 +02:00
Thomas Haller
cf9b8d3bad libnm/keyfile: implement ethernet.s390-options in keyfile
Currently, nm_setting_wired_get_s390_option() returns the key
in an undefined order. Hence, the keyfile writer and the test
need to awkwardly sort the keys first. That will be solved better
in the next commit, when nm_setting_wired_get_s390_option() returns
the items sorted by key.
2019-04-25 09:07:55 +02:00
Thomas Haller
2f9e55ee52 shared,libnm-core: use nm_utils_named_value_list_sort() 2019-04-25 08:53:51 +02:00
Thomas Haller
6d472dacb4 shared: add nm_utils_named_value_list_*() utils
nm_utils_named_value_list_find(), nm_utils_named_value_list_sort(),
and nm_utils_named_value_list_is_sorted().
2019-04-25 08:53:51 +02:00
Thomas Haller
020c4c81d8 cli: drop GValue transform functions for strdict and implement it in _get_fcn_gobject_impl()
The only remaining GValue transform function was from GHashTable (of (str,str) type)
to string. Drop that too, and implement the conversion in _get_fcn_gobject_impl().

Note that there are few GObject properties of type GHashTable and most
of them implement their own logic. This only applies to
"802-3-ethernet.s390-options".

Also, always sort the keys. Otherwise, the output is not stable.
2019-04-25 08:20:03 +02:00
Thomas Haller
e55a45faa2 cli: drop GValue transformation of GBytes to string and implement bytes getter via _get_fcn_gobject_impl()
The g_value_register_transform_func() for handling GBytes was not actually used.
All properties of type G_TYPE_BYTES have their explit handler how to convert bytes
to string. That is good, because the implementation there was very bad (it did not
honor pretty/parsable get-type).

Also, merge _get_fcn_gobject_bytes() into _get_fcn_gobject_impl(). We
already have a generic handler that handles properties solely based on
the GObject type: _get_fcn_gobject_impl(). Just let it also handle
bytes. It's better to have fewer handlers, if they don't need special
context.
2019-04-25 08:20:03 +02:00
Thomas Haller
d4d1e5f00d cli: drop GValue transform function for G_TYPE_STRV to G_TYPE_STRING
It's ugly to modify the global behavior of glib to convert between
types. Instead, _get_fcn_gobject_impl() is perfectly capable to implement
converting a strv array to string.
2019-04-25 08:20:03 +02:00
Thomas Haller
655a920577 cli: cleanup and fix handling of unset/empty "ipv4.dns-options"
"ipv4.dns-options" and "ipv6.dns-options" are special, in that they can
be either unset/default or an empty list of options. That means, nmcli
must treat these two options differently.

For the (terse) getter, it returns "" for default and " " for empty.
The setter must likewise support and distingish between these two cases.

Cleanup the handling of such options. This only applies to properties of
type "multilist". Hence, add multilist.clear_emptyunset_fcn() handler
that indicates that the property is of that kind.

Try:

  nmcli connection modify "$PROFILE" ipv4.dns-options ''
  nmcli connection modify "$PROFILE" ipv4.dns-options ' '

and compare the output:

  nmcli connection show "$PROFILE" | sed -n '/ipv4.dns-options/ s/.*/<\0>/p'
  nmcli -t connection show "$PROFILE" | sed -n '/ipv4.dns-options/ s/.*/<\0>/p'
  nmcli -o connection show "$PROFILE" | sed -n '/ipv4.dns-options/ s/.*/<\0>/p'
2019-04-25 08:13:02 +02:00
Thomas Haller
bee4d30bec cli: add RETURN_STR_TEMPORARY() macro to "clients/common/nm-meta-setting-desc.c"
Will be used next.
2019-04-25 07:53:48 +02:00
Thomas Haller
d76f3748de cli: use escaped-tokens style for team-link-watcher list properties
The link-watcher properties are not expected to contain any special values
that require escaping. Hence, change the tokenizing from plain splitting
at ',' to escaped-tokens style is likely to not affect any existing
setups.

Still, all our properties should be handled the same way (including a
tokenizing which allows escaping to represent every possible value).
2019-04-25 07:50:59 +02:00
Thomas Haller
a473ab431a cli: refactor team-link-watcher to/from strings
Stricter parsing of the string:

- reject attributes that don't make sense depending on the type.

- reject duplicate attributes.
2019-04-25 07:50:47 +02:00
Thomas Haller
2800574221 shared: fix to/from string of vlanid and missed-max values for NMTeamLinkWatcher
The vlanid and missed-max values have non-zero default values.
That is what nm_utils_team_link_watcher_from_string() honors.

Note that nm_utils_team_link_watcher_to_string() must omit printing
the value only if it's the default value too.

Otherwise, these values are not preserved during a to string conversion
and back.

Maybe a better fix would be to always print the values, regardless of
the default value. But arguably, that is quite ugly because in most
cases we don't want to cluter the string output with values that are
left at the default.
2019-04-25 07:49:56 +02:00
Thomas Haller
2aa81edeaf shared/tests: add test for NMTeamLinkWatcher to/from string 2019-04-25 07:49:56 +02:00
Thomas Haller
7a25f67af7 shared/tests: add tests for libnm-core-aux
These tests cannot (easily) be under "shared/nm-libnm-core-aux/tests"
because libnm/libnm-core requires code under shared while
"nm-libnm-core-aux" requires libnm/libnm-core. With autotools that is
not problem, but with meson we include sub directories in a particular
order and there is no way to foward declare stuff (AFAIK). To avoid
the circular dependency, add the tests to "clients/common/tests", which
is always built last.
2019-04-25 07:47:37 +02:00
Thomas Haller
911f2dfe56 shared: fix missing space printing "send-always" flag of NMTeamLinkWatcher 2019-04-25 07:47:09 +02:00
Thomas Haller
db9fbcee6c cli,shared: move NMTeamLinkWatcher to/from string function to "nm-libnm-core-aux.h"
to/from string functions are useful. We should be able to reuse them.
Move them to their own location.

Also, it moves independent code out of "clients/common/nm-meta-setting-desc.c"
which is already one of the largest source files we have.

Also, it makes the code unit-testable, which is obviously required
as the code has bugs.
2019-04-25 07:46:17 +02:00
Thomas Haller
14b94e6adf shared: add "nm-libnm-core-aux/nm-libnm-core-aux.h" 2019-04-25 07:45:31 +02:00
Beniamino Galvani
bb9e3195d2 manager: merge branch 'bg/sw-device-sleep-rh1701585'
https://bugzilla.redhat.com/show_bug.cgi?id=1701585
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/123
2019-04-24 16:20:52 +02:00
Beniamino Galvani
32ee51eee0 manager: unmanage software devices when networking gets disabled
If a user disables networking, we consider that as an indication that
also software devices must be disconnected. OTOH, we don't want to
destroy them for external events as a system suspend.
2019-04-24 16:20:11 +02:00
Beniamino Galvani
656753b708 manager: clear unmanaged-sleeping flag on software devices on resume
When networking is disabled at NM startup we unmanage all devices
(including software ones) due to SLEEPING. After networking gets
enabled again we must clear the unmanaged-sleeping flag on software
devices.
2019-04-24 16:20:11 +02:00
Beniamino Galvani
2d347e7e17 cli: don't wait for connection change on update failure
When saving a connection, we wait the connection-changed signal before
proceeding to ensure that the remote connection is up to date.
However, no signal is emitted if the update fails and so we shouldn't
wait for it.

Fixes: a370faeb59 ('cli: wait for changed signal after updating a connection'):

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/124
https://bugzilla.redhat.com/show_bug.cgi?id=1702203
2019-04-24 16:18:25 +02:00
Till Maas
fb9f28a323 README: Update git clone command
https://github.com/NetworkManager/NetworkManager/pull/349
2019-04-24 13:19:34 +02:00
Thomas Haller
17adf58d5d tools: fix out-of-tree build test "tools/check-docs.sh" for duplicate generated sources
When we do an in-tree-build with autotools and an out-of-tree build
with meson (all in the same source directory), then we have the
following files:

  libnm-core/nm-core-enum-types.h
  libnm/nm-enum-types.h
  build/libnm-core/nm-core-enum-types.h
  build/libnm/nm-enum-types.h

This caused "tools/check-docs.sh" for `ninja -C build test` to fail,
because the files are detected twice:

    --- command ---
    /data/src/NetworkManager/tools/check-docs.sh /data/src/NetworkManager /data/src/NetworkManager/build
    --- stderr ---
    8a9
    > nm-core-enum-types
    38a40
    > nm-enum-types
    *** Error: libnm classes not included in docs/libnm/libnm-docs.xml ***
    -------
2019-04-23 11:45:06 +02:00
Thomas Haller
a9b4362fc5 tools: cleanup path variable in "tools/check-docs.sh"
- don't append the path separator to the SOURCEDIR variable.
  Instead, use the path separator when we need it.
2019-04-23 11:45:06 +02:00
Thomas Haller
b237c4303f release: bump version to 1.19.1-dev after 1.18.0 release
After 1.18.0 is released, merge it back into master so that
1.18.0 is part of the history of master. That means,
  $ git log --first-parent master
will also traverse 1.18.0 and 1.18-rc*.

Also bump the micro version to 1.19.1-dev to indicate that this is
after 1.18.0 is out.
2019-04-21 12:56:26 +02:00
Thomas Haller
cb73953183 release: bump version to 1.18.0 2019-04-21 12:45:54 +02:00
Thomas Haller
b86830512e release: update NEWS 2019-04-21 12:45:08 +02:00
Thomas Haller
d1484f5f36 libnm: add missing NM_AVAILABLE_IN_1_18 markers to nm_ip_routing_rule_*() API
(cherry picked from commit 32594889bf)
2019-04-21 12:42:57 +02:00
Thomas Haller
32594889bf libnm: add missing NM_AVAILABLE_IN_1_18 markers to nm_ip_routing_rule_*() API 2019-04-21 12:42:38 +02:00
Thomas Haller
f43fb59b6d gitlab-ci: install glib2-doc via "contrib/fedora/REQUIRED_PACKAGES"
We also generate a source tarball and artifact it.

Hence, we need proper gtk-doc links. This requires files in
/usr/share/gtk-doc/html for adding cross links. Install glib2-doc
package.

Note that in containers dnf is configured to not install documentation
files. We need to override that.

(cherry picked from commit a0f31e4038)
2019-04-20 21:02:16 +02:00
Thomas Haller
a0f31e4038 gitlab-ci: install glib2-doc via "contrib/fedora/REQUIRED_PACKAGES"
We also generate a source tarball and artifact it.

Hence, we need proper gtk-doc links. This requires files in
/usr/share/gtk-doc/html for adding cross links. Install glib2-doc
package.

Note that in containers dnf is configured to not install documentation
files. We need to override that.
2019-04-20 19:36:39 +02:00
A S Alam
a7474edcc6 po: updated Panjabi (pa) Translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/120
(cherry picked from commit 0247c06d97)
2019-04-20 18:07:07 +02:00
A S Alam
0247c06d97 po: updated Panjabi (pa) Translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/120
2019-04-20 18:06:28 +02:00
Thomas Haller
69652d40f7 gitlab-ci: don't use "test && cmd" in build step
We don't want stesp to return an error, which is what
"test && cmd" does, if the test evaluates to false.

Instead, use "! test || cmd" which has more the semantics
that we want.

(cherry picked from commit 2a2c58339b)
2019-04-20 08:56:30 +02:00
Thomas Haller
6ea499ac40 libnm: don't return deep-copied strv array from nm_tc_qdisc_get_attribute_names()
Most of the caller won't require a deep-clone of the attribute
names. Likely, the fetch the name, so they can lookup the attributes.
In that common case, there is no need to clone the strings themself.

(cherry picked from commit 01e7cb11bf)
2019-04-20 08:56:29 +02:00
Thomas Haller
70d8f5ddfe libnm-core: avoid cloning attributes of NMTCQdisc/NMTCAction to convert to string
(cherry picked from commit 48316f987a)
2019-04-20 08:56:27 +02:00
Thomas Haller
2a2c58339b gitlab-ci: don't use "test && cmd" in build step
We don't want stesp to return an error, which is what
"test && cmd" does, if the test evaluates to false.

Instead, use "! test || cmd" which has more the semantics
that we want.
2019-04-20 08:53:37 +02:00
Thomas Haller
01e7cb11bf libnm: don't return deep-copied strv array from nm_tc_qdisc_get_attribute_names()
Most of the caller won't require a deep-clone of the attribute
names. Likely, the fetch the name, so they can lookup the attributes.
In that common case, there is no need to clone the strings themself.
2019-04-20 08:09:52 +02:00
Thomas Haller
48316f987a libnm-core: avoid cloning attributes of NMTCQdisc/NMTCAction to convert to string 2019-04-20 08:09:33 +02:00
Thomas Haller
79ecdb589b gitlab-ci: build release tarball and artifact it
(cherry picked from commit 84e19c6ca9)
2019-04-19 11:31:57 +02:00
Thomas Haller
84e19c6ca9 gitlab-ci: build release tarball and artifact it 2019-04-19 09:38:12 +02:00
Thomas Haller
7973680ca2 gitlab-ci: build on Ubuntu 16.04, 18.04 and Debian stretch (9), testing, sid
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/119
(cherry picked from commit 1ca380f69f)
2019-04-19 08:22:14 +02:00
Thomas Haller
1ca380f69f gitlab-ci: build on Ubuntu 16.04, 18.04 and Debian stretch (9), testing, sid
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/119
2019-04-19 08:20:12 +02:00
Thomas Haller
fdac4b3bcf build/meson: skip building fake-typelib if gnome.compile_resources() too old
Otherwise, the meson configure step fails with:

  libnm/fake-typelib/meson.build:23:0: ERROR: The "dependencies" argument of gnome.compile_resources() can not
  be used with the current version of glib-compile-resources due to
  <https://bugzilla.gnome.org/show_bug.cgi?id=774368>

The fake-typelib is not really essential. Don't fix it, just print
a warning that we are unable to build it.
2019-04-19 07:34:41 +02:00
Till Maas
51aee380c0 contrib/rpm: Provide list of units to %systemd_postun
%systemd_postun is meant to be run with arguments and Fedora Rawhide
seems to enforce this now. Therefore provide the units there, too.

https://github.com/NetworkManager/NetworkManager/pull/348
(cherry picked from commit 7d62f81e2e)
2019-04-18 21:51:35 +02:00
Till Maas
7d62f81e2e contrib/rpm: Provide list of units to %systemd_postun
%systemd_postun is meant to be run with arguments and Fedora Rawhide
seems to enforce this now. Therefore provide the units there, too.

https://github.com/NetworkManager/NetworkManager/pull/348
2019-04-18 21:51:10 +02:00
Thomas Haller
69b8036f37 build/meson: fix location of introspection files
With glib < 2.51.3, gdbus-codegen does not understand "--output-directory" [1].
Hence, the generated files are like

    "build/dbus-org.freedesktop.NetworkManager.Device.WifiP2P.xml"

instead of

    "build/introspection/dbus-org.freedesktop.NetworkManager.Device.WifiP2P.xml"

But gnome.gdbus_codegen() returns a path as if it would be inside
"build/introspection". Hack around that, by patching the correct path
otherwise. This is still ugly, because repeated "ninja -C build" calls
will always try to rebuild this target (because the wrong file name
is considered).

See also [2].

[1] ee09bb704f
[2] 2e93ed58c3/mesonbuild/modules/gnome.py (L1170)

(cherry picked from commit ad9e5995e1)
2019-04-18 20:20:46 +02:00
Thomas Haller
ed88c71f15 platform: fix nm_platform_lnk_gre_to_string() for tap links
Why didn't we get a compiler warning about this bug?
At least clang (3.8.0-2ubuntu4, Ubuntu 16.04) warns:

    CC       src/platform/src_libNetworkManagerBase_la-nm-platform.lo
  ../src/platform/nm-platform.c:5389:14: error: data argument not used by format string [-Werror,-Wformat-extra-args]
                      lnk->remote ? nm_sprintf_buf (str_remote, " remote %s", nm_utils_inet4_ntop (lnk->remote, str_remote1)) : "",
                      ^

Fixes: 4c2862b958 ('platform: add gretap tunnels support')
(cherry picked from commit dfb899f465)
2019-04-18 20:20:44 +02:00
Thomas Haller
ad9e5995e1 build/meson: fix location of introspection files
With glib < 2.51.3, gdbus-codegen does not understand "--output-directory" [1].
Hence, the generated files are like

    "build/dbus-org.freedesktop.NetworkManager.Device.WifiP2P.xml"

instead of

    "build/introspection/dbus-org.freedesktop.NetworkManager.Device.WifiP2P.xml"

But gnome.gdbus_codegen() returns a path as if it would be inside
"build/introspection". Hack around that, by patching the correct path
otherwise. This is still ugly, because repeated "ninja -C build" calls
will always try to rebuild this target (because the wrong file name
is considered).

See also [2].

[1] ee09bb704f
[2] 2e93ed58c3/mesonbuild/modules/gnome.py (L1170)
2019-04-18 20:18:17 +02:00