Commit graph

26943 commits

Author SHA1 Message Date
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
Thomas Haller
ee4e679bc7
dns: don't apply DNS configuration for external connections
External connections are devices that are configured outside of
NetworkManager. Such devices should be mostly ignored and not
be interfered with.

Note that we tend to create external connection profiles for
such devices. That happens for example if you use wg-quick to
manage a WireGuard interface outside of NetworkManager. But it
really happens for any interface.

This generated profile has no DNS configuration. Unless we use
the systemd-resolved backend, they thus don't contribute to the DNS
settings (which is fine).

However, with systemd-resolved, NetworkManager would also reset
the DNS configuration of those external interfaces. That is clearly
wrong. NetworkManager should only care about the interfaces that it
actively manages and leave others alone.

How to reproduce: use systemd-resolved and configure an interface outside
of NetworkManager. Note that `nmcli device` shows the state as
"connected (externally)". Note that `resolvectl` shows the DNS configuration
on that external interface. Do something in NetworkManager to trigger
a DNS update (e.g. SIGHUB or reactivate a profile). Note in `resolvectl`
that the external interface's DNS configuration was wiped.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/563#note_673283
(cherry picked from commit 395665902b)
2020-11-17 18:51:59 +01:00
Aleksander Morgado
e0da93172f
wwan: update default connection timeout to 200s
The following merge request in ModemManager introduces a more or less
common timeout value for the connection attempts in all plugin and
protocol implementations:

  https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/391

The value chosen by default for the steps that may take long to
complete in a connection attempt is 180s, and 120s for the steps in
the disconnection path.

Until now, every different plugin or protocol had a different timeout
value, all of them <= 180s, and with that change in ModemManager, the
values are now aligned for all.

Note, though, that this does not mean that a connection attempt will
take always less than 180s, as there may be multiple other steps in
addition to the one that took the maximum timeout. The value chosen
for NetworkManager is a compromise between the new defaults from MM
and what the user would expect under e.g. very low quality conditions.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/678
(cherry picked from commit 5b7ce438d9)
2020-11-16 16:08:30 +01:00
Beniamino Galvani
cd58512ba3 dns: sd-resolved: fix hash table initialization
The hash table was not initialized if there was no D-Bus connection at
the time of object creation.

Fixes: f70ee67058 ('dns: sd-resolved: reset interface configuration on deactivation')

https://bugzilla.redhat.com/show_bug.cgi?id=1894839
(cherry picked from commit d6457902d1)
2020-11-09 08:59:01 +01:00
Antonio Cardace
5d63508bb1
merge branch 'ac/bridge_mtu_autoadjust' into master
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/656

(cherry picked from commit c4b6962ed2)
2020-11-02 17:47:27 +01:00
Antonio Cardace
864872e9a8
bridge: force (hack)-set of the MTU when explicitly set in the profile
Kernel does a auto-mtu adjusting process whenever a port is added/removed from
the bridge, this can cause issues when NM wants to explicitly set an MTU which is
equal to the bridge default one (1500) because if later a port is added with a
different MTU the kernel will assign the bridge that port's MTU resulting in the bridge
runtime configuration differing from the bridge's NM connection profile.

What we can do is to always apply the MTU manually for the bridge (if explicitly
set by the profile), after doing so the kernel won't modify the MTU anymore,
which is what we want, problem is that kernel won't actually apply the MTU
to the netdev if it's not actually changing so we first apply it to
MTU-1 and then to the desired value.

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

Signed-off-by: Antonio Cardace <acardace@redhat.com>
(cherry picked from commit e23798a5e5)
2020-11-02 17:47:26 +01:00
Antonio Cardace
8d8017a620
bridge: set MTU at link creation time
https://bugzilla.redhat.com/show_bug.cgi?id=1778590

Signed-off-by: Antonio Cardace <acardace@redhat.com>
(cherry picked from commit 516c623618)
2020-11-02 17:47:26 +01:00
Antonio Cardace
05e8b018ec
platform: allow setting the MTU at link creation time
Add a parameter to the 'link_add()' virtual function so that
the MTU will be configured (via netlink) by the kernel when
creating the link.

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

Signed-off-by: Antonio Cardace <acardace@redhat.com>
(cherry picked from commit ba2ee46254)
2020-11-02 17:47:26 +01:00