Commit graph

1165 commits

Author SHA1 Message Date
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
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
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
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
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
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
b3401bf921 device: add nm_device_get_applied_setting() 2016-02-12 13:46:12 +01:00
Dan Williams
e2637760f1 wifi: allow autoconnect on AP/AdHoc mode connections with manual IP configuration
The existing checks assumed that all AP/AdHoc connections would use the
shared IP method.  But what we really want to check for here is whether the
connection is AP/AdHoc.  Leave the existing 'shared' check for backwards
compatibility.

Also move the check above the timestamp check, since the user shouldn't need
to manually set a timestamp just to get an AP-mode connection to autoconnect.
2016-02-11 14:37:38 -06:00
gunchleoc
007aeba021 wifi: fixed some strings "cannot specific" => "cannot specify"
https://github.com/NetworkManager/NetworkManager/pull/2
2016-02-11 15:31:07 +01:00
Beniamino Galvani
b5a469a894 device: check nm_ip6_config_get_address_first_nontentative() argument
Since commit 9ff161b2a1 ("device: move have_ip6_address() to
nm_ip6_config_get_address_first_nontentative()") the IP configuration
argument of nm_ip6_config_get_address_first_nontentative() must be
non-NULL. Add checks where needed.

Fixes: 9ff161b2a1
2016-02-03 17:54:12 +01:00
Thomas Haller
118a75fcde device: check ext_ip6_config_captured for ll_addr in dhcp6_start_with_link_ready()
We should not check ip6_config for the link local address because
ip6_config contains the merged settings we want to configure,
not the addresses that are actually configured on the device.
Check ext_ip6_config_captured for that.

Also, reuse nm_ip6_config_get_address_first_nontentative() which
only takes an address after it survived DAD.
2016-02-02 11:43:57 +01:00
Thomas Haller
9ff161b2a1 device: move have_ip6_address() to nm_ip6_config_get_address_first_nontentative() 2016-02-02 11:43:57 +01:00
Thomas Haller
5ff8decb8f device: add ext_ip6_config_captured to remember the last-read platform configuration
ext_ip6_config gets modified to only contain items that are configured
externally, not by internal choice.
2016-02-02 11:43:57 +01:00
Beniamino Galvani
dc4d0a4200 device/team: fix tiny memory leak
Fixes: 10f9b6c58b
2016-02-01 22:26:05 +01:00
Thomas Haller
72255b71d7 utils: pass entire return statement to NM_UTILS_LOOKUP_DEFINE() 2016-02-01 14:20:26 +01:00
Dan Williams
2d1638bba9 core,dhcp: look for IPv6LL address in composite config
It will only be in ext_ip6_config if it was added by the kernel,
which isn't usually the case since NM handles IPv6LL address
generation on new enough kernels.

If the LL address isn't found, IPv6 configuration will never
complete because DHCPv6 was started already but lack of an LL
address bails out early without handling the error.

Fixes: b8c2fc26c1
2016-01-29 16:00:54 -06:00
Thomas Haller
17c5e4ec65 device: don't iterate over a va_list more then once
Calling va_start() (with va_end()) in between seems to work and
is done by systemd and other code occasionally.

However, it's not clear that this really works on every architecture.
So just replace thise one instance with a different implementation
by passing the arguments as an array.
2016-01-29 14:29:28 +01:00
Dan Williams
1cf4727766 wwan: retry connect on some errors and save them for log messages
First, cb751012a2 mistakenly converted the
act_stage_context_step() in connect_ready() to connect_context_clear()
instead of connect_context_step().  This would cause the IP Type retry
logic to fail and no further types to be tried.  It also throws
away the ctx->first_error and causes all errors that MM returns on the
connect attempt to be dropped on the floor.

Second, not all errors should cause an advance to the next IP Type,
since some errors aren't related to it.  Specifically, MM_CORE_ERROR_RETRY
when using Simple.Connect() means that a timeout was reached
in the internal connect logic, not a modem or network error.  In
that case, try the connect again with the same IP Type before advancing
to the next type.

Fixes: cb751012a2

Tested-by: Ladislav Michl <ladis@linux-mips.org>
Tested-by: Tore Anderson <tore@fud.no>
2016-01-28 12:25:47 -06:00
Thomas Haller
53233bb04c bluez: own reference to connection provider in NMBluezDevice 2016-01-27 14:18:38 +01:00
Thomas Haller
94dcffc475 bluez: own reference to connection provider in NMBluezManager 2016-01-27 14:18:38 +01:00
Thomas Haller
7cc54d5bb9 bluez: fix invoking parent dispose() function in NMBluezManager
Fixes: bf5a6ad443
2016-01-27 14:18:38 +01:00
Thomas Haller
66438de577 core: reject existing links when trying to add a link via platform
When we decide to add a new link, we alredy checked that no such link exists
(ignoring race conditions).

It is wrong to accept a EXITS failure when adding the link. There is no guarantee
that the existing link has all the same properties as the one we intend to add.
More importantly, this link was added externally outside of NetworkManager and it
should not be taken over.

Just treat EXISTS as a failure as any other.
2016-01-25 13:35:10 +01:00
Thomas Haller
4ab3fd37f9 device: add _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST enum
NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST is a multi-flag value combining all
the hooks that compose a user-request. Add a special value that has no esplicit
meaning except that it ~is~ a user-request.
2016-01-24 16:07:01 +01:00
Thomas Haller
02ec76df5a device: cleanup handling available-connections
For update, don't delete first and add it again. Just do it
in one step.

For recheck, don't delete all connections first to add them
all anew. Instead, check what changes and only emit the changed
signal if there are any actual changes.
2016-01-24 16:07:01 +01:00
Thomas Haller
9b3b94858b device/trivial: rename functions for available-connections 2016-01-24 16:07:01 +01:00
Thomas Haller
6c6ab10dea core/trivial: rename NM_UTILS_STRING_LOOKUP_TABLE* to NM_UTILS_LOOKUP*
Due to using a switch stetement, it is no longer only useful for looking
up strings, and it certainly doesn't use a table anymore.
2016-01-24 14:29:37 +01:00
Thomas Haller
3ed2488d74 utils: use NM_UTILS_STRING_LOOKUP_TABLE_ITEM() macro 2016-01-24 14:20:58 +01:00
Beniamino Galvani
8cba3e046e core: list iptables sharing rules in the right order
The rules were added to the list using g_slist_append() and then
applied one at time using "iptables --insert" which puts them at the
beginning of the chain, reversing the initial order.

Instead, list them in the desired order and use g_slist_prepend() to
achieve the same result. This has no functional changes.
2016-01-23 10:01:21 +01:00
Thomas Haller
944065c115 core: check generated virtual interfaceplatform name
https://bugzilla.redhat.com/show_bug.cgi?id=1300755
2016-01-21 18:38:52 +01:00
Thomas Haller
f1fba3eb02 wifi: fix crash due to wrong ownership handling in nm_supplicant_manager_iface_release()
nm_supplicant_manager_iface_get() would cache and reuse the supplicant
interface. But no ref-counting was in place so that the first user returning
the interface via nm_supplicant_manager_iface_release() would destroy the
instance for others.

This is broken for a very long time. Which shows that we hardly ever
have a cache-hit and usually create a new instance. So, instead of
letting nm_supplicant_manager_create_interface() check for existing
supplicant interface, always create a new instance. This also makes
sense, because we would expect that per ifname only one instance is
requested at a time. Also add an assertion that we don't return
multiple supplicant interface instances for the same ifname.

Drop nm_supplicant_manager_iface_release() in favor of requiring users
to unref the returned instance.

Also, use a GSList instead of a GHashTable for the cache.

Also, previously callers would pass @is_wireless to nm_supplicant_manager_iface_get(),
but the cache lookup did not consider that value. That doesn't matter
now as we always create a new instance.

https://bugzilla.redhat.com/show_bug.cgi?id=1298007
2016-01-21 14:58:55 +01:00
Thomas Haller
8dcf4d32e9 device/wifi: remove unnecessary call to remove_supplicant_interface_error_handler()
remove_supplicant_interface_error_handler() is not needed as we later disconnect
all handlers for @self.
2016-01-21 14:58:54 +01:00
Thomas Haller
84828960ff device/wifi: replace cancel_pending_scan() with nm_clear_g_source() 2016-01-21 14:58:54 +01:00
Thomas Haller
0a2ff1d16d device/ethernet: cleanup clearing handlers registered to supplicant interface 2016-01-21 14:58:54 +01:00
Thomas Haller
30f72c2753 device/ethernet: use nm_clear_g*() function in remove_supplicant_interface_error_handler() 2016-01-21 14:58:54 +01:00
Dan Williams
0a12a1711c libnm-core,core,cli: fix spelling of NM_IP_TUNNEL_MODE_UNKNOWN
Fixes: b614a5ec61
Fixes: ae8c7a8967
Fixes: 570fdce93f
2016-01-20 11:27:22 -06:00
Beniamino Galvani
75068a085a device: detect duplicate IPv4 addresses when method=auto 2016-01-20 11:53:47 +01:00
Beniamino Galvani
28f6e8b4d2 device: detect duplicate IPv4 addresses when method=manual 2016-01-20 11:53:47 +01:00
Beniamino Galvani
83b712aa42 core: add test for NMArpingManager 2016-01-20 11:53:47 +01:00
Beniamino Galvani
7a0fe9b21e core: add NMArpingManager
Add a new object which implements the logic for announcing IP
addresses and detecting duplicates using arping.

Based-on-patch-by: Jiří Klimeš <jklimes@redhat.com>
2016-01-20 11:53:47 +01:00
Beniamino Galvani
f607a16994 device/macvlan: implement dispose()
When the object gets disposed, parent must be unreferenced and signals
disconnected.

Fixes: 4de8851eca

https://bugzilla.redhat.com/show_bug.cgi?id=1299803
2016-01-20 11:41:59 +01:00
Beniamino Galvani
701d98acc5 device: fix check on device state in carrier_changed()
The function can now be called on unrealized devices before the
initial unmanaged flags are set and for those devices
nm_device_get_managed() will return TRUE. Since we only accept
states > UNMANAGED, return early when the condition is not met.

Fixes the following failed assertion:

carrier_changed: assertion 'priv->state >= NM_DEVICE_STATE_UNAVAILABLE' failed

https://bugzilla.gnome.org/show_bug.cgi?id=760844
2016-01-20 09:53:10 +01:00
Thomas Haller
76f90812f4 device: clear queued_state callback in dispose
dispose() calls _cleanup_generic_pre() which in turn already calls
nm_device_queued_state_clear(). So we would expect that at the end
of dispose() no queued-state is pending.

However, there there are crashes reports in queued_set_state() with the
device instance already destructed (rh#1270247). Add this check trying
to avoid the crash and closing in on the cause.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1180827
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1270247
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1298009
2016-01-19 13:00:20 +01:00
Thomas Haller
1e90ef2043 device: remove unrealized device without connections on idle handler
Emitting the NM_DEVICE_REMOVED signal can cause the destruction of the
device, thus it should be emitted on an idle handler.
2016-01-19 11:38:29 +01:00
Lubomir Rintel
f7c76b372c device: don't remove a devices on connection availability checks
The availability checks are called from places that don't assume the device
will be removed mid-air. Call the removal routine only when we're the very
last thing that's being done.
2016-01-18 21:09:28 +01:00