When a connection is updated by Update() and the new settings contain *no*
secrets, leave the previous secrets untouched. This makes updating connection
parameters much easier. Users (clients) need not to bother with secrets when
they only want adjust a parameter.
Use case:
- GetSettings()
- modify the settings
- Update()
E.g. nmcli con mod my-wifi connection.zone home
https://bugzilla.gnome.org/show_bug.cgi?id=728920
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>
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.
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.
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.
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>
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>
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>
Before, NMSettingsConnection had two internal properties 'unsaved' and
'nm-generated'. Now, implement these properties as #NMSettingsConnectionFlags.
Signed-off-by: Thomas Haller <thaller@redhat.com>
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>
The entry can't be empty. Otherwise removing the value and saving connection
would result in the primary option containing only the first character of the
original value.
clang warns about uninitialized variables @__cur_setting_name and
@__cur_property_name as used inside @__code. Before calling to @__code,
explicitly initialize the values.
Making all in tests
make[4]: Entering directory `./NetworkManager/libnm-core/tests'
CC test-general.o
test-general.c:2730:24: error: variable '__cur_property_name' is uninitialized when used here [-Werror,-Wuninitialized]
NMTST_VARIANT_DROP_PROPERTY (NM_SETTING_CONNECTION_SETTING_NAME,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../include/nm-test-utils.h:1079:20: note: expanded from macro 'NMTST_VARIANT_DROP_PROPERTY'
&& !strcmp (__cur_property_name, __property_name)) \
^~~~~~~~~~~~~~~~~~~
../../include/nm-test-utils.h:1023:3: note: expanded from macro 'NMTST_VARIANT_EDITOR'
__code; \
^
test-general.c:2729:2: note: variable '__cur_property_name' is declared here
NMTST_VARIANT_EDITOR (connection_dict,
^
../../include/nm-test-utils.h:1015:3: note: expanded from macro 'NMTST_VARIANT_EDITOR'
const char *__cur_setting_name, *__cur_property_name; \
^
[...]
Signed-off-by: Thomas Haller <thaller@redhat.com>
When the caller wants to clear all settings (thus providing
@setting_name NULL), a NM_VARIANT_TYPE_CONNECTION variant is
expected. This would lead to a crash when constructing the
@error literal due to uninitialized @key.
Clang also warns:
Making all in .
make[4]: Entering directory `./NetworkManager/libnm-core'
CC nm-connection.lo
../libnm-core/nm-connection.c:1016:25: error: variable 'key' is uninitialized when used here [-Werror,-Wuninitialized]
key);
^~~
../libnm-core/nm-connection.c:962:17: note: initialize the variable 'key' to silence this warning
const char *key;
^
= NULL
1 error generated.
Fixes: acf86f68b3
Signed-off-by: Thomas Haller <thaller@redhat.com>
Check whether NM is running before comparing nmcli and NM versions. Returning
NMC_RESULT_ERROR_NM_NOT_RUNNING is in accordance with other nmcli commands.
Applies to status commands such as "nmcli radio" or "nmcli g status".
This is consistent with other commands.
The "RUNNING" field is now always "running", the tool will just return
an error instead of setting it to "not running". It never signalled
whether the daemon was actually running anyway, only whether the client
managed to connect to it.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Seems like 128k is not enough for systems with many interfaces. This adds 4k
per device, while keeping the 128k minimum. Therefore this change only
affects systems with more than 32 interfaces.
https://bugzilla.redhat.com/show_bug.cgi?id=1141256
dcbw points out that g_dbus_connection_get_unique_name() can be used
to distinguish private from bus connections without us needing to keep
track ourselves.
_nm_dbus_new_connection_async() wasn't marking the connection as
private when it was private, causing
_nm_dbus_new_proxy_for_connection*() to pass the wrong args. Fix that.