Commit graph

696 commits

Author SHA1 Message Date
Lubomir Rintel 1491efa5d8 meson: run the check-export.sh in test phase
Targets not depended on by anything are not useful and likely never get run.
2018-06-28 20:38:52 +02:00
Lubomir Rintel d6c08691d9 libnm/meson: make generate_setting_docs depend on the typelib
Otherwise it would attempt to use a system-wide installed one, resulting
in sadness and misery.
2018-06-28 20:38:52 +02:00
Lubomir Rintel 21840f5321 meson: generate-setting-docs.py environment correctly
It's ugly, because meson doesnt' seem to provide any useful facilities for
dealing with environment variables. Not my fault.
2018-06-28 20:38:52 +02:00
Timothy Redaelli 9be0c3330d contrib/rpm: Use Open vSwitch instead of OpenVSwitch
The correct naming is Open vSwitch so use it instead of OpenVSwitch

[lkundrak@v3.sk: added some more cases of the same]

https://github.com/NetworkManager/NetworkManager/pull/150

Fixes: 830a5a14cb
2018-06-28 20:31:32 +02:00
Lubomir Rintel 3cd9322298 libnm: add support form 6LoWPAN devices 2018-06-26 16:21:55 +02:00
Lubomir Rintel b7173ad7a7 devices: add NMDevice6Lowpan 2018-06-26 16:21:55 +02:00
Lubomir Rintel 7c1f3650a1 core: add NMSetting6Lowpan 2018-06-26 16:21:55 +02:00
Lubomir Rintel a3baf1ca21 libnm: add support for WPAN devices 2018-06-26 16:21:55 +02:00
Lubomir Rintel 179909a4f2 devices: add NMDeviceWpan 2018-06-26 16:21:54 +02:00
Lubomir Rintel 8884b2cb5e core: add NMSettingWpan 2018-06-26 16:21:54 +02:00
Thomas Haller 9bc6ca96f6 libnm: fix leaking filename in NMRemoteConnection
Fixes: bd6fe17815
2018-06-21 16:06:41 +02:00
Lubomir Rintel 0132da1ddb libnm: add nm_utils_get_timestamp_msec() 2018-06-15 16:23:30 +02:00
Lubomir Rintel 07fd0502f6 wifi: expose LastScan as milliseconds not seconds
This doesn't wrap around in 68 years of uptime and is consistent with
o.fd.NM.Checkpoint.Created.
2018-06-15 16:23:30 +02:00
Lubomir Rintel 1c0aa397b3 libnm: correctly demarshall (u)int64 values 2018-06-15 16:23:30 +02:00
Thomas Haller 576cbb771a libnm: always return VPN connections's banner
It's not libnm's responsibility to hide the banner
depending on the VPN state. libnm should cache and expose
NetworkManager's state, and if the VPN connection has
a banner there, it should be returned.

The previous behavior was since ever in libnm, and in libnm-glib since
the banner was introduced in commit e5b834c1f9.
I think it's wrong if libnm tries too hard putting additional logic
on top of what is on D-Bus.
2018-06-15 11:56:04 +02:00
Simon Fels 58cdc7b550 libnm-core: add wake-on-wlan configuration items
Co-authored-by: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
2018-06-15 09:46:26 +02:00
Beniamino Galvani bb20f2eb61 macsec: enable send-sci by default and make the option configurable
It is safer to enable send-sci by default because, at the cost of
8-byte overhead, it makes MACsec work over bridges (note that kernel
also enables it by default). While at it, also make the option
configurable.

https://bugzilla.redhat.com/show_bug.cgi?id=1588041
2018-06-14 15:13:11 +02:00
Lubomir Rintel c00e17578f wifi: expose the LastScan property
This is the time when the last Wi-Fi scan finished. It will help clients
decide whether the AP list is fresh enough.
2018-06-13 14:44:06 +02:00
Lubomir Rintel bd6fe17815 libnm/remote-connection: add filename property 2018-06-11 15:06:49 +02:00
Francesco Giudici 7a0b6b17bb libnm-core: add ipv6.dhcp-duid property
allow to specify the DUID to be used int the DHCPv6 client identifier
option: the dhcp-duid property accepts either a hex string or the
special values "lease", "llt", "ll", "stable-llt", "stable-ll" and
"stable-uuid".

"lease": give priority to the DUID available in the lease file if any,
         otherwise fallback to a global default dependant on the dhcp
         client used. This is the default and reflects how the DUID
         was managed previously.
"ll": enforce generation and use of LL type DUID based on the current
      hardware address.
"llt": enforce generation and use of LLT type DUID based on the current
       hardware address and a stable time field.
"stable-ll": enforce generation and use of LL type DUID based on a
             link layer address derived from the stable id.
"stable-llt": enforce generation and use of LLT type DUID based on
              a link layer address and a timestamp both derived from the
              stable id.
"stable-uuid": enforce generation and use of a UUID type DUID based on a
               uuid generated from the stable id.
2018-06-08 18:23:31 +02:00
Thomas Haller f445128af4 build/meson: fix meson build for shared files
The files in shared/nm-utils are not compiled as one static library,
instead each subproject that needs (parts of) them, re-compiles the
files individually.

The major reason for that is, because we might have different compile
flags, depending on whether we build libnm-core or
libnm-util/libnm-glib. Actually, I think that is not really the case,
and maybe this should be refactored, to indeed build them all as a
static library first.

Anyway, libnm-util, libnm-glib, clients' common lib, they all need a
different set of shared files that they should compile. Refactor
"shared/meson.build" to account for that and handle it like autotools
does.

Another change is, that "shared_c_siphash_dep" no longer advertises
"include_directories: include_directories('c-siphash/src')". We don't
put c-siphash.h into the include search path. Users who need it, should
include it via "#include <c-siphash/src/c-siphash.h>". The only exception
is when building shared_n_acd library, which is not under our control.
2018-05-31 15:59:38 +02:00
Thomas Haller b7426e91db build: use default NM_BUILD_* defines for tests
Use two common defines NM_BUILD_SRCDIR and NM_BUILD_BUILDDIR
for specifying the location of srcdir and builddir.

Note that this is only relevant for tests, as they expect
a certain layout of the directories, to find files that concern
them.
2018-05-31 15:59:38 +02:00
Thomas Haller 0aff056a63 doc: add units to nm_device_get_mtu() 2018-05-23 16:17:03 +02:00
Harry Mallon 5f62b126d5 doc: add units to some libnm (and libnm-glib) function docs
https://mail.gnome.org/archives/networkmanager-list/2018-May/msg00027.html
2018-05-23 16:17:03 +02:00
Beniamino Galvani db80d5f62a build: meson: add missing nm-autoptr.h to libnm headers
Fixes: ff8e563365

https://bugzilla.gnome.org/show_bug.cgi?id=795965
2018-05-11 18:20:24 +02:00
Thomas Haller d4093a3a2c clients/tests: add python test script for nmcli tests
Add a test which runs nmcli against our stub NetworkManager
service and compares the output.

The output formats of nmcli are complicated and not easily understood.
For example how --mode tabular|multiline interacts with selecting
output-fields (--fields) and output modes ([default]|--terse|--pretty).
Also, there are things like `nmcli connection show --order $FIELD_SPEC`.

We need unit tests to ensure that we don't change the output
accidentally.
2018-05-11 16:51:20 +02:00
Thomas Haller 9628aabc2f tests: use libnm via pygobject in tools/test-networkmanager-service.py
tools/test-networkmanager-service.py is our NetworkManager stub server.

NetworkManager uses libnm(-core) heavily, for example to decide whether
a connection verifies (nm_connection_verify()) and for normalizing
connections (nm_connection_normalize()).

If the stub server wants to mimic NetworkManager, it also must use these
function. Luckily, we already can do so, by loading libnm using python
GObject introspection.

We already correctly set GI_TYPELIB_PATH search path, so that the
correct libnm is loaded -- provided that we build with introspection
enabled.

We still need to gracefully fail, if starting the stub server fails.
That requries some extra effort. If the stub server notices that
something is missing, it shall exit with status 77. That will cause
the tests to g_test_skip().
2018-05-11 16:51:20 +02:00
Harry Mallon fe3db7aed3 doc: fix GTK-Doc NMRoute links
https://mail.gnome.org/archives/networkmanager-list/2018-May/msg00000.html
2018-05-11 16:49:25 +02:00
Lubomir Rintel e69d386975 all: use the elvis operator wherever possible
Coccinelle:

  @@
  expression a, b;
  @@
  -a ? a : b
  +a ?: b

Applied with:

  spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir .

With some manual adjustments on spots that Cocci didn't catch for
reasons unknown.

Thanks to the marvelous effort of the GNU compiler developer we can now
spare a couple of bits that could be used for more important things,
like this commit message. Standards commitees yet have to catch up.
2018-05-10 14:36:58 +02:00
Beniamino Galvani ed817e9ca3 libnm: export nm_connection_get_setting_tc_config()
Fixes: da13c7a1a4
2018-05-05 10:45:33 +02:00
Beniamino Galvani 37dc58f6c7 libnm: add missing device includes to NetworkManager.h 2018-05-02 09:14:56 +02:00
Beniamino Galvani 1b5925ce88 all: remove consecutive empty lines
Normalize coding style by removing consecutive empty lines from C
sources and headers.

https://github.com/NetworkManager/NetworkManager/pull/108
2018-04-30 16:24:52 +02:00
Beniamino Galvani 19876b4cfe shared: drop duplicate c-list.h header
Use the one from the project just imported.
2018-04-18 15:22:14 +02:00
Thomas Haller acc8244ca2 all: add D-Bus property "Flags" for Settings.Connection interface
The D-Bus interface already has a boolean property "Unsaved".

While that is nicer too look at (in the API), adding a new flag
is very cumbersome, and also has more overhead. For example,
it requires extending the D-Bus API, all the way down to libnm.

Add a flags argument, that will allow to add future boolean
flags easier.
2018-04-16 15:30:07 +02:00
Thomas Haller 684bf31150 all: unify spelling of translators hint in source code
Use the same form everywhere: "TRANSLATORS" instead of "Translators".
The manual also seems to prefer the upper-case form [1].

  $ sed 's/\<Translators\>: /TRANSLATORS: /g' $(git grep -l Translators) -i

[1] https://www.gnu.org/software/gettext/manual/gettext.html
2018-04-13 10:00:09 +02:00
Beniamino Galvani 0136915211 build: meson: add prefix to test names
There are multiple tests with the same in different directories; add a
unique prefix to test names so that it is clear from the output which
one is running.
2018-04-12 09:21:10 +02:00
Beniamino Galvani 0c39a02ce0 build: meson: enable all tests again
Some tests were disabled because they failed when run in parallel.
Now that we use the wrapper script they succeed and can be enabled
again.
2018-04-12 09:21:10 +02:00
Beniamino Galvani a2479b95c0 build: meson: use run-nm-test.sh to run tests
Like autotools, use the wrapper script 'run-nm-test.sh' that starts a
separate D-Bus session when needed.
2018-04-12 09:21:10 +02:00
Thomas Haller 735dc41bd0 libnm: rework checkpoint API
The libnm API fir checkpoints was only introduced with 1.11. It
is not yet stable, so there is still time to adjust it. Note that
this changes API/ABI of the development branch.

Changes:

- we only add async variants of the checkpoint functions. I believe
  that synchronous D-Bus methods are fundamentally flawed, because
  they mess up the ordering of events.
  Rename the async functions by removing the "_async" suffix. This
  matches glib style, for which the async form is also not specially
  marked.

- for function that refere to a particular checkpoint (rollback and
  destroy), accept the D-Bus path as string, instead of an NMCheckpoint
  instance. This form is more flexible, because it allows to use
  the function without having a NMCheckpoint instance at hand. On the
  other hand, if one has a NMCheckpoint instance, he can trivially
  obtain the path to make the call.
2018-04-04 14:02:13 +02:00
Thomas Haller f67303221b checkpoint: allow resetting the rollback timeout via D-Bus
This allows to adjust the timeout of an existing checkpoint.

The main usecase of checkpoints, is to have a fail-safe when
configuring the network remotely. By allowing to reset the timeout,
the user can perform a series of actions, and keep bumping the
timeout. That way, the entire series is still guarded by the same
checkpoint, but the user can start with short timeout, and
re-adjust the timeout as he goes along.

The libnm API only implements the async form (at least for now).
Sync methods are fundamentally wrong with D-Bus, and it's probably
not needed. Also, follow glib convenction, where the async form
doesn't have the _async name suffix. Also, accept a D-Bus path
as argument, not a NMCheckpoint instance. The libnm API should
not be more restricted than the underlying D-Bus API. It would
be cumbersome to require the user to lookup the NMCheckpoint
instance first, especially since libnm doesn't provide an efficient
or convenient lookup-by-path method. On the other hand, retrieving
the path from a NMCheckpoint instance is always possible.
2018-04-04 14:02:13 +02:00
Thomas Haller ab8312a18e checkpoint: generate GIR information for NMCheckpointCreateFlags
Note that this changes API for checkpoint_create_async() in Python
via GIR. Previously it would require an integer argument, now a flags
argument. But this API is still unstable, it will be introduced with
1.12.
2018-04-04 14:02:13 +02:00
Thomas Haller 6f85d3e0b9 libnm: fix crash creating checkpoint during find_checkpoint_info()
Now that the D-Bus signals in server are reordered, creating
a checkpoint in libnm crashes:

  $ examples/python/gi/checkpoint.py create 4

    #0  0x00007ffff6d011ee in __strcmp_sse2_unaligned () at /lib64/libc.so.6
    #1  0x00007fffeb611c90 in find_checkpoint_info (manager=manager@entry=0x5555559e5110 [NMManager], path=0x7fffdc0092f0 "/org/freedesktop/NetworkManager/Checkpoint/6")
        at libnm/nm-manager.c:153
    #2  0x00007fffeb611d8f in checkpoint_added (manager=0x5555559e5110 [NMManager], checkpoint=checkpoint@entry=0x555555a122d0 [NMCheckpoint]) at libnm/nm-manager.c:1194
    #3  0x00007fffef7db929 in g_cclosure_marshal_VOID__OBJECTv (closure=0x5555559e4b30, return_value=<optimized out>, instance=<optimized out>, args=<optimized out>, marshal_data=<optimized out>, n_params=<optimized out>, param_types=0x5555559e2fc0) at gmarshal.c:2102
    #4  0x00007fffef7d8976 in _g_closure_invoke_va (closure=0x5555559e4b30, return_value=0x0, instance=0x5555559e5110, args=0x7fffffffc1c8, n_params=1, param_types=0x5555559e2fc0)
        at gclosure.c:867
    #5  0x00007fffef7f3ff4 in g_signal_emit_valist (instance=instance@entry=0x5555559e5110, signal_id=signal_id@entry=97, detail=0, var_args=var_args@entry=0x7fffffffc1c8) at gsignal.c:3300
    #6  0x00007fffef7f4b48 in g_signal_emit_by_name (instance=instance@entry=0x5555559e5110, detailed_signal=detailed_signal@entry=0x7fffffffc310 "checkpoint-added") at gsignal.c:3487
    #7  0x00007fffeb6156d1 in deferred_notify_cb (data=0x5555559e5110) at libnm/nm-object.c:219
    #8  0x00007fffeb615ae7 in object_property_maybe_complete (self=0x5555559e5110 [NMManager]) at libnm/nm-object.c:555
    #9  0x00007fffeb615e5d in object_created (obj=<optimized out>, path=<optimized out>, user_data=<optimized out>) at libnm/nm-object.c:576
    #10 0x00007fffeb61648b in handle_object_array_property (pi=<optimized out>, value=0x7fffdc075070, property_name=0x7fffeb67f117 "checkpoints", self=0x5555559e5110 [NMManager])
        at libnm/nm-object.c:671
    #11 0x00007fffeb61648b in handle_property_changed (self=self@entry=0x5555559e5110 [NMManager], dbus_name=<optimized out>, value=<optimized out>) at libnm/nm-object.c:740
    #12 0x00007fffeb6166e9 in properties_changed (proxy=<optimized out>, changed_properties=<optimized out>, invalidated_properties=<optimized out>, user_data=0x5555559e5110)
        at libnm/nm-object.c:772
    ...

That is, because NetworkManager now first emits signals that the checkpoint
object was created, before answering the D-Bus request. That makes more
sense, but leads to this crash.

The ugliness of how libnm handles object visibility is considerable.
libnm hides objects until they are fully initialized. So, when
the async create-checkpoint operation returns, the object might not
yet be ready to be exposed. We need to delay the result. It would be
better if the API would simply return the created path.
2018-04-04 14:02:13 +02:00
Thomas Haller 4c67e0d5ec libnm: minor cleanup of nm_manager_get_device_by_path() 2018-04-04 14:02:13 +02:00
Beniamino Galvani d169cde872 libnm: don't use GTK-Doc comment in nm-autoptr.h
It generates the following warning:

libnm/nm-autoptr.h:25: Error: NM: identifier not found on the first line:
 * Note that you might use this header with older versions of libnm

Fixes: ff8e563365
2018-03-28 17:51:36 +02:00
Thomas Haller ff8e563365 libnm: add nm-autoptr.h header
"nm-autoptr.h" is done in a way that allows you to copy the header
in your source tree to support older versions of libnm, that didn't
contain the header yet. For example, we might want to use it in
network-manager-applet, but we don't want to bump the libnm dependency
to 1.11.2+ only to get this functionality.

Note that G_DEFINE_AUTOPTR_CLEANUP_FUNC() was added in glib 2.43.4,
and requires compiler support for the cleanup attribute. The compiler
support is taken as given, because we rely on it already. However,
NetworkManager and network-manager-applet still don't depend on a glib
version recent enough to provide these macros. To actually use them
(*inside*) NetworkManager/network-manager-applet, we either would have
to bump the glib minimal dependency, or reimplement g_autoptr in
/shared/nm-utils/nm-glib.h compat header.

https://bugzilla.gnome.org/show_bug.cgi?id=794294
2018-03-27 10:36:12 +02:00
Thomas Haller fc813d1c9e libnm: don't use deprecated tags for GOobject introspection
https://bugzilla.gnome.org/show_bug.cgi?id=744250
https://bugzilla.gnome.org/show_bug.cgi?id=794658
2018-03-26 12:50:43 +02:00
Jiří Klimeš aea3593a43 libnm: don't use deprecated tags for GOobject introspection
Top level tags are deprecated in favour of identifier annotations.
https://mail.gnome.org/archives/commits-list/2013-October/msg03220.html
https://wiki.gnome.org/action/show/Projects/GObjectIntrospection/Annotations?action=show&redirect=GObjectIntrospection%2FAnnotations#Type_signature

Signed-off-by: Jiří Klimeš <jklimes@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=744250
2018-03-26 12:46:22 +02:00
Corentin Noël 468a019333 gobject-introspection: made several fixes to the annotations
https://bugzilla.gnome.org/show_bug.cgi?id=794658
2018-03-26 12:45:49 +02:00
Benjamin Berg 26c215e22d Add calls to g_simple_async_result_set_check_cancellable
If an operation is cancelled through the GCancellable, then the idiom is
that the operation is always cancelled, even if it has finished
successfully. To ensure this is the case, add calls to
g_simple_async_result_set_check_cancellable everywhere.

Without this, e.g. gnome-control-center will crash when switching away
from the power panel quickly, as the NMClient creation finishes
asynchronously and g-c-c assume that G_IO_ERROR_CANCELLED is returned to
ensure it doesn't access the now invalid user_data parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=794088
2018-03-08 14:52:45 +01:00
Thomas Haller 65049f6736 libnm/tests: fix compilation of test-general
../libnm/tests/test-general.c: In function ‘test_fixup_vendor_string’:
    ../libnm/tests/test-general.c:70:3: error: initializer element is not constant
       T_DATA ("3Com", "3Com"),
       ^
    ../libnm/tests/test-general.c:70:3: error: (near initialization for ‘data[0]’)
    ../libnm/tests/test-general.c: In function ‘test_fixup_product_string’:
    ../libnm/tests/test-general.c:365:3: error: initializer element is not constant
       T_DATA  ("10/100BaseTX [RTL81xx]", "RTL81xx"),
    ...

Fixes: 817fce917b
2018-02-26 14:42:09 +01:00