Commit Graph

15047 Commits

Author SHA1 Message Date
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
Dan Winship
ca18b2d442 libnm: create NMDhcpConfig as parent of NMDhcp4Config and NMDhcp6Config
As with NMIP4Config and NMIP6Config, merge the two DHCP config classes
into one in the public API.
2014-11-07 07:49:40 -05:00
Dan Winship
d34910b128 libnm: create NMIPConfig as parent of NMIP4Config and NMIP6Config
Create NMIPConfig as the parent of NMIP4Config and NMIP6Config, and
remove the two subclasses from the public API; while it's convenient
to still have both internally, they are now identical to the outside
world.
2014-11-07 07:49:40 -05:00
Dan Winship
f8dcb9510c libnm-core: don't warn about unrecognized properties
b64c82a3 removed the warning in libnm-util when
nm_setting_new_from_hash() sees an unrecognized property, but we were
still warning in the equivalent libnm-core code. But it doesn't make
sense to warn here either: we do add new properties sometimes, but we
always make sure that older clients still get the information they
need as well, so they can just ignore the new property.
2014-11-07 07:49:40 -05:00
Dan Winship
d16905df63 libnm-core, libnm, core: add AddressData and RouteData properties
Add AddressData and RouteData properties to NMSettingIPConfig and
NMIP[46]Config. These are like the existing "addresses" and "routes"
properties, but using strings and containing additional attributes,
like NMIPAddress and NMIPRoute.

This only affects the D-Bus representations; there are no API changes
to NMSettingIP{,4,6}Config or NMIP{4,6}Config as a result of this; the
additional information is just added to the existing 'addresses' and
'routes' properties.

NMSettingIP4Config and NMSettingIP6Config now always generate both
old-style data ('addresses', 'address-labels', 'routes') and new-style
data ('address-data', 'gateway', 'route-data') when serializing to
D-Bus, for backward compatibility. When deserializing, they will fill
in the 'addresses' and 'routes' properties from the new-style data if
it is present (ignoring the old-style data), or from the old-style
data if the new-style isn't present.

The daemon-side NMIP4Config and NMIP6Config always emit changes for
both 'Addresses'/'Routes' and 'AddressData'/'RouteData'. The
libnm-side classes initially listen for changes on both properties,
but start ignoring the 'Addresses' and 'Routes' properties once they
know the daemon is also providing 'AddressData' and 'RouteData'.
2014-11-07 07:49:40 -05:00
Dan Winship
f17699f4e3 libnm-core: add NMSettingIPConfig:gateway, drop NMIPAddress:gateway
The gateway is a global property of the IPv4/IPv6 configuration, not
an attribute of any particular address. So represent it as such in the
API; remove the gateway from NMIPAddress, and add it to
NMSettingIPConfig.

Behind the scenes, the gateway is still serialized along with the
first address in NMSettingIPConfig:addresses, and is deserialized from
that if the settings dictionary doesn't contain a 'gateway' key.

Adjust nmcli's interactive mode to prompt for IP addresses and gateway
separately. (Patch partly from Jirka Klimeš.)
2014-11-07 07:49:40 -05:00
Dan Winship
329791ad55 all: stop pretending to support multiple "gateway"s
NMSettingIP[46]Config let you associate a gateway with each address,
and the writable settings backends record that information. But it
never actually gets used: NMIP4Config and NMIP6Config only ever use
the first gateway, and completely ignore any others. (And in the
common usage of the term, an interface can only have one gateway
anyway.)

So, stop pretending that multiple gateways are meaningful; don't
serialize or deserialize gateways other than the first in the
'addresses' properties, and don't read or write multiple gateway
values either.
2014-11-07 07:49:40 -05:00
Dan Winship
35f6264745 core, clients: implement dhcp-send-hostname for IPv6
Now that NMSettingIP6Config inherits the dhcp-send-hostname property
from NMSettingIPConfig, fix things up so that it actually gets used.

(Note that this changes behavior: previously if ip6.dhcp-hostname was
unset, no hostname would be sent. Now, the system hostname will be
set. Also, ifcfg-rh does not currently support this property, so there
is no way to disable this...)
2014-11-07 07:49:40 -05:00
Dan Winship
3f30c6f1c2 libnm-core: extract NMSettingIPConfig superclass out of IP4, IP6 classes
Split a base NMSettingIPConfig class out of NMSettingIP4Config and
NMSettingIP6Config, and update things accordingly.

Further simplifications of now-redundant IPv4-vs-IPv6 code are
possible, and should happen in the future.
2014-11-07 07:49:40 -05:00
Dan Winship
39709fdc2e libnm-core: add NMIPAddress/NMIPRoute attributes, use for labels
Add key-value attributes to NMIPAddress and NMIPRoute, and use them to
store IPv4 address labels. Demote NMSettingIP4Config:address-labels to
a D-Bus-only property, and arrange for :addresses setter to read the
labels out of that property when creating the addresses.
2014-11-07 07:49:40 -05:00
Dan Winship
21c8a6b20e libnm-core, all: merge IPv4 and IPv6 address/route types
Merge NMIP4Address and NMIP6Address into NMIPAddress, and NMIP4Route
and NMIP6Route into NMIPRoute. The new types represent IP addresses as
strings, rather than in binary, and so are address-family agnostic.
2014-11-07 07:49:40 -05:00
Dan Winship
303e84e65e libnm-core: tweak handling of overridden properties
nm_setting_compare() and nm_setting_diff() were ignoring the get_func
of overridden properties, because that function requires passing an
NMConnection, and they didn't have one to pass. This wasn't a problem
yet because the only user of _nm_setting_class_override_property()
wasn't using a get_func anyway, but it would cause problems later.

The connection arg to NMSettingPropertyGetFunc is really there to be
used by D-Bus-only properties (which don't get compared anyway), not
for ordinary property overrides. So split it into two different
function types: NMSettingPropertySynthFunc (used by D-Bus-only
properties, to synthesize a fake property value for D-Bus, possibly
using other properties in the NMConnection), and
NMSettingPropertyGetFunc (used by overridden properties for both D-Bus
and comparison purposes, and not getting an NMConnection argument).
2014-11-07 07:49:40 -05:00
Dan Winship
ec976324b8 libnm-core: fix NMSetting property override docs
The docs for _nm_setting_class_add_dbus_only_property() and
_nm_setting_class_override_property() mistakenly still referred to
some functionality that didn't make it into the final version, and
also had only been partially updated for the GValue->GVariant change.
2014-11-07 07:49:39 -05:00
Thomas Haller
5bcd54ad82 vpn: fix cleanup of connection timeout in maybe_complete()
Fixes: a966a5e8b5
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 13:44:00 +01:00
Thomas Haller
57133a389f dhcp/test: fix compiler warning about pointer arithmetric for void*
clang warns:

    make[4]: Entering directory `./NetworkManager/src/dhcp-manager/tests'
      CC       test-dhcp-utils.o
    test-dhcp-utils.c:684:2: error: arithmetic on a pointer to void is a GNU extension [-Werror,-Wpointer-arith]
            COMPARE_ID (nothex, TRUE, nothex, strlen (nothex));
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    test-dhcp-utils.c:667:23: note: expanded from macro 'COMPARE_ID'
                    g_assert (memcmp (p + 1, expected, expected_len) == 0); \
                                      ~ ^

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 12:38:12 +01:00
Thomas Haller
890fff4be7 dhcp: fix swapped order of argument for logging function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 12:33:18 +01:00
Thomas Haller
252286729c gitignore: ignore dhcp test binary
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 12:25:33 +01:00