Commit Graph

11063 Commits

Author SHA1 Message Date
Dan Williams
b5668f22be ifcfg-rh: (trivial) fix formatting 2014-11-07 12:09:54 -06:00
Thomas Haller
065a3240fb policy: fix get_best_device() to return only active devices from the list
This fixes an assertion during shutdown. NMManager:dispose()
calls remove_device(), which eventually hit the assertion
in nm_default_route_manager_ip4_get_best_device().

Remove the assertion, but also make sure that the function only
returns devices from the provided list. It is counter intuitive,
that the function might return devices that are not in the provided
list.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 18:50:31 +01:00
Jiří Klimeš
9ed96e15eb build: add the compatibility header for g_clear_pointer()
Necessary for GLib < 2.34
2014-11-07 17:10:39 +01:00
Dan Winship
99d0fe3006 core: fix new NMIP4Config and NMIP6Config properties
The AddressData and RouteData marshalling code were still using the
types from an earlier version of the branch. Fix that.
2014-11-07 11:09:35 -05:00
Thomas Haller
2cfd1647d3 core: ensure generated connections has no gateway if it has no addresses
Fixes: f17699f4e3
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 16:35:00 +01:00
Thomas Haller
d4417e3460 core: merge branch 'th/bgo735512_route_metric'
Now NetworkManager will add a route for every device/VPN
that is not never-default. Multiple routes are prioritized
via the route metric.

https://bugzilla.gnome.org/show_bug.cgi?id=735512
https://bugzilla.redhat.com/show_bug.cgi?id=663730

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:42:52 +01:00
Thomas Haller
5dcd853bff core: even vor MODEM devices don't add IPv6 default routes without gateway
We'll ever have WWAN devices with a NULL gateway because the IPv6 over
WWAN still uses router advertisements to get a prefix. Thus you'll
always have a gateway if the device has real IPv6 connectivity.

For the IPv4 case, we still allow default routes without gateway on
WWAN.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
6e409ef91f policy: return best config based on the internal sorting of NMDefaultRouteManager
Now that both VPN and devices are managed (and ordered) by
NMDefaultRouteManager, refactor get_best_config() to use the
priority accordingly.

Before, we would first iterate over all VPN connections and
returning the best one. Only if no suitable VPN connection
was found, a best device would be returned.
Modify get_best_config() to treat VPN and device the same and
return the best one based on the route metric.

With this change, get_best_config() gives consistent results
together with get_best_device(). Also, you can configure
that a device gets a higher priority then a VPN.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
f22c72d299 policy: improve get_best_device() to strictly adhering the sort order of the entries
get_best_device() has two different modes depending on the @fully_activated argument.
If @fully_activated, it only considers devices that are considered as active.
Otherwise, it returns the best activating device (if that device is expected
to be better then any of the already activated devices).

Before, the check whether an activated device is considered best device
also involved looking at the device state. This redundancy was harmful
because part of NMDefaultRouteManager considered a device as fully activated,
but get_best_device() might not return them.

Split get_best_device() in two parts. The one part _ipx_get_best_activating_device()
now checks for still activating devices. When inspecting devices with
an entry, those devices are weighted according to _ipx_get_best_device().
That means that both functions now give a consistent result.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
eb61cdc6c5 policy: set default routes for VPN via NMDefaultRouteManager
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
ff40ccf899 policy: move get_best_config() function to nm-default-route-manager
No functional change, only refactoring by moving and combining the code.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
a39a3ae4cd policy: track default route for VPN in NMDefaultRouteManager
Extend NMDefaultRouteManager to track NMVpnConnection beside
NMDevice. That way, all default routes are managed by
NMDefaultRouteManager.

For VPN connections the manager also tracks connections that are
set never_default. That is useful because NMPolicy still uses VPNs
without default route to setup DNS. Hence, NMDefaultRouteManager
trackes those connections to have the relative priority of the
devices.
Interestingly, that means that for VPNs that are ipv4.never-default,
ipv4.route-metric still has an effect in determining relative priorities
for DNS configuration.

This commit only adds the parts to track the default route. NMPolicy
still sets the route as before.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
a94605f92b policy: better sync get_best_device() with NMDefaultRouteManager
NMDefaultRouteManager has a sorted list of routes. Change get_best_device()
to better consider that list when choosing a best device.

Always prefer the priority as reported from entry->effective_metric
if the device is registered to have a default route. Before for
!fully_activated, we choose the metric based on
nm_device_get_ipx_route_metric().

Add more checks in case of equal priority. For @fully_activated,
always prefer the device that is sorted by NMDefaultRouteManager.
For non @fully_activated, prefer the device with an entry.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
0fc47f3b57 policy: move get_best_device() function to nm-default-route-manager
No functional change, only refactoring by moving and combining the code.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
e8824f6a52 policy: add manager for default routes and support multiple default routes
Up to now, NMPolicy would iterate over all devices to find the "best"
device and assign the default route to that device.

A better approach is to add a default route to *all* devices that
are never-default=no. The relative priority is choosen according to
the route metrics.

If two devices receive the same metric, we want to prefer the device
that activates first. That way, the default route sticks to the same
device until a better device activates or the device deactivates.
Hence, the order of activation is imporant in this case (as it is
already now).

Also, if several devices have identical metrics, increment their
metrics so that every metric is unique.
This makes the routing deterministic according to what we choose as best
device.

A special case is assumed devices. In this case we cannot adjust the metric
in face of equal metrics.

Add a new singleton class NMDefaultRouteManager that has a list of all
devices and their default routes. The manager will order the devices by
their priority and configure the routes using platform.

Also update the metric for VPN connections. Later we will track VPN
routes also via NMDefaultRouteManager. For now, fix the VPN metric because
otherwise VPNs would always get metric 1024 (which is usually much larger then the
device metrics).

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
cc9fad612e policy: remove redundant check for never-default in get_best_ipx_config()
get_best_ip4_config() and get_best_ip6_config() checked both for
never-default of the setting. This check was redundant, because
the never-default value was already merged into NMIPXConfig.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
2f90ecbfbb policy: minor refactoring in get_best_ipx_device()
In get_best_ip4_device() and get_best_ip6_device(), move
conditions to check for suitable connection first.
Makes the following patch more coherent.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
227aebf4b6 policy: fix updating the default route for VPN
When adding a default route fails, the most common
reason is that we don't have a direct route to the gateway.
In that case, NMPolicy tries to add a direct route to
the gateway and then retries adding the default route.

For VPN however, previously NMPolicy would not added a direct
route to the gateway via the VPN device. Instead it would add a
direct route to the external gateway via the parent interface.
That is wrong.

Indeed the external gateway must be reachable directly not via the
VPN interface itself. But for that the vpn connection already sets
a route via nm_device_set_vpn4_config().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
22fe5d67a7 vpn: add nm_vpn_connection_get_connection_id() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
276424c881 core: remove unneeded check in nm_ip4_config_commit() for default routes
These lines are part of NM for a very long time.
I think they are wrong, because the default route is not
added to the NMIP4Config/NMIP6Config objects.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
f5c0646e1c device: add function nm_device_uses_assumed_connection()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:11 +01:00
Thomas Haller
0c355ea5a0 platform: support route_get_all() to return route for every ifindex
By passing an ifindex of 0, the search is not limited to a certain
ifindex.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:11 +01:00
Thomas Haller
3ef807c6ae platform: extend nm_platform_ipX_route_get_all() to return default-routes only
Add a new enum NMPlatformGetRouteMode. This extends the existing
functions nm_platform_ip4_route_get_all() and nm_platform_ip6_route_get_all()
to return default routes only.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:11 +01:00
Thomas Haller
644eadcf80 core: add nm_ip4_config_get_subnet_for_host() function
And nm_ip6_config_get_subnet_for_host().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:11 +01:00
Thomas Haller
3c17254823 core: fix comparing metric for IPv6 routes
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Thomas Haller
df923622b1 core: overwrite the default route priority via connection setting
Make use of the new setting nm_setting_ip_config_get_route_metric()
If set, this override the route metric determined based on the device
type.

Similarly for VPN also prefer the setting from the connection. Thereby change
the default priority (for VPN that have their own device) to NM_VPN_ROUTE_METRIC_DEFAULT
instead of NM_PLATFORM_ROUTE_METRIC_DEFAULT. The latter would be a very
low priority compared to the default metrics for devices.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Thomas Haller
172c1eb652 core: add explicit functions for the route priority/metric
Before, we would always call unanimously nm_device_get_priority()
to get the default route metric for a device. Add new functions
nm_device_get_ip4_route_priority() and nm_device_get_ip6_route_priority()
and use them at the proper places.

Also add new function nm_vpn_connection_get_ip4_route_metric() and
nm_vpn_connection_get_ip6_route_metric().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Thomas Haller
a2662633a5 core: modify the values/route metric returned by nm_device_get_priority()
nm_device_get_priority() is used to select the "best" device
for the default route. The absolute values don't matter
at that point and the relative ordering is not changed by
this patch.

It is also directly used for route priority/metric. As we soon
allow the user to overwrite the setting, we want to get more
space between the individual device-types.

That way, a user could overwrite the default metric for a wifi
device to be 109 (making it lower then the default value 110), but
still less preferred then other non-wifi types.

Obviously, this patch is a visible change of behavior as now
routes get different metrics assigned.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Thomas Haller
52ddd72bde core: cleanup type of route metric to ensure guint32
Kernel, netlink an NMPlatformRoute treat route metrics as
uint32. Fix several places to use the exact type.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Thomas Haller
36d99dbed5 cli: support new property NM_SETTING_IP_CONFIG_ROUTE_METRIC
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Thomas Haller
7a55191079 cli: add utility methods for gint64 types
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Thomas Haller
ce7fc351db libnm: add NMSettingIPConfig:route-metric
https://bugzilla.gnome.org/show_bug.cgi?id=735512
https://bugzilla.redhat.com/show_bug.cgi?id=663730

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Thomas Haller
627ad6f805 keyfile: add support for G_INT64 properties
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Thomas Haller
808ad85ff4 core: forward declare NMVpnConnection in nm-types.h
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:05 +01:00
Thomas Haller
c52e331014 core: move definition of NMLinkType to nm-types.h
As we use NMLinkType in NetworkManagerUtils.h, we cannot use
the utils header without nm-platform.h. That is clearly wrong.
Apparently NMLinkType has a wider use outside of platform (and
its name is not prefixed with 'platform' either).

Move the enum definition to nm-types.h.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:05 +01:00
Thomas Haller
c262819360 platform: don't include gsystem-local-alloc.h in nm-platform.h
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:05 +01:00
Thomas Haller
0500bade77 core: fix leak of lookup_addr in NMPolicy
Also, as we now evaluate the arguments of logging statements
lazily, refactor a logging statement.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:05 +01:00
Thomas Haller
f892ac4f45 core/trivial: remove semicolon from macro
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:05 +01:00
Thomas Haller
6a59ab0b86 all: add macro NM_IN_SET
Copied from systemd's macro IN_SET from /src/shared/macro.h

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:05 +01:00
Jiří Klimeš
94ffb8f43e merge: fixes for team activation (rh #1155993)
https://bugzilla.redhat.com/show_bug.cgi?id=1155993
2014-11-07 14:27:22 +01:00
Lubomir Rintel
892602c912 device: Don't delete the link if a re-activation is scheduled 2014-11-07 14:26:41 +01:00
Lubomir Rintel
842648a992 team: Don't let teamd rip off the link when it terminates
We might be reactivating a connection on the device and don't want it to go
away. In other cases we still take care of the link deletion ourselves.
2014-11-07 14:26:41 +01:00
Lubomir Rintel
5aa93e5518 connections: Don't give up if we've not seen an active connection yet
It will appear later on.

https://bugzilla.redhat.com/show_bug.cgi?id=1149200
2014-11-07 14:26:41 +01:00
Lubomir Rintel
42b9e82839 libnm: Complete activation when ActiveConnection abruptly disappears
A NMActiveConnection may disappear before a match with NMDevice is found. In
such case recheck_pending_activations() would never call the activation
callback and the client would hang indefinitely:

libnm-Message: PC: (0x95bf088) NMManager:active-connections => '['/org/freedesktop/NetworkManager/ActiveConnection/225']' (ao / NMActiveConnection)
libnm-Message: PC: (0x95bf088) NMManager:activating-connection => ''/'' (o / NMActiveConnection)
libnm-Message: PC: (0x95d0a28) NMActiveConnection:state => '4' (u)
libnm-Message: PC: (0x95d0a28) NMActiveConnection:devices => '[]' (ao / NMDevice)
libnm-Message: PC: (0x95bf088) NMManager:active-connections => '[]' (ao / NMActiveConnection)
*hang*

Let's listen for active-connection-removed and tear down the activation with
an error if the removed connection is one we're activating.
2014-11-07 14:26:41 +01:00
Lubomir Rintel
b4fe3b7cd9 libnm: Drop a wrong assert
An active connection object could disappear from the bus before its removal
from NMManager:active-connections is signalled -- don't assert it's gone from
there already.

Here /o/fd/NM/ActiveConnection/81 disappears shortly after it's added:

libnm-Message: PC: (0x9ebd088) NMManager:active-connections => '['/org/freedesktop/NetworkManager/ActiveConnection/81', '/org/freedesktop/NetworkManager/ActiveConnection/80']' (ao / NMActiveConnection)
libnm-Message: PC: (0x9ebd088) NMManager:activating-connection => ''/'' (o / NMActiveConnection)
libnm-Message: PC: (0x9ed1458) NMDeviceTeam:state => '110' (u)
libnm-Message: PC: (0x9ed1458) NMDeviceTeam:state-reason => '(110, 0)' ((uu))
libnm-Message: PC: (0x9ece9a0) NMActiveConnection:state => '3' (u)
libnm-Message: PC: (0x9ebd088) NMManager:state => '20' (u)
libnm-Message: PC: (0x9ebd088) NMManager:devices => '['/org/freedesktop/NetworkManager/Devices/0', '/org/freedesktop/NetworkManager/Devices/2', '/org/freedesktop/NetworkManager/Devices/3']' (ao / NMDevice)
libnm-Message: PC: (0x9ebd088) NMManager:active-connections => '['/org/freedesktop/NetworkManager/ActiveConnection/81', '/org/freedesktop/NetworkManager/ActiveConnection/80']' (ao / NMActiveConnection)
libnm-Message: PC: (0x9ece9a0) NMActiveConnection:state => '4' (u)
libnm-Message: PC: (0x9ece9a0) NMActiveConnection:devices => '[]' (ao / NMDevice)
libnm-Message: Could not create object for /org/freedesktop/NetworkManager/ActiveConnection/81: Method "GetAll" with signature "s" on interface "org.freedesktop.DBus.Properties" doesn't exist

(process:18042): libnm-CRITICAL **: object_creation_failed: assertion 'find_active_connection_by_path (self, failed_path) == NULL' failed
2014-11-07 14:26:41 +01:00
Dan Winship
7c214de45b libnm: rename NMVpnPluginUiInterface, add to NetworkManager.h
Rename NMVpnPluginUiInterface to NMVpnEditorPlugin (to clarify that
it's unrelated to NMVpnPlugin), and add it to NetworkManager.h.

Rename NMVpnPluginUiWidgetInterface to NMVpnEditor, because it's not a
widget, and will soon be used for non-gui editing too. (Also, add a
placeholder for the method that non-gui editing will use.)

Fix the typedefs to not mix up the (dummy) NMVpnEditorPlugin and
NMVpnEditor types with the types of their interface structs. Update to
use G_DEFINE_INTERFACE.

Drop NMVpnPluginUiInterfaceProp; it doesn't matter what codes plugin
implementations use for the interface properties that they implement.
2014-11-07 08:00:32 -05:00
Jiří Klimeš
8e99b44f08 dhcp: fix building without sys/auxv.h 2014-11-07 13:57:40 +01:00
Dan Winship
4160f6c590 all: reorganize IP address/gateway/route properties 2014-11-07 07:50:06 -05:00
Dan Winship
e374923bbe all: allow route metrics to be "0"
Change NMIPRoute to use "-1" for "default", so that "0" is a valid
metric. Update everything for that.
2014-11-07 07:49:41 -05:00
Dan Winship
ff608c24cd libnm-core: don't serialize empty address-labels
If no address in an NMSettingIP4Config has a label, then don't bother
serializing an array of empty strings.
2014-11-07 07:49:41 -05:00