core: add macros NM_FLAGS_HAS(), NM_FLAGS_ANY() and NM_FLAGS_ALL()

Signed-off-by: Thomas Haller <thaller@redhat.com>
core: log when emitting RECHECK_ASSUME signal

Signed-off-by: Thomas Haller <thaller@redhat.com>
platform/trivial: move code in nm-platform.c

Signed-off-by: Thomas Haller <thaller@redhat.com>
platform: log ifindex and ifname when deleting addresses or routes

Signed-off-by: Thomas Haller <thaller@redhat.com>
platform: add @peer_address argument to nm_platform_ip4_address_delete()

Deleting an IPv4 address using libnl requires the proper peer address.
Pass the address of the peer on to nm_platform_ip4_address_delete().

Signed-off-by: Thomas Haller <thaller@redhat.com>
settings: add NMSettingsConnection:flags

Signed-off-by: Thomas Haller <thaller@redhat.com>
settings: implement 'unsaved' and 'nm-generated' as #NMSettingsConnectionFlags

Before, NMSettingsConnection had two internal properties 'unsaved' and
'nm-generated'. Now, implement these properties as #NMSettingsConnectionFlags.

Signed-off-by: Thomas Haller <thaller@redhat.com>
core: add "nm-generated-assumed" flag to NMSettingsConnection

NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED is a special kind of
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED, that was generated for
connection assumption.

At the moment, the flag is used identical to NM_GENERATED. Later,
NM_GENERATED will get a slightly different meaning.

Signed-off-by: Thomas Haller <thaller@redhat.com>
core: use "nm-generated-assumed" flag instead of "nm-generated" for assumed connections

At a few places, we checked for nm_device_uses_generated_connection()
whether to touch the device or not. nm_device_uses_generated_connection() used
to look at the "nm-generated" property of the NMSettingsConnection.

We are about to change the meaning of "nm-generated", which will mean
"any connection generated by NM, for whatever reason".

Instead now use the new "nm-generated-assumed" connection flag that has
the meaning "nm-generated" used to have.
So rename nm_device_uses_generated_connection() to nm_device_uses_generated_assumed_connection()
which looks at the "nm-generated-assumed" flag instead.

Also, be more strict in nm_device_uses_generated_assumed_connection() to require
both an "nm-generated-assumed" connection *and* an active connection that is
nm_active_connection_get_assumed().

Signed-off-by: Thomas Haller <thaller@redhat.com>
bluez: simplify cleanup of generated PAN connection

For PAN devices we create an unsaved connection if no matching
connection exists. After the device gets removed, we want to clean
up that connection, unless it was modified/saved in the meantime.

Before this was accomplished by creating a clone of the original
connection. When deciding whether the temporary connection was
modified, we would compare the current state with the original.

This can now be simplified, because we have the nm-generated flag
that gets cleared whenever the user modifies or saves the connection.
This code is also more robust, because the previous implementation
was a hack, but could not reliably detect whether the connection
was modified by the user.

Signed-off-by: Thomas Haller <thaller@redhat.com>
core: clean up nm-generated-assumed connections when assumption fails or connection disconnects

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
core: recheck_assume_connection() do nothing if the device is not disconnected

Signed-off-by: Thomas Haller <thaller@redhat.com>
core: merge branch 'th/bgo731937_delete_nm_generated_connection'

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
libnm: merge saved and unsaved connection methods

Merge nm_remote_settings_add_connection() and
nm_remote_settings_add_connection_unsaved(), and likewise
nm_remote_connection_commit_changes() and
nm_remote_connection_commit_changes_unsaved(), by adding a boolean
flag to each saying whether to save to disk.
libnm: make sync/async APIs more GLib-like

Make synchronous APIs take GCancellables, and make asynchronous APIs
use GAsyncReadyCallbacks and have names ending in "_async", with
"_finish" functions to retrieve the results.

Also, make nm_client_activate_connection_finish(),
nm_client_add_and_activate_finish(), and
nm_remote_settings_add_connection_finish() be (transfer full) rather
than (transfer none), because the refcounting semantics become
slightly confusing in some edge cases otherwise.
libnm: add some missing sync/async method variants

Add the missing variant in most places in the API where previously
there was either only a synchronous version or only an asynchronous
version.

There is not yet a synchronous nm_client_activate_connection(),
nm_client_add_and_activate_connection(), or
nm_remote_settings_add_connection(), because the existing async code
depends on waiting for other asynchronous events, so making them run
synchronously is slightly more complicated. But these APIs can be
added later.
libnm: make sync/async APIs more GLib-like (bgo #736988)
libnm: fix compilation for wrong g_return call on void/non-void function

Fixes: 41eca3ea490c819c263aa986e1e9bad813dcfe47
Signed-off-by: Thomas Haller <thaller@redhat.com>
platform: fix parsing vxlan netlink message for older kernel

vxlan_info_data_parser() must take care of missing netlink attributes.
Otherwise, older kernels will crash NM.

Also, workaround compilation against old kernel headers which are
missing 'struct ifla_vxlan_port_range'. We do this by defining our
own 'struct nm_ifla_vxlan_port_range' version.

Reported-by: Javier Jardón <jjardon@gnome.org>
Signed-off-by: Thomas Haller <thaller@redhat.com>
cli: also show team and bridge specific details for devices

Now it is only SLAVES field, common for bond, team and bridge devices.