Commit graph

649 commits

Author SHA1 Message Date
Thomas Haller
c4a087c36d core: wait for IPv6 link local address with method 'auto' and 'link-local' (bgo#707155)
With the methods 'auto' and 'link-local' we check now, that the device
has a usable IPv6 LL address configured (after DAD, no longer tentative).

We wait for up to 5 seconds, for a suitable LL address to appear.
Currently, if the address does not get ready, we don't create one and
IPv6 configuration fails.

This is relevant for the methods 'link-local' and 'auto'. In the latter
case, because we cannot send router solitations without link local
address.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-08 00:46:33 +01:00
Thomas Haller
f059298896 trivial: whitespace fix
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-07 21:32:08 +01:00
Thomas Haller
10bd060076 core: IPv6 mode link-local must not behave like auto (bgo#706618, bgo#707155)
In act_stage3_ip6_config_start, for IPv6 mode link-local, we check
if there is already an IPv6 address configured. If yes, we are
already done.

For now, as current workaround, if the LL does not exist, we
NM_ACT_STAGE_RETURN_STOP.

Later, we will POSTPONE and wait a timeout until we see a LL address
that is no longer TENTATIVE. The same should be done for method auto,
so that the device is usable to send router solitations (bgo#707155).

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-07 21:19:57 +01: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
b7300bbe5a core: improve handling of NPAR/SR-IOV devices (rh #804527)
Use the new kernel physical_port_id interface property to recognize
when two devices are just virtual devices sharing the same physical
port, and refuse to bond/team multiple slaves on the same port.
2013-11-06 10:26:16 -05:00
Dan Winship
a4dcd66698 core: fix the reporting of failed slaves
If nm_device_enslave_slave() failed, the slave would log that it was
waiting for the master to activate (even if the master was already
active). Fix it to log an error and fail its activation instead.
2013-11-06 10:26:16 -05:00
Dan Williams
f4befaab00 core: also check specific object when determining available connections 2013-10-31 15:33:57 -05:00
Dan Williams
1768b3abd5 core: add slave to master in stage1_prepare, not nm_device_activate()
When ActiveConnections take over authentication, it may mean that the
master active connection is still handling authentication when the
slave starts to activate.  Thus the master device may still be in
DISCONNECTED state and not ready to enslave the slave.
2013-10-31 14:15:08 -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
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
Pavel Šimerda
8e17fc2aa4 device: remove unused 'dev_state' variable
Reported-by: Julien Nabet <serval2412@yahoo.fr>
2013-10-20 18:24:26 +02:00
Dan Winship
f03635e5ac core: don't have IP4 and IP6 configs on slaves
Although it's convenient in some places to have IP configs on all
connections, it makes more sense in other places to not have IP
configs on slaves. (eg, it's confusing for nmcli, etc, to report a
full NMSettingIP4Config on a slave device). So revert parts of the
earlier patch. However, it's still safe to assume that s_ip4 != NULL
if method != DISABLED, so some of the earlier simplifications can
stay.

Also, add nm_utils_get_ip_config_method(), which returns the correct
IP config method for a connection, whether the connection has IP4 and
IP6 settings objects or not, and use that to keep some more of the
simplifications from the earlier patch.
2013-10-14 12:07:37 -04:00
Dan Winship
68f12b4e9c settings: make connections always have s_ip4 and s_ip6
Make sure that all connections returned from NMSettings or created via
AddAndActivateConnection have an NMSettingIP4Config and an
NMSettingIP6Config, with non-NULL methods, and get rid of
now-unnecessary checks for those.

Also move the slaves-can't-have-IP-config checks into the
platform-independent code as well. This also gets rid of spurious
"ignoring IP4/IP6 configuration" warnings in ifcfg-rh when reading a
slave ifcfg file.

Partly based on a patch from Pavel.

https://bugzilla.gnome.org/show_bug.cgi?id=708875
2013-10-11 12:24:34 -04:00
Dan Williams
09bde40f02 core: fix PropertiesChanged signals for IP-related properties
To present a consistent API to clients, the IP-related properties
are only valid when the device has finished IP configuration.  But
they are set before that happens, and their change notifications
were emitted before the IP configuration was considered valid.
Re-emit the change notifications when the device enters the IP_CHECK
state (and thus has IP configuration) and also when the device
deactivates to enusre clients have up-to-date IP-related property
information.

For the changes to has_ip_config(), the priv->ipX_state checks are
not necessary since the device will have valid IP configuration
when it enters the IP_CHECK state.  The other checks can be
consolidated into a single statement.

Acked-by: Dan Winship
2013-10-09 13:59:42 -05:00
Dan Williams
9543e45afe core: allow IPv4 to proceed if IPv6 is globally disabled but set to "auto" (rh #1012151)
If the user disabled IPv6 support in the kernel with "ipv6.disable=1" on the
kernel boot line, then any attempts to open IPv6 sockets (which libndp does)
will fail.  This failed the entire connection, even if IPv6's "may-fail"
property was TRUE.  Instead, just fail IPv6 and allow IPv4 to proceed.  If
IPv4 fails or is disabled, then other logic will fail the entire connection.
2013-10-07 11:53:18 -05:00
Thomas Haller
db9b7e10ac core: update existing IP[46]Config of device instead of replacing it (bgo #707617)
When the IP[46]Config changes, a new configuration gets assembled.
Before, whenever the new configuration was different than the current
one, the IP[46]Config of the device was completely replaced. This also
meant, that the old dbus IP[46]Config object was removed and the new one
was exported.

Now instead of recreating a new configuration, it updates the existing
(already exported) configuration in-place.

Also, add new gobject properties 'gateway' and 'searches' to the config class,
they will be exported over dbus.

Also, whenever any of the exported properties changes, make sure that a
notify signal gets emitted.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-25 23:12:37 +02:00
Dan Winship
b91d029021 core: short-circuit nm_device_spec_match_list()
If there are no specs, then the device can't match, so don't call the
virtual method (which might do work like building comparison strings
even when the list is empty).
2013-09-24 11:54:34 -04:00
Jiří Klimeš
76c34d48ed core,settings: do not call functions with connection==NULL (rh #1008151)
check 'req' and 'connection' variables. Apparently, they can be NULL
on some circumstances.

NetworkManager[2830]: <info> (p6p1): device state change: secondaries -> disconnected (reason 'connection-removed') [90 30 38]
NetworkManager[2830]: <info> (p6p1): deactivating device (reason 'connection-removed') [38]
kernel: [ 2623.609111] NetworkManager[2830]: segfault at 50 ip 00007f1a309bf6a1 sp 00007fffc59e67e0 error 6 in NetworkManager[7f1a30915000+104000]
NetworkManager[2830]: (nm-device.c:5043):nm_device_state_changed: runtime check failed: (in_state_changed == FALSE)
NetworkManager[2830]: <info> (p6p1): device state change: disconnected -> failed (reason 'secondary-connection-failed') [30 120 54]
NetworkManager[2830]: nm_act_request_get_connection: assertion `NM_IS_ACT_REQUEST (req)' failed
NetworkManager[2830]: nm_connection_get_id: assertion `connection != NULL' failed
NetworkManager[2830]: <warn> Activation (p6p1) failed for connection '(null)'
NetworkManager[2830]: nm_settings_connection_get_timestamp: assertion `connection != NULL' failed
abrt[2882]: Saved core dump of pid 2830 (/usr/sbin/NetworkManager) to /var/tmp/abrt/ccpp-2013-09-15-11:38:39-2830 (18952192 bytes)
systemd[1]: NetworkManager.service: main process exited, code=dumped, status=11/SEGV
systemd[1]: Unit NetworkManager.service entered failed state.

https://bugzilla.redhat.com/show_bug.cgi?id=1008151
2013-09-17 19:14:39 +02:00
Dan Williams
42b6c6eac0 core: fix call to nm_device_bring_up()
Typo in ebdf1796f1
2013-09-12 19:11:06 -05:00
Dan Winship
ebdf1796f1 core: implement :mtu and :cloned-mac-address for VLAN 2013-09-12 18:34:23 -04:00
Dan Winship
68bb65fbab core: fix nm_device_supports_vlans()
The platform knows which device types support VLANs, so just ask it,
rather than only doing VLANs on ethernet.
2013-09-12 18:34:23 -04:00
Dan Winship
e0f0f60ff5 core: remove nm_device_hwaddr_matches() / get_connection_hw_address()
These were only needed to support the possibility of VLANs having
arbitrary additional hardware settings.
2013-09-12 18:34:23 -04:00
Dan Williams
fa0112c0ca core: handle externally added IPv6 adresses and routes on IP change
Cache externally added IP details and represent them via the D-Bus
interface, and also merge them into the final device config to ensure
they aren't lost if DHCP renews or RA changes occur.
2013-09-05 14:24:06 -05:00
Jiří Klimeš
650cbc6660 trivial: fix build by returning FALSE in gboolean nm_device_set_is_nm_owned()
g_return_val_if_fail (NM_IS_DEVICE (device), FALSE);
2013-09-05 09:14:57 +02:00
Thomas Haller
958ec36b96 core: delete virtual devices created by NM when they are deactivated.
Virtual/software devices that were created by NM should be deleted when
the device gets deactivated.

https://bugzilla.gnome.org/show_bug.cgi?id=695705
https://bugzilla.redhat.com/show_bug.cgi?id=953300

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-04 18:21:49 +02:00
Thomas Haller
c6458cab36 core: add flag is_nm_owned to NMDevice
Add a flag to indicate that the device is owned by NM.
This is interesting for software/virtual devices, that were created by
NM and should be deleted when the interface gets deactivated.

This flag is not implemented as a glib property.

Maybe this flag can be consolidated with the managed flag. For now it is
unclear how to do it, so add this flag. It should be easy later to
replace it again.

https://bugzilla.gnome.org/show_bug.cgi?id=695705
https://bugzilla.redhat.com/show_bug.cgi?id=953300

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-04 18:21:49 +02:00
Pavel Šimerda
e0c2b970d6 trivial: add some comments to nm-device's link-changed handlers
Acked-by: Dan Winship <danw@gnome.org>
2013-08-30 10:54:20 +02:00
Colin Walters
ff89e98fac trivial: consistently #include "libgsystem.h" rather than just gsystem-local-alloc.h
libgsystem contains more than just the local allocation macros; in the
future we will likely want to make use of some of this such as the
structured logging support.
2013-08-29 16:16:35 -05:00
Dan Williams
179dae7c68 core: fix setting is_software for software devices created by NM
These devices don't have a platform device at creation time, thus
is_software wasn't getting set properly.  Move the is_software
decision to constructed() because by this point, the iface and
ifindex (if present) will be known for all cases and thus we can
figure out if it's a software device or not in one place.
2013-08-26 13:14:01 -05:00
Pavel Šimerda
68e250f86a core: reset ipv6 sysctls only for managed devices
Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Pavel Šimerda
c1f45eb2df core: match connections to connections instead of devices
This backwards compatible patch adds the possibility to use new
nm_device_generate_connection() API via update_connection() virtual
method implementations in NMDevice subclasses.

Compatibility is achieved by first trying to use the older API and
match_l2_config() virtual method and only then moving on to
update_connection().

The nm_device_generate_connection() calls update_connection() to create
type-specific NMSetting instances and verifies the connection before
returning it. To avoid tinkering with NMSettingConnection in
update_connection() we use a class attribute called connection_type
which is used by nm_device_generate_connection() itself.

Known issues:

* nm_device_generate_connection() method doesn't implement DHCP lease
configuration matching. We shouldn't actually need it but if a use case
for that will come out, we can fix it later.

* nm_device_generate_connection() doesn't fill in the slave-specific
options.

* update_connection() is not implemented and connection_type is not set
in the subclasses. This will be fixed in individual patches.

* NMSetting's compare_property() implementations in combination with
NM_SETTING_COMPARE_FLAG_CANDIDATE are not yet fully ready thus rendering
false negatives in some cases. Same as above.

Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Pavel Šimerda
155ec4c382 core: implement nm_device_is_software()
Cache the result of nm_platform_link_is_software() in NMDevice.

Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Pavel Šimerda
5affa446aa core: remove assume from nm-activation-request
Whether an active connection is assumed or connected from scratch is
only important during nm_device_activate(). When the activation process
is set up, there's no difference from any other active connection.

Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Dan Winship
bc091f2f3e core: add NMManager:startup property
Add a property on NMManager indicating that it is currently starting
up and activating startup-time/boot-time network connections.

"startup" is initially TRUE, and becomes FALSE once all NMDevices
report that they have no pending activity (eg, trying to activate,
waiting for a wifi scan to complete, etc). This is tracked via a new
NMDevice:has-pending-activity property, which is maintained partially
by the device itself, and partially by other parts of the code.
2013-08-16 17:27:34 -04:00
Dan Winship
75ea0b0593 core: remove some dead code in NMDevice 2013-08-16 17:27:34 -04:00
Jiri Pirko
23836e8146 core: add support for team device
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-15 10:54:15 -05:00
Thomas Haller
e26642c26c trivial: fix spelling errors in code comments
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-12 13:31:07 -05:00
Dan Williams
0c8d8b4da3 core: update UDI when it's available
Software devices don't have a UDI until udev finds them, and since we need
to know about the software devices before udev finds them the UDI will be
missing.  Instead of requiring a UDI on NMDevice creation, update the
property from the NMPlatform link change signal when udev does find the
device.

Now that a UDI is no longer required for device creation, software devices
added by NM would be created in the platform_link_added_cb() signal
handler triggered by the various software device creation methods in
system_create_virtual_device() (eg nm_platform_bridge_add() etc).  Then
the NMDevice created in system_create_virtual_device() would be a duplicate
and cause problems when it was added.  Since system_create_virtual_device()
needs to do setup on some devices, suppress the device creation from the
platform link added handler in this function.

Much of this is a hack which should be cleaned up later.
2013-08-07 12:53:24 -05:00
Thomas Haller
81ed5307d3 fixup! core: fix cleanup of NMDevices that fail construction
The unref in finalize is not needed, because the hash table gets already freed
in dispose.

Note that setting available_connections to NULL in dispose is not really
needed, because (altough dispose might be called more than once) there
is a guarded by "priv->disposed = TRUE;". But leave it for clearity in
case somebody tries to access the pointer (which shouldn't happen).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-07 12:53:24 -05:00
Dan Winship
588547b343 core: fix cleanup of NMDevices that fail construction
We were leaving signal handlers attached to devices that failed in
constructor() (and also leaking the available_connections hash). Fix
that.
2013-08-06 16:36:51 -05:00
Dan Winship
04bd4a9ea5 core: don't log warnings when devices are removed
If a device is removed, then trying to reset its IPv6 state will cause
nm_utils_do_sysctl() to log a warning since the path no longer exists.
So don't try to do it in that case.
2013-08-06 11:49:06 -04:00
Pavel Šimerda
320a9d16a3 all: replace struct in_addr with guint32 2013-08-03 00:15:07 -05:00
Pavel Šimerda
6762b2f792 core: use NMIP[46]Route in nm-ip[46]-config 2013-08-03 00:15:07 -05:00
Dan Williams
0aada347c1 core: recognize and handle external IPv4 routes and addresses added under NM
Don't blow them away on DHCP/VPN/IP changes.
2013-08-02 17:19:36 -05:00
Dan Williams
455df69f02 core: fix handling of externally added IPv4 adresses and routes on IP change
The switch to combine IPv4 configs to arrive at the final config would
cause externally added addresses and routes to be removed from the
interface when a DHCP or LLv4 event came in, becasue the externally
added details weren't cached anywhere and thus would be dropped on the
IP changes.
2013-08-02 17:19:36 -05:00
Dan Williams
5c1ec7cedf core: track VPN routes on the master device, not the VPN
When a VPN wanted to add some routes (like the host route for the
VPN gateway) it would add them itself and listen for parent device
events and re-add them if necessary.  That's pretty fragile, plus
the platform blows away routes that aren't part of the IP config
that's getting applied.

So we might as well just have the VPN connection tell the parent
what the routes are, and have the parent device handle updating
the routing.  The routes are through the parent device anyway,
and so are "owned" by the parent too.
2013-08-02 17:19:35 -05:00
Dan Williams
468243baf2 core: combine and apply IPv4 configs instead of applying directly
Like IPv6, keep the DHCP/LLv4 config separate and combine it with the
NMSettingIP4Config to arrive at the final, combined IP4 config.  This
brings the behavior in line with IPv6 code flow and will allow adding
the VPN routes config into the mix more easily.
2013-08-02 17:19:35 -05:00
Pavel Šimerda
356cad68fa platform: add reason attribute to all signals 2013-08-02 23:12:21 +02:00
Pavel Šimerda
2167e4376b Revert "platform: work around missing kernel netlink notifications of default route changes"
This reverts commit 42b4323902.
2013-08-02 22:17:06 +02:00