Commit graph

26246 commits

Author SHA1 Message Date
Thomas Haller
60f92ca403
contrib/rpm: prefer keyfile settings plugin from Fedora 33 and newer
This change is for Fedora 33 and newer. For now, also enable it for RHEL
9 and newer, but it must still be decided whether that will be done
there as well.

https://mail.gnome.org/archives/networkmanager-list/2020-May/msg00002.html
https://fedoraproject.org/wiki/Changes/NetworkManager_keyfile_instead_of_ifcfg_rh
https://lists.fedoraproject.org/archives/list/devel-announce@lists.fedoraproject.org/thread/OLOU27DAON2TYGTAVZ35GZE2BEIN42U3/
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/OLOU27DAON2TYGTAVZ35GZE2BEIN42U3/
https://pagure.io/fesco/issue/2432

https://bugzilla.redhat.com/show_bug.cgi?id=1857391
(cherry picked from commit 3e475e5cd1)
2020-08-17 15:41:57 +02:00
Thomas Haller
53d15e95c1
scripts: use "/bin/cat" in NM-log
Ubuntu 16.04 doesn't have merged /usr directories and cat is in
/bin/cat.

(cherry picked from commit 67cc4544f7)
2020-08-17 15:41:32 +02:00
Thomas Haller
18171a3a33
build: merge branch 'th/fix-lto'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/605

(cherry picked from commit b8ac53905d)
2020-08-17 15:40:06 +02:00
Thomas Haller
8fbf6aeced
contrib/rpm: enable LTO by default on Fedora 33
With Fedora 33, LTO will be enabled by default via CFLAGS in
redhat-rpm-config ([1]).

That basically sets "CFLAGS=-flto -ffat-lto-objects".

Note that we have our own configure/meson option to enable LTO.
With "--with-lto" we set CFLAGS="-flto -flto-partition=none". This
is necessary due ([2], [3]).

So, disable Fedora's automatism, but turn on the suitable configure
option to get working LTO.

[1] 5baaf4a99c
[2] e6cf4213a7 ('build: fix building with LTO')
[3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48200#c28

(cherry picked from commit 839ba57c7f)
2020-08-17 15:40:06 +02:00
Thomas Haller
aabbd0e8de
build: disable "-Wstringop-overflow" warning with LTO enabled
No amount of _Pragma was able to disable this warning.

    In function ‘strncpy’,
        inlined from ‘_nm_strndup_a_step’ at ./shared/nm-glib-aux/nm-macros-internal.h:1367:3,
        inlined from ‘nms_keyfile_nmmeta_check_filename’ at src/settings/plugins/keyfile/nms-keyfile-utils.c:61:0:
    /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
      106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
          |          ^
    src/settings/plugins/keyfile/nms-keyfile-utils.c: In function ‘nms_keyfile_nmmeta_check_filename’:
    src/settings/plugins/keyfile/nms-keyfile-utils.c:44: note: length computed here
       44 |  len = strlen (filename);
          |
    lto1: all warnings being treated as errors

Oddly enough, gcc is still emitting the warning even with "-Wno-stringop-overflow",
but at least it doesn't break the build.

(cherry picked from commit 407a1f1e98)
2020-08-17 15:40:05 +02:00
Thomas Haller
6f82699ef7
clients/tests: ensure that we run nmcli before client tests for LTO
nmcli is build with libtool, so "clients/cli/nmcli" is really a shell script
that invokes the real nmcli (at "clients/cli/.libs/nmcli").

When building with LTO for some reasons "clients/cli/nmcli" still
does some build steps during the first invocation.

That means, if we run `make check-local-clients-tests-test-client` it
would first do the final build step. This takes a while, and the test
times out (worse, we do that build step many times in parallel).

Avoid that by invoking "clients/cli/nmcli" first.

(cherry picked from commit 00e3fc036a)
2020-08-17 15:40:05 +02:00
Thomas Haller
bfa5a58642
build: fix generating "NetworkManager.ver" with LTO
We use a linker version script "NetworkManager.ver", to hide
symbols from NetworkManager that are not used. That is important
due to our habit of using internal helper libraries that we link
statically everywhere, without handpicking the symbols we actually
need. We want the tooling to get rid of unnecessary symbols.

However, NetworkManager loads shared libraries for settings and device
plugins. These libraries require symbols from the NetworkManager binary,
but which one depends on build options. Hence, we also generate
"NetworkManager.ver" by the "tools/create-exports-NetworkManager.sh"
script.

For that the script uses "nm" to find symbols that are undefined in the
plugin libraries but defined in NetworkManager. With autotools the
script looked at "./src/.libs/libNetworkManager.a" to find the present
symbols. Note that for meson that already didn't work, and we build
instead an intermediate NetworkManager binary first (with all symbols
exposed). With LTO, "nm" doesn't find all symbols in
"./src/.libs/libNetworkManager.a", and consequently they are not
exported and dropped/hidden.

This also causes unit tests to fail with LTO, because our test script
"tools/check-exports.sh" catches such bugs.

Fix that by also with autotools generate a complete "NetworkManager-all-sym"
binary that is used to generate "NetworkManager.ver", before rebuilding
"NetworkManager" again.

(cherry picked from commit c92a3ca5c2)
2020-08-17 15:40:05 +02:00
Thomas Haller
043bf59602
build: prefer python3 over python2 in autotools's configure script
On Debian sid, pygobject no longer builds "python-gobject" for
python2. Still, python2 may be installed and detected preferably
by AM_PATH_PYTHON(). Add workaround.

(cherry picked from commit 54a1cfa973)
2020-08-17 15:40:05 +02:00
Thomas Haller
f5aafb9da4
core: avoid deprecated matchfilecon SELinux API instead of selabel
The matchfilecon API is deprecated for a very long time. Since selinux 3.1
the functions are also marked as deprecated in the header, which causes
compiler warnings and build failures.

Update the code to use selabel API instead.

(cherry picked from commit 173533c3b2)
2020-08-17 15:40:05 +02:00
Thomas Haller
12fa5897ad
all: avoid wrong compiler warning about uninitalized variables with LTO
Seems with LTO the compiler can sometimes think that thes variables are
uninitialized. Usually those code paths are only after an assertion was
hit (g_return*()), but we still need to workaround the warning.

(cherry picked from commit 70971d1141)
2020-08-17 15:40:05 +02:00
Thomas Haller
20cc1385dd
tests: fix handling of $NMTST_LIBTOOL in "tools/run-nm-test.sh" script
(cherry picked from commit 0bd8160029)
2020-08-17 15:40:05 +02:00
Thomas Haller
df626ef80b
n-dhcp4: merge branch 'th/fix-lto-compiler-warnings'
https://github.com/nettools/n-dhcp4/pull/20

(cherry picked from commit 689ebd0d60)
2020-08-17 15:39:45 +02:00
Thomas Haller
2ea10a4c23
n-dhcp4/connection: avoid compiler warning in n_dhcp4_c_connection_connect() about fd_udp uninitialized
With LTO and optimizations enabled, we get a compiler warning about fd_udp
not initialized:

  ../src/n-dhcp4-c-connection.c: In function ‘n_dhcp4_c_connection_connect’:
  ../src/n-dhcp4-c-connection.c:196:13: error: ‘fd_udp’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    196 |         r = epoll_ctl(connection->fd_epoll,
        |             ^
  ../src/n-dhcp4-c-connection.c:185:16: note: ‘fd_udp’ was declared here
    185 |         int r, fd_udp;
        |                ^

6c6e936898
(cherry picked from commit 4e0e002092)
2020-08-17 15:39:44 +02:00
Thomas Haller
9a021d7227
n-dhcp4/packet: avoid compiler warning in n_dhcp4_c_socket_packet_recv()
gcc-10.2.1-1.fc32 with optimizations and LTO enabled can think that "len"
is uninitialized. Let packet_recv_udp() always set the length.

  ../src/n-dhcp4-socket.c: In function ‘n_dhcp4_c_socket_packet_recv.constprop’:
  ../src/n-dhcp4-incoming.c:210:29: error: ‘len’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    210 |         incoming->n_message = n_raw;
        |                             ^
  ../src/n-dhcp4-socket.c:558:16: note: ‘len’ was declared here
    558 |         size_t len;
        |                ^

142eedcfc3
(cherry picked from commit 08318a0bac)
2020-08-17 15:39:44 +02:00
Thomas Haller
99b362c944
core: fix selecting of best-default-route to consider only unicast routes
Fixes: 5d0d13f570 ('platform: add support for local routes')
(cherry picked from commit 2a1bac6b8a)
2020-08-14 16:54:01 +02:00
Thomas Haller
cf3cff4f12
core: only expose "type unicast" routes on D-Bus
Currently, we would not mark non-unicast routes with their type, so they
would wrongly appear as unicast routes in the D-Bus API.

That is wrong. For now, just hide them.

Fixes: 5d0d13f570 ('platform: add support for local routes')
(cherry picked from commit 5035687a7b)
2020-08-14 16:53:57 +02:00
Thomas Haller
4e6fcb4a71
settings: suppress wrong warning about wait-device-timeout for devices that are still busy
Imagine we wait for a device, the device appears and starts activating.
That might take a while (during which it has a pending action). In the
meantime, the "connection.wait-device-timeout" timeout expires.

Now we want to log a warning about profiles that don't have their
device upon timeout. However, that the device is still busy at that
point is irrelevant. Skip logging a message about those profiles.

Fixes: 3df662f534 ('settings: rework wait-device-timeout handling and consider device compatibility')
(cherry picked from commit d9568ca3ee)
2020-08-13 10:19:30 +02:00
Thomas Haller
f0d8d6f157
initrd: always set "connection.wait-device-timeout" even if profile has no interface-name set
Since commit 3df662f534 ('settings: rework wait-device-timeout
handling and consider device compatibility'), "connection.wait-device-timeout"
works with profiles in general and doesn't require an interface-name
set.

Remove that restriction and let initrd generator create profiles that
always wait.

(cherry picked from commit 52af5e901e)
2020-08-12 17:43:38 +02:00
Beniamino Galvani
68e82810e7
initrd: merge branch 'bg/initrd-wait-rh1853348'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/599

(cherry picked from commit 9f4ab95c01)
2020-08-12 17:30:22 +02:00
Beniamino Galvani
98ccd2a10e
initrd: wait for bootdev or all devices if rd.neednet=1
The network-legacy dracut module waits for all ethernet devices if the
command line contains rd.neednet=1. It also waits for the device
specified by 'bootdev='.

Do the same.

https://bugzilla.redhat.com/show_bug.cgi?id=1853348
(cherry picked from commit f114e16fdd)
2020-08-12 17:30:21 +02:00
Beniamino Galvani
e2830af77a
initrd: disable STP on bridges
NM enables by default STP on bridges, which causes a forwarding delay
of 15 seconds on boot. Disable it.

(cherry picked from commit 0a006c0412)
2020-08-12 17:30:21 +02:00
Thomas Haller
df5785f22e
core: merge branch 'th/settings-wait-device-timeout'
https://bugzilla.redhat.com/show_bug.cgi?id=1853348

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

(cherry picked from commit 63daaa6d21)
2020-08-12 16:46:24 +02:00
Thomas Haller
7ab8c5ba25
settings: rework wait-device-timeout handling and consider device compatibility
A profile can configure "connection.wait-device-timeout" to indicate
that startup complete is blocked until a suitable device around.
This is useful for NetworkManager-wait-online and initrd mode.

Previously, we looked at NMPlatform whether a link with matching
interface-name was present. That is wrong because it cannot handle
profiles that rely on "ethernet.mac-address" setting or other "match"
settings. Also, the mere presence of the link does not yet mean
that the NMDevice was created and ready. In fact, there is a race here:
NMPlatform indicates that the device is ready (unblocking NMSettings),
but there is no corresponding NMDevice yet which keeps NetworkManager
busy to block startup complete.

Rework this. Now, only check whether there is a compatible device for
the profile.

Since we wait for compatible devices, it works now not only for the
interface name. Note that we do some optimizations so that we don't have
to re-evaluate all profiles (w.r.t. all devices) whenever something on the
device changes: we only care about this when all devices finally become
ready.

Also, we no longer start the timeout for "connection.wait-device-timeout"
when the profile appears. Instead, there is one system-wide start time
(NMSettingsPrivate.startup_complete_start_timestamp_msec). That simplifies
code and makes sense: we start waiting when NetworkManager is starting, not
when the profile gets added. Also, we wait for all profiles to become
ready together.

(cherry picked from commit 3df662f534)
2020-08-12 16:46:23 +02:00
Thomas Haller
1745b4e0c0
settings: let NMSettings reference NMManager
NMSettings needs access to the list of all devices, which is tracked
by NMManager. Of course, this ties NMSettings and NMManager closer
together. Note that NMManager already owns a reference to NMSettings,
so they are in fact related.

The alternatives of just letting NMSettings reference NMManager (and
vice versa) would be more complicated, and likely not help to simplify
the code (on the contrary).

(cherry picked from commit d27a6055b9)
2020-08-12 16:46:23 +02:00
Antonio Cardace
61e0b949b3
bond: merge branch 'ac/bond_reapply'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/598
(cherry picked from commit ac6f21cae4)
2020-08-06 18:05:59 +02:00
Antonio Cardace
88a399637a
bond: let 'reapply()' reapply all supported options
Reapply now handles all the options supported by kernel and NM, meaning
that some options are simply not allowed to be set while keeping the
bond up, one of those options is the mode for instance.

https://bugzilla.redhat.com/show_bug.cgi?id=1847814
(cherry picked from commit 746dc119a6)
2020-08-06 17:57:23 +02:00
Antonio Cardace
63b5274dda
bond: fix can_reapply_change() false positives
can_reapply_change() would wrongly return true for
unsupported reapply values because it used 'nm_setting_bond_get_option_default()'
that is ill-named because it returns the overriden option other than
its default value.

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

Fixes: 9bd07336ef ('bond: bond options logic rework')
(cherry picked from commit 04d6ca1fb8)
2020-08-06 17:57:12 +02:00
Antonio Cardace
908d1f6cb7
shared: extend NM_IN_STRSET and NM_IN_SET to support up to 20 args
https://bugzilla.redhat.com/show_bug.cgi?id=1847814
(cherry picked from commit 2e70391033)
2020-08-06 17:54:42 +02:00
Beniamino Galvani
0af19c832b dhcp: merge branch 'bg/dhcpv6-hostname-rh1858344'
Fix setting hostname from DHCPv6

https://bugzilla.redhat.com/show_bug.cgi?id=1858344
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/589
(cherry picked from commit 7bf7223ece)
2020-08-06 11:26:46 +02:00
Beniamino Galvani
4e1da002a9 policy: get the DHCPv6 hostname from the FQDN option
There isn't any 'host-name' option for DHCPv6. Read instead the
'fqdn-fqdn' option that carries the FQDN assigned by the server to the
client.

(cherry picked from commit 1f74ea52f5)
2020-08-06 11:22:28 +02:00
Beniamino Galvani
c6a7618f2b dhcp: export the DHCPv6 FQDN option
The dhclient backend already exports all the option passed by
dhclient, including the FDQN. Export it also for the systemd backend.

(cherry picked from commit 1621a6ddb1)
2020-08-06 11:22:28 +02:00
Beniamino Galvani
813fb7d64e systemd: dhcp6: parse the FQDN option
Parse option 39 (Client Fully Qualified Domain Name, RFC 4704) from the DHCP
reply, which specifies the FQDN assigned by the server to the client.

c43eea9f2e
2020-08-06 11:21:52 +02:00
Beniamino Galvani
e2248143af systemd: dhcp6: remove assertions in dhcp6_option_parse_domainname()
Assertions are for programming errors; here the input comes directly
from the DHCP response packet.

af710b535b
2020-08-06 11:20:19 +02:00
Li-Hao Liao (Leon Liao)
0107c1add3 platform: add the NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE status check
In some cases, the wow is not configured and the
NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE is set.
So, add the NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE status check.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/597
(cherry picked from commit 3ba31aad58)
2020-08-06 11:06:08 +02:00
Thomas Haller
029d07b019
wifi: avoid crash due to incomplete Wi-Fi API info
In this case, GetAll failed with "Timeout was reached". We still
create a dummy BSS info, because we kept track of the object to
start with. That way, we don't simply want to ignore the failure,
because NMDeviceWifi might track this NMWifiAP already, and we may
need an update (even if we failed to fetch the requested information).

However, that later leads to a crash, because NMDeviceWifi expect the BSSID
present then.

Avoid that, by don't processing such APs.

    #0  g_logv (log_domain=0x7f2ac10a60a9 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=<optimized out>) at ../glib/gmessages.c:1377
    #1  0x00007f2acf152233 in g_log
        (log_domain=log_domain@entry=0x7f2ac10a60a9 "NetworkManager", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7f2acf1a46ff "%s: assertion '%s' failed")
        at ../glib/gmessages.c:1415
    #2  0x00007f2acf152a2d in g_return_if_fail_warning
        (log_domain=log_domain@entry=0x7f2ac10a60a9 "NetworkManager", pretty_function=pretty_function@entry=0x7f2ac10a9e70 <__func__.50> "try_fill_ssid_for_hidden_ap", expression=expression@entry=0x7f2ac10a86d0 "bssid") at ../glib/gmessages.c:2771
    #3  0x00007f2ac108a402 in try_fill_ssid_for_hidden_ap (ap=0x5569978b61c0 [NMWifiAP], self=0x55699786ea00 [NMDeviceWifi]) at src/devices/wifi/nm-device-wifi.c:1883
    #4  supplicant_iface_bss_changed_cb (iface=0x556997777260 [NMSupplicantInterface], bss_info=0x7f2ab4028f00, is_present=1, self=0x55699786ea00 [NMDeviceWifi])
        at src/devices/wifi/nm-device-wifi.c:1946
    #5  0x00007f2ace246af0 in ffi_call_unix64 () at ../src/x86/unix64.S:76
    #6  0x00007f2ace2462ab in ffi_call (cif=cif@entry=0x7ffd9c107c90, fn=fn@entry=0x7f2ac1089e80 <supplicant_iface_bss_changed_cb>, rvalue=<optimized out>, avalue=avalue@entry=0x7ffd9c107ba0)
        at ../src/x86/ffi64.c:525
    #7  0x00007f2acf23e87a in g_cclosure_marshal_generic_va
        (closure=<optimized out>, return_value=<optimized out>, instance=<optimized out>, args_list=<optimized out>, marshal_data=<optimized out>, n_params=<optimized out>, param_types=<optimized out>) at ../gobject/gclosure.c:1614
    #8  0x00007f2acf23dae6 in _g_closure_invoke_va
        (closure=closure@entry=0x5569978a0cc0, return_value=return_value@entry=0x0, instance=instance@entry=0x556997777260, args=args@entry=0x7ffd9c107f00, n_params=2, param_types=0x55699775b990) at ../gobject/gclosure.c:873
    #9  0x00007f2acf2566e9 in g_signal_emit_valist (instance=0x556997777260, signal_id=<optimized out>, detail=0, var_args=var_args@entry=0x7ffd9c107f00) at ../gobject/gsignal.c:3407
    #10 0x00007f2acf256c63 in g_signal_emit (instance=instance@entry=0x556997777260, signal_id=<optimized out>, detail=detail@entry=0) at ../gobject/gsignal.c:3554
    #11 0x00005569972ece61 in _bss_info_changed_emit (self=self@entry=0x556997777260 [NMSupplicantInterface], bss_info=bss_info@entry=0x7f2ab4028f00, is_present=is_present@entry=1)
        at src/supplicant/nm-supplicant-interface.c:555
    #12 0x00005569972ed3a0 in _bss_info_properties_changed (self=0x556997777260 [NMSupplicantInterface], bss_info=0x7f2ab4028f00, properties=<optimized out>, initial=<optimized out>)
        at src/supplicant/nm-supplicant-interface.c:758
    #13 0x00005569972f756b in _bss_info_get_all_cb (result=0x0, error=<optimized out>, user_data=0x7f2ab4028f00) at src/supplicant/nm-supplicant-interface.c:784
    #14 0x0000556997217bc1 in _nm_dbus_connection_call_default_cb (source=0x5569977480c0 [GDBusConnection], res=<optimized out>, user_data=user_data@entry=0x556997855d50)
        at shared/nm-glib-aux/nm-dbus-aux.c:74
    #15 0x00007f2acf339e4a in g_task_return_now (task=task@entry=0x7f2ab4003f00 [GTask]) at ../gio/gtask.c:1214
    #16 0x00007f2acf33aa3d in g_task_return (task=0x7f2ab4003f00 [GTask], type=<optimized out>) at ../gio/gtask.c:1283
    #17 0x00007f2acf33b4fe in g_task_return (type=G_TASK_RETURN_ERROR, task=<optimized out>) at ../gio/gtask.c:1861
    #18 g_task_return_error (task=<optimized out>, error=<optimized out>) at ../gio/gtask.c:1867
    #19 0x0000556997893f40 in  ()
    #20 0x3a85d39adfae7f00 in  ()
    #21 0x00007f2ab4003cc0 in  ()
    #22 0x00007f2acf396460 in g_dbus_connection_call_done () at ../gio/gdbusconnection.c:2059
    #23 0x00007f2ab4003f00 in  ()
    #24 0x0000000000000086 in  ()
    #25 0x0000000000000018 in  ()
    #26 0x00007f2acf339e4a in g_task_return_now (task=0x7f2ab4003f00 [GTask], task@entry=0x7f2ab4003cc0 [GTask]) at ../gio/gtask.c:1214
    #27 0x00007f2acf33aa3d in g_task_return (task=0x7f2ab4003cc0 [GTask], type=<optimized out>) at ../gio/gtask.c:1283
    #28 0x00007f2acf33b4fe in g_task_return (type=G_TASK_RETURN_ERROR, task=<optimized out>) at ../gio/gtask.c:1861
    #29 g_task_return_error (task=<optimized out>, error=<optimized out>) at ../gio/gtask.c:1867
    #30 0x0000003000000028 in  ()
    #31 0x00007ffd9c108290 in  ()

Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')
(cherry picked from commit 4d878d7012)
2020-08-04 19:27:47 +02:00
Thomas Haller
181fd5c611
cloud-setup: fix allocating buffer for GetConfigMetadataMac in _get_config_metadata_ready_check()
It's not a severe issue, because the GetConfigMetadataData struct is
larger than GetConfigMetadataMac.

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
(cherry picked from commit 460afe6d50)
2020-08-04 19:27:47 +02:00
Beniamino Galvani
80835f8f89 n-dhcp4: fix BPF filter endianness issue
The BPF filter takes the byte containing IP Flags and performs a
bitwise AND with "ntohs(IP_MF | IP_OFFMASK)".

On little-endian architectures the IP_MF flag (0x20) is ANDed with
0xFF3F and so the presence of the flag is correctly detected ignoring
other flags as IP_DF (0x40) or IP_RF (0x80).

On big-endian, "ntohs(IP_MF | IP_OFFMASK)" is 0x3FFF and so the filter
wrongly checks the presence of *any* flags. Therefore, a packet with
the DF flag set is dropped.

Instead, take the two bytes containing flags and offset:

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |Version|  IHL  |Type of Service|          Total Length         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |         Identification        |Flags|      Fragment Offset    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

and verify that IP_MF and the offset are zero.

Fixes: e43b1791a3 ('Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4'')

https://bugzilla.redhat.com/show_bug.cgi?id=1861488
https://github.com/nettools/n-dhcp4/pull/19
(cherry picked from commit 03d38e83e558802a82cb0e4847cb1f1ef75ccd16)
(cherry picked from commit 0024cef238)
2020-08-04 16:28:11 +02:00
Thomas Haller
da2c6eaae7
gitlab-ci: check "examples/python/gi/nm-wg-set" with black
(cherry picked from commit 9fa59c156b)
2020-08-04 15:02:00 +02:00
Thomas Haller
4cddb12bbf
examples: run python black on "examples/python/gi/nm-wg-set"
black by default only considers files that have a ".py" extension.

(cherry picked from commit 1acd64b7a2)
2020-08-04 15:01:37 +02:00
Beniamino Galvani
905d4eb36e dhcp6: don't require a hardware address
The systemd DHCPv6 client requires a hardware address only to
determine the IAID; NM always overrides the IAID with its own and
therefore the hwaddr is not used.

Removing such requirement allows DHCPv6 to run over PPP, which is
useful with DHCPv6-PD to get a prefix from the ISP.

To test this, I set up a server with pppoe-server, radvd and the Wide
DHCPv6 server providing an address and a prefix. On the client, NM was
able to obtain a prefix using both dhcp=dhclient and dhcp=systemd.

Note that if there is no hardware address and you specify
ipv6.dhcp-duid=ll or ipv6.dhcp-iaid=mac, a warning will be emitted and
NM will use a random DUID/IAID.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/478
(cherry picked from commit 76a6a30577)
2020-07-29 18:21:38 +02:00
Beniamino Galvani
ce3dffd24e device: downgrade warning about IPv6 MTU if IPv6 is disabled
If IPv6 is disabled, changing the IPv6 MTU fails and NM complains with
a warning. Since this error is expected and doesn't do any harm,
downgrade the logging level to DEBUG.

Since IPv6 kernel support can be built as a module, we have to check
the existence of /proc/sys/net/ipv6 every time. Instead of checking it
and then setting the MTU (adding one /proc access for everyone), just try
to set the MTU; in case of failure, determine the reason for the error.

https://bugzilla.redhat.com/show_bug.cgi?id=1840989
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/585
(cherry picked from commit 9c09dcedaf)
2020-07-24 13:43:18 +02:00
Beniamino Galvani
dc3f9f52ab libnm-core: support 'clsact' qdisc
The 'clsact' qdisc is similar to 'ingress' but supports both ingress
and egress [1]. It uses the same handle as 'ingress' and has two child
classes :fff2 (ingress) and :fff3 (egress) on which filters can be
attached.

With clsact, for example, it becomes possible to do port mirroring
with a single qdisc:

  nmcli connection modify mirror +tc.qdisc "clsact"
  nmcli connection modify mirror +tc.tfilter
    "parent ffff:fff3 matchall action mirred egress mirror dev dummy1"
  nmcli connection modify mirror +tc.tfilter
    "parent ffff:fff2 matchall action mirred egress mirror dev dummy1"

instead of two (ingress + i.e. prio). We don't support yet the
symbolic names 'ingress' and 'egress' for :fff2 and :fff3 in the
filter.

See-also: https://bugzilla.redhat.com/show_bug.cgi?id=1436535

[1] https://lwn.net/Articles/671458/

(cherry picked from commit e6acf64859)
2020-07-23 14:19:50 +02:00
Thomas Haller
a99be8c009 libnm: use nm_streq() in "libnm-core/nm-utils.c"
(cherry picked from commit 3945471752)
2020-07-23 14:19:42 +02:00
Beniamino Galvani
90cb61f8fd merge: branch 'bg/sleep-unmanaged-rh1855563'
https://bugzilla.redhat.com/show_bug.cgi?id=1855563
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/580

(cherry picked from commit 116c49fceb)
2020-07-21 09:07:58 +02:00
Beniamino Galvani
e1755048e3 policy: block connection from autoconnect in case of failed dependency
A connection that fails due to dependency-failed is not able to
reconnect until the master connection activates again; when this
happens, the master clears the blocked reason for all its slaves in
activate_slave_connections() and tries to reconnect them. For this to
work, the slave should be marked as blocked when it fails with
dependency-failed.

(cherry picked from commit 725fed01cf)
2020-07-21 09:07:58 +02:00
Beniamino Galvani
971897195a manager: fix race condition when resuming from sleep
If the device state change (to disconnected or unmanaged) triggered by
a sleep event happens after the wake, the devices becomes wrongly
unmanaged and it's necessary to manually manage it again, or restart
NM.

During the wake event we should disconnect the device_sleep_cb()
callback for all devices because we don't want to react to state
changes anymore; in particular we don't need to detect when the device
becomes disconnected to unmanage it.

(cherry picked from commit fe2d93980b)
2020-07-21 09:07:57 +02:00
Beniamino Galvani
5555887e12 po: RHEL 8.3 translations - fr,ja,zh-CN
(cherry picked from commit 74a36168bb)
2020-07-17 16:02:23 +02:00
Beniamino Galvani
223f741810 core: fix check on master active-connection failure
The previous check was never satisfied, as the device is assigned to
the active-connection and realized early. Instead, check the
master_ready flag, which tells if the master is ready and, therefore,
if the slave has already been added to the master.

Before this commit, in some cases a device didn't detect that the
master failed and kept waiting forever.

https://bugzilla.redhat.com/show_bug.cgi?id=1845018
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/568
(cherry picked from commit 0911d2a4ee)
2020-07-17 08:59:45 +02:00
Beniamino Galvani
680c0b8812 team: perform cleanup immediately when connecting to teamd fails
When NM fails to connect to teamd during an activation, it sets the
device state to FAILED. Eventually the device will become DISCONNECTED
and will call the ->deactivate() method that will perform the cleanup
of timers, teamd process and teamdctl instance.

However, in this way, when the device is DISCONNECTED timers are still
armed and can be triggered in the wrong state. Instead, perform the
cleanup immediately on failure.

https://bugzilla.redhat.com/show_bug.cgi?id=1856723
(cherry picked from commit 26e97fcd0d)
2020-07-16 09:44:54 +02:00
Antonio Cardace
c24394c3dc
core: merge branch 'ac/vrf_local_route_fix'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/579

(cherry picked from commit 1b1a764445)
2020-07-15 11:54:52 +02:00