Commit graph

14929 commits

Author SHA1 Message Date
Thomas Haller
7752f390c2 cli: declare external variable nm_cli in <nmcli.h> header 2016-05-03 11:53:15 +02:00
Thomas Haller
a9908c012c cli: remove unused functions 2016-05-03 11:53:15 +02:00
Thomas Haller
d742ea7817 cli: don't allow multiple <ifname> arguments to device-reapply
Just like `nmcli device connect` only allows one argument, don't allow
multiple device arguments for reapply.

Allowing multiple device names makes it more complicated to add
additional options to the command. For example, it would be useful
to have a

    nmcli device reapply eth0 connection id other-connection

but when allowing multiple device names, it gets more complicated in
documentation, command line parsing and bash completion.

Note that the user can achieve a very similar outcome by using the
shell:

    for DEV in eth0 eth1 eth2; do
        nmcli device reapply $DEV &
    done
    wait

argubaly, this doesn't report the exit status properly. To properly
handle that would require more effort. Also, it is somewhat less
efficient, but well.

This is an API change, however it is very new API that probably nobody
is using much. Also, the documentation (man nmcli) didn't mention the
possibility to pass multiple device names.
2016-05-03 11:52:57 +02:00
Thomas Haller
b217b68b80 cli: refactor cleanup in do_device_reapply() 2016-05-03 11:52:40 +02:00
Thomas Haller
c71bd9df82 device: improve error message for failure to reapply 2016-05-03 11:52:40 +02:00
Thomas Haller
a51b947f25 device: fix check for invalid keys during reapply
Was completely wrong and failed to find first_invalid_key.
As a consequence, hit the assertion at the end.
2016-05-03 11:52:40 +02:00
Thomas Haller
b52d25e129 device: clear secrets from applied connection during reapply
The applied connection must have no secrets. It's unclear whether
there are any secrets at this point (possibly). To be sure, clear them.
2016-05-03 11:52:40 +02:00
Thomas Haller
ec840b0331 device: allow reapply with a different connection.uuid 2016-05-03 11:52:40 +02:00
Thomas Haller
ad38a1acb8 device: allow reapply if connection.id differs 2016-05-03 11:52:39 +02:00
Thomas Haller
05478e4f4c utils: refactor _nm_utils_ascii_str_to_int64()
To allow for trailing whitespace, we don't need to copy and trunacate
the input string. g_ascii_strtoll() conveniently returns the location via
the endptr argument.
2016-05-03 11:52:39 +02:00
Beniamino Galvani
904f840c20 device: merge branch 'bg/ip-method-fail-fixes-bgo741347'
https://bugzilla.gnome.org/show_bug.cgi?id=741347
2016-05-02 18:22:32 +02:00
Beniamino Galvani
f377e055bf device: add dhcp_schedule_restart() helper 2016-05-02 18:21:19 +02:00
Beniamino Galvani
cf4e2c7ab9 device: retry DHCPv6 when a lease expires
Make DHCPv6 more robust WRT temporary failures of servers by retrying
DHCP for a predefined number of times at regular intervals when the
lease expires.

https://bugzilla.gnome.org/show_bug.cgi?id=741347
2016-05-02 18:21:18 +02:00
Beniamino Galvani
ac52b95684 device: retry DHCPv4 when a lease expires
Make DHCPv4 more robust WRT temporary failures of servers by retrying
DHCP for a predefined number of times at regular intervals when the
lease expires.

https://bugzilla.gnome.org/show_bug.cgi?id=741347
2016-05-02 18:21:18 +02:00
Beniamino Galvani
363d5b33ec device: group DHCP6 private members 2016-05-02 18:21:18 +02:00
Beniamino Galvani
3f5ee827a9 device: group DHCP4 private members 2016-05-02 18:21:18 +02:00
Beniamino Galvani
b84768581e device: fail activation immediately only when may-fail=no
Introduce the nm_device_ip_method_failed() function to check if the
failure of an IP method should cause the activation to fail, and use
it where appropriate.

http://bugzilla.gnome.org/show_bug.cgi?id=741347
2016-05-02 18:21:18 +02:00
Beniamino Galvani
c0d322720a core: introduce nm_utils_dnsmasq_status_to_string() 2016-05-02 15:06:43 +02:00
Beniamino Galvani
d317709c10 dnsmasq-manager: trivial: remove unused signal slot 2016-05-02 15:06:43 +02:00
Beniamino Galvani
cce83f4f78 dnsmasq-manager: trivial: move class and object functions at bottom 2016-05-02 15:06:42 +02:00
Thomas Haller
c5ac691744 build: cleanup includes of <gmodule.h>
<gmodule.h> is implicitly included by <gio/gio.h> which is available
everywhere. For that reason, we would not have to include this header
at all. However, it is recommended to explicitly include <gmodule.h>
where needed.

So, include it where needed -- if <gio/gio.h> wouldn't be there --
and drop it from where it is not needed.
2016-04-30 03:42:16 +02:00
Thomas Haller
9f29cc13e7 man: clearify rc-manager symlink setting in NetworkManager.conf 2016-04-30 03:16:41 +02:00
Beniamino Galvani
a47c13a7a2 device: postpone updates of IP configuration when a commit is pending
When a new dynamic configuration is received, it is stored in a member
of private structure (e.g. @dhcp6_ip6_config) and a commit is
scheduled. Before the commit is executed, an update_ipx_config() could
be called and it would change the configuration before it is
committed.

This race condition causes failures in assigning the addresses
received through DHCPv6 when the internal client is used (but
potentially other clients and methods are affected).

To fix it, postpone updates of IP configurations when a commit is
already pending.
2016-04-29 17:16:25 +02:00
Thomas Haller
69863204e2 core,libnm: merge branch 'th/module-close' 2016-04-29 15:48:27 +02:00
Thomas Haller
c6a92224a4 settings: don't unload settings plugins on failure
Also, registering a weak-pointer to close the module that
was just made as resident is pointless.
2016-04-29 15:48:18 +02:00
Thomas Haller
cd39cbfc1f device: don't unload device plugins on failure 2016-04-29 15:41:41 +02:00
Thomas Haller
264189e756 libnm/vpn: don't close the VPN plugin library on cleanup
Closing the library will interfere badly as the glib types cannot be
unregistered. We must leak the library handle.

Switch to dlopen() instead of g_module_open(), because the former
supports RTLD_NOLOAD. This is useful for two reasons:

  - checking the file prior loading only makes any sense when
    dlopen() would actually load a file anew.

  - if the library was loaded before, we want to return the handle.
    On the other hand, if the library was not loaded, we leak the
    handle.

Thereby, refactor the code from if-else blocks to return-early, because
the function nicely does individual steps and if one fails just error
out.
2016-04-29 15:38:29 +02:00
Thomas Haller
b52485b34b libnm/vpn: fix checking service name in nm_vpn_plugin_info_new_search_file()
Fixes: 3adf782ab5
2016-04-29 15:28:04 +02:00
Lubomir Rintel
eafa6f725b systemd: fix conversion from size_t on s390
On s390 size_t is an unsigned long, not an unsigned int. They both are
of the same size and can be cast to each other safely, but the compiler
still seems unhappy about incompatible pointers.

https://github.com/systemd/systemd/pull/3147
2016-04-29 12:47:34 +02:00
Lubomir Rintel
76844c65d6 ifupdown: avoid calloc()
It can return NULL and makes Coverity upset:

CID 75369 (#1 of 1): Dereference null return value (NULL_RETURNS)
4.  dereference: Dereferencing a null pointer ret.
2016-04-29 12:47:34 +02:00
Lubomir Rintel
2e563d9c84 ifnet: fix error handling
CID 76722 (#1 of 1): Logically dead code (DEADCODE)
dead_error_line: Execution cannot reach this statement:
g_set_error(error, nm_setti....
2016-04-29 12:47:34 +02:00
Lubomir Rintel
dc9bba9e51 config: call va_end() in unexpected code path too
CID 99747 (#1 of 1): Missing varargs init or cleanup (VARARGS)
13.  missing_va_end: va_end was not called for ap.
2016-04-29 12:47:34 +02:00
Beniamino Galvani
a06487a6ae cli: handle device failure when activating
We might receive the update of the device state to FAILED when the
active connection is still in ACTIVATING. Handle this case properly.
2016-04-29 11:16:30 +02:00
Thomas Haller
f027b71f65 build: cleanup include of <config.h>
It is recomended to include <config.h> with angle brackets [1].

Note, that usually we don't include <config.h> directly, except in
two places we have to (because there we include conflicting libraries
that must be included before "nm-default.h").
In that case, define __CONFIG_H__ which is used as include guard around
<config.h> by "nm-default.h".

[1] https://www.gnu.org/software/autoconf/manual/autoconf-2.66/html_node/Configuration-Headers.html
2016-04-28 19:02:58 +02:00
Thomas Haller
497a21fb3d wwan/trivial: fix whitespace and indention 2016-04-28 17:39:20 +02:00
Thomas Haller
c1147fc71b libnm/vpn: don't leak editor-plugin if nm_vpn_editor_plugin_load() fails 2016-04-28 15:00:04 +02:00
Thomas Haller
d350d72a2e libnm: store NMConnectionPrivate via g_object_set_qdata()
g_object_get_data() and g_object_get_qdata() end up to be identical,
except that g_object_get_data() also requires to intern the string
on every lookup (which involves a hash lookup and locking).
2016-04-28 14:58:17 +02:00
Thomas Haller
8bc895d5aa manager: embed NMManagerPrivate data directly into NMManager struct
For a type to be inheritable, its public struct (NMManager) must
be known. As nobody inherits NMManager, we can make it private.

As the struct is private anyway, we can also reuse it for the private
data directly, instead of registering NMManagerPrivate in the manager
class.

There are advantages and disadvantages:

  + simplifies debugging, as the self pointer also contains the
    private data.
  + removes a small overhead of tracking the private data separately
  - is a different way to implement the class, contrary to many
    other classes.
  - inheriting from the class later requires reverting this change
    (but we will never inherit from NMManager).
  - as it is now, nobody uses the priv field directly and we still
    access it via NM_MANAGER_GET_PRIVATE(self). However, the presence
    of the priv field might encourage us to use it directly -- which
    increases above disadvantages.
2016-04-28 14:36:24 +02:00
Thomas Haller
d27a80c4df manager: make NMManager's structs private
They are only useful when we want to derive a class
from NM_TYPE_MANAGER -- which we clearly don't.
2016-04-28 14:20:11 +02:00
Thomas Haller
bb8b9ca6f5 manager: remove unused signal slots from NMManagerClass 2016-04-28 14:20:00 +02:00
Thomas Haller
e0cf9319b7 sleep-monitor: merge branch 'th/sleep-monitor-merge-bgo765682'
https://bugzilla.gnome.org/show_bug.cgi?id=765682
2016-04-28 13:49:28 +02:00
Thomas Haller
1e3b2cbb77 sleep-monitor: make sleep-monitor not a singleton
The only user of the sleep-monitor singleton was NMManager anyway.
Also, even if we ever get more users that are interested in the SLEEPING
signal, we would hook them onto NMManager -- because NMManager should
collect, coordinate and possibly forward the SLEEPING signal. In no case,
another object should react on the SLEEPING signal and thus bypassing the
NMManager.
2016-04-28 13:45:49 +02:00
Thomas Haller
07db1217a9 sleep-monitor: merge RESUMING signal into NMSleepMonitor's SLEEPING signal
Having two signals is more complicated and everybody who cares about
one signal also cares about the other.
2016-04-28 13:20:09 +02:00
Thomas Haller
2208ca3726 sleep-monitor: unify and cleanup logging 2016-04-28 13:00:12 +02:00
Thomas Haller
a22851dc59 sleep-monitor: create D-Bus proxy asynchronously for upower sleep-monitor 2016-04-28 13:00:12 +02:00
Thomas Haller
2b087b4782 sleep-monitor: cleanup #if usage by using USE_UPOWER in "nm-sleep-monitor.c" 2016-04-28 13:00:12 +02:00
Thomas Haller
400e9fc9fb sleep-monitor: use defines for D-Bus paths for upower's sleep-monitor 2016-04-28 13:00:12 +02:00
Thomas Haller
6864a7036f sleep-monitor: use dispose() method for upower's sleep-monitor 2016-04-28 13:00:12 +02:00
Thomas Haller
c76eb3e8f7 sleep-monitor: merge "nm-sleep-monitor-upower.c" into "nm-sleep-monitor.c"
Both files do very similar things, with "nm-sleep-monitor-upower.c"
being suboptimal, for example by creating the proxy synchronously.

Clean that up in the next steps. Just basic merging for now.
2016-04-28 13:00:12 +02:00
Thomas Haller
b97ae18379 sleep-monitor: rename file "nm-sleep-monitor-systemd.c" to "nm-sleep-monitor.c"
Next, we will merge "nm-sleep-monitor-upower.c" into "nm-sleep-monitor.c".
2016-04-28 13:00:12 +02:00