Commit graph

79 commits

Author SHA1 Message Date
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
Dan Williams
42b4323902 platform: work around missing kernel netlink notifications of default route changes
It appears the kernel does not send notifications via netlink if the
default route is removed in some cases.  This causes the platform
route cache to become stale, and thus when the default route is
reset by NM the platform thinks the route already exists, and does
not add it.  But the route doesn't exist, becuase the kernel silently
removed it without telling anyone.

Fix that with a big hammer by flushing/refilling the route cache when
devices are deactivated (deletion of their addresses causes the default
route to be removed by the kernel) and when the default route is
updated by NM itself.

Pavel: if we find a more granular method, we should probably revert
this as the cache refill can be expensive.
2013-07-31 12:14:52 -05:00
Pavel Šimerda
a560148d27 core: use address lifetimes from router discovery 2013-07-30 11:40:19 +02:00
Pavel Šimerda
0e361e894c core: turn link_changed() into a proper virtual function 2013-07-29 13:51:13 +02:00
Dan Williams
fe5f0d2070 core: let device classes indicate their HW address will never change (bgo #701744)
Bluetooth device hardware addresses won't change during the lifetime
of the object (since that would mean a completely new device) and
they also won't have an ifindex because they aren't netdevices.

Various bits of the core periodically call nm_device_update_hw_address()
to update a device's hardware address, but this function expects that
any device with a hardware address also has an ifindex.  Except that
Bluetooth devices don't because they aren't netdevices.

Modify the get_hw_address_length() function to return a boolean
indicating whether or not the address can ever change, and set that
for BT devices.  nm_device_update_hw_address() then exits early if
there's no point in re-checking the hardware address, avoiding the
assertion.

https://bugzilla.gnome.org/show_bug.cgi?id=701744
2013-07-22 15:56:34 -05:00
Dan Winship
17e91fd46a core: change the rules for ignore-carrier
The previous ignore-carrier rules did not work well with dynamic IP
(dhcp/slaac) connections. Change the rule so that only static IP
connections can be activated when carrier is not present (but both
static and dynamic connections will remain up when carrier is lost).
2013-07-22 11:30:21 -04:00
Pavel Šimerda
bd1c7fbece device: use internal router discovery implementation 2013-07-20 17:08:01 +02:00
Pavel Šimerda
f7b2443035 core: always commit ip[46]-config to nm-platform
This is necessary to update the address lifetimes.
2013-07-20 15:30:09 +02:00
Pavel Šimerda
d8e6065f63 core: switch nm-ip4-config's NMIP[46]Address to NMPlatformIP[46]Address 2013-07-20 15:30:08 +02:00
Pavel Šimerda
74621a8f5c core: replace nm_ip[46]_config_diff()
Callers of these functions now only care whether two IP configs are
different and not what specific property changed, so we can simplify
this code down to a simple comparison for equality, based on the hashing
that's already done for the DNS manager.
2013-07-20 15:30:08 +02:00
Dan Williams
c370c04fee core: fix trailing semicolon that caused all IP6 configs never to get applied 2013-07-15 17:10:45 -05:00
Pavel Šimerda
d42f99f590 device: clean up ip6 configuration flow
IP6 configuration is now stored in ac_ip6_config and dhcp6_ip6_config
and passing them as function arguments is avoided. Written with Dan
Williams.
2013-07-15 15:53:43 +02:00
Pavel Šimerda
19747082b2 trivial: remove unused tried_ipv6 2013-07-09 12:29:47 +02:00
Pavel Šimerda
019dd1b7d8 trivial: remove unused system.h includesl 2013-07-05 17:22:34 +02:00
Pavel Šimerda
253906ecd2 trivial: simplify nm_ip[46]_config_diff() result check
nm_ip[46]_config_diff() explicitly checks for NULL arguments.
2013-07-04 18:15:08 +02:00
Pavel Šimerda
8de1b1732e trivial: move merge_ip6_configs() to nm-ip6-config 2013-07-04 13:37:26 +02:00
Pavel Šimerda
7967a6524a trivial: move a couple of functions to nm-ip[46]-config
Note that this patch doesn't effectively change any code.

Functions moved from nm-system:

* nm_system_apply_ip?_config → nm_ip?_config_commit
* ip?_dest_in_same_subnet → nm_ip?_config_destination_is_direct

Functions moved from NetworkManagerUtils:

* nm_utils_merge_ip?_config → nm_ip?_config_merge_setting

Functions renamed (and moved down to form one group):

* nm_ip?_config_new_for_interface → nm_ip?_config_capture

(The rationale for the rename is that from the achitectural point of
view it doesn't matter whether the function creates a new object or
updates an existing one. After the rename, it's obvious that
nm_ip?_config_capture() and nm_ip?_config_commit() are counterparts of
each other.)
2013-07-03 16:12:23 +02:00
Jiří Klimeš
e2b7c4824d core: fix IP_DONE vs. IP_FAIL states
0652d9c596 changed IP states like this:
        |        old behaviour          |  new behaviour
---------------------------------------------------------
success | IP_DONE && config is not NULL |    IP_DONE
failure | IP_DONE && config is NULL     |    IP_FAIL

But some failure paths was not updated.
2013-07-03 10:48:14 +02:00
Pavel Šimerda
ca6b360089 core: don't use flags for nm_system_apply_ip[46]_config
nm_platform_*_sync() functions check the cached kernel configuration
items (addresses, routes) before adding addresses to the kernel.
Therefore we don't need to be so careful about pushing NetworkManager
configuration to the kernel.

This patch helps to avoid having to compare nm_ip[46]_config objects,
which should only be created when a configuration change is being
performed.
2013-07-02 22:49:56 +02:00
Pavel Šimerda
f548a49782 trivial: clarify has_ip_config()
Make it more explicit that it returns TRUE for UNMANAGED state.
2013-07-02 20:12:54 +02:00
Jiří Klimeš
5e9ab28c5a core: call nm_device_queue_state() instead of direct state transition
in nm_device_start_ip_check(), because it is called from the state handler
(nm_device_state_changed()).

Errors:
(devices/nm-device.c:5585):nm_device_state_changed: runtime check failed: (priv->in_state_changed == FALSE)
<info> (eth0): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
2013-07-02 15:36:46 +02:00