Commit graph

489 commits

Author SHA1 Message Date
Dan Williams
befa9083e8 core: fuzzier matching of generated connections to persistent ones
When generating a connection, if the device has no non-link-local IPv6
address, then it's unclear whether (a) the connection was link-local
originally, or (b) the connection was 'auto' but IPv6 failed or timed
out.

In this case, if there is a persistent connection that is 'auto' but
the generated connection is 'link-local', the persistent connection
should be used.

Add a more-testable framework for doing the connection matching to
handle this.
2013-12-05 17:09:46 -06:00
Dan Williams
75d694db9b core: optimize generated connection matching a bit
Do a quick check to see if the connetion is compatible with the device
before we start doing a relatively heavy connection comparison.
2013-12-05 16:07:24 -06:00
Dan Williams
5f15409684 libnm-util: add INFERRABLE flag and remove CANDIDATE
INFERRABLE means the opposite of CANDIDATE; a property which NetworkManager
can read ("infer") from the system or the kernel when generating
connections.  CANDIDATE isn't a great name and thus dies.
2013-12-05 16:07:24 -06:00
Jiří Klimeš
b7d6c61fe7 manager: handle NULL ifname in nm_manager_can_device_auto_connect gracefully 2013-12-04 16:11:10 +01:00
Jiří Klimeš
41d3efbd73 manager: do not create software devices when device was manually disconnected
We can only create virtual interfaces when the connection has autoconnect
property *and* the device was not manually disconnected before.

Without this commit NetworkManager would auto-activate all virtual connections
when a change was done (e.g. new virtual connection was addded).
2013-12-04 16:06:08 +01:00
Jiří Klimeš
6c96f5f777 manager: fix connection auto-activation in timestamp-based order (rh #1029854)
This commit fixes a regression from a1f16cd4d9
(nm-policy.c change).

https://bugzilla.redhat.com/show_bug.cgi?id=1029854
2013-11-29 15:42:37 +01:00
Dan Williams
308f2c08dd Revert "core: add Devices property to Manager"
This reverts commit c1768154c4.

Not supposed to be committed yet, see dcbw/dbus-properties for the
real patch.
2013-11-25 15:19:09 -06:00
Dan Williams
c1768154c4 core: add Devices property to Manager
Helps other bindings.
2013-11-25 11:59:13 -06:00
Jiří Klimeš
46a7760ead core: do not generate a connection for loopback interface (rh #1032594)
Else loopback is managed, and could be easily disconnected, which causes various
issues with applications. So do not manage it for now, to be on the safer side.

https://bugzilla.redhat.com/show_bug.cgi?id=1032594
2013-11-20 19:07:48 +01:00
Dan Williams
6a75c9b8e8 core: allow default wired connections to stay up when quitting
Previously, the default wired connection was removed on quit when the
device was cleaned up.  This is inconsistent with other connections.
Leave the default wired connection up when quitting to fix this
inconsistency.

This allows default wired connections to be assumed when NM starts.
2013-11-14 11:34:07 -06:00
Dan Winship
3c236c88eb core: fix re-activation of existing active connection
The change to allow an NMConnection to only be active on a single
device accidentally broke the case of re-activating a connection on
the same device. Fix that.
2013-11-13 13:35:41 -05:00
Thomas Haller
97935382f4 coverity: fix various warnings detected with Coverity
These are (most likely) only warnings and not severe bugs.
Some of these changes are mostly made to get a clean run of
Coverity without any warnings.

Error found by running Coverity scan

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Co-Authored-By: Jiří Klimeš <jklimes@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Dan Williams
f413911239 core: don't deactivate assumed connections when quitting
If an assumed bridge/bond/team/whatever happened to be in the process
of activating (perhaps it had no recognized slaves and was waiting for
them to continue with IP configuration) when NM quits, don't deactivate
the device and blow away the assumed configuration.
2013-11-08 16:46:45 -06:00
Dan Winship
6b7ebc0eb9 core: NMManager:state fixes for assumed connections, etc
Don't set NMManager:state to CONNECTING when assuming a connection,
since it's not actually "connecting".

If there are active connections, but none has the default route, then
the global state should be CONNECTED_LOCAL, not CONNECTED_GLOBAL.

Also tweak the semantics of CONNECTING/DISCONNECTING slightly; we only
set state to CONNECTING when connecting a new connection if we are not
already CONNECTED_GLOBAL, and we only set it to DISCONNECTING if we
will be DISCONNECTED afterward.
2013-11-08 16:46:45 -06:00
Pavel Šimerda
ce810d3660 core: remove non-NM-created bridge workarounds
Handle bridges like any other devices since soon we'll be able to
take them over without changing their existing configuration.
2013-11-08 16:46:45 -06:00
Dan Williams
d6b9465b18 core: find assumed connection masters
If an assumed connection should have a master (bridge port, bond slave,
etc) it needs to notify its master that it's a slave.  Since slaves
are ordered after their masters at start, the master should already
have a generated connection which we can use as the master.
2013-11-08 16:46:44 -06:00
Dan Williams
61744d41bb core: add nm_active_connection_[get|set]_assumed()
Various code during the activation paths will want to know whether
the connection is assumed or not, so that it doesn't do stuff that
touches the device.
2013-11-08 16:46:44 -06:00
Dan Williams
e7567859c9 core: allow devices to activate their generated connections
If the device has a valid generated connection, it's already applied
and the device is already "activated" outside NM, so let activation
happen inside NM regardless of whether the device is available or not
according to NM.
2013-11-08 16:46:44 -06:00
Dan Williams
ffea69e06b trivial: refine connection generation logging 2013-11-08 16:46:44 -06:00
Dan Williams
24995b2c96 core: don't generate connections for devices NM just created
No sense in doing that, since they were just created and can't possibly
have any relevant configuration yet.
2013-11-08 16:46:44 -06:00
Dan Williams
0321073b3c core: capture initial device DHCP IP configuration
At least gives us DNS servers and definite gateway.
2013-11-08 16:46:44 -06:00
Dan Williams
b54a9868fd core: clean up legacy connection matching; remove match_l2_config
All previous users of this API are gone, so remove it.
2013-11-08 16:46:22 -06:00
Dan Williams
a31dfea052 core: fix assumed active connection exporting after ff7e47a4 (core: kill PendingActivation and move authorization to NMActiveConnection)
Assumed active connections never got a D-Bus path and were never exported
to D-Bus.
2013-11-07 11:53:23 -06:00
Dan Williams
60cf32f271 trivial: quiet log message about failing to determine virtual interface name
In the case of autoconnect VLANs or IB partitions, if the parent interface
hasn't been detected yet at startup, then the get_virtual_interface_name()
won't be able to find the parent yet.  That's normal, and when the parent
is found, system_create_virtual_device() will be run again and the parent
will be found, and the autoconnect VLAN/IB partition will be created.

But we shouldn't warn that the parent can't be found when that might be
a normal occurance.
2013-11-07 11:33:16 -06:00
Pavel Šimerda
2b2383e9c5 core: add device-generated connection to settings
Only NMSettingsConnections can be activated on device, and
get_connection() wasn't doing that.  So the generated connection
must be added to NMSettings.  That also triggers the
ConnectionProvider's 'connection-added' signal with the happy
result of adding the new connection to the device's
AvailableConnections list.

Acked-by: Dan Williams <dcbw@redhat.com>
2013-11-06 17:55:06 -06:00
Dan Williams
9d00229447 core: rework ignore-carrier device behavior
Previously, ignore-carrier devices were always in the unavailable state
until they were activated.  This required some complicated code to keep
track of whether the device was available or not based on what connections
existed, whether those connections were static-IP, and whether the device
was ignore-carrier.  Various bits of the code used nm_device_can_activate()
for two different purposes: (1) to determine if the device was available
on an L2 basis, which nm_device_can_activate() wasn't well-suited to, and
(2) whether a specific connection could be activated at a given time
based on ignore-carrier and whether the connection was static IP or not.

Remove that complexity and confusion by making ignore-carrier devices
always move to DISCONNECTED state, and simply refuse to activate
connections that require connectivity, but allow connections that don't
require connectivity.  Also, when the device has no carrier, don't
add connections that require connectivity to the AvailableConnections
device property.
2013-11-06 17:55:05 -06:00
Dan Winship
a1f16cd4d9 core: don't allow activating the same connection twice (rh #997998)
Change the rules for connection activation so that a given
NMConnection can only be used by a single NMActiveConnection at any
given time.
2013-11-06 10:21:27 -05:00
Jiří Klimeš
8ec031fb0e core: again allow calling AddAndActivateConnection() without a connection
When settings are NULL or empty in impl_manager_add_and_activate_connection(),
the connection is created and completed by nm_utils_complete_generic() or
nm_device_complete_connection().

Also, do not assert in nm_connection_is_type(). Returning FALSE there is
sufficient.

Related commit a878cd8145
2013-11-01 14:07:04 +01:00
Jiří Klimeš
6457e2c367 core: fix crash on an activation error
Reported by Oleksii Shevchuk (alxchk) on IRC
2013-11-01 10:23:09 +01:00
Dan Williams
35124dbb14 core: extend ActivateConnection to allow NULL connection paths
When called with a connection path, activates that connection.

When called without a connection path, picks the best available
connection to activate for that device.

Doesn't work with VPN connections because they don't have devices.
2013-10-31 15:33:58 -05:00
Dan Williams
ff7e47a418 core: kill PendingActivation and move authorization to NMActiveConnection
Besides killing PendingActivation, this patch decouples ActiveConnection
creation from actually activating that connection.  This allows the
ActiveConnection to complete authorization asynchronously.  This will
also be used in the future for handling the DEACTIVATING state of devices
(for "pre-down" functionality).
2013-10-31 14:55:32 -05:00
Dan Williams
3bb2b158cd core: switch NMActiveConnection master to an NMActiveConnection instead of NMDevice
We need to track the master active connection, since it may require authentication
or other operations to complete before the device actually starts activating.
2013-10-31 14:15:08 -05:00
Dan Williams
4237df8c21 core: allow active connection 'master' to be set after object creation
We want to create the object earlier now, and figuring out the master is
a lot of code that we don't want to run before creating the object.  The
master still must be set before exporting the object over D-Bus though,
as before.
2013-10-31 14:15:08 -05:00
Dan Williams
0e595abcf3 core: pass NMAuthSubject around activation paths instead of uid + dbus sender 2013-10-31 14:15:08 -05:00
Dan Williams
bcef423174 core: use NMAuthSubject in D-Bus triggered activation paths 2013-10-31 14:15:08 -05:00
Dan Williams
07b07a988a core: use NMAuthSubject in the manager for non-activation paths 2013-10-31 14:15:08 -05:00
Dan Williams
7a9d5a262a core: grab remote process id when authenticating D-Bus clients 2013-10-31 14:15:07 -05:00
Dan Williams
a007292937 core: move VPN active connection creation to the manager
Eventually the manager will create both NMActRequest and
NMVPNConnection subclasses directly, instead of leaving
NMVPNConnection creation to the VPN manager.

This also ensures that VPN connections get their user_requested
attribute set correctly, which wasn't happening before in the
case of secondary VPN connections.
2013-10-31 14:15:07 -05:00
Dan Williams
3660a80c29 core: export new active connection from the manager
When we eventually do authorization in the ActiveConnection itself,
we want to make sure the AC doesn't get exported until everything
is authorized.  Thus let the manager handle exporting the objects
since it knows when the AC will be authorized or not.
2013-10-31 14:15:07 -05:00
Dan Williams
4e4e14e65c core: more flattening of PendingActivation objects
Do less authentication in the PA and make the DBusGMethodInvocation
opaque to the PA.  This pushes the responsibility for replying to
the D-Bus method call closer to the D-Bus method handler instead
of stuffing it all into the PA.  This does mean we need to get
the D-Bus sender name and the sender UID and pass that into the
pending_activation_new(), but we'll clean that up in a bit.
2013-10-31 14:15:07 -05:00
Dan Williams
f94ac164a6 core: make nm_manager_activate_connection() take a Device, not a path
Simpler; everywhere that called it has an NMDevice already anyway.
2013-10-31 14:15:07 -05:00
Dan Williams
a878cd8145 core: move connection completion code closer to callers
Move the connection completion code out of the PendingActivation
object and into the D-Bus method handler for AddAndActivate.  This is
part of simplifying PendingActivation so we can fold its functionality
into NMActiveConnection and use the AC objects to track all activation
requests from start to finish.

This also requires a bit of reorganization since the PA used to handle
some of the request validation but that now needs to be handled by
each DBus method itself.

Previously the PA tracked the connection path, but that's really
quite unecessary, we might as well just track the actual connection
object itself.  This allows us to only validate the path once, instead
of three times like the code did before.  This does require a boolean
"add_and_activate" variable though, because the PA handles the DBus
method return and it needs to know whether the request came from
ActivateConnection or AddAndActivateConnection, which was previously
handled by checking pending->connection, which only AddAndActivate set.
2013-10-31 14:15:07 -05:00
Jiří Klimeš
5bbde1b87e core: fix an error message - connection ID vs. interface name 2013-10-24 12:19:20 +02:00
Jiří Klimeš
f4dbf27410 core: track autoconnect for removed software devices (rh #1005913)
When an interface is manually disconnected NM remembers that, and prevents
automatic activation of the device.
However, software devices are removed when they are disconnected, and thus
the state of the device is lost. We need to track autoconnect outside the
device - hash table of interface names not allowed to activate automatically.

Without that the device would be auto-activated again and again, even if
explicitly disconnected.
Test case:
$ nmcli con add type bond ifname bb con-name bb-con
$ nmcli con add type bond-slave ifname em1 con-name b1-con master bb
$ nmcli dev disconnect bb

https://bugzilla.redhat.com/show_bug.cgi?id=1005913
2013-10-24 11:58:18 +02:00
Thomas Haller
3eb1d5e902 core: cleanup freeing of glib collections of pointers
When freeing one of the collections such as GArray, GPtrArray, GSList,
etc. it is common that the items inside the connections must be
freed/unrefed too.

The previous code often iterated over the collection first with
e.g. g_ptr_array_foreach and passing e.g. g_free as GFunc argument.
For one, this has the problem, that g_free has a different signature
GDestroyNotify then the expected GFunc. Moreover, this can be
simplified either by setting a clear function
(g_ptr_array_set_clear_func) or by passing the destroy function to the
free function (g_slist_free_full).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 19:53:57 +02:00
Thomas Haller
c67f978df0 core: fix compiler warnings -Werror=shadow by trivial renaming of variables
https://bugzilla.gnome.org/show_bug.cgi?id=710497

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 18:45:22 +02:00
Thomas Haller
bf5a6ad443 bluez: enable both BlueZ4 and 5 and select it dynamically at runtime
NMBluezManager is now a proxy and only delegates to either
NMBluez4Manager or NMBluez5Manager. It detects the running BlueZ
version at runtime, and once it decides for one version, it cannot be
changed anymore as long NetworkManager is running.

This means, when switching from BlueZ4 to BlueZ5 or vice versa you have
to restart NetworkManager. This should be acceptable, because it is
not a common use case (most systems won't have both versions installed
anyway) and it greatly simplifies implementation.

Also note that NMBluez4Manager and NMBluez5Manager do not implement a
common interface. NMBluezManager delegates to the correct manager.
Having them share an common interface or base class would not simplify
the code, because NMBluezManager not only delegates, but it also acts as
a proxy until it is decided which BlueZ version is running. So, this
proxy-like behaviour would still be needed. The alternative would be to
merge the functionality of all three NMBluez*Manager classes into one.

This also removes the --enable-bluez4 configure switch, because both
versions are now always enabled.

https://bugzilla.gnome.org/show_bug.cgi?id=709412

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-18 19:56:37 +02:00
Thomas Haller
3344ce9ff6 bluez: copy bluez-manager file for version 4 and 5
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-18 19:56:37 +02:00
Dan Williams
6b8bf26b79 platform: don't treat unrecognized WiMAX devices as Ethernet
If the WiMAX plugin isn't installed, or the WiMAX device isn't
recognized, NetworkManager shouldn't treat the interface as
regular ethernet since the device requires specific setup to
be ready for IP configuration, which of course NetworkManager
can't do because the WiMAX plugin isn't loaded.  Ignore them
instead.
2013-10-18 11:28:01 -05:00
Jiří Klimeš
33f8218023 trivial: fix indentation in nm_manager_activate_connection() 2013-10-18 09:02:26 +02:00