Commit graph

7409 commits

Author SHA1 Message Date
Lubomir Rintel
fd314ed7f7 device-factory/trivial: rename get_virtual_iface_name() to get_connection_iface() 2016-02-17 18:43:02 +01:00
Thomas Haller
8c1a9bbb8c utils: fix NM_UTILS_ENUM2STR_DEFINE() which always returned the last element
Fixes: 174b25d98c
2016-02-17 15:17:11 +01:00
Thomas Haller
e13925597f platform: add IN6_ADDR_GEN_MODE_RANDOM to nm_platform_link_inet6_addrgenmode2str()
There is a new address generation mode.
2016-02-17 14:19:19 +01:00
Thomas Haller
c6849be179 platform: use nm_platform_link_inet6_addrgenmode2str() in link-to-string
Reuse the to-string function nm_platform_link_inet6_addrgenmode2str() to print the
addrgenmode for nm_platform_link_to_string().

Also, now we support NM_IN6_ADDR_GEN_MODE_STABLE_PRIVACY.
2016-02-17 14:01:49 +01:00
Thomas Haller
c205ee6ce0 platform: stack-allocate temporary string in nm_platform_link_tun_get_properties_ifname() 2016-02-17 13:39:55 +01:00
Beniamino Galvani
b8c677a0eb manager: fix typo in error message
Fixes: 1762d58a8c
2016-02-16 16:22:50 +01:00
Thomas Haller
3d759b1f11 platform: during @abort_parsing goto stop in event_handler_recvmsgs()
Now, that we no longer overwrite @err, we can jump to stop: instead
of out:.
2016-02-16 14:13:25 +01:00
Thomas Haller
329ac02d38 platform: don't set @err during stop: in event_handler_recvmsgs()
If we break the loop normally, @err must be already set to zero.
The only other way this can happen is when the credentials are
invalid. Move setting @err to there.
2016-02-16 14:13:25 +01:00
Thomas Haller
3f00899bde platform: continue reading in event_handler_recvmsgs() when not handling events
If @handle_events is FALSE, we want to drain the socket. In that case
even when encountering an error error we don't want to abort, but instead
continue reading the next message.
2016-02-16 14:13:25 +01:00
Thomas Haller
dc97a3b39b platform: fix error handling in event_handler_recvmsgs()
@abort_parsing is set TRUE at two places, which also explicitly
set @err to something. We don't want to reset @err and got to the
next @hdr. Instead error out first.
2016-02-16 14:13:25 +01:00
Thomas Haller
43381f9b85 platform: downgrade logging message to TRACE level in event_handler_recvmsgs()
Doesn't seem important and might be triggered by other processes.
2016-02-16 14:13:25 +01:00
Thomas Haller
9254cbe875 platform: don't return number of messages from event_handler_recvmsgs()
The value is not used by the callers. Also, with @handle_events set
to false, it is not clear what the value really means because we skip
over errors.
2016-02-16 14:13:25 +01:00
Thomas Haller
04805f659f platform: simplify event_handler_recvmsgs() by using cleanup attribute 2016-02-16 14:13:25 +01:00
Thomas Haller
dec682f6d1 platform/tests: workaround test failure for kernel bug
Unenslaving from a bridge can cause a spurious RTM_DELLINK signal.
NMPlatform does raise those signals, but fixes the state of the
cache afterwards. Workaround the test failure.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1285719
2016-02-16 13:01:47 +01:00
Beniamino Galvani
1bb3b6a4c6 libnm-core: make ipvx.dhcp-timeout signed
Change the dhcp-timeout property in NMSettingIPConfig to int type for
consistency with the dad-timeout property. For dad-timeout -1 means
"use default value", while for dhcp-timeout probably we will never use
negative values, but it seems more correct to use the same type for
the two properties.
2016-02-16 11:37:26 +01:00
Beniamino Galvani
206e074863 libnm,core,cli: move dhcp-timeout property to generic NMSettingIPConfig
The property applies to both IPv4 and IPv6 and so it should not be in
NMSettingIP4Config but in the base class.
2016-02-16 11:37:26 +01:00
Thomas Haller
54dc789314 device: fix signature for @flags argument of impl_device_reapply()
Thereby, also adjust the type for libnm's wrapper function -- as
we already broke ABI.
2016-02-16 11:24:49 +01:00
Thomas Haller
62910d19d7 core: add NMDevice's GetAppliedConnection D-Bus call
Expose applied connection in D-Bus API.

https://bugzilla.gnome.org/show_bug.cgi?id=760884
2016-02-16 11:24:49 +01:00
Thomas Haller
6898e2169e all: add version-id argument to device's Reapply method
This breaks API and ABI for the functions related to Reapply,
which got introduced in the current 1.1 development phase.

The version-id is here to allow users to error out if the connection
on the device was changed by a concurrent action.

https://bugzilla.gnome.org/show_bug.cgi?id=761714
2016-02-16 11:24:49 +01:00
Thomas Haller
b96a40c2ec core: add version-id to NMActiveConnection
This field will be later used by NMDevice's Reapply and
GetAppliedConnection methods. The usecase is to first fetch
the currently applied connection, adjust it and reapply it.
Using the version-id, a concurrent modification can be detected
and Reapply can reject the invocation.
2016-02-16 11:24:49 +01:00
Thomas Haller
4b76d86698 core/trivial: rename local function in "nm-settings-connection.c"
Only D-Bus implementations should be named "^impl_.*", not a helper
function.
2016-02-16 11:24:22 +01:00
Thomas Haller
5637d72af2 device: fix wrongly managing external devices by assuming on PLATFORM_INIT
Otherwise, a tun device from external openvpn service will be managed by
NetworkManager.

  <debug> [1455615148.716529] [devices/nm-device.c:9082] _set_unmanaged_flags(): [0x55e6f5756070] (tun7): unmanaged: flags set to [!sleeping,!loopback,!platform-init,!user-config,!external-down=0x0/0xa19/managed, set-managed [platform-init=0x10], reason managed, transition-state)
  <info>  (tun7): device state change: unmanaged -> unavailable (reason 'managed') [10 20 2]

Fixes: 87a3df2e57
2016-02-16 10:44:42 +01:00
Beniamino Galvani
10b222288e wifi: don't touch by default current powersave setting
Some drivers (or things outside NM like 'powertop') may turn powersave
on, so don't touch it unless explicitly configured by user.

To achieve this, add new 'default' and 'ignore' options; the former
can be used to fall back to a globally configured setting, while the
latter tells NM not to touch the current setting.

When 'default' is specified, a missing global default configuration is
equivalent to 'ignore'.

It is possible to enable Wi-Fi power saving for all connections by
dropping a file in /etc/NetworkManager/conf.d with the following
content:

 [connection]
 wifi.powersave=3

https://bugzilla.gnome.org/show_bug.cgi?id=760125
2016-02-16 00:18:06 +01:00
Beniamino Galvani
0f5c5ad446 dhcp/systemd: accept default gateway in classless static routes option
RFC 3442 allows a default gateway to be specified in option 121
(Classless Static Routes) and override the Router option.  Implement
this in the internal DHCP client.

https://bugzilla.gnome.org/show_bug.cgi?id=761268
2016-02-16 00:08:15 +01:00
Thomas Haller
87a3df2e57 device: remove default-unmanaged and refactor unmanaged flags
Get rid of NM_UNMANAGED_DEFAULT and refine the interaction between
unmanaged flags, device state and managed property.

Previously, the NM_UNMANAGED_DEFAULT was special in that a device was
still considered managed if it had solely the NM_UNMANAGED_DEFAULT flag
set and its state was managed. Thus, whether the device (state) was managed,
depended on the device state too.

Now, a device is considered managed (or unmanaged) based on the unmanaged
flags and realization state alone. At the same time, the device state
directly corresponds to the managed property of the device. Of course,
while changing the unmanaged flags, that invariant is shortly violated
until the state transistion is complete.

Introduce more unmanaged flags whereas some of them are non-authorative.
For example, the EXTERNAL_DOWN flag has only effect as long as the user
didn't explicitly manage the device (NM_UNMANAGED_USER_EXPLICIT). In other
words, certain flags can render other flags ineffective. Whether the device
is considered managed depends on the flags but also at the explicitly unset flags.
In a way, this is similar to previous where NM_UNMANAGED_DEFAULT was ignored
(if no other flags were present).

Also, previously a device that was NM_UNMANAGED_DEFAULT and in disconnected
state would transition back to unmanaged. No longer do that. Once a device is
managed, it stays managed as long as the flags indicate it should be managed.
However, the user can also modify the unmanaged flags via the D-Bus API.

Also get rid or nm_device_finish_init(). That was previously called
by NMManager after add_device(). As we now realize devices (possibly
multiple times) this should be handled during realization.

https://bugzilla.gnome.org/show_bug.cgi?id=746566
2016-02-15 21:40:02 +01:00
Thomas Haller
2a17dbf48b device/trivial: rename nm_device_set_unmanaged_flags() 2016-02-15 21:33:32 +01:00
Thomas Haller
02dbe670ca device: for available connections check whether they are available for user-request
But not with ignoring-carrier and ignoring-ap.
2016-02-15 21:33:32 +01:00
Lubomir Rintel
30ce8c305b device: always do a unrealized delete check when rechecking available connections
It could be that what changed is the unrealize flag, not the number available
connections. That could happen when a last connection for a software device
is removed.
2016-02-15 21:32:49 +01:00
Lubomir Rintel
8b2abe0e2c device: check avaliable connections are really available
The nm_device_check_connection_available() call seem to have been accidentally
removed from nm_device_recheck_available_connections() resulting in all
connections always being added.

Fixes 02ec76df5a
2016-02-15 21:32:49 +01:00
Thomas Haller
0fbe055e2a utils: use stack allocated buffer for path in nm_utils_get_start_time_for_pid() 2016-02-15 18:41:11 +01:00
Thomas Haller
1178f814a1 dnsmasq: refactor creating dnsmasq command line args to pass listen_address argument 2016-02-15 18:41:11 +01:00
Thomas Haller
64335f9ebf dnsmasq: kill running process from pidfile synchronously
This should avoid a race when stopping dnsmasq.

This is still a hack, because we don't want to ever wait
for a process to terminate.

A better solution would be to have nm-dnsmasq-manager managing
the global state. Not only the dnsmasq instance of on NMDevice.
Instead it should keep track of all the child processes it starts
and it wants to start. This way, starting a new process should be
delayed until any (child or non-child) instances are gone.
That however would be a bigger change.

https://bugzilla.gnome.org/show_bug.cgi?id=728342
https://bugzilla.gnome.org/show_bug.cgi?id=762008
2016-02-15 18:41:11 +01:00
Thomas Haller
9c0cfbbae6 platform: fix detection of link-type for netlink event
Often a netlink event doesn't contain enough information to determine
the link type. Then we consult sysctl or ethtool. However, if we already
have the same object cached, we want to reused the (once detected) link-type.

There was a bug in lookup of the cached object.
2016-02-15 17:19:22 +01:00
Thomas Haller
9ce0995efb platform: change format to print link-type in nm_platform_link_to_string() 2016-02-15 16:23:38 +01:00
Thomas Haller
16434c85f8 ifcfg-rh/tests: refactor test using helper functions and drop ASSERT() macro 2016-02-15 14:26:53 +01:00
Thomas Haller
e663b88c59 all/trivial: rename STRLEN() macro to NM_STRLEN()
We should not have defines/macros in header files without a nm/NM
prefix. STRLEN() was one of the few offenders.

https://mail.gnome.org/archives/networkmanager-list/2016-February/msg00048.html
2016-02-14 11:34:42 +01:00
Beniamino Galvani
b9bb1c793d device/vlan: check existence of ip6 configuration before reapplying it
The connection might not have an ipv6 configuration, check for this
before calling nm_device_reactivate_ip6_config().

Fixes: 45b77dbcfc

https://bugzilla.redhat.com/show_bug.cgi?id=1307070
2016-02-12 17:22:21 +01:00
Thomas Haller
89e806e1a6 systemd: don't use <uchar.h>
Not around on Ubuntu 12.04. Define the char16_t and char32_t types
ourselves.

Fixes: 2835934244
2016-02-12 17:03:28 +01:00
Lubomir Rintel
ace8d96bed test: assert that the signal connection succeeds properly
0 is not success and negative can not happen, as Coverity points out.
2016-02-12 15:48:12 +01:00
Lubomir Rintel
d9218f6074 device: warn if we couldn't reapply the ip configuration
Coverity is suspicious and rightly so.
2016-02-12 15:48:12 +01:00
Lubomir Rintel
86a0a14687 test: avoid assert with side effect
Not a real problem, but makes Coverity uncomfortable.
2016-02-12 15:48:12 +01:00
Thomas Haller
2c2d9d2e4c build: cleanup default includes
- "gsystem-local-alloc.h" and <gio/gio.h> are already included via
  "nm-default.h". No need to include them separately.

- include "nm-macros-internal.h" via "nm-default.h" and drop all
  explict includes.

- in the modified files, ensure that we always include "config.h"
  and "nm-default.h" first. As second, include the header file
  for the current source file (if applicable). Then follow external
  includes and finally internal nm includes.

- include nm headers inside source code files with quotes

- internal header files don't need to include default headers.
  They can savely assume that "nm-default.h" is already included
  and with it glib, nm-glib.h, nm-macros-internal.h, etc.
2016-02-12 15:36:01 +01:00
Beniamino Galvani
97be12b662 platform: always try to refetch new ethernet links
Due to a kernel bug [1], we sometimes receive spurious NEWLINK
messages after a wifi interface has disappeared. Since the link is not
present anymore we can't determine its type and thus it will show up
as a Ethernet one, with no address specified.  Request the link again
to check if it really exists.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1302037

https://bugzilla.gnome.org/show_bug.cgi?id=761151
2016-02-12 14:41:56 +01:00
Thomas Haller
fa8c0877ce trivial: fix spelling in comment 2016-02-12 14:26:54 +01:00
Beniamino Galvani
b3401bf921 device: add nm_device_get_applied_setting() 2016-02-12 13:46:12 +01:00
Thomas Haller
d4479a9b10 coding-style: remove unnecessary braces 2016-02-12 13:01:53 +01:00
chrysn
a94fb97763 core: include dnsmasq config files in shared connections
The dnsmasq process started as DHCP and DNS server for shared
connections now accepts additional configuration files at
/etc/NetworkManager/dnsmasq-shared.d/.

https://bugzilla.gnome.org/show_bug.cgi?id=761717
2016-02-12 13:01:34 +01:00
Thomas Haller
2835934244 systemd: merge branch 'systemd' into master 2016-02-12 11:14:26 +01:00
Thomas Haller
1a716a7cd2 systemd: update code from upstream
This is a direct dump from systemd git on 2016-02-11, git commit
95adafc428b5b4be0ddd4d43a7b96658390388bc (v229).

======

SYSTEMD_DIR=../systemd
COMMIT=95adafc428b5b4be0ddd4d43a7b96658390388bc

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files :/src/systemd/src/ | xargs -d '\n' rm -f

nm_copy_sd() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd "src/basic/alloc-util.c"
nm_copy_sd "src/basic/alloc-util.h"
nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/escape.c"
nm_copy_sd "src/basic/escape.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/fd-util.c"
nm_copy_sd "src/basic/fd-util.h"
nm_copy_sd "src/basic/fs-util.c"
nm_copy_sd "src/basic/fs-util.h"
nm_copy_sd "src/basic/hash-funcs.c"
nm_copy_sd "src/basic/hash-funcs.h"
nm_copy_sd "src/basic/hashmap.c"
nm_copy_sd "src/basic/hashmap.h"
nm_copy_sd "src/basic/hexdecoct.c"
nm_copy_sd "src/basic/hexdecoct.h"
nm_copy_sd "src/basic/hostname-util.c"
nm_copy_sd "src/basic/hostname-util.h"
nm_copy_sd "src/basic/in-addr-util.c"
nm_copy_sd "src/basic/in-addr-util.h"
nm_copy_sd "src/basic/io-util.c"
nm_copy_sd "src/basic/io-util.h"
nm_copy_sd "src/basic/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/mempool.h"
nm_copy_sd "src/basic/mempool.c"
nm_copy_sd "src/basic/parse-util.c"
nm_copy_sd "src/basic/parse-util.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/prioq.h"
nm_copy_sd "src/basic/prioq.c"
nm_copy_sd "src/basic/random-util.c"
nm_copy_sd "src/basic/random-util.h"
nm_copy_sd "src/basic/refcnt.h"
nm_copy_sd "src/basic/set.h"
nm_copy_sd "src/basic/siphash24.c"
nm_copy_sd "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/stdio-util.h"
nm_copy_sd "src/basic/string-table.c"
nm_copy_sd "src/basic/string-table.h"
nm_copy_sd "src/basic/string-util.c"
nm_copy_sd "src/basic/string-util.h"
nm_copy_sd "src/basic/strv.c"
nm_copy_sd "src/basic/strv.h"
nm_copy_sd "src/basic/time-util.c"
nm_copy_sd "src/basic/time-util.h"
nm_copy_sd "src/basic/umask-util.h"
nm_copy_sd "src/basic/unaligned.h"
nm_copy_sd "src/basic/utf8.c"
nm_copy_sd "src/basic/utf8.h"
nm_copy_sd "src/basic/util.c"
nm_copy_sd "src/basic/util.h"
nm_copy_sd "src/libsystemd-network/arp-util.c"
nm_copy_sd "src/libsystemd-network/arp-util.h"
nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-network.c"
nm_copy_sd "src/libsystemd-network/dhcp-option.c"
nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd "src/libsystemd-network/lldp.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.c"
nm_copy_sd "src/libsystemd-network/lldp-network.h"
nm_copy_sd "src/libsystemd-network/lldp-network.c"
nm_copy_sd "src/libsystemd-network/lldp-port.c"
nm_copy_sd "src/libsystemd-network/lldp-port.h"
nm_copy_sd "src/libsystemd-network/lldp-tlv.c"
nm_copy_sd "src/libsystemd-network/lldp-tlv.h"
nm_copy_sd "src/libsystemd-network/network-internal.c"
nm_copy_sd "src/libsystemd-network/network-internal.h"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd "src/libsystemd-network/sd-lldp.c"
nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd "src/shared/dns-domain.c"
nm_copy_sd "src/shared/dns-domain.h"
nm_copy_sd "src/systemd/_sd-common.h"
nm_copy_sd "src/systemd/sd-dhcp6-client.h"
nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd "src/systemd/sd-dhcp-client.h"
nm_copy_sd "src/systemd/sd-dhcp-lease.h"
nm_copy_sd "src/systemd/sd-event.h"
nm_copy_sd "src/systemd/sd-ndisc.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4acd.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
nm_copy_sd "src/systemd/sd-lldp.h"
2016-02-12 10:47:07 +01:00
Beniamino Galvani
08c3378f64 core: fix matching of default metric value for static routes
When NM tries to match a generated connection to a persistent one, it
considers also the metric of static routes. However, if the field is
set to -1 (use default value for the device) on the persistent
connection, the comparison will always fail because the generated
connection contains the actual value read from kernel.

To fix the issue, modify check_possible_match() to deal correctly with
-1 and translate it to the expected value for the current device when
performing the comparison.

This allows connections with static routes and default metric to
properly be re-assumed when NM is restarted.

https://bugzilla.redhat.com/show_bug.cgi?id=1302532
2016-02-11 21:57:45 +01:00