Commit graph

1182 commits

Author SHA1 Message Date
Dan Williams
751a37bf43 wifi: ignore monitor interfaces
If a monitor interface is created, NM will grab that interface
and change it to station mode.  That's not very nice.

https://mail.gnome.org/archives/networkmanager-list/2016-February/msg00068.html
2016-02-24 11:43:42 +01:00
Thomas Haller
1b00009169 device: add new NMDeviceType NM_DEVICE_TYPE_VETH
Based-on-patch-by: Jiří Klimeš <jklimes@redhat.com>
2016-02-23 23:15:37 +01:00
Lubomir Rintel
f6d0fc3341 wifi: avoid autoconnecting Ad-Hoc networks with method=auto
This fixes the issue where all Ad-Hoc networks try to connect one after one on
NM startup instead of the managed network that has AP available.

Fixes: e2637760f1
2016-02-22 17:11:01 +01:00
Thomas Haller
c210134bd5 device: revert overruling NM_UNMANAGED_USER_SETTINGS decision
Since commit 87a3df2e57, the unmanaged
flag NM_UNMANAGED_USER_SETTINGS could be overwritten via an explict
user decision (NM_UNMANAGED_USER_EXPLICIT).

It makes sense to allow user configuration from file to be changable
by an explict user action via D-Bus at runtime.

However, it also changes behavior for devices that are currently explicitly
managed. Previously, a reload of the NM_UNMANAGED_USER_SETTINGS would
immediately unmanaged the device:

  - for keyfile: send SIGHUP to reload NetworkManager.conf
  - for ifcfg-rh: `nmcli connection [re]load`

So this change in behavior could negatively affect users who rely
on being able to configure "NM_CONTROLLED=no" and expect to unmanaged
the device immediately. Thus revert the change.

Note that NM_UNMANAGED_USER_SETTINGS is anyway ugly and should be
deprecated:
  - for keyfile, why having the option "keyfile.unmanaged-devices"
    instead of a generic options?
  - for ifcfg-rh, why put per-device configuration in a per-connection
    file?
The preferred way is to configure NM_UNMANAGED_USER_UDEV via
"ENV{NM_UNMANAGED}". Maybe we should also add a new configuration
scheme via NetworkManager.conf.

https://bugzilla.gnome.org/show_bug.cgi?id=762331
2016-02-22 16:24:32 +01:00
Thomas Haller
569cca6595 device: rename NM_UNMANAGED_USER_CONFIG to NM_UNMANAGED_USER_SETTINGS
The NM_UNMANAGED_USER_SETTINGS flags are determined by the settings plugins.
That is, either:
  - keyfile's "unmanaged-devices" configuration option
  - ifcfg-rh's "NM_CONTROLLED" option
  - ifnet's "managed" option

Rename NM_UNMANAGED_USER_CONFIG to NM_UNMANAGED_USER_SETTINGS to reflect
that it this is user configuration determined by the settings plugin.
2016-02-22 16:14:39 +01:00
Thomas Haller
8bace23beb all: cleanup includes and let "nm-default.h" include "config.h"
- All internal source files (except "examples", which are not internal)
  should include "config.h" first. As also all internal source
  files should include "nm-default.h", let "config.h" be included
  by "nm-default.h" and include "nm-default.h" as first in every
  source file.
  We already wanted to include "nm-default.h" before other headers
  because it might contains some fixes (like "nm-glib.h" compatibility)
  that is required first.

- After including "nm-default.h", we optinally allow for including the
  corresponding header file for the source file at hand. The idea
  is to ensure that each header file is self contained.

- Don't include "config.h" or "nm-default.h" in any header file
  (except "nm-sd-adapt.h"). Public headers anyway must not include
  these headers, and internal headers are never included after
  "nm-default.h", as of the first previous point.

- Include all internal headers with quotes instead of angle brackets.
  In practice it doesn't matter, because in our public headers we must
  include other headers with angle brackets. As we use our public
  headers also to compile our interal source files, effectively the
  result must be the same. Still do it for consistency.

- Except for <config.h> itself. Include it with angle brackets as suggested by
  https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
2016-02-19 17:53:25 +01:00
Lubomir Rintel
89d6fa6aa9 device: don't allways set assumed reason when platform init is done
When the device is transitioning from unmanaged to disconnected for "assumed"
reason, bring_up is not called. This is not a good thing in numerous
instances, e.g.:

1.) vlans that we've created need that to set IFF_UP and read carrier
otherwise they won't be available for connections.

2.) veths that are being managed need to start the deferred carrier check
so that the behavior matches real Ethernet.

3.) Hardware devices that were plugged in while NetworkManager is running
that need the IFF_UP for a carrier check, possibly enqueueing a deferred one.

Fixes: 5637d72af2.
2016-02-19 14:40:16 +01:00
Thomas Haller
7197425137 device: expose NMIP4Config:addresses in stable/defined sort order
Like we already do for IPv6 addresses, we should expose addresses
in a defined, stable sort order.

Clients usually show the addresses in the same order as obtained
via D-Bus.
2016-02-18 21:53:03 +01:00
Beniamino Galvani
86f005ea4b device: fix assertion on unmanaged_mask for slave devices
When executing these commands:

  ip link add br0 type bridge
  ip link set dev br0 up
  ip link add dummy1 type dummy
  ip link set dev dummy1 up
  ip addr add 1.1.1.1/24 dev br0
  brctl addif br0 dummy1
  sleep 1
  ip link del br0
  ip link del dummy1

the following assertion was failing:

  nm_device_master_release_one_slave: runtime check failed: (NM_FLAGS_HAS (slave_priv->unmanaged_mask, NM_UNMANAGED_IS_SLAVE))

  #0  g_logv()
  #1  g_log()
  #2  g_warn_message()
  #3  nm_device_master_release_one_slave()
  #4  nm_device_cleanup()
  #5  _set_state_full()
  #6  nm_device_state_changed()
  #7  nm_device_unrealize()
  #8  _platform_link_cb_idle()
  #9  g_main_context_dispatch()
  #10 g_main_context_dispatch()
  #11 g_main_context_iterate()
  #12 g_main_loop_run()
  #13 main()

Upon slave removal we unrealize the device, resetting the unmanaged
flags to NM_UNMANAGED_PLATFORM_INIT, then we clean up the device and
call nm_device_master_release_one_slave(), which asserts the presence
of NM_UNMANAGED_IS_SLAVE flag cleared just before.

Drop the check.

Fixes: 87a3df2e57
2016-02-18 14:18:07 +01:00
Thomas Haller
f31954c071 device: don't overwrite get_connection_iface() by default
Factories that overwrite this function are not supposed to chain
up the parent implementation. Thus there is no reason to have
a default implementation and it's clearer to inline it.
2016-02-17 18:43:45 +01:00
Lubomir Rintel
8b016cd9a7 device: remove interface name checks from all classes
Generic check_connection_compatible() already does the check.
2016-02-17 18:43:44 +01:00
Lubomir Rintel
f9ec713641 device: move the interface name check from manager
We not only want to check the device name when creating a virtual device, but
also when determining if the connection can actually be activated there.

Otherwise the device names will mix up if there's more connections that use
virtual devices of the same type.
2016-02-17 18:43:44 +01:00
Lubomir Rintel
cd81e0bd9f device-factory: always use the factory to determine the connection's interface name
This makes things a bit simpler when determining if any connection is
activatable on an existing device.
2016-02-17 18:43:33 +01:00
Lubomir Rintel
fd314ed7f7 device-factory/trivial: rename get_virtual_iface_name() to get_connection_iface() 2016-02-17 18:43:02 +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
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