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>
core/trivial: remove semicolon from macro

Signed-off-by: Thomas Haller <thaller@redhat.com>
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>
platform: don't include gsystem-local-alloc.h in nm-platform.h

Signed-off-by: Thomas Haller <thaller@redhat.com>
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>
core: forward declare NMVpnConnection in nm-types.h

Signed-off-by: Thomas Haller <thaller@redhat.com>
keyfile: add support for G_INT64 properties

Signed-off-by: Thomas Haller <thaller@redhat.com>
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>
cli: add utility methods for gint64 types

Signed-off-by: Thomas Haller <thaller@redhat.com>
cli: support new property NM_SETTING_IP_CONFIG_ROUTE_METRIC

Signed-off-by: Thomas Haller <thaller@redhat.com>
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>
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>
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>
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>
core: fix comparing metric for IPv6 routes

Signed-off-by: Thomas Haller <thaller@redhat.com>
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>
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>
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>
device: add function nm_device_uses_assumed_connection()

Signed-off-by: Thomas Haller <thaller@redhat.com>
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>