Commit graph

111 commits

Author SHA1 Message Date
Alex Henrie
0004a408ae
device: introduce ipv6.mtu property
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1003

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1231
2022-05-27 08:51:44 +02:00
Adrian Freihofer
cbde63a493
settings: add ipv4.link-local flag
Introduction of a new setting ipv4.link-local, which enables
link-local IP addresses concurrently with other IP address assignment
implementations such as dhcp or manually.
No way is implemented to obtain a link-local address as a fallback when
dhcp does not respond (as dhcpd does, for example). This could be be
added later.

To maintain backward compatibility with ipv4.method ipv4.link-local has
lower priority than ipv4.method. This results in:
* method=link-local overrules link-local=disabled
* method=disabled overrules link-local=enabled

Furthermore, link-local=auto means that method defines whether
link-local is enabled or disabled:
* method=link-local --> link-local=enabled
* else --> link-local=disabled

The upside is, that this implementation requires no normalization.
Normalization is confusing to implement, because to get it really
right, we probably should support normalizing link-local based on
method, but also vice versa. And since the method affects how other
properties validate/normalize, it's hard to normalize that one, so that
the result makes sense. Normalization is also often not great to the
user, because it basically means to modify the profile based on other
settings.

The downside is that the auto flag becomes API and exists because
we need backward compatibility with ipv4.method.
We would never add this flag, if we would redesign "ipv4.method"
(by replacing by per-method-specific settings).

Defining a default setting for ipv4.link-local in the global
configuration is also supported.
The default setting for the new property can be "default", since old
users upgrading to a new version that supports ipv4.link-local will not
have configured the global default in NetworkManager.conf. Therefore,
they will always use the expected "auto" default unless they change
their configuration.

Co-Authored-By: Thomas Haller <thaller@redhat.com>
2022-05-27 08:24:28 +02:00
Lubomir Rintel
99d92e2f10 libnm-client: fix some comments
Correct the mismatched arguments and descriptions, likely a copy &
paste error.
2022-05-06 18:33:27 +02:00
Lubomir Rintel
a3174af914 libnm: fix placement of some "Since:" tags
libnm-client-impl/nm-client.c:8398: warning: multi-line since docs found
  libnm-client-impl/nm-device-macvlan.c:115: warning: multi-line since docs found
  libnm-client-impl/nm-device-vxlan.c:540: warning: multi-line since docs found
  libnm-client-impl/nm-device-vxlan.c:92: warning: multi-line since docs found
  libnm-core-impl/nm-setting-ethtool.c:41: warning: multi-line since docs found
  libnm-core-impl/nm-setting-ip-config.c:2475: warning: multi-line since docs found
  libnm-core-impl/nm-setting-ip-config.c:2504: warning: multi-line since docs found
2022-05-06 18:33:27 +02:00
Lubomir Rintel
649314ddaa libnm: replace nm-types.h by defining the types in respective headers
The typedefs in nm-types.h confuse gtkdoc-scan. It generates a
libnm-sections.txt file like this:

  <SECTION>
  <FILE>nm-types</FILE>
  <TITLE>NMDeviceOvs</TITLE>
  NMAccessPoint
  NMActiveConnection
  NMCheckpoint
  NMClient
  NMDevice
  ...

Note the wrongly picked title and, more importantly, the object types in
a bogus section. This in turn makes gtkdoc-mkdb fail to include the
property and signal documentation in appropriate sections.

Without nm-types.h, we need to mind the header dependencies. This means
that we need to order the headers that define types before the ones that
use them. Also, we need to break the depencency loops in few palces.
2022-05-06 18:33:27 +02:00
Thomas Haller
e5d4194673
build/meson: avoid compiler warning generating "NM-1.0.gir"
In glib_dep we specify

  "-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40"

which is the dependency we use almost everywhere. With g-ir-scanner
this causes compiler warnings:

    [xxx] Generating NM-1.0.gir with a custom command
    /src/NetworkManager/build/tmp-introspectnas6f9u5/NM-1.0.c: In function ‘dump_object_type’:
    /src/NetworkManager/build/tmp-introspectnas6f9u5/NM-1.0.c:252:13: warning: Not available before 2.70
      252 |   if (G_TYPE_IS_FINAL (type))
          |             ^~~~~~~~~~~~~~~~~
    /src/NetworkManager/build/tmp-introspectnas6f9u5/NM-1.0.c: In function ‘dump_fundamental_type’:
    /src/NetworkManager/build/tmp-introspectnas6f9u5/NM-1.0.c:370:13: warning: Not available before 2.70
      370 |   if (G_TYPE_IS_FINAL (type))
          |             ^~~~~~~~~~~~~~~~~
    g-ir-scanner: link: gcc -o /src/NetworkManager/build/tmp-introspectnas6f9u5/NM-1.0 /src/NetworkManager/build/tmp-introspectnas6f9u5/NM-1.0.o -L. -Wl,-rpath,. -Wl,--no-as-needed -L/src/NetworkManager/build/src/libnm-client-impl -Wl,-rpath,/src/NetworkManager/build/src/libnm-client-impl -lnm -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lgmodule-2.0 -ludev -lgirepository-1.0 -lgio-2.0 -lgobject-2.0 -Wl,--export-dynamic -lgmodule-2.0 -pthread -lglib-2.0 -lglib-2.0

Work around that.

Meson's gnome.generate_gir() is not very flexibly in allowing to
pass extra `--cflags-begin {} --cflags-end` parameters.
Hack around by adding a pseudo dependency that resets
these defines.

See-also: https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/331
See-also: 1234e5583a ('build/autotools: avoid compiler warning generating "NM-1.0.gir"')
2022-05-02 22:05:06 +02:00
Thomas Haller
723e1fc76f
libnm: move dependency to libnm-crypto out of libnm-core's "nm-utils.c"
libnm-core is also used by the daemon, thus currently dragging in
libnm-crypto there. But could we ever drop that dependency?

One use of the libnm-crypto is in functions like nm_utils_file_is_certificate()
in "nm-utils.h". These are part of the public API of libnm.

But this is not used by the daemon. Move it to "libnm-client-core"
to be closer to where it's actually used.

As we have unit tests in "libnm-core-impl/tests" that test this function,
those unit tests also would need to move to "libnm-client-impl".
Instead, add the actual implementation of these function to "libnm-crypto"
and test it there.

This patch moves forward declarations from public header "nm-utils.h" to
"nm-client.h". Arguably, "nm-client.h" is not a great name, but we don't
have a general purpose header in "libnm-client-public", so use this.
Note that libnm users can only include <NetworkManager.h> and including
individual files is not supported (and even prevented). Thus moving
the declarations won't break any users.
2022-03-29 11:56:04 +02:00
Beniamino Galvani
4a8a3847ad libnm: support radio flags 2022-03-29 09:34:07 +02:00
Thomas Haller
b1b1ee8cc4
libnm/tests: test that nm_vpn_service_plugin_read_vpn_details() does not consume "QUIT" command 2022-03-28 10:40:00 +02:00
Thomas Haller
6235815248
libnm: handle NUL characters in nm_vpn_service_plugin_read_vpn_details() and fix test
We expect to read NUL terminated strings. Upon NUL, we should do
something. Treat it as a line break.

Fixes: 8ae9cf4698 ('Revert "libnm: buffer reads in nm_vpn_service_plugin_read_vpn_details()"')
2022-03-28 10:36:05 +02:00
Bryan Jacobs
8ae9cf4698
Revert "libnm: buffer reads in nm_vpn_service_plugin_read_vpn_details()"
This partially reverts commit 4a9fcb0fc3, which replaced one-byte
reads with buffered ones in the VPN service plugin.

Unfortunately the buffering means that commands coming after the magic
"DONE" string were being pulled into the buffer. Secrets agents expect
a "QUIT" to come after the "DONE", and since with buffering "QUIT" was
in the buffer, this led to a twenty-second delay on every VPN
connection using a secrets manager.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1164

Fixes: 4a9fcb0fc3 ('libnm: buffer reads in nm_vpn_service_plugin_read_vpn_details()')
2022-03-28 09:39:13 +02:00
Thomas Haller
9b030a3988
all: change scheduling priority for idle actions to G_PRIORITY_DEFAULT_IDLE
g_idle_add() uses G_PRIORITY_DEFAULT_IDLE priority. Most of the time we don't
care much about the priority.

But at the places that this patch changes, I think that using
G_PRIORITY_DEFAULT_IDLE (and following g_idle_add()) is more correct. The
reason for this is not very strong, except that it's probably the better
choice. And the old choice was made because I didn't realize that
g_idle_add() uses another default priority. Hence, the old choice was not
for good reasons either.
2022-03-13 11:59:42 +01:00
Thomas Haller
ae0cc9618c
libnm: fix assertion in NMClient checking for current main context
NMClient is strongly tied to the GMainContext with which it was created.
Several operations must only be called from within the context. There
was an assertion for that.

However, creating (and init_async()) should be allowed to call not
from within the GMainContext. So if the current context has no owner
(is not acquired), then it's also OK.

Fix the assertion for that.

Fixes: ce0e898fb4 ('libnm: refactor caching of D-Bus objects in NMClient')
2022-03-11 12:11:44 +01:00
Thomas Haller
a9d521bf8c
libnm: fix uninitialized GError in NMClient's _init_start_cancel_on_idle_cb()
Found with `git grep 'GError.*[^,)];'| grep ' *= *NULL;' -v`

Fixes: ce0e898fb4 ('libnm: refactor caching of D-Bus objects in NMClient')
2022-03-09 23:14:37 +01:00
Wen Liang
549761b0ad libnm: fix crash during the restart after killed
When cloud-init job (metadata service crawler) starts, it sends the
SIGTERM signal to nm-cloud-setup and force the nm-cloud-setup to
restart, however, because the error is not initialized as NULL in
`_init_start_cancelled_cb()` before it is set, nm-cloud-setup will hit
a dumped core.

TO fix it, initialize the error as NULL in `_init_start_cancelled_cb()`.

https://bugzilla.redhat.com/show_bug.cgi?id=2027674

Fixes: ce0e898fb4 ('libnm: refactor caching of D-Bus objects in NMClient')

Backtrace:

 #0  g_logv (log_domain=0x7f833a872071 "GLib", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=<optimized out>) at ../glib/gmessages.c:1413
 #1  0x00007f833a81f043 in g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at ../glib/gmessages.c:1451
 #2  0x00007f833ab97230 in nm_utils_error_set_cancelled (is_disposing=<optimized out>, instance_name=<optimized out>, error=0x7ffff79cb980) at src/libnm-glib-aux/nm-shared-utils.c:2599
 #3  nm_utils_error_set_cancelled (is_disposing=0, instance_name=0x0, error=0x7ffff79cb980) at src/libnm-glib-aux/nm-shared-utils.c:2590
 #4  _init_start_cancelled_cb (cancellable=<optimized out>, user_data=0x5640ca292150) at src/libnm-client-impl/nm-client.c:7324
 #5  _init_start_cancelled_cb (cancellable=<optimized out>, user_data=0x5640ca292150) at src/libnm-client-impl/nm-client.c:7307
 #6  0x00007f833a93094a in _g_closure_invoke_va (param_types=0x0, n_params=<optimized out>, args=0x7ffff79cbb40, instance=0x5640ca267020, return_value=0x0, closure=0x5640ca29d430)
     at ../gobject/gclosure.c:873
 #7  g_signal_emit_valist (instance=0x5640ca267020, signal_id=<optimized out>, detail=0, var_args=var_args@entry=0x7ffff79cbb40) at ../gobject/gsignal.c:3406
 #8  0x00007f833a930a93 in g_signal_emit (instance=instance@entry=0x5640ca267020, signal_id=<optimized out>, detail=detail@entry=0) at ../gobject/gsignal.c:3553
 #9  0x00007f833a9a6475 in g_cancellable_cancel (cancellable=0x5640ca267020) at ../gio/gcancellable.c:513
 #10 g_cancellable_cancel (cancellable=0x5640ca267020) at ../gio/gcancellable.c:487
 #11 0x00005640ca1a8bd4 in sigterm_handler (user_data=0x5640ca267020) at src/nm-cloud-setup/main.c:599
 #12 0x00007f833a819d4f in g_main_dispatch (context=0x5640ca268ef0) at ../glib/gmain.c:3337
 #13 g_main_context_dispatch (context=0x5640ca268ef0) at ../glib/gmain.c:4055
 #14 0x00007f833a86e608 in g_main_context_iterate.constprop.0 (context=0x5640ca268ef0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4131
 #15 0x00007f833a819463 in g_main_loop_run (loop=0x5640ca24fdb0) at ../glib/gmain.c:4329
 #16 0x00005640ca1a6d04 in nmc_client_new_waitsync (cancellable=0x5640ca267020, out_nmc=0x7ffff79cbfa0, error=0x7ffff79cbf98, first_property_name=0x5640ca1b11db "instance-flags",
     first_property_name=0x5640ca1b11db "instance-flags") at src/libnm-client-aux-extern/nm-libnm-aux.c:129
 #17 0x00005640ca1a3863 in main (argc=1, argv=<optimized out>) at src/nm-cloud-setup/main.c:639
2022-03-09 09:24:25 -05:00
Lubomir Rintel
7f1840bbb6 libnm: fix an assert in nm_client_get_capabilities()
The length argument is optional. That makes sense, because the returned
array is NUL-terminated.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1136
2022-03-09 14:18:26 +01:00
Thomas Haller
dab2ee8ac5
all: suppress wrong gcc-12 warning "-Wdangling-pointer"
gcc-12.0.1-0.8.fc36 is annoying with false positives.
It's related to g_error() and its `for(;;) ;`.

For example:

    ../src/libnm-glib-aux/nm-shared-utils.c: In function 'nm_utils_parse_inaddr_bin_full':
    ../src/libnm-glib-aux/nm-shared-utils.c:1145:26: error: dangling pointer to 'error' may be used [-Werror=dangling-pointer=]
     1145 |                     error->message);
          |                          ^~
    /usr/include/glib-2.0/glib/gmessages.h:343:32: note: in definition of macro 'g_error'
      343 |                                __VA_ARGS__);         \
          |                                ^~~~~~~~~~~
    ../src/libnm-glib-aux/nm-shared-utils.c:1133:31: note: 'error' declared here
     1133 |         gs_free_error GError *error = NULL;
          |                               ^~~~~
    /usr/include/glib-2.0/glib/gmessages.h:341:25: error: dangling pointer to 'addrbin' may be used [-Werror=dangling-pointer=]
      341 |                         g_log (G_LOG_DOMAIN,         \
          |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      342 |                                G_LOG_LEVEL_ERROR,    \
          |                                ~~~~~~~~~~~~~~~~~~~~~~~
      343 |                                __VA_ARGS__);         \
          |                                ~~~~~~~~~~~~
    ../src/libnm-glib-aux/nm-shared-utils.c:1141:13: note: in expansion of macro 'g_error'
     1141 |             g_error("unexpected assertion failure: could parse \"%s\" as %s, but not accepted by "
          |             ^~~~~~~
    ../src/libnm-glib-aux/nm-shared-utils.c:1112:14: note: 'addrbin' declared here
     1112 |     NMIPAddr addrbin;
          |              ^~~~~~~

I think the warning could potentially be useful and prevent real bugs.
So don't disable it altogether, but go through the effort to suppress it
at the places where it currently happens.

Note that NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER macro only expands
to suppressing the warning with __GNUC__ equal to 12. The purpose is to
only suppress the warning where we know we want to. Hopefully other gcc
versions don't have this problem.

I guess, we could also write a NM_COMPILER_WARNING() check in
"m4/compiler_options.m4", to disable the warning if we detect it. But
that seems too cumbersome.
2022-02-21 19:50:52 +01:00
Val Och
3b67b7768d
libnm: fix nm_client_add_and_activate_connection2_finish annotation
Mark out_result as out argument. Fixes an issue when using libnm bindings.

Fixes: fbb038af5e ('all: return output dictionary from "AddAndActivate2"')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1092
2022-02-09 18:29:33 +01:00
Thomas Haller
d501e96857
libnm: use MODEM_CAPS_3GPP()/MODEM_CAPS_3GPP2() macros in get_setting_type() 2022-01-29 16:22:30 +01:00
Thomas Haller
8f6423ac06
libnm,core: use NM_FLAGS_ANY() for MODEM_CAPS_3GPP()/MODEM_CAPS_3GPP2()
Macros should (where possible and sensible) behave function-like.
That means for example, that they evaluate arguments only once, and
use parentheses around code that expands, so that unexpected uses
work correctly. The parentheses was missing.

Instead, just use the NM_FLAGS_ANY() macro which gets this right.
2022-01-29 16:22:30 +01:00
Daniele Palmas
ca8168775c
libnm,core: add 5GNR device modem capability
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1076
2022-01-29 16:15:29 +01:00
Thomas Haller
039f0b2803
libnm: add code comments to NMClient 2022-01-28 11:01:53 +01:00
Thomas Haller
125b1f9a9a
libnm/tests: enable check for dangling pointer in test_activate_virtual() 2022-01-28 11:01:53 +01:00
Thomas Haller
8eef822093
libnm: fix dangling pointer in "o" properties when unregistering NMObject
When NMClient gets destroyed, it unrefs all NMObject. We need to unbreak
cycles then, and the property getters must return NULL. In particular,
for "o" type properties (NMLDBusPropertyO), this was not done correctly.
For example, calling nm_device_get_active_connection() while/after
destroying the NMClient can give a dangling pointer and assertion
failure. This will also be covered by test_activate_virtual(). Probably
a similar issue can happen, when a D-Bus object gets removed (without
destroying NMClient altogether).

The fix is that nml_dbus_property_o_clear() needs to clear "nmobj". That
is correct, because the pointer is no longer valid and should not be there.
And the unit test shows that in fact a pointer is left there, and
clearing it fixes it.

That was different from an earlier attempt to fix this (in commit 62b2aa85e8
('Revert "libnm: fix dangling pointer in public API while destructing NMClient"')),
where clearing the pointer at a different place broke things. That
attempt was wrong, because nml_dbus_property_o_notify_changed() needs to be the
one that sets/clears nmobj field during a regular update. But the case
here is not a regular update, nml_dbus_property_o_clear() happens during
unregister/cleanup, and then we need to clear the pointer.

Fixes: ce0e898fb4 ('libnm: refactor caching of D-Bus objects in NMClient')

https://bugzilla.redhat.com/show_bug.cgi?id=2039331
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/896
See-also: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1064

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1075
2022-01-28 11:01:45 +01:00
Thomas Haller
62b2aa85e8
Revert "libnm: fix dangling pointer in public API while destructing NMClient"
This breaks test @nmcli_monitor. With this patch, `nmcli monitor` no
longer prints "There's no primary connection". Need to investigate why.
For now, revert the patch.

This reverts commit 2afecaf908.
2022-01-25 21:40:38 +01:00
Thomas Haller
26c43e4bcc
libnm/tests: fix race in test test_activate_virtual()
ERROR: src/libnm-client-impl/tests/test-nm-client - Bail out! nm:ERROR:src/libnm-client-impl/tests/test-nm-client.c:807:_dev_eth0_1_state_changed_cb: assertion failed (old_state == NM_DEVICE_STATE_PREPARE): (100 == 40)

Fixes: bc9aa72c88 ('libnm/tests: add unit test for checking dangling pointer in libnm')
2022-01-21 13:44:01 +01:00
Thomas Haller
2afecaf908
libnm: fix dangling pointer in public API while destructing NMClient
While (and after) NMClient gets destroyed, nm_device_get_active_connection()
gives a dangling pointer. That can lead to a crash. This probably
affects all NMLDBusPropertyO type properties.

It's not clear how to fix that best. Usually, NMClient does updates in
two phases, first it processes the D-Bus events and tracks internal
data, then it emits all GObject signals and notifications.

When an object gets removed from the NMClient cache, then the second
phase is not fully processed, because the object is already removed
from the cache. Thus, the property was not properly cleared leaving
a dangling pointer.

A simple fix is to always clear the pointer during the first phase. Note that
effectively we do the same also for NMLDBusPropertyAO (by clearing the
"pr_ao->arr"), so at least this is consistent.

Somehow it seems that we should make sure that the "second" phase gets
full processed in this case too. But it's complicated, and it's not
clear how to do that. So this solution seems fine.

https://bugzilla.redhat.com/show_bug.cgi?id=2039331
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/896
2022-01-21 12:09:45 +01:00
Thomas Haller
bc9aa72c88
libnm/tests: add unit test for checking dangling pointer in libnm
When destroying NMClient, nm_device_get_active_connection() still
return dangling pointers. Add a unit test for that bug.

Obviously, the bug currently exists, so the relevant code is commented
out.
2022-01-21 12:08:01 +01:00
Ana Cabral
74c08c7084 openvswitch: Add ovs-dpdk n_rxq property
https://bugzilla.redhat.com/show_bug.cgi?id=2001563
2022-01-10 22:48:30 +00:00
Ana Cabral
f0cb75f669 trivial: fix typos 2022-01-10 22:48:30 +00:00
Thomas Haller
615221a99c format: reformat source tree with clang-format 13.0
We use clang-format for automatic formatting of our source files.
Since clang-format is actively maintained software, the actual
formatting depends on the used version of clang-format. That is
unfortunate and painful, but really unavoidable unless clang-format
would be strictly bug-compatible.

So the version that we must use is from the current Fedora release, which
is also tested by our gitlab-ci. Previously, we were using Fedora 34 with
clang-tools-extra-12.0.1-1.fc34.x86_64.

As Fedora 35 comes along, we need to update our formatting as Fedora 35
comes with version "13.0.0~rc1-1.fc35".
An alternative would be to freeze on version 12, but that has different
problems (like, it's cumbersome to rebuild clang 12 on Fedora 35 and it
would be cumbersome for our developers which are on Fedora 35 to use a
clang that they cannot easily install).

The (differently painful) solution is to reformat from time to time, as we
switch to a new Fedora (and thus clang) version.
Usually we would expect that such a reformatting brings minor changes.
But this time, the changes are huge. That is mentioned in the release
notes [1] as

  Makes PointerAligment: Right working with AlignConsecutiveDeclarations. (Fixes https://llvm.org/PR27353)

[1] https://releases.llvm.org/13.0.0/tools/clang/docs/ReleaseNotes.html#clang-format
2021-11-29 09:31:09 +00:00
Lubomir Rintel
065fa15a0a libnm.pc: plugindir & configdir
Carry them over from NetworkManager.pc, they're potentially useful.
2021-11-03 12:19:36 +01:00
Robin Ebert
5582f658cd
libnm-core: Add connection.dns-over-tls property 2021-10-15 10:00:20 +02:00
Fernando Fernandez Mancera
74dfc86aa4 libnm: introduce nm_device_get_ports() to NMDevice
This patch is introducing a "ports" property to NMDevice. In addition it
is introducing nm_device_get_ports() and deprecating
nm_device_bond_get_slaves(), nm_device_bridge_get_slaves(),
nm_device_ovs_bridge_get_slaves(), nm_device_ovs_interface_get_slaves()
and nm_device_team_get_slaves().

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-11 09:38:24 +02:00
Fernando Fernandez Mancera
cf867e8ff5 dbus-metadata: make 'extra' available from NML_DBUS_META_PROPERTY_INIT_FCN()
Currently a NML_DBUS_META_PROPERTY_INIT_FCN() property does not have
'extra' field available. In order to be able to call
'nml_dbus_property_ao_notify()' from the callback, the 'extra' field
must be available.

The patch is also dropping 'use_notify_update_prop' field as it only
existed to differentiate the union.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-11 09:35:15 +02:00
Fernando Fernandez Mancera
05c062fc80 libnm-utils: let nml_dbus_property_ao_clear() return changed_prop
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-11 09:35:15 +02:00
Fernando Fernandez Mancera
d36d1f83c2 libnm-utils: expose nml_dbus_property_ao_notify()
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-11 09:35:15 +02:00
Fernando Fernandez Mancera
866ce41be8 nm-device: introduce property_ao array
This patch is introducing the property_ao array of type
NMLDBusPropertyAO.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-10 13:06:45 +02:00
Thomas Haller
f918fc3c82
libnm: drop unnecessary code from "nm-device-bond.c" for "hw_address" 2021-10-06 18:02:30 +02:00
Fernando Fernandez Mancera
ec8df200f6 libnm: add NMIPAddress and NMIPRoute dups backported symbols from 1.30.8
The nm_ip_address_dup() and nm_ip_route_dup() symbols were exposed in
libnm 1.32 and then backported to 1.30.8.

Export it also with version @libnm_1_30_8; this allows a program build
against libnm 1.30.8 to keep working with later versions of the library.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-05 14:09:15 +02:00
Beniamino Galvani
57c1982867 libnm: add required-timeout backported symbol from 1.30.8
The nm_setting_ip_config_get_required_timeout() symbol was introduced
in libnm 1.32.4 and then backported to 1.30.8.

Export it also with version @libnm_1_30_8; this allows a program built
against libnm 1.30.8 to keep working with later versions of the
library.
2021-09-23 09:01:10 +02:00
gaoxingwang
2a36f8c2f1
libnm: fix leak and return "failures" from nm_client_load_connections()
Due to this, `nmcli connection load` would also not print a warning
about failure to load obviously bogus files:

  $ nmcli connection load /bogus

Note that load is also used to unload files, so if the file name is a
possibly valid name for a non-existing file, there is no failure. For
example, we get no warning for

  $ nmcli connection load /etc/NetworkManager/system-connections/bogus

Even if currently no such file is loaded, then the operation would still
silently succeed, instead of succeeding the first time only. That is because
load should be idempotent.

[thaller@redhat.com: rewrote commit message]

Fixes: 4af6219226 ('libnm: implement nm_client_load_connections_async() by using GDBusConnection directly')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/794

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/979
2021-09-13 08:32:45 +02:00
Thomas Haller
c39859d240
libnm/tests: replace NM_PRAGMA_WARNING_DISABLE() by _nm_unused 2021-08-31 16:34:02 +02:00
Thomas Haller
10e0c4261e
format: reformat code with clang-format-12.0.1-1.fc34
The formatting produced by clang-format depends on the version of the
tool. The version that we use is the one of the current Fedora release.

Fedora 34 recently updated clang (and clang-tools-extra) from version
12.0.0 to 12.0.1. This brings some changes.

Update the formatting.
2021-08-30 13:14:00 +02:00
Gris Ge
9958510f28
bond: add support of queue_id of bond port
Introduced `NMSettingBondPort` to hold the new setting class with single
property `NM_SETTING_BOND_PORT_QUEUE_ID`.

For dbus interface, please use `bond-port` as setting name and
`queue-id` as property name.

Unit test cases for ifcfg reader and writer included.

Signed-off-by: Gris Ge <fge@redhat.com>

https://bugzilla.redhat.com/show_bug.cgi?id=1949127

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/952
2021-08-26 23:04:31 +02:00
Thomas Haller
ea49b50651
all: add some README.md files describing the purpose of our sources 2021-08-19 17:51:11 +02:00
Thomas Haller
3f6365f5d0
all: use G_CALLBACK() macro instead of plain cast 2021-08-05 14:59:11 +02:00
Thomas Haller
593cb57eb6
all: rename nm_utils_strdict_*() to nm_strdict_*() 2021-08-02 09:26:48 +02:00
Thomas Haller
4ac66a4215
all: rename nm_utils_strdup_reset*() to nm_strdup_reset*() 2021-08-02 09:26:47 +02:00
Thomas Haller
4c3aac899e
all: unify and rename strv helper API
Naming is important, because the name of a thing should give you a good
idea what it does. Also, to find a thing, it needs a good name in the
first place. But naming is also hard.

Historically, some strv helper API was named as nm_utils_strv_*(),
and some API had a leading underscore (as it is internal API).

This was all inconsistent. Do some renaming and try to unify things.

We get rid of the leading underscore if this is just a regular
(internal) helper. But not for example from _nm_strv_find_first(),
because that is the implementation of nm_strv_find_first().

  - _nm_utils_strv_cleanup()                 -> nm_strv_cleanup()
  - _nm_utils_strv_cleanup_const()           -> nm_strv_cleanup_const()
  - _nm_utils_strv_cmp_n()                   -> _nm_strv_cmp_n()
  - _nm_utils_strv_dup()                     -> _nm_strv_dup()
  - _nm_utils_strv_dup_packed()              -> _nm_strv_dup_packed()
  - _nm_utils_strv_find_first()              -> _nm_strv_find_first()
  - _nm_utils_strv_sort()                    -> _nm_strv_sort()
  - _nm_utils_strv_to_ptrarray()             -> nm_strv_to_ptrarray()
  - _nm_utils_strv_to_slist()                -> nm_strv_to_gslist()
  - nm_utils_strv_cmp_n()                    -> nm_strv_cmp_n()
  - nm_utils_strv_dup()                      -> nm_strv_dup()
  - nm_utils_strv_dup_packed()               -> nm_strv_dup_packed()
  - nm_utils_strv_dup_shallow_maybe_a()      -> nm_strv_dup_shallow_maybe_a()
  - nm_utils_strv_equal()                    -> nm_strv_equal()
  - nm_utils_strv_find_binary_search()       -> nm_strv_find_binary_search()
  - nm_utils_strv_find_first()               -> nm_strv_find_first()
  - nm_utils_strv_make_deep_copied()         -> nm_strv_make_deep_copied()
  - nm_utils_strv_make_deep_copied_n()       -> nm_strv_make_deep_copied_n()
  - nm_utils_strv_make_deep_copied_nonnull() -> nm_strv_make_deep_copied_nonnull()
  - nm_utils_strv_sort()                     -> nm_strv_sort()

Note that no names are swapped and none of the new names existed
previously. That means, all the new names are really new, which
simplifies to find errors due to this larger refactoring. E.g. if
you backport a patch from after this change to an old branch, you'll
get a compiler error and notice that something is missing.
2021-07-29 10:26:50 +02:00