Commit graph

7859 commits

Author SHA1 Message Date
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
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
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
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
Thomas Haller
6e45909f79 sleep-monitor/trivial: rename "sd_proxy" instance to "proxy"
It's not only relevant for systemd (sd).
2016-04-28 13:00:11 +02:00
Thomas Haller
aaa28d4d40 platform: add nm_linux_platform_lookup()
Give a direct access to the cache to lookup values there. This is only
useful for testing.
2016-04-28 12:53:21 +02:00
Thomas Haller
d933164087 platform: change order in which fields are compared in nm_platform_ip4_route_cmp()
..., nm_platform_ip6_route_cmp(), nm_platform_ip4_address_cmp() and
nm_platform_ip6_address_cmp().

Compare those fields first, for which we expect that their properties
differ. E.g. usually, each route destination in a set is unique, thus by
comparing those fields first we shortcut some comparisons.
2016-04-28 12:53:21 +02:00
Thomas Haller
4c2410bc92 platform: extend NMIPConfigSource to preserve the rtm_protocol field
For addresses (NMPlatformIPAddress) the @addr_source field is ignored
on a platform level. That is, all addresses inside the platform cache
have this value set to NM_IP_CONFIG_SOURCE_KERNEL. Maybe, for that reason,
the source should not be a part of the NMPlatformIPAddress structure, but
it is convenient for users to piggy back the source inside the platform
address structure.

For routes, the source is stored in NMPlatformIPRoute's @rt_source
field. When adding a route to kernel, we set the @rtm_protocol of the
route depending on the source. However, we want to map different source
values to the same protocol value.

On the other hand, when kernel sends us a route that gets put inside
the cache, we must preserve the protocol value and must not map
different protocol values to the same source.
The reason is, that a user can add two routes that only differ by
@rtm_protocol. In that sense, the @rtm_protocol fields is part of the
unique ID of a kernel route, and thus different values must map to
different sources.

Fix this, by extending the range of NMIPConfigSource to contain
a range of protocol fields.
2016-04-28 12:53:21 +02:00
Thomas Haller
e26fcce0f8 platform: refactor marking cloned routes in platform
We handle cloned routes (that have rtm_flags RTM_F_CLONED) differently.
We used to mark such routes by hacking NMIPConfigSource to have a special
value. No longer do this, because it mixes different concepts.

Note that the rt_cloned filed fits into a hole in the aligment
of NMPlatformIPRoute. Thus there is almost no overhead to this
change.
2016-04-28 12:53:21 +02:00
Thomas Haller
9e83383223 platform: add nmp_utils_ip_config_source_to_string()
Expose nmp_utils_ip_config_source_to_string() in the header file and
implement it via NM_UTILS_ENUM2STR_DEFINE().
2016-04-28 12:53:21 +02:00
Thomas Haller
6bf022359f core/trivial: rename "source" field of addresses and routes
The "source" field of NMPlatformIPRoute (now "rt_source") maps to the
protocol field of the route. The source of NMPlatformIPAddress (now
"addr_source") has no direct equivalent in the kernel.

As their use is different, they should have different names. Also,
the name "source" is used all over the place. Hence give the fields
a more distinct name.
2016-04-28 12:53:21 +02:00
Thomas Haller
44753a590e platform: sort links by ifindex in nm_platform_link_get_all()
This way, we get a defined order at startup.

Also, get rid of the logging statements. It was used for
debugging, but a "getter" really should not log the stuff it
is returning.
2016-04-28 12:53:21 +02:00
Thomas Haller
5fe99a1d1a core: add nm_utils_ipx_address_clear_host_address() util 2016-04-28 12:53:21 +02:00
Beniamino Galvani
0589e659ca device/ethernet: ignore s390 'portname' attribute when not set
The 'portname' sysfs attribute of s390 devices is deprecated since
kernel 4.4 and always set to 'no portname required'. But even on older
kernels such value must be interpreted as an unset portname and thus
ignored.

https://bugzilla.redhat.com/show_bug.cgi?id=1327204
2016-04-28 09:25:41 +02:00
Thomas Haller
e0c272c153 manager: use _LOGx() macros in nm-manager
They give each logging message a "manager: " prefix.
2016-04-27 18:29:51 +02:00
Beniamino Galvani
5b70254ea0 ifcfg-rh: emit a warning when DEFROUTE=no and GATEWAY is set 2016-04-27 17:15:49 +02:00
Thomas Haller
7f7e1eb60b settings: fix write_hostname for relative-symbolic links
g_file_read_link() "reads" the symbolic link. If it's a relative path,
we get a relative path which is anchored on @file. We must resolve that
to be absolute.
2016-04-27 15:03:50 +02:00
Thomas Haller
d6e7fa164b settings: remove unnecessary "file" field for hostname from NMSettingPrivate 2016-04-27 14:51:55 +02:00
Thomas Haller
c4b88bf23f utils: add nm_utils_read_link_absolute() 2016-04-27 14:51:55 +02:00
Francesco Giudici
19350c8975 settings: add notification after connections load
The notification was missing from a long time. The issue has been exposed only
now due to the c57e5a6b66 fix which properly
implemented the "startup-complete" notification substituting out of place code
which masked the bug.
2016-04-27 11:10:58 +02:00
Thomas Haller
767fa0ed3d settings: disconnect connection_ready_changed() handler when reaching startup_complete
We connect to notify::startup-complete signal of each connection,
but after we signal startup-complete once, we don't need that
signal anymore. Disconnect.
2016-04-26 15:48:20 +02:00
Thomas Haller
2789345d5b dns: add new rc-manager=unmanaged
The following settings are effectively identical:

    dns=none,rc-manager=*any*
    dns=none,rc-manager=unmanaged
    dns=default,rc-manager=unmanaged

The new setting is only there for completeness and only
makes sense for a dns plugin.
2016-04-26 13:58:28 +02:00
Thomas Haller
161f86b5b3 dns: merge the dns "mode" and "rc-manager"
Already previously, the mode and rc-manager were intertwined in a complicated
way:

  - dns=none effectively disables rc-manager.

  - if resolv.conf was immutable, it would disable the rc-manager
    by setting "resolv_conf_mode=NM_DNS_MANAGER_RESOLV_CONF_UNMANAGED".

  - resolv_conf_mode was anyway a redundant piece of information to
    rc_manager.

Now there are only two relevant settings: priv->plugin and
priv->rc_manager. And they can be set independently from each other.
Before that was not possible. For example, you could not set a
dns plugin with rc-manager=unmanaged (the only way to achive that
was via an immutable resolv.conf or by having rc-manager=symlink
and let resolv.conf link somewhere else.
2016-04-26 13:58:28 +02:00
Thomas Haller
83fd710005 dns: when clearing "plugin" always disconnect signal handlers 2016-04-26 13:58:28 +02:00
Thomas Haller
a252dfdb9d dns: initialize rc-manager in init_resolv_conf_mode()
The "dns" and "rc-manager" properties are strongly related. Initialize them
together in init_resolv_conf_mode().

One difference is, that we now set rc_manager before setting the mode.
But that shouldn't matter.
2016-04-26 13:58:28 +02:00
Thomas Haller
aea2d98e2d dns: split parsing of rc-manager out of init_resolv_conf_manager()
Makes more sense in the next commit, when init_resolv_conf_manager()
gets merged with init_resolv_conf_mode(). Bear with me.
2016-04-26 13:58:28 +02:00
Thomas Haller
cd6a469668 dns: rename "rc-manager=none" to "symlink"
We already have "rc-manager=file", rename "rc-manager=none" to "symlink"
because that better describes what it is actually doing. Of course, the
old name is still accepted.
2016-04-26 13:58:27 +02:00
Thomas Haller
89cf9429a7 device: generate stable UUID for default-wired-connection
Generate a stable connection UUID for the default-wired-connection.
Otherwise, on every reboot, the UUID changes although the generated
connection is the same.

But also hash into the UUID the machine-id, the device name and the
hardware address. So, the UUID is only the same if the connection is
identical in every aspect.

Also, the UUID is used as Network_ID for the stable-privacy address
generation mode. It is bad to re-create different UUIDs on every boot
as it causes different addresses.
2016-04-26 12:50:16 +02:00
Thomas Haller
54233b6f3b core: use nm_utils_machine_id_read() in "nm-dhcp-client.c" 2016-04-26 12:48:28 +02:00
Thomas Haller
f137af2e23 core: add nm_utils_machine_id_read() and parse() util 2016-04-26 12:48:27 +02:00
Thomas Haller
d787b8c827 core: add nm_utils_get_secret_key() util 2016-04-26 12:48:27 +02:00
Lubomir Rintel
dd4d8b24da linux-platform: re-read the link type if the name changed
For some device types, we use the DEVTYPE from sysfs to determine the
link type. However, the way we read from sysfs can race with device
renames and we could miss the chance to read DEVTYPE correctly.

This doesn't completely fix the sysfs race, but cures the boot-time race
with systemd renaming the device while we are initializing the link.

We ideally should use GUDev for all sysfs accesses, but that would need
some more work for this particular case as currently we need the link type
before we have an udev device instance.

https://bugzilla.gnome.org/show_bug.cgi?id=764803

Co-Authored-By: Beniamino Galvani <bgalvani@redhat.com>
2016-04-26 12:20:42 +02:00
Dan Williams
8c8a577a30 dhcp/systemd: actually hook up information-only mode
Fixes: 89d1e46615
Tested-by: Celti on IRC
2016-04-25 17:00:54 -05:00
Lubomir Rintel
a57227914e bluetooth: add a missing GError initializer
(cherry picked from commit 3ad7be3e6a)
2016-04-25 16:10:28 +02:00
Thomas Haller
316359d8b6 settings: refactor read_hostname_*() 2016-04-25 15:26:26 +02:00
Thomas Haller
79d85ca180 settings: cleanup #if blocks for HOSTNAME_PERSIST_* 2016-04-25 15:26:26 +02:00
Patrick J. Volkerding
1a714ee5e6 settings: fix Slackware hostname setting
https://mail.gnome.org/archives/networkmanager-list/2016-April/msg00075.html
2016-04-25 15:26:20 +02:00
Thomas Haller
a09a5f7fc1 sleep-monitor: disconnect signal handlers from D-Bus proxy on destroy
The lifetime of the proxy is not necesarily the same as the lifetime
of the NMSleepMonitor instance. Disconnect the signals during dispose().
2016-04-25 13:50:54 +02:00
Thomas Haller
753f727af5 sleep-monitor: don't localize messages in core daemon
The daemon does not run with a particular locale of a user. Localizing
makes no sense (at least, we don't do it usually and it would make
logging localized).
2016-04-25 13:43:06 +02:00