Commit graph

29321 commits

Author SHA1 Message Date
Thomas Haller
1c85bc5ead
std-aux: work around "-Wunused-but-set-variable" warning with clang in nm_auto()
We use the cleanup attribute heavily. It's useful for deferring
deallocation. For example, we have code like:

  gs_unref_object NMBluezManager *self_keep_alive = g_object_ref(self);

where we don't use the variable otherwise, except for owning (and
freeing) the reference. This already lead to a compiler warning about
unused variable, which we would workaround with

  _nm_unused gs_unref_object NMBluezManager *self_keep_alive = g_object_ref(self);

With clang 13.0.0~rc1-1.fc35, this got worse. Now for example also

    static inline void
    nm_strvarray_set_strv(GArray **array, const char *const *strv)
    {
        gs_unref_array GArray *array_old = NULL;

        array_old = g_steal_pointer(array);

        if (!strv || !strv[0])
            return;

        nm_strvarray_ensure(array);
        for (; strv[0]; strv++)
            nm_strvarray_add(*array, strv[0]);
    }

leads to a warning

    ./src/libnm-glib-aux/nm-shared-utils.h:3078:28: error: variable array_old set but not used [-Werror,-Wunused-but-set-variable]
        gs_unref_array GArray *array_old = NULL;
                               ^

This is really annoying. We don't want to plaster our code with _nm_unused,
because that might hide actual issues. But we also want to keep using this
pattern and need to avoid the warning.

A problem is also that GCC usually does not warn about truly unused
variables with cleanup attribute. Clang was very useful here to flag
such variables. But now clang warns about cases which are no bugs, which
is a problem. So this does loose some useful warnings. On the other hand,
a truly unused variable (with cleanup attribute) is ugly, but not an actual
problem.

Now, with clang 13, automatically mark nm_auto() variables as _nm_unused
as workaround.
2021-10-08 15:56:10 +02:00
Vojtech Bubela
0ed099374d
libnm: fix crash in _nm_ip_route_validate_all for invalid route
backtrace from coredump, NetworkManager-1.30.6-1.fc34

  #0  verify
      (setting=0x55d081fe8690, connection=<optimized out>, error=0x7ffe0fa06870)
      at libnm-core/nm-setting-ip-config.c:5249
  #1  0x000055d081ab98d4 in verify
      (setting=0x55d081fe8690, connection=0x55d0820a2b80, error=0x7ffe0fa06870)
      at libnm-core/nm-setting-ip4-config.c:119
  #2  0x000055d081aa3d54 in _nm_connection_verify
      (connection=0x55d0820a2b80, error=0x7ffe0fa068c0)
      at libnm-core/nm-connection.c:1441
  #3  0x000055d081aa78ec in nm_connection_normalize
      (connection=0x55d0820a2b80, parameters=0x0, modified=0x0, error=0x7ffe0fa06de8)
      at libnm-core/nm-connection.c:1688
  #4  0x000055d081aa81f4 in _nm_connection_replace_settings
      (connection=0x55d0820a2b80, new_settings=<optimized out>, parse_flags=_NM_SETTING_PARSE_FLAGS_LAST, error=0x7ffe0fa06de8) at libnm-core/nm-connection.c:432
  #5  0x000055d081aa83a6 in _nm_simple_connection_new_from_dbus
      (dict=0x55d082089950, error=0x7ffe0fa06de8, parse_flags=_NM_SETTING_PARSE_FLAGS_LAST) at libnm-core/nm-simple-connection.c:77
  #6  0x000055d081bbf942 in settings_connection_update
      (self=0x55d081fdd9f0, is_update2=1, context=0x7fc06c021dd0, new_settings=0x55d082089950, flags=NM_SETTINGS_UPDATE2_FLAG_TO_DISK)
      at src/core/settings/nm-settings-connection.c:1637
  #7  0x000055d081bbfb09 in impl_settings_connection_update2
      (obj=0x55d081fdd9f0, interface_info=<optimized out>, method_info=<optimized out>, connection=<optimized out>, sender=<optimized out>, invocation=0x7fc06c021dd0, parameters=0x55d0820f5e60) at src/core/settings/nm-settings-connection.c:1796
  #8  0x00007fc08a9db482 in call_in_idle_cb.lto_priv () at /lib64/libgio-2.0.so.0

Fixes: bb6c2d7371 ('libnm: ensure stable behavior in _nm_ip_route_attribute_validate_all()')
2021-10-08 15:10:19 +02:00
Thomas Haller
fc220f94af
build/tests: ignore all valgrind warnings about unhandled syscalls
valgrind might log warnings about syscalls that it doesn't implement.
When we run valgrind tests, we check that the command exits with
success, but we also check that there is no unexpected content in the
valgrind log.

Those warnings are not relevant for us. We don't unit-tests valgrind, we
unit tests NetworkManager. Let's always remove such warnings with `sed`.

We already did that previously, but only for a explicit list of tests.
Now do it for all tests.

This is currently relevant on Fedora 35 and Ubuntu devel, where the
"close_range" syscall is used by libc, but not supported by valgrind.

While at it, rework the confusing logic of "HAS_ERRORS" variable.
2021-10-08 12:45:51 +02:00
Thomas Haller
34410c9c3e
contrib: fix motd comment in "nm-in-container.sh" 2021-10-08 12:35:15 +02:00
Thomas Haller
dae5e01171
glib-aux: rename nm_g_timeout_add_source_seconds() to nm_g_timeout_add_seconds_source()
There is g_idle_add(), g_timeout_add() and g_timeout_add_seconds().

We have alternatives nm_g_idle_add_source() and
nm_g_timeout_add_source().

I find the previous name nm_g_timeout_add_source_seconds() inconsistent
with the pattern, and get it always wrong on first try. Rename.
2021-10-08 09:20:58 +02:00
Thomas Haller
098a963e42
core: simplify nm_dbus_utils_g_value_set_object_path() 2021-10-07 08:10:05 +02:00
Thomas Haller
c1305dc801
core: in NMNetns use GSource for idle dispatch of platform signal 2021-10-07 08:10:05 +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
Thomas Haller
a3ca768fbc
std-aux: minor cleanup in nm_steal_int() to compare number explicitly against zero 2021-10-06 17:55:11 +02:00
Thomas Haller
6b3862e39a
NEWS: update 2021-10-06 11:26:32 +02:00
Thomas Haller
a44e5c3918
NEWS: add entries that were backported to 1.32 minor releases 2021-10-06 11:04:22 +02:00
Thomas Haller
7f25335767
NEWS: reorder entries from stable releases
Have the newest 1.32 stable release listed first. Then we can look at
the diff between the versions of the NEWS file and see whether they
agree.
2021-10-06 10:56:24 +02:00
Thomas Haller
fefaab7d50
CONTRIBUTING: update style 2021-10-06 09:23:46 +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
Thomas Haller
0ee3100ba1
l3cfg: fix nm_l3_config_data_new_clone() for different ifindex 2021-10-04 15:40:15 +02:00
Thomas Haller
d8ac65cfa0
platform: add nmp_object_cmp_full() to ignore ifindex for comparison 2021-10-04 15:40:15 +02:00
Thomas Haller
82260cc5c2
contrib: add "contrib/scripts/test-ppp.sh" test script 2021-10-04 15:40:15 +02:00
Thomas Haller
1b488fe34c
contrib: make it easy to test PPPoE in container script
It doesn't actually work inside the root-less container...
Well, it works as far as starting to activate, before it
fails. That is still somewhat useful. So have it there...
2021-10-04 15:40:15 +02:00
Thomas Haller
7bb1d9b1f4
src/c-list: reimport
git subtree pull --prefix src/c-list git@github.com:c-util/c-list.git main --squash
2021-10-01 16:18:06 +02:00
Thomas Haller
7521ea44a3 Squashed 'src/c-list/' changes from 96455db9f04a..a0970f12f1f4
a0970f12f1f4 c-list: avoid comma-operator in conditionals
2ea502c5ee83 c-list: return self from c_list_init()
ca473417f7b3 build: use c99 instead of c11
99d8daf152fa ci: run on windows-2016
857a37cfc960 test/embed: split off GNU-extensions
c09e29697912 ci: run through MSVC
c3ba3dc82466 build: run test_embed only with gcc/clang
77c872dcc67d test/api: split of GNU tests
3ab849ea658e test/basic: test_extensions() -> test_gnu()
04fda9508c86 c-list: reorder iterators
58ab8fb29472 test: add c_list_entry_offset() to API tests
6d2fdc76de70 build: update AUTHORS
92b893fb3c4b c-list: remove trailing '\\' from macro definitions
c255c6a97a04 c-list: use size_t
b47da33dedf1 c-list: use uintptr_t for pointer arithmetic in c_list_entry()
9b798f50bbd0 c-list: require CList pointer for argument to c_list_entry() macro
42bbf43ab0af test: guard gcc'ism
942fcfd80862 c-list: make _c_list_entry_eval() part of the API
73a620259ca0 c-list: don't use elvis operator for c_list_entry() macro
da5e122bd698 test: drop unused argc/argv
f1eadf27377e test: verify c_list_entry() does not double-evaluate

git-subtree-dir: src/c-list
git-subtree-split: a0970f12f1f406a5578a5dedf3580cd682e55812
2021-10-01 16:17:09 +02:00
Thomas Haller
d1049035ab
c-list: re-import git-subtree for 'src/c-list'
The subtree was moved from "shared/c-list" to "src/c-list". That confuses
git-subtree. To fix it, reimport the code with

  rm -rf src/c-list
  git commit -a -m 'dummy commit'
  git subtree add --prefix src/c-list git@github.com:c-util/c-list.git 96455db9f04a6c9101a00957161551aea700b6aa --squash

Then rebase the result to drop the bogus dummy commit from the history.

To update the library use:

  git subtree pull --prefix src/c-list git@github.com:c-util/c-list.git main --squash
2021-10-01 16:16:38 +02:00
Thomas Haller
59d9106df3 Squashed 'src/c-list/' content from commit 96455db9f04a
git-subtree-dir: src/c-list
git-subtree-split: 96455db9f04a6c9101a00957161551aea700b6aa
2021-10-01 16:15:48 +02:00
Thomas Haller
b58d2bb2bc
c-rbtree: re-import git-subtree for 'src/c-rbtree'
The subtree was moved from "shared/c-rbtree" to "src/c-rbtree". That confuses
git-subtree. To fix it, reimport the code with

  rm -rf src/c-rbtree
  git commit -a -m 'dummy commit'
  git subtree add --prefix src/c-rbtree git@github.com:c-util/c-rbtree.git 8aa7bd1828eedb19960f9eef98d15543ec9f34eb --squash

Then rebase the result to drop the bogus dummy commit from the history.

To update the library use:

  git subtree pull --prefix src/c-rbtree git@github.com:c-util/c-rbtree.git main --squash
2021-10-01 16:12:15 +02:00
Thomas Haller
1b61323231 Squashed 'src/c-rbtree/' content from commit 8aa7bd1828ee
git-subtree-dir: src/c-rbtree
git-subtree-split: 8aa7bd1828eedb19960f9eef98d15543ec9f34eb
2021-10-01 16:10:39 +02:00
Thomas Haller
5afcf33b70
c-siphash: re-import git-subtree for 'src/c-siphash'
The subtree was moved from "shared/c-siphash" to "src/c-siphash". That confuses
git-subtree. To fix it, reimport the code with

  rm -rf src/c-siphash
  git commit -a -m 'dummy commit'
  git subtree add --prefix src/c-siphash git@github.com:c-util/c-siphash.git eb87a9c4a5b0441ede073597253e1d0b7785e6be --squash

Then rebase the result to drop the bogus dummy commit from the history.

To update the library use:

  git subtree pull --prefix src/c-siphash git@github.com:c-util/c-siphash.git main --squash
2021-10-01 16:07:26 +02:00
Thomas Haller
12bb8b9b71 Squashed 'src/c-siphash/' content from commit eb87a9c4a5b0
git-subtree-dir: src/c-siphash
git-subtree-split: eb87a9c4a5b0441ede073597253e1d0b7785e6be
2021-10-01 16:01:48 +02:00
Thomas Haller
d4ee5acffc
src/c-stdaux: reimport
git subtree pull --prefix src/c-stdaux git@github.com:c-util/c-stdaux.git main --squash
2021-10-01 15:57:23 +02:00
Thomas Haller
49a6a3da1d Squashed 'src/c-stdaux/' changes from 346623b40eb8..8652c488b8f1
8652c488b8f1 test: provide prototypes
c5f166d02ff6 test: remove unnecessary unused attribute from main argc
8572cd4d1225 test: remove unused args from main
5c4f161f9c11 test: add missing _c_unused_

git-subtree-dir: src/c-stdaux
git-subtree-split: 8652c488b8f1c29629a5179d4551d0a691ae5901
2021-10-01 15:56:42 +02:00
Thomas Haller
613a6c7db1
c-stdaux: re-import git-subtree for 'src/c-stdaux'
The subtree was moved from "shared/c-stdaux" to "src/c-stdaux". That confuses
git-subtree. To fix it, reimport the code with

  rm -rf src/c-stdaux
  git commit -a -m 'dummy commit'
  git subtree add --prefix src/c-stdaux git@github.com:c-util/c-stdaux.git 346623b40eb8137cae7568a69ee42253ff098ff7 --squash

Then rebase the result to drop the bogus dummy commit from the history.

To update the library use:

  git subtree pull --prefix src/c-stdaux git@github.com:c-util/c-stdaux.git main --squash
2021-10-01 15:56:32 +02:00
Thomas Haller
80ee976ec0 Squashed 'src/c-stdaux/' content from commit 346623b40eb8
git-subtree-dir: src/c-stdaux
git-subtree-split: 346623b40eb8137cae7568a69ee42253ff098ff7
2021-10-01 15:51:56 +02:00
Thomas Haller
e0c58598e1
n-dhcp4: re-import git-subtree for 'src/n-dhcp4'
The subtree was moved from "shared/n-dhcp4" to "src/n-dhcp4". That confuses
git-subtree. To fix it, reimport the code with

  rm -rf src/n-dhcp4
  git commit -a -m 'dummy commit'
  git subtree add --prefix src/n-dhcp4 git@github.com:nettools/n-dhcp4.git 281f431756e32b6a978a92e6c1a95478917a6720 --squash

Then rebase the result to drop the bogus dummy commit from the history.

To update the library use:

  git subtree pull --prefix src/n-dhcp4 git@github.com:nettools/n-dhcp4.git master --squash
2021-10-01 15:47:12 +02:00
Thomas Haller
b6bd5bb7c5 Squashed 'src/n-dhcp4/' content from commit 281f431756e3
git-subtree-dir: src/n-dhcp4
git-subtree-split: 281f431756e32b6a978a92e6c1a95478917a6720
2021-10-01 15:43:42 +02:00
Thomas Haller
2259824316
n-acd: re-import git-subtree for 'src/n-acd'
The subtree was moved from "shared/n-acd" to "src/n-acd". That confuses
git-subtree. To fix it, reimport the code with

  rm -rf src/n-acd
  git commit -a -m 'dummy commit'
  git subtree add --prefix src/n-acd git@github.com:nettools/n-acd.git a600afc870872bbdfc8081ca68d5665334cb9e6e --squash

Then rebase the result to drop the bogus dummy commit from the history.

To update the library use:

  git subtree pull --prefix src/n-acd git@github.com:nettools/n-acd.git master --squash
2021-10-01 15:39:56 +02:00
Thomas Haller
9412d8fa46 Squashed 'src/n-acd/' content from commit a600afc87087
git-subtree-dir: src/n-acd
git-subtree-split: a600afc870872bbdfc8081ca68d5665334cb9e6e
2021-10-01 15:27:52 +02:00
Thomas Haller
25ec8f4451
l3cfg: fix assertion failure in _obj_state_zombie_lst_get_prune_lists()
"nm_assert(_self->priv.p->combined_l3cd_commited)" might fail during deactivate.
At that point the combined/commited config is NULL, but we still have zombies.
2021-09-30 15:10:19 +02:00
Beniamino Galvani
fcfaf78c91
l3cfg: fix dns options in _init_from_connection_ip() 2021-09-30 15:10:18 +02:00
Thomas Haller
5efd3134e4
l3cfg: accept NULL NML3ConfigData for several getters
We often want to be pedantic about not accepting %NULL for getters (or ref,
unref, etc). Often that is also inconvenient, so we would need to write:

  if (l3cd)
      strv = nm_l3_config_data_get_nameservers(l3cd, addr_family, &len);
  else
      len = 0;

(and, make sure that strv does not trigger a maybe-uninitialized warning).

Being pedanic here is more cumbersome than helpful. Accept NULL to return
the sensible default.

Also add nm_l3_config_data_get_dns_priority_or_default() helper which maps
NULL or a missing value to zero. This is also only for convenience for certain
callers.
2021-09-30 15:10:18 +02:00
Thomas Haller
e60843e245
glib-aux: add nm_memcmp_n()/nm_memeq_n() helpers 2021-09-30 15:10:18 +02:00
Thomas Haller
8ad4f7b70f
glib-aux: add nm_strv_equal_n_null() helper (and related)
The plain nm_strv_equal(), nm_strv_equal_n(), nm_strv_cmp_n() functions
treat NULL strv arrays (without specified length) different than strv
arrays of length zero. They do so, because that is useful sometimes.

Sometimes it is not useful and we want to treat empty arrays the same
as a NULL array. Add helpers for that.
2021-09-30 15:10:18 +02:00
Thomas Haller
c32ddc30c0
glib-aux: add nm_g_variant_singleton_{i_0,as,aay,au}() helpers 2021-09-30 15:10:17 +02:00
Thomas Haller
6837095aab
n-acd: fix handling of N_ACD_E_DROPPED
N_ACD_E_DROPPED is an error code of n-acd, albeit internal. But such codes are returned
as postive values, unlike error codes from errno.h (which are negative).

Fix comparing for N_ACD_E_DROPPED, otherwise the error gets propagate to the caller
when we should handle it internally.
2021-09-30 15:10:17 +02:00
Vojtech Bubela
e989cbbd99
nmcli: show default instead of null adress
invoking nmcli command without arguments will now show "default"
instead of null adress in route4 or route6 section.
2021-09-29 10:29:31 +02:00
Thomas Haller
17fd1e4708
l3cfg/trivial: explain commit-type in code comments 2021-09-29 09:26:43 +02:00
Beniamino Galvani
8a06d66d0e
l3cfg: fix nm_l3cfg_commit_type_register() to set commit_type and add debug logging
Co-authored-by: Thomas Haller <thaller@redhat.com>
2021-09-28 22:18:13 +02:00
Thomas Haller
f3def63fed
std-aux: add nm_clear_fd() helper 2021-09-28 15:58:29 +02:00
Thomas Haller
81ed762d46
glib-aux/trivial: update code comment for nm_g_idle_add() 2021-09-28 15:58:28 +02:00
Thomas Haller
78c716cfaf
l3cfg: track "never-default" in NML3Cfg 2021-09-28 13:20:28 +02:00
Thomas Haller
01a09d1194
libnm: minor cleanup of NM_TERNARY_FROM_OPTION_BOOL()/NM_TERNARY_TO_OPTION_BOOL() 2021-09-28 13:19:37 +02:00
Thomas Haller
37047aba36
std-aux: add nm_assert_addr_family_or_unspec() and nm_utils_addr_family_other() helpers 2021-09-28 12:56:39 +02:00
Thomas Haller
c9a833c910
l3cfg: drop nm_l3cfg_property_emit_register() API
The idea was that NMIPConfig would register itself with the property (like "address-data")
and then NML3Cfg would emit the property changed notification.

However, we can already achive that via the regular notification, in particular
by listening to NM_L3_CONFIG_NOTIFY_TYPE_PLATFORM_CHANGE_ON_IDLE notification.

Also, NML3Cfg does not really understand the details when the property should
be emitted. For example, many routes not not exposed via "route-data" property,
and changes to those should not trigger a notification.

Drop the unused API.
2021-09-27 10:09:50 +02:00