Commit graph

649 commits

Author SHA1 Message Date
Beniamino Galvani
c029502912 ipv4ll: use internal implementation 2015-05-11 10:48:48 +02:00
Beniamino Galvani
c6302f3227 device: fix device state transition after IPv4LL failure
Don't terminate the entire connection if IPv4LL configuration fails
but instead call nm_device_check_ip_failed() to check the result of
IPv6 as well.
2015-05-11 10:48:48 +02:00
Beniamino Galvani
33d4232c3d device/trivial: move nm_device_check_ip_failed()
Move nm_device_check_ip_failed() upwards as it will be used by IPv4LL
code.
2015-05-11 10:48:48 +02:00
Beniamino Galvani
7a7f280ef3 device/trivial: rename 'aipd' and 'autoip4' to 'ipv4ll' 2015-05-11 10:48:48 +02:00
Lubomir Rintel
6fba9fd2e5 device: make sure NMDevice doesn't vanish halfway through applying configuration
It could be that the device was removed and the default route manager holds the
last reference:

  Breakpoint 1, dispose (object=0x90e710 [NMDeviceTun]) at devices/nm-device.c:8588
  8588            NMDevice *self = NM_DEVICE (object);
  (gdb) bt
  #0  0x000000000045d24e in dispose (object=0x90e710 [NMDeviceTun]) at devices/nm-device.c:8588
  #1  0x00007ffff4d29b7c in g_object_unref (_object=0x90e710) at gobject.c:3133
  #2  0x00000000004b0a61 in _entry_at_idx_remove (entry=<optimized out>) at nm-default-route-manager.c:192
  #3  0x00000000004b0a61 in _entry_at_idx_remove (vtable=<optimized out>, self=<optimized out>, entry_idx=<optimized out>) at nm-default-route-manager.c:638
  #4  0x00000000004adb51 in _ipx_update_default_route (vtable=0x7b1850 <vtable_ip6>, self=0x7da610 [NMDefaultRouteManager], source=<optimized out>) at nm-default-route-manager.c:814
  #5  0x0000000000459ccb in nm_device_set_ip6_config (self=0x90e710 [NMDeviceTun], new_config=<optimized out>, commit=<optimized out>, reason=<optimized out>) at devices/nm-device.c:6213
  #6  0x0000000000450c92 in ip6_config_merge_and_apply (self=0x90e710 [NMDeviceTun], commit=0, out_reason=0x0) at devices/nm-device.c:3670
  #7  0x0000000000452d06 in update_ip_config (self=0x90e710 [NMDeviceTun], initial=<optimized out>) at devices/nm-device.c:6915
  #8  0x000000000046253e in queued_ip_config_change (user_data=<optimized out>) at devices/nm-device.c:6945
  #9  0x00007ffff4a257fb in g_main_context_dispatch (context=0x7ca3e0) at gmain.c:3111
  #10 0x00007ffff4a257fb in g_main_context_dispatch (context=context@entry=0x7ca3e0) at gmain.c:3710
  #11 0x00007ffff4a25b98 in g_main_context_iterate (context=0x7ca3e0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3781
  #12 0x00007ffff4a25ec2 in g_main_loop_run (loop=0x7ca4a0) at gmain.c:3975
  #13 0x0000000000444bbe in main (argc=<optimized out>, argv=<optimized out>) at main.c:486
  (gdb)

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x7ffff4d4f164 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=args@entry=0x7fffffffd5b0) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  (gdb) bt
  #0  0x00007ffff4a2c970 in g_logv (log_domain=0x7ffff4d4f164 "GLib-GObject", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=args@entry=0x7fffffffd5b0) at gmessages.c:1046
  #1  0x00007ffff4a2cbaf in g_log (log_domain=log_domain@entry=0x7ffff4d4f164 "GLib-GObject", log_level=log_level@entry=G_LOG_LEVEL_WARNING, format=format@entry=0x7ffff4d563b0 "invalid unclassed pointer in cast to '%s'") at gmessages.c:1079
  #2  0x00007ffff4d481f9 in g_type_check_instance_cast (type_instance=0x90e710, iface_type=<optimized out>) at gtype.c:4030
  #3  0x0000000000459ceb in nm_device_set_ip6_config (self=0x90e710, new_config=<optimized out>, commit=<optimized out>, reason=0x0) at devices/nm-device.c:6217
  #4  0x0000000000450c92 in ip6_config_merge_and_apply (self=0x90e710, commit=0, out_reason=0x0) at devices/nm-device.c:3670
  #5  0x0000000000452d06 in update_ip_config (self=0x90e710, initial=<optimized out>) at devices/nm-device.c:6915
  #6  0x000000000046253e in queued_ip_config_change (user_data=<optimized out>) at devices/nm-device.c:6945
  #7  0x00007ffff4a257fb in g_main_context_dispatch (context=0x7ca3e0) at gmain.c:3111
  #8  0x00007ffff4a257fb in g_main_context_dispatch (context=context@entry=0x7ca3e0) at gmain.c:3710
  #9  0x00007ffff4a25b98 in g_main_context_iterate (context=0x7ca3e0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3781
  #10 0x00007ffff4a25ec2 in g_main_loop_run (loop=0x7ca4a0) at gmain.c:3975
  #11 0x0000000000444bbe in main (argc=<optimized out>, argv=<optimized out>) at main.c:486
  (gdb)

https://bugzilla.gnome.org/show_bug.cgi?id=748193
2015-05-11 10:44:02 +02:00
Dan Williams
aba250a7d4 core: move permanent and initial MAC address reading to NMDevice and NMPlatform
Ethernet, WiFi, and VLAN used the same implementation for initial address.

Ethernet and WiFi used the same implementation (and duplicated code) for
permanent MAC address, plus they both used ethtool in what should be
generic code, which is better done in the platform.
2015-05-06 16:14:25 -05:00
Dan Williams
ddaea22332 platform: move driver & firmware version reading into the platform 2015-05-06 16:14:25 -05:00
Dan Williams
fb1d04099f core: don't activate failed queued activation requests
If the queued activation request failed before the device is
finished deactiving the old request, don't start activating
the failed queued request.
2015-05-06 16:14:24 -05:00
Thomas Haller
8ebb8d0d0f device: allow reloading of the ignore-carrier flag
Now on SIGHUP, when reloading NetworkManager configuration, also reload
the ignore-carrier flag.

While a device is activated, the reload is ignored until the device
deactivates.

Maybe it would be simpler just not to cache ignore_carrer and let it
take effect immediately. But not caching ignore_carrer has the
additional downside that every call to is_available must check the
specs -- which in sum is potentially expensive for something that
almost never changes.

https://bugzilla.gnome.org/show_bug.cgi?id=748050
2015-05-05 16:53:51 +02:00
Thomas Haller
2d333a1769 config: make ignore-carrier option reloadable
Only move the ignore-carrier option from NMConfig to
NMConfigData. The ignore-carrier option is still
immutable after startup.

https://bugzilla.gnome.org/show_bug.cgi?id=748050
2015-05-05 16:51:19 +02:00
Dan Williams
388b7830f3 platform: don't wait for udev before announcing links 2015-05-01 14:25:55 -05:00
Dan Williams
3006df940c core: add generic NMDevice function to recheck availability
And use it everywhere.
2015-05-01 14:18:29 -05:00
Thomas Haller
bdaaf9849b platform: don't accept lowering IPv6 hop-limit from RA (CVE-2015-2924)
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=6fd99094de2b83d1d4c8457f2c83483b2828e75a
http://seclists.org/oss-sec/2015/q2/46
https://bugzilla.redhat.com/show_bug.cgi?id=1209902
https://bugzilla.redhat.com/show_bug.cgi?id=1209903
2015-04-29 14:14:20 +02:00
Thomas Haller
c6529a9d74 platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.

While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.

With this change, NMPlatform instances can be used individually, not
only as a singleton instance.

Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.

Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.

Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.

This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
2015-04-21 17:51:34 +02:00
Thomas Haller
ccba1b1e2d trivial: fix spelling in comments 2015-04-20 11:27:56 +02:00
Jiří Klimeš
fc6373bea9 device: add nm-plugin-missing property indicating NM device plugin not available
It is useful for indicating that the device type is supported but the required
plugin is not installed.
2015-04-20 10:00:28 +02:00
Jiří Klimeš
8257940606 core: (trivial) fix spelling in comments 2015-04-20 09:45:57 +02:00
Thomas Haller
255f30c362 device/logging: downgrade log level of "Activation: Stage x of 5" messages
Only downgrade the <info> levels to <debug>. Leave
warnings unchanged.

https://bugzilla.redhat.com/show_bug.cgi?id=1212196
2015-04-18 21:41:40 +02:00
Thomas Haller
b91b8a035c core/logging: reduce info logging messages for devices
https://bugzilla.redhat.com/show_bug.cgi?id=1212196
2015-04-18 21:41:40 +02:00
Thomas Haller
9983e4eff5 device/logging: log connection UUID when activating connection
It is often hard to understand whether we activate an assumed
connection. Only the UUID is unique.
2015-04-18 21:41:40 +02:00
Thomas Haller
756b756c2c device: expose nm_device_has_capability() function 2015-04-18 21:41:40 +02:00
Thomas Haller
2117bef864 device: use NMDeviceCapabilities enum for device capabilities 2015-04-18 21:41:40 +02:00
Lubomir Rintel
adb6e9afb1 device: move the decision whether to wait for IFF_UP a virtual function
We'd like to override it for veths.
2015-04-13 13:51:27 +02:00
Lubomir Rintel
d78f4614a0 device: use "new-activation" reason when deactivating for another activation
"user-requested" has a side effect of disabling autoconnect.

Fixes: 600489003f
2015-04-08 10:00:14 +02:00
Lubomir Rintel
1ad193a017 device,libnm,cli: add "new-activation" reason for device state change
It will be used when the device is disconnected for new connection activation.
2015-04-08 10:00:11 +02:00
Lubomir Rintel
c1c3d7e145 device: translate NM_DEVICE_STATE_REASON_UNKNOWN to "unknown" 2015-04-08 09:59:24 +02:00
Lubomir Rintel
4cb97cf66f manager: remove a connection from device if we're activating it on another device
The connection now might be being activated on another device. Defer the
removal until we're sure the activation request will proceed and only add the
active connection afterwards.

https://bugzilla.gnome.org/show_bug.cgi?id=730492
2015-04-03 18:59:33 +02:00
Lubomir Rintel
0f71335d52 device: use UNMANAGED reason instead of REMOVED when unmanaging devices upon quit
Since f85513b (device: do not touch sysctls after the device was removed) the
device is not unconfigured/cleaned up when it's removed. When we're quitting
the device is not actually removed, we're just unmanaging it -- let's just
use a different reason so that the cleanup runs.

Fixes: f85513b8e4
2015-04-02 11:19:55 -04:00
Lubomir Rintel
dc1928a0d0 device: progress the device activation if it has a valid assumed connection
If we detect a LL address and this not decide to readd it, don't stop at
ip-config; progress to ip-check.

Fixes: 396dc2b3b4
2015-04-01 14:59:16 +02:00
Dan Williams
99a6201264 core: use dev_id when calculating the interface IPv6 IID (rh #1101809)
Some device types (s390 OSA and ipvlan) can use the same link-layer address
for multiple virtual interfaces, and the kernel used the dev_id property
to differentiate these devices when constructing the IID.  NM should do
this too to prevent IID clashes.

https://bugzilla.redhat.com/show_bug.cgi?id=1101809
2015-03-27 15:11:34 -05:00
Lubomir Rintel
396dc2b3b4 device: if there's a ll address already don't re-commit it
Configuration commit is an unsafe thing to do for assumed connections,
it can remove an externally added address we don't know about yet.

The device already has a link-local address; for an assumed connection
it's the reason we assumed the method=link-local in the first place.
2015-03-17 17:16:03 +01:00
Lubomir Rintel
a8a9955d75 device: fix a couple of copy & paste errors 2015-03-17 15:36:12 +01:00
Lubomir Rintel
f85513b8e4 device: do not touch sysctls after the device was removed
Paths to sysctls don't use ifindex and device names can be reused. If someone
removes a device and quickly creates a device with the same name, chances are
we're cleaning up the device that was just added.

Sadly, it seems there's no better API than sysctl-- neither netlink nor procfs
symlinks with ifindex or anything like that.
2015-03-17 15:36:12 +01:00
Lubomir Rintel
2e99ddb7a7 device: unschedule ip update if we just scheduled ip configuration
It would subtract the configuration from device confguration that's not yet
applied. This a the race where the loose the address while activating a
connection that has both IPv6 and IPv4 configuration.

Fixes: 557667df12

https://bugzilla.gnome.org/show_bug.cgi?id=746066
2015-03-13 08:21:57 +01:00
Lubomir Rintel
a772fde00d trivial: move nm_device_queued_ip_config_change_clear()
Just move it upwards, we'll need it in
nm_device_activate_schedule_ip4_config_result().
2015-03-13 08:21:45 +01:00
Dan Williams
d2de83e0f7 device: don't assume valid ip4/ip6 config in nm_device_get_ipX_route_metric()
These functions will sometimes get called on updates to the device's IP
config due to external changes, or when addresses get flushed from the
device when activating it.  If the device is a slave device, then at
this point its NMConnection won't have an IP settings.  Suppress the
warning that gets printed when s_ip == NULL, because it's expected.
2015-03-12 15:04:16 -05:00
Dan Williams
1dae47e9cc device: fix handling if DHCP hostname for configure-and-quit
Fixes: 5149fd120d
2015-03-12 14:38:01 -05:00
Lubomir Rintel
7ba2a058f2 nm-device: avoid improper IPv6 MTU configuration
Ensure it's always (before address configuration starts and on updates) >= 1280
and not higher than the device MTU.
2015-03-09 18:21:01 +01:00
Lubomir Rintel
1bc202af02 nm-device: move device MTU setting from IP4Config to NMDevice
Just a refactoring, no functional change. This will make it easier to
coordinate the device MTU with IPv6 MTU.
2015-03-09 18:21:01 +01:00
Lubomir Rintel
4d6bf4eef3 nm-device: set ipv6 mtu at config commit time
Just a refactoring, doesn't make any actual difference. It is consistent with
IPv4 and will make it easier to implement a policy to recover from incorrect
MTUs settings.
2015-03-09 18:21:01 +01:00
Lubomir Rintel
f981407a02 core: pass ifindex as parameter to nm_ip6_config_new() 2015-02-27 16:50:09 +01:00
Dan Williams
84f54f0a5f core: pass ifindex as parameter to nm_ip4_config_new() 2015-02-27 16:50:09 +01:00
Lubomir Rintel
52711b5d89 ip6-config: keep track of ifindex
No functional change, a cosmetic thing for now.

We want it set before any routes are added and ensure routes have a valid
ifindex before we pass it to the platform.

In a future NMRouteManager will need to look up the route for a device in
its cache thus we'll need to make sure routes passed to the it have an
appropriate ifindex set.
2015-02-27 16:48:27 +01:00
Lubomir Rintel
747292a4c3 ip4-config: keep track of ifindex
No functional change, a cosmetic thing for now.

We want it set before any routes are added and ensure routes have a valid
ifindex before we pass it to the platform.

In a future NMRouteManager will need to look up the route for a device in
its cache thus we'll need to make sure routes passed to the it have an
appropriate ifindex set.
2015-02-27 16:48:27 +01:00
Lubomir Rintel
874e4a7595 core: split route management code out from platform
Create a NMRouteManager singleton.

Refactor, no functional changes apart from change of log domain from
LOGD_PLATFORM to LOGD_CORE.

Subsequent commit will keep track of the conflicting routes, avoid overwriting
older ones with newer ones and apply the new ones when the old ones go away.
2015-02-27 16:48:27 +01:00
Lubomir Rintel
600489003f device: set the reason for when deactivating for another activation
It's always user requested -- auto activation never happens on already active
devices. nm_device_release_one_slave() rightly asserts teardown with
(un)configuration does not happen for no reason at all.

https://bugzilla.gnome.org/show_bug.cgi?id=744812
2015-02-24 18:43:00 +01:00
Thomas Haller
0bfe635119 device: accept user activation request while waiting for carrier
https://bugzilla.redhat.com/show_bug.cgi?id=1079353
2015-02-24 11:49:04 +01:00
Thomas Haller
d80f1bf4f0 device: eliminate direct calls to check_connection_available() in favor of nm_device_check_connection_available()
It was confusing to understand the difference between calling nm_device_connection_is_available()
and check_connection_available(), they behaved similar, but not really
the same. Especially nm_device_connection_is_available() would look
first into @available_connetions, and might call check_connection_available()
itself. Whereas @available_connetions was also populated by testing
check_connection_available(). This interrelation makes it hard to
understand when nm_device_connection_is_available() returned true.

Rename nm_device_connection_is_available() to nm_device_check_connection_available()
and remove all direct calls of check_connection_available() in favor of
the wrapper nm_device_check_connection_available().

Now we only call nm_device_check_connection_available() with different
parameters (@flags and @specific_object). We also have the additional
guarantee that specifying more @flags will widen the result and making
a connection "more" available, while specifying a @specific_object will
restrict it.

This also changes behavior in several cases. For example before
nm_device_connection_is_available() for user-requests would always
declare matching connections available on Wi-Fi devices (only)
regardless of the device state. Now the device state gets consistently
considered.

For default-unmanaged devices it also changes behavior in complicated
ways, because before we would put connections into @available_connetions
for every device-state, but nm_device_connection_is_available() had a
special over-ride only for unmanaged-state.

This also fixes a bug, that user can activate an unavailable Wi-Fi
device:
  nmcli radio wifi off
  nmcli connection up wlan0
2015-02-24 11:49:04 +01:00
Thomas Haller
37ebeccaa7 device: implement flag NM_DEVICE_CHECK_DEV_AVAILABLE_IGNORE_CARRIER for is_available() 2015-02-24 11:49:04 +01:00
Thomas Haller
52dbb2398a device: add flags to nm_device_is_available() 2015-02-24 11:49:04 +01:00