Commit Graph

14110 Commits

Author SHA1 Message Date
Beniamino Galvani
5996565ca9 manager: retry virtual connections when a device is added or changes
When a new device gets added or when an existing one changes name,
virtual connections that refer to it as parent device may become
ready, so let's try to activate them.

Previously we tried to activate virtual connections only on startup
and, after commit d8e1590c50 ("manager: retry device creation for
connection that would use a newly created device"), also when a
connection was added/changed, but this doesn't cover the case in which
a parent device appears or changes name at runtime.

https://bugzilla.redhat.com/show_bug.cgi?id=1275875
2016-01-15 09:36:19 +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
Lubomir Rintel
8b18c613ab manager: don't reject all internal activations on non-autoconnectable devices
When there's a slave that allows autoconnection and an unrealized master this
would cause the master activation to fail.

For the actual auto-activations the proper check is already done in NMPolicy's
auto_activate_device().
2016-01-13 17:21:31 +01:00
Lubomir Rintel
a6c8a45463 platform: fix a typo when comparing the peer addresses 2016-01-12 17:59:23 +01:00
Lubomir Rintel
5e8e81e2cf ip4-config: be a bit more tolerant when dumping the connection
This one single commit magically turns a nightmare into a summer breeze.
2016-01-12 17:59:23 +01:00
Thomas Haller
466a081c0f dispatcher: add assertion and code comment to complete_script() 2016-01-12 16:24:38 +01:00
Thomas Haller
2b54bd6a53 dispatcher: fix use-after-free in complete_script()
complete_request() possibly frees the request, making the @script and @request
a dangling pointer. We must not use those pointers, except a plain pointer-
comparison.
2016-01-12 16:24:38 +01:00
Lubomir Rintel
ddc6d97f00 dispatcher: only evaluate the number of the scripts if the request is still there
The request could have been completed by the call to complete_request() just above.
In that case we should just return instead of looking for nowait scripts to run.

  Core was generated by `/usr/libexec/nm-dispatcher'.
  Program terminated with signal SIGSEGV, Segmentation fault.
  #0  0x00007f6c916ad0fb in complete_script (script=<error reading variable: value has been optimized out>, script=<error reading variable: value has been optimized out>) at nm-dispatcher.c:349
  349                     if (   script->request->num_scripts_nowait == 0
  (gdb) bt
  #0  0x00007f6c916ad0fb in complete_script (script=<error reading variable: value has been optimized out>, script=<error reading variable: value has been optimized out>) at nm-dispatcher.c:349
  #1  0x00007f6c8f02d484 in g_child_watch_dispatch (source=<optimized out>, callback=<optimized out>, user_data=<optimized out>) at gmain.c:5148
  #2  0x00007f6c8f03079a in g_main_context_dispatch (context=0x7f6c9358d9a0) at gmain.c:3109
  #3  0x00007f6c8f03079a in g_main_context_dispatch (context=context@entry=0x7f6c9358d9a0) at gmain.c:3708
  #4  0x00007f6c8f030ae8 in g_main_context_iterate (context=0x7f6c9358d9a0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3779
  #5  0x00007f6c8f030dba in g_main_loop_run (loop=0x7f6c9358da80) at gmain.c:3973
  #6  0x00007f6c916abcd4 in main (argc=1, argv=0x7ffee4326768) at nm-dispatcher.c:935
  (gdb)

Fixes: e97a334e37

https://bugzilla.redhat.com/show_bug.cgi?id=1297826
2016-01-12 15:48:03 +01:00
Beniamino Galvani
49832fd394 core: merge branch 'bg/vlan-hwaddr-ipv6-rh1286105'
https://bugzilla.redhat.com/show_bug.cgi?id=1286105
2016-01-12 09:59:39 +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
Beniamino Galvani
9b94d33232 libnm: add versioning comments and macros to nm_device_reapply*()
Fixes: 278fd4fb0f
2016-01-12 09:51:44 +01:00
Beniamino Galvani
59dc2eb29a libnm: keep symbols sorted in libnm.ver 2016-01-12 09:51:41 +01:00
Thomas Haller
d8384aa8e6 trivial: fix whitespace 2016-01-11 14:25:38 +01:00
Thomas Haller
61f400ac03 core/device: merge branch 'th/device-realize-bgo760450'
https://bugzilla.gnome.org/show_bug.cgi?id=760450
2016-01-11 14:11:24 +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
Lubomir Rintel
4059b253b7 merge: branch 'lr/reapply'
https://bugzilla.gnome.org/show_bug.cgi?id=758463
2016-01-10 23:23:58 +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
Thomas Haller
06dfaeec09 audit: allow passing GDBusMethodInvocation context to audit methods 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
fa6375cd8b cli: add nmcli d reapply
Client support for O.FD.NM.Device.Reapply().
2016-01-10 23:13:34 +01:00
Lubomir Rintel
278fd4fb0f libnm: add nm_device_reapply()
Client support for O.FD.NM.Device.Reapply().
2016-01-10 23:13:34 +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
Thomas Haller
4706df11fd trivial: fix whitespace 2016-01-08 16:11:56 +01:00
Jordi Mas
d85b57946a ca: update Catalan (ca) translation (bgo #760147)
https://bugzilla.gnome.org/show_bug.cgi?id=760147
2016-01-08 15:09:43 +01:00
Thomas Haller
bc7ad75d99 contrib/rpm: install pre-up dispatcher script "10-ifcfg-rh-routes.sh" as no-wait
The main reason to introduce the "no-wait.d" dispatcher directory was
"10-ifcfg-rh-routes.sh", which (as a pre-up script) delays activation.
We even extracted the script to a separate package on RHEL to avoid
delays by default.

Invoke the script via no-wait.d.
2016-01-08 14:27:18 +01:00
Beniamino Galvani
7976edb723 manager: get rid of unused defines 2016-01-07 22:40:58 +01:00
Thomas Haller
bcd28951a4 gitignore: ignore "include/" directory
When switching between "nm-1-0" branch and "master", it is
common to have a left-over "include/" directory with build
artifacts. Add it to gitignore.
2016-01-07 17:49:38 +01:00
Thomas Haller
39d6976e89 build: minor change creating symlinks in install-exec-hook for nmtui 2016-01-07 17:41:58 +01:00
Michael Biebl
39fc73eed9 build: use symlinks for nmtui
Make /usr/bin/nmtui-* symbolic links to /usr/bin/nmtui.

https://bugzilla.gnome.org/show_bug.cgi?id=759824
2016-01-07 17:41:53 +01:00
Beniamino Galvani
3b35bf0ad7 core: merge branch 'bg/device-zero-mac-fix-rh1288110'
Fix activation for ethernet devices that appear with a zero initial
MAC address.

https://bugzilla.redhat.com/show_bug.cgi?id=1288110
2016-01-07 13:39:41 +01:00