Commit graph

1127 commits

Author SHA1 Message Date
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
Thomas Haller
3d463e2f69 device: only set NMDevice as "real" at the end of nm_device_realize_finish()
Only set the device as "real" at the end of nm_device_realize_finish(),
not already during nm_device_realize_start()/realize_start_setup().
2016-01-17 22:40:09 +01:00
Thomas Haller
9c2266741b device: cleanup unrealized device without connection
During nm_device_unrealize(), the connection might still
have some connections that only get removed later. We must
garbage collect unrealized devices when they loose their
available-connections, not during unrealize.

Fixes: 436ec5b8e3
2016-01-17 22:40:09 +01:00
Thomas Haller
eab9cca87c device: refactor cp_connection* functions to use @self pointer 2016-01-17 22:40:09 +01:00
Thomas Haller
7830b79d50 device: minor logging changes to device creation 2016-01-17 22:38:28 +01:00
Lubomir Rintel
c4bd0cc5cb device: always process hop limit and MTU from the RA
Apply MTU and hop limit when managed or other flag is set as well. This wasn't
the case for the first RA and the previous commit made it slightly worse by
always ignoring it.

Fixes: ad2584c375
2016-01-15 12:08:24 +01:00
Lubomir Rintel
ad2584c375 device: apply the iv6 configuration as soon as we get the RA
With DHCPv6 it might be quite some time (we may even time out) until we get all
the information to finish activation, but we already have the addresses and
routes.
2016-01-14 21:00:59 +01:00
Thomas Haller
3dc28b2b23 device: don't progress to ip-check if the DHCPv6 is still pending 2016-01-14 21:00:59 +01:00
Lubomir Rintel
ac457aa322 device: use the REMOVED only when unmanaging an active device while quitting
For the devices that are not active we still want to run the cleanup path.

Fixes: 3e2fce288a
2016-01-14 17:46:20 +01:00
Lubomir Rintel
3e2fce288a device: use the REMOVED reason when unmanaging the device while quitting
With the final removal the reason of NOW_UNMANAGED causes the cleanup on the
device to be run, which downs the device:

  #0  nm_platform_link_set_down (self=0x555555a29bb0, ifindex=1711) at platform/nm-platform.c:1111
  #1  0x00005555555d6ccf in nm_device_take_down (self=self@entry=0x555555c07c70, block=block@entry=1) at devices/nm-device.c:8175
  #2  0x00005555555df0c7 in _set_state_full (self=0x555555c07c70, state=NM_DEVICE_STATE_UNMANAGED, reason=NM_DEVICE_STATE_REASON_NOW_UNMANAGED, quitting=quitting@entry=0) at devices/nm-device.c:9825
  #3  0x00005555555dfa97 in nm_device_state_changed (self=<optimized out>, state=<optimized out>, reason=<optimized out>) at devices/nm-device.c:10084
  #4  0x00005555555e472c in nm_device_set_unmanaged_flags (self=<optimized out>, flag=flag@entry=NM_UNMANAGED_INTERNAL, unmanaged=unmanaged@entry=1, reason=reason@entry=NM_DEVICE_STATE_REASON_NOW_UNMANAGED)
      at devices/nm-device.c:8745
  #5  0x00005555555e54a9 in nm_device_set_unmanaged_quitting (self=<optimized out>) at devices/nm-device.c:8806
  #6  0x000055555565b1aa in remove_device (manager=manager@entry=0x555555a4a2c0, device=0x555555c07c70, quitting=quitting@entry=1, allow_unmanage=allow_unmanage@entry=1) at nm-manager.c:833
  #7  0x0000555555660b81 in nm_manager_stop (self=0x555555a4a2c0) at nm-manager.c:4389
  #8  0x00005555555b3f9b in main (argc=1, argv=0x7fffffffdba8) at main.c:493
2016-01-14 12:29:03 +01:00
Lubomir Rintel
cdc8a92b37 device: the unrealized devices can attempt to autoconnect 2016-01-13 18:10:25 +01:00
Lubomir Rintel
71f92bf72d device: trivial: streamline nm_device_autoconnect_allowed()
The function returns early when autoconnect is off, so there's no reason to
branch for that case below. The signal is only generated for autoconnect=true.
2016-01-13 18:10:17 +01:00
Beniamino Galvani
45b77dbcfc device/vlan: reapply IPv6 configuration after MAC change
https://bugzilla.redhat.com/show_bug.cgi?id=1286105
2016-01-12 09:56:14 +01:00
Beniamino Galvani
d26a8c2eed device: export nm_device_reactivate_ip{4,6}_config functions
nm_device_reactivate_ip6_config() will be used to reconfigure IPv6
addressing when a VLAN interface changes MAC.
2016-01-12 09:56:14 +01:00
Thomas Haller
d8384aa8e6 trivial: fix whitespace 2016-01-11 14:25:38 +01:00
Thomas Haller
a602b18f74 device: refactor virtual function NMDevice:unrealize_notify() to only clear properties
Change the meaning of unrealize_notify() similar to realize_start_notify(),
which only resets device properites during unrealize.
2016-01-11 14:05:49 +01:00
Thomas Haller
ec3613f27c device/trivial: rename virtual function NMDevice:unrealize() to unrealize_notify() 2016-01-11 14:05:49 +01:00
Thomas Haller
2550850f54 device: pass NMPlatformLink instance as const pointer 2016-01-11 14:05:49 +01:00
Thomas Haller
633e105455 device/trivial: rename realize/setup function in NMDevice 2016-01-11 14:05:49 +01:00
Thomas Haller
169c5b7a52 device: remove unused virtual function NMDevice:realize()
The idea of NMDevice:realize() was to
  (1) update the device properties
  (2) fail realization if some critical properties are missing

(1) is already done during nm_device_setup_start().
(2) was only implemented by NMDeviceVlan:realize(), but it
basically was just checking whether such a platform device exists.
Other implementations don't do that either and it opens up for a race
when the device gets deleted externally.
2016-01-11 14:05:49 +01:00
Thomas Haller
eee00a8355 device/vlan: refactor handling platform properties for NMDeviceVlan
Extract a function update_properties() similar to other device
implementations. It reads the device specific data from platform
and raises property-changed notifications.

update_properties() is now called by realize_start_notify().
NMDeviceVlan:realize() -- which previously implemented something like
update_properties() -- now does nothing. Note that previously
realize() might have failed, but this is different from other device
implementations and it was unclear what a failure really meant.
Ok, it might fail because the link was not found in the platform cache.
But other implementations don't check that either, so why vlan? And
how to handle that properly anyway?
Therefore realize()'s implementation is no longer needed because
nm_device_realize() already calls realize_start_setup(), which
calls realize_start_notify() and update_properties().

update_connection() no longer refreshes the device properties.
Instead it only modifies the passed-in NMConnection. It's a bit
ugly that update_connection() uses both cached properties from
NMDeviceVlan (vlan_id) and platform properties (xgress maps).
Also, update_connection() doesn't return early on error but continues
trying to update the NMConnection. The reason is that update_connection()
cannot return a failure status.
2016-01-11 14:05:49 +01:00
Thomas Haller
225ce48b8a device/vlan: remove unreachable code from realize()
plnk->id is unsigned. It cannot be negative.
2016-01-11 14:05:49 +01:00
Thomas Haller
492691dfb2 device: remove unneeded implementations of realize()
The virtual function NMDevice:realize() is only called by
nm_device_realize() and immediately followed by nm_device_setup_start().

Devices already overwrite setup_start_notify() to update their properties.
No need to duplicate that in realize().
2016-01-11 14:05:49 +01:00
Thomas Haller
4c6b991bb0 device: move implementation of NMDevice:setup_start() to realize_start_setup()
All implementations of NMDevice:setup_start() in derived classes
invoke the parent implementation first. Enforce that by moving
NMDevice:setup_start() to realize_start_setup() and only notify
derived classes afterwards via NMDevice:realize_start_notify().
2016-01-11 14:05:49 +01:00
Thomas Haller
0311a0eae3 device: remove unused virtual function NMDevice:setup_finish() 2016-01-11 12:22:19 +01:00
Thomas Haller
1dbee32150 device: add realize_start_setup() function
Don't call the virtual function directly. Instead add
a wrapper function.
2016-01-11 12:22:19 +01:00
Thomas Haller
72e118716e trivial: fix whitespace 2016-01-11 12:22:19 +01:00
Thomas Haller
7db95727d5 device: refactor reapply_connection()
Reapplying a connection should not be done by iterating over and
(unsorted) @diffs array. Instead the order matters! E.g. first layer 2
before IP settings. Thus extracting those individual updates on a per-setting
base to different reapply_*() functions is more complicated, albeit incorrect
in complex cases. We need full control over how to reapply changes, one
after the other.

Also, once we start applying changes, we cannot really abort on error.
We can only continue best-effort and hope for the best.

Also, always reapply certain settings, even if the configuration doesn't
change. That means, if the user externally deletes a static IP address,
he can call reapply() to restore it. Even though he doesn't provide a
different setting to apply.

Also revert the changes to nm_device_reapply_settings_immediately().
Effectively there is little code that can be reused.

Add audit logging.
2016-01-10 23:14:29 +01:00
Lubomir Rintel
8adff4993c device: apply the firewall zone and metered state on Reapply()
Reuse some code with the immediate reapply mechanism.
2016-01-10 23:14:29 +01:00
Lubomir Rintel
02bf4db8bc device: add possibility to reapply the ipv6 settings 2016-01-10 23:14:29 +01:00
Lubomir Rintel
a5b6436a90 device: add possibility to reapply the ipv4 settings 2016-01-10 23:14:29 +01:00
Lubomir Rintel
1490c36bb9 device: add O.FD.NM.Device.Reapply() call
The introspection data and daemon stub. There's no settings that can be
reapplied at the moment.
2016-01-10 23:13:34 +01:00
Lubomir Rintel
21fa044df0 device: refactor the ip cleanup
Split it up and move upwards. It will be useful for runtime reconfig of
IPv4 configuration.
2016-01-10 23:12:48 +01:00
Beniamino Galvani
92149f223f device: wait for valid MAC before making ethernet devices available
In certain situations, ethernet links first appear with a zero MAC
address and then the MAC changes some time later. Currently NM does
not deal correctly with this scenario since it initializes wrong
@initial_hwaddr and @permanent_hwaddr on the device and tries to
immediately activate it.

To fix this, initialize the device's addresses only when the MAC
becomes valid and make the device available only at that point.
2016-01-07 11:53:05 +01:00
Beniamino Galvani
2a0a9aa2e4 device/trivial: split out nm_device_update_initial_hw_address() 2016-01-07 11:52:52 +01:00
Beniamino Galvani
44789e3291 core: simplify generation of default connection for new devices
Instead of using a signal for triggering the generation of a default
connection when the device becomes managed, let the manager wait for a
transition to UNAVAILABLE or DISCONNECTED states.

This partially reverts b3b0b46250 ("device: retry creation of
default connection after link is initialized").
2016-01-07 11:52:52 +01:00
Thomas Haller
1a835ad3d0 wifi: refactor creation of NMDeviceWifi/NMDeviceOlpcMesh to initialize in constructed() method 2016-01-06 22:18:25 +01:00
Thomas Haller
044de4cea2 wifi: don't fail construction of NMDeviceWifi in constructor
We cannot abort the construction of a GLib object instance
like we did for NMDeviceWifi and NMDeviceOlpcMesh when
nm_platform_wifi_get_capabilities() failed.

Instead, check the capabilities first (in the factory method)
and only create the object instance when the device can be handled.

https://bugzilla.gnome.org/show_bug.cgi?id=760154
2016-01-06 22:18:25 +01:00
Thomas Haller
e2e22eb574 wifi-olpc: refactor NMDeviceOlpcMesh to hold pointer to NMManager
Objects that register to a signal of a singleton should own a reference
to the singleton to ensure the proper lifetime of the singleton upon shutdown.
2016-01-06 22:18:25 +01:00