Commit graph

26950 commits

Author SHA1 Message Date
Beniamino Galvani
dedcba61ef dns: sd-resolved: fix hash table iteration
g_hash_table_iter_next() wants a (gpointer *), not an (int *).

Fixes: f70ee67058 ('dns: sd-resolved: reset interface configuration on deactivation')
(cherry picked from commit 526b484be1)
2020-11-30 23:04:37 +01:00
Thomas Haller
e749a1a5db
dns: merge branch 'th/dns-resolved-default-route'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/694

(cherry picked from commit bb9dcde97f)
2020-11-27 10:54:46 +01:00
Thomas Haller
c182984469
dns: detect support of systemd-resolved's SetLinkDefaultRoute() and avoid it
We now always use SetLinkDefaultRoute(), but that API was only added in
systemd v240 ([1]).

We could just always call the non-existing method, and ignore the
error. However, that feels ugly. Would systemd-resolved log warnings
about that? Should we suppress all messages about that failure (not
good for debugging).

Instead, make an effort to detect support of the function, and avoid
calling it. That is significantly more complicated than just always
calling the method and not care.

Note that even if systemd-resolved does not support SetLinkDefaultRoute(),
we cannot do anything smart about that. We would simply rely on
systemd-resolved (hopefully) doing the right thing automatically.
That's better and simpler than explicitly adding a "~." domain in
the fallback case.

Also, detecting support is straight forward in the common case, where
there is either success or a clear "org.freedesktop.DBus.Error.UnknownMethod"
error. In cases where there is any other failure, we don't really know.
In that case, we keep trying to use the API under the assumption that
it should work.

[1] https://github.com/systemd/systemd/commit/7 ## 7673795dcf5797491e7f785cbf5077d29a15db4

(cherry picked from commit 44ebb99cfa)
2020-11-27 10:54:45 +01:00
Thomas Haller
3f16b988a4
dns: preserve DNS settings for systemd-resolved to resend
When the DNS settings change, we update the request_queue_lst_head list,
with all the requests we want to send.

Then, send_updates() will try to send it. It might not do it right away,
if resolved is not on the bus or the D-Bus connection is not fully inialized
(meaning, we don't know the name owner yet). In those cases, we would
keep the list of requests, and send them later.

However, when sending them, we would also forget about the configuration.

That means, if you restart systemd-resolved, then the daemon drops off
the bus and reappears. I think that systemd-resolved in fact persists
the configuration during restart. So, usually the settings are still the
same after restart. However, we should do better here: if the service
appears, we should send the settings again.

This means to not forget the requests after we send them once -- at
least, until a new update replaces them.

(cherry picked from commit 4fc44952f7)
2020-11-27 10:54:45 +01:00
Thomas Haller
3cb7b3a8a2
dns: minor cleanup of call_done() in "nm-dns-systemd-resolved.c"
(cherry picked from commit 42d47d1cd7)
2020-11-27 10:54:45 +01:00
Thomas Haller
4401c6d567
dns: cleanup RequestItem and track ifindex and self parameter
We will need these changes next:

- add "self" and "ifindex" fields to RequestItem struct. We will
  pass on these structs are user-data for the callbacks, so that
  we afterwards know which request completed.

- add DBUS_OP_SET_LINK_DEFAULT_ROUTE global variable. We don't
  clone the "operation" string but use string literals. However,
  string literals are not guaranteed to be deduplicated, so we
  should only compare them with strcmp(). The static variable
  avoids this: we can use pointer equality to compare it.
  This will be used next.

(cherry picked from commit 8af6647cda)
2020-11-27 10:54:45 +01:00
Thomas Haller
3b1ae89d2f
core: recognize "wifi.scan-generate-mac-address-mask" as valid "NetworkManager.conf" option
Fixes: 32f4abe90b ('config: warn about unknown keys in config files')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/595
(cherry picked from commit d615b902d8)
2020-11-27 09:58:45 +01:00
Beniamino Galvani
145fe0d82c ovs: merge branch 'bg/rh1899745'
https://bugzilla.redhat.com/show_bug.cgi?id=1899745
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/691

(cherry picked from commit e2ed707c87)
2020-11-26 18:00:40 +01:00
Beniamino Galvani
031583c1d3 ovs: avoid ovs error when same MAC is set on a local interface and bridge
If the same MAC address is set on both the bridge connection and the
interface connection, and the interface is local, NM currently sets
the hwaddr record in both Bridge and Interface ovsdb tables. As a
result, ovs complains with error:

  bridge|ERR|interface br0: ignoring mac in Interface record (use Bridge record to set local port's mac)

Avoid this error: if the bridge and interface MACs are the same, just
set the address in the Bridge table; if they are different, give a
more detailed warning and ignore the interface MAC.

https://bugzilla.redhat.com/show_bug.cgi?id=1899745
(cherry picked from commit c4beaac67b)
2020-11-26 18:00:40 +01:00
Beniamino Galvani
38d0c2f12b ovs: rename variable
@interface_is_internal is a bad name. The variable indicates whether
the interface is the local interface.

(cherry picked from commit e9e99b8677)
2020-11-26 18:00:40 +01:00
Beniamino Galvani
435d662669 initrd: fix parsing of ip= arguments with empty first token
The parser checks if the first token of an ip= argument is an IP
address to determine which of the two possible syntaxes is used:

 ip=<interface>:{dhcp|on|any|dhcp6|auto6}[:[<mtu>][:<macaddr>]]
 ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}[:[<mtu>][:<macaddr>]]

This works as long as the first token is not empty, which - according
to the dracut.cmdline man page - seems to be guaranteed.

However, the network-legacy dracut plugin accepts an empty interface
or client IP. Also, if a user needs DHCP and wants to specify a
hostname, the only possible syntax is:

 ip=::::<hostname>::dhcp

Change the parser to check the second token instead, similarly to what
the network-legacy module does [1].

[1] https://github.com/dracutdevs/dracut/blob/050/modules.d/40network/net-lib.sh#L490

https://bugzilla.redhat.com/show_bug.cgi?id=1900260
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/693
(cherry picked from commit b0c018830e)
2020-11-26 18:00:32 +01:00
Thomas Haller
c6fb949789
trivial: fix coding style
(cherry picked from commit e7d828f6a0)
2020-11-24 18:56:03 +01:00
Beniamino Galvani
ae453f0ae8 dns: fix setting systemd-resolved name servers for default route
If the interface is the DNS default route but has no domain, its name
servers were not sent to systemd-resolved. Fix this.

Fixes: ee9fab0361 ('dns: fix handling default routing domains with systemd-resolved')
(cherry picked from commit 195cbf3cee)
2020-11-24 18:29:23 +01:00
Beniamino Galvani
23fb0f26de initrd: merge branch 'bg/initrd-vlan'
https://bugzilla.redhat.com/show_bug.cgi?id=1898294
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/581
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/509
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/685

(cherry picked from commit 2889a3a5c5)
2020-11-24 10:08:54 +01:00
Beniamino Galvani
4b0007b037 initrd: disable ipv4 and ipv6 by default for vlan parent connection
Change the generator to disable by default IP configuration for the
parent connection of a VLAN, because that is what a user would expect
and what the legacy module does. Of course if the user explicitly
configures DHCP or an address for the parent interface, that overrides
the default.

Note that now the generator always creates a connection for the parent
interface. Before this commit, it did only when there was an explicit
ip= argument for the parent interface.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/509
(cherry picked from commit f2e51ace68)
2020-11-24 10:08:53 +01:00
Beniamino Galvani
f766b3cbae initrd: fix parsing of ip= argument with dotted interface name
The command line parser looks for a dot or a colon to determine
whether the first token in a ip= argument is a IPv4 address (dot), an
IPv6 address (colon) or an interface name (none). This strategy
doesn't work for interface names containing a dot (typically VLANs).

Instead, try to parse the IPv4/IPv6 address in the token; if this
fails then consider the token as an interface name.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/581
(cherry picked from commit 4aa902ecf5)
2020-11-24 10:08:53 +01:00
Beniamino Galvani
58a6697e96 initrd: add test for prefixed address in ip= argument
(cherry picked from commit 584e9048b3)
2020-11-24 10:08:53 +01:00
Beniamino Galvani
10f2600832 initrd: merge branch 'ac/cmdline_reader_ipv6_off' into master
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/539
(cherry picked from commit 3093a0073b)
2020-11-24 10:05:45 +01:00
Antonio Cardace
23364aa8f3 NEWS: update
Signed-off-by: Antonio Cardace <acardace@redhat.com>
(cherry picked from commit 8764d47af6)
2020-11-24 10:04:12 +01:00
Antonio Cardace
ad3088f63f initrd: disable ipv6 when 'off|none' is set in the 'ip' option
This is potentially a breaking change, formerly speciyfing 'none|off'
in the kernel cmdline option 'ip' was understood by the dracut
network-module as doing 'ipv6.method=auto' which is clearly incosistent
with the 'off' naming, thus 'off|none' now means to actually disable
both ipv6 and ipv4 (unless a static ip is provided).

Unit test added.

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

Reverts: 440a0b4078 ('initrd: set ipv6.method=auto when the autoconfiguration field is 'none'')
Signed-off-by: Antonio Cardace <acardace@redhat.com>
(cherry picked from commit fc7c83cbdd)
2020-11-24 10:02:53 +01:00
Thomas Haller
9596fd1c74
core: fix modifying connection during recheck_assume_connection()
Since commit d35d3c468a ('settings: rework tracking settings
connections and settings plugins') must settings connections not
be modified. They must be treated immutable and only updated by
replacing them with a new variant. There is even an assertion
for that.

Fix the code that attempts to modify an existing NMConnection.

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

Fixes: f2fe6c03ee ('manager: don't treat the initramfs-configured DHCP connections as generated')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/690
(cherry picked from commit eed23269bd)
2020-11-24 08:50:46 +01:00
Thomas Haller
6b316a1991
build/meson: fix build to always set "-W" compiler flags
We must set these compiler flags independent as to whether this
is a release build or a debug build.

In most cases, we don't differentiate between release and debug build
anyway. Granted, we have "-D more_asserts=100" and set "-O" CFLAGS,
but that is more granular and not a simple "buildtype".

In particular, these compiler flags apply to all kinds of builds.

This is important, because otherwise we get build failures, because
also in release build we want to build with `-Werror` and `-Wall`.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/692
(cherry picked from commit c0c6470e4d)
2020-11-23 21:07:51 +01:00
Thomas Haller
76ba56c7bf
gitignore: ignore "/docs/libnm/libnm.actions"
Dunno why this file now gets generated.

(cherry picked from commit df76da8ea0)
2020-11-23 19:08:10 +01:00
Thomas Haller
034db883b3
Revert "dns: change default DNS priority of VPNs to -50"
Revert this change. One problem is that none of the current GUIs
(nm-connection-editor, gnome-control-center, plasma-nm) expose the
dns-priority option. So, users tend to have their profile value set to
0. Changing the default means for them not only a change in behavior,
but its hard to fix via the GUI.

Also, what other call DNS leaks, is Split DNS to some. Both uses make
sense, but have conflicting goals. The default cannot accommodate both
at the same time.

Also, with split DNS enabled (dnsmasq, systemd-resolved), the concern
for DNS leaks is smaller. Imagine:

  Wi-Fi profile with ipv4.dns-priority (effectively) 100, domain "example.com".
  VPN profile with ipv4.dns-priority (effectively) 50 and a default route.

That is a common setup that one gets by default (and what probably many
users have today). In such a case with split DNS enabled, the Wi-Fi's DNS
server only sees requests for "*.example.com". So, it does not leak
everything.

Hence, revert this change before 1.28.0 release to the earlier behavior.

This reverts commit af13081bec.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/688
(cherry picked from commit ff71bbdc42)
2020-11-23 19:00:15 +01:00
Thomas Haller
90a36d5efe
build: merge branch 'th/workaround-glib-atomic-pointer-get'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/667

(cherry picked from commit b57198a7bc)
2020-11-23 15:26:50 +01:00
Thomas Haller
c807e77271
libnm: with meson include "nm-default.h" for glib-mkenums sources
We also do that for the autotools implementation.

(cherry picked from commit fd57e9665c)
2020-11-23 15:26:49 +01:00
Thomas Haller
294efba18f
libnm/tests: include "nm-default.h" for "libnm-core/tests/nm-core-tests-enum-types.c"
With glib2-2.67.0-1.fc34.x86_64.rpm, clang-11.0.0-2.fc34.x86_64.rpm, the
generated code emits a compiler warning:

    libnm-core/tests/nm-core-tests-enum-types.c:17:7: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      if (g_once_init_enter (&g_define_type_id__volatile))
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
        (!g_atomic_pointer_get (location) &&                             \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~
    libnm-core/tests/nm-core-tests-enum-types.c:40:7: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      if (g_once_init_enter (&g_define_type_id__volatile))
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
        (!g_atomic_pointer_get (location) &&                             \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~
    libnm-core/tests/nm-core-tests-enum-types.c:63:7: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
      if (g_once_init_enter (&g_define_type_id__volatile))
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
        (!g_atomic_pointer_get (location) &&                             \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~

We could pass "-Wincompatible-pointer-types-discards-qualifiers" as CFLAGS
when building this file. However, we have a workaround in our "nm-glib-aux/nm-glib.h",
so we can instead include "nm-default.h". At first glance, that might look like
the less preferable solution. However, this file is only there for unit tests,
and we also include "nm-default.h" for other sources that are generated with
"glib-mkenums". So, doing it also for our tests becomes the preferable solution.

(cherry picked from commit 755d97d38c)
2020-11-23 15:26:48 +01:00
Thomas Haller
a1f3cebbec
shared: don't enforce unset G_LOG_DOMAIN in "nm-default.h"
When including <glib.h>, it will always define G_LOG_DOMAIN if it
is not yet defined.

Usually we want to include "nm-default.h" as very first header. In that
case, <glib.h> is not yet included. Then the previous check #error works
well.

However, if we include "nm-default.h" in sources generated by
glib-mkenums, then the generator first already includes <glib.h>,
and thus defines G_LOG_DOMAIN. It does so for "libnm-core/nm-core-enum-types.c"
and "libnm/nm-enum-types.c", where the #error would not trigger.
But we will also include "nm-default.h" for "libnm-core/tests/nm-core-tests-enum-types.c".
That will start triggering this #error.

While in general we want to include "nm-default.h" first, we also need
to support cases where <glib.h> gets included first. Thus this error is
not useful. Remove it.

(cherry picked from commit 42fa8f3d27)
2020-11-23 15:26:48 +01:00
Thomas Haller
6ded463f36
shared: also reimplement g_atomic_pointer_set() macro
It's not strictly necessary, because contrary to g_atomic_pointer_get()
and g_atomic_pointer_compare_and_exchange(), glib's variant for the
setter is mostly fine.

Still, reimplement it, because we use typeof() eagerly and can thus add
more static checks than glib.

(cherry picked from commit 7c60e984b6)
2020-11-23 15:26:48 +01:00
Thomas Haller
1e4cfba6dc
shared: add a compat implementation for g_atomic_pointer_get()
With glib2-2.67.0-1.fc34.x86_64.rpm, clang-11.0.0-2.fc34.x86_64.rpm, we
get a failure for g_atomic_pointer_get():

    ../shared/nm-glib-aux/nm-hash-utils.c:38:9: error: passing 'typeof (*(&global_seed)) *' (aka 'const unsigned char *volatile *') to parameter of type 'const guint8 **' (aka 'const unsigned char **') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
        g = g_atomic_pointer_get(&global_seed);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~
    ../shared/nm-glib-aux/nm-hash-utils.c:109:32: error: passing 'typeof (*(&global_seed)) *' (aka 'const unsigned char *volatile *') to parameter of type 'const guint8 **' (aka 'const unsigned char **') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
        return ((*((const guint *) _get_hash_key())) ^ static_seed) ?: 3679500967u;
                                   ^~~~~~~~~~~~~~~
    ../shared/nm-glib-aux/nm-hash-utils.c:84:14: note: expanded from macro '_get_hash_key'
            _g = g_atomic_pointer_get(&global_seed); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~
    ../shared/nm-glib-aux/nm-hash-utils.c:123:9: error: passing 'typeof (*(&global_seed)) *' (aka 'const unsigned char *volatile *') to parameter of type 'const guint8 **' (aka 'const unsigned char **') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
        g = _get_hash_key();
            ^~~~~~~~~~~~~~~
    ../shared/nm-glib-aux/nm-hash-utils.c:84:14: note: expanded from macro '_get_hash_key'
            _g = g_atomic_pointer_get(&global_seed); \
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~

(cherry picked from commit 5e57ea37f0)
2020-11-23 15:26:47 +01:00
Thomas Haller
595c5854ad
introspection: avoid compiler warning in generated introspection files
Disable "-Wincompatible-pointer-types-discards-qualifiers" warning, as
this breaks build of the gdbus-codegen files.

With glib2-2.67.0-1.fc34.x86_64.rpm, clang-11.0.0-2.fc34.x86_64.rpm, we
get a failure to build generated code:

    introspection/org.freedesktop.NetworkManager.AccessPoint.c:438:1: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    G_DEFINE_INTERFACE (NMDBusAccessPoint, nmdbus_access_point, G_TYPE_OBJECT)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:1784:47: note: expanded from macro 'G_DEFINE_INTERFACE'
    #define G_DEFINE_INTERFACE(TN, t_n, T_P)                    G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, ;)
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:1803:61: note: expanded from macro 'G_DEFINE_INTERFACE_WITH_CODE'
    #define G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, _C_)     _G_DEFINE_INTERFACE_EXTENDED_BEGIN(TN, t_n, T_P) {_C_;} _G_DEFINE_INTERFACE_EXTENDED_END()
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2042:7: note: expanded from macro '_G_DEFINE_INTERFACE_EXTENDED_BEGIN'
      if (g_once_init_enter (&g_define_type_id__volatile))  \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
        (!g_atomic_pointer_get (location) &&                             \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~
    introspection/org.freedesktop.NetworkManager.AccessPoint.c:944:1: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    G_DEFINE_TYPE_WITH_CODE (NMDBusAccessPointProxy, nmdbus_access_point_proxy, G_TYPE_DBUS_PROXY,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:1615:56: note: expanded from macro 'G_DEFINE_TYPE_WITH_CODE'
    #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)          _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2032:3: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN'
      _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2000:7: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER'
      if (g_once_init_enter (&g_define_type_id__volatile))  \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
        (!g_atomic_pointer_get (location) &&                             \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~
    introspection/org.freedesktop.NetworkManager.AccessPoint.c:1729:1: error: passing 'typeof (*(&g_define_type_id__volatile)) *' (aka 'volatile unsigned long *') to parameter of type 'gsize *' (aka 'unsigned long *') discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
    G_DEFINE_TYPE_WITH_CODE (NMDBusAccessPointSkeleton, nmdbus_access_point_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:1615:56: note: expanded from macro 'G_DEFINE_TYPE_WITH_CODE'
    #define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_)          _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END()
                                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2032:3: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN'
      _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/gobject/gtype.h:2000:7: note: expanded from macro '_G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER'
      if (g_once_init_enter (&g_define_type_id__volatile))  \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gthread.h:260:7: note: expanded from macro 'g_once_init_enter'
        (!g_atomic_pointer_get (location) &&                             \
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /usr/include/glib-2.0/glib/gatomic.h:112:38: note: expanded from macro 'g_atomic_pointer_get'
        __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \
                                         ^~~~~~~~~~~~~~~~~

(cherry picked from commit 03d9ec27fa)
2020-11-23 15:26:47 +01:00
Thomas Haller
6ba600cb38
build: don't depend dispatcher code on introspection sources
The dispatcher code does not use the generated introspection sources
(anymore). Don't add a dependency.

(cherry picked from commit e0a3a5e2f8)
2020-11-23 15:26:47 +01:00
Thomas Haller
d10d14d7ba
tests: avoid race condition in nmtstc_service_cleanup()
It seems it can happen that the service is not yet unregistered from the
D-Bus broker, even if we already reaped the PID.

    /builds/NetworkManager/NetworkManager/tools/run-nm-test.sh --called-from-make /builds/NetworkManager/NetworkManager/build    --launch-dbus=auto /builds/NetworkManager/NetworkManager/build/libnm/tests/test-nm-client
    --- stdout ---
    /libnm/device-added:
    nmtst: initialize nmtst_get_rand() with NMTST_SEED_RAND=0
    --- stderr ---
    **
    test:ERROR:../shared/nm-test-utils-impl.c:216:nmtstc_service_cleanup: assertion failed: (!name_exists(info->bus, "org.freedesktop.NetworkManager"))

Workaround by waiting a bit.

We now iterate the main GMainContext, unlike before. But that
should not cause any problems for the test.

(cherry picked from commit 1b8ccacc5d)
2020-11-23 15:26:46 +01:00
Thomas Haller
20cfc1f395
shared/tests: add nmtst_main_context_iterate_until_full() helper
(cherry picked from commit 230250e629)
2020-11-23 15:26:46 +01:00
Thomas Haller
ddb69b211c
shared/tests: add nmtst_g_source_nop() helper
(cherry picked from commit ca2b79d9aa)
2020-11-23 15:26:46 +01:00
Thomas Haller
4d572bea7e
platform/tests: better handling "timeout_msec" argument in nmtst_main_context_iterate_until()
nmtst_main_context_iterate_until() is a macro, and we don't want to restrict the
valid integer type (or range) of the "timeout_msec" argument.

In particular, if the user calculates a timeout with "timestamp_msec -
now_msec", the resulting "timeout_msec" might be a negative gint64.
We should handle that gracefully, and not let it be cast to a huge
unsigned int.

(cherry picked from commit 6cb6888404)
2020-11-23 15:19:35 +01:00
Thomas Haller
b6a9242b1a
dns: fix accessing NULL domains.reverse array in rebuild_domain_lists()
Fixes: fbf1683c1a ('dns: more debug logging for DNS settings in rebuild_domain_lists()')
(cherry picked from commit 937c8a4669)
2020-11-20 22:52:54 +01:00
Thomas Haller
9e83dafda4
dns: merge branch 'th/dns-resolved-fix-exclusive'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/687

(cherry picked from commit 4f19fd6ce2)
2020-11-20 19:14:33 +01:00
Thomas Haller
ab0dcafb6e
dns: set first Domains/DefaultRoute in systemd-resolved before DNS
(cherry picked from commit 95017dccdd)
2020-11-20 19:14:33 +01:00
Thomas Haller
3ce2ea7f12
dns: more debug logging for DNS settings in rebuild_domain_lists()
(cherry picked from commit fbf1683c1a)
2020-11-20 19:14:09 +01:00
Thomas Haller
b8dab47705
dns: fix handling default routing domains with systemd-resolved
We used to set "~." domains for all devices that should be used for
resolving unknown domains.

Systemd-resolved also supports setting "SetLinkDefaultRoute()".
We should only set the wildcard domain if we want that this
interface is used exclusively. Otherwise, we should only set
DefaultRoute. See ([1], [2], [3], [4]).

Otherwise the bad effect is if other components (wg-quick) want
to set exclusive DNS lookups on their link. That is achieved by
explicitly adding "~." and that is also what resolved's
`/usr/sbin/resolvconf -x` does. If NetworkManager sets "~." for
interfaces that are not important and should not be used exclusively,
then this steals the DNS requests from those external components.

In NetworkManager we know whether a link should get exclusive lookups
based on the "ipv[46].dns-priority" setting.

[1] https://www.freedesktop.org/software/systemd/man/org.freedesktop.resolve1.html
[2] https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html
[3] https://github.com/systemd/systemd/issues/17529#issuecomment-730522444
[4] https://github.com/systemd/systemd/pull/17678

(cherry picked from commit ee9fab0361)
2020-11-20 19:10:44 +01:00
Thomas Haller
83c760014e
dns: assert domains are unset at start of rebuild_domain_lists()
(cherry picked from commit a875d154de)
2020-11-20 19:10:44 +01:00
Thomas Haller
0bfc2b6db9
dns: assert that priorities in rebuild_domain_lists() are increasing
This is nm_assert(). The compiler should be able to completely eliminate
this code in production.

(cherry picked from commit 05f8ccc817)
2020-11-20 19:10:44 +01:00
Thomas Haller
2502b88511
dns: cleanup handling of shadowed priorities rebuild_domain_lists()
domain_is_shadowed() only works, because we pre-sort all items. When
we call domain_is_shadowed(), then "priority" must be not smaller than
any priority already in the dictionary.

Let's add an nm_assert() for that.

While at it, I also found it ugly to rely on

  GPOINTER_TO_INT(g_hash_table_lookup(ht, domain))

returning zero to know whether the domain is tracked. While more
cumbersome, we should check whether the value is in the hash (and not).
Not whether the value does not translate to zero.

Add domain_ht_get_priority() for that.

(cherry picked from commit 5902f1c91f)
2020-11-20 19:10:43 +01:00
Thomas Haller
59d48fcc35
dns: track NMDnsConfigData as keys of a dictionary
There is unnecessary overhead of tracking a separate
key and value in a GHashTable.

Use g_hash_table_add().

(cherry picked from commit d10d96a45c)
2020-11-20 19:10:43 +01:00
Thomas Haller
795eca6e1b
dns: cleanup allocation of NMDnsConfigData and NMDnsIPConfigData
(cherry picked from commit 190eeb5e9f)
2020-11-20 19:10:43 +01:00
Thomas Haller
0464c36a02
core/ovs: fix leak of "NMOvsdbPrivate.db_uuid
Also, never update the value to %NULL. If the current
message does not contain a UUID, keep the previous one.

Fixes: 830a5a14cb ('device: add support for OpenVSwitch devices')
(cherry picked from commit 609b08e2eb)
2020-11-19 14:33:38 +01:00
Thomas Haller
b9f802122a
build: fix handling NMTST_SKIP_PYTHON_BLACK for skipping make check-python-black test
Fixes: c537852231 ('build: optionally skip python black check by setting NMTST_SKIP_PYTHON_BLACK=1')
(cherry picked from commit ebbc2c9c0d)
2020-11-19 14:33:35 +01:00
Andrew Zaborowski
03b63a893f
iwd: Fix a use after free
In connection_removed we use the id.name that was being g_freed a few
lines further down.

Fixes: bea6c40367 ('wifi/iwd: handle forgetting connection profiles')
(cherry picked from commit c1ff06e119)
2020-11-19 14:33:32 +01:00
Thomas Haller
d535da216c
dns: fix _dns_manager_set_ip_config() for missing device
Fixes: 395665902b ('dns: don't apply DNS configuration for external connections')
(cherry picked from commit adaeb7a872)
2020-11-19 09:29:17 +01:00