Commit graph

27991 commits

Author SHA1 Message Date
Thomas Haller
008302aa4e
all: use NM_IW_ESSID_MAX_SIZE define instead of literally 32 2021-03-18 11:38:21 +01:00
Thomas Haller
cd00b04099
libnm: expose NM_IW_ESSID_MAX_SIZE define 2021-03-18 11:30:56 +01:00
Andrew Zaborowski
1708e9a3cc
iwd: Don't call IWD methods when device unmanaged
When using IWD-side autoconnect mode (current default), in .deactivate()
and .deactivate_async() refrain from commanding IWD to actually
disconnect until the device is managed.  Likely the device is already
disconnected but in any case it's up to IWD to decide in this mode.

Calling IWD device's .Disconnect() D-Bus method has the side effect of
disabling autoconnect and doing this while NM is still in platform-init
was unexpectedly leaving the device without autoconnect after
platform-init was done, according to user reports.

Fixes: dc0e31fb70 ('iwd: Add the wifi.iwd.autoconnect setting')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/786
2021-03-18 10:28:38 +01:00
Thomas Haller
758fbd7aac
glib-aux: use g_cancellable_connection() in nm_utils_invoke_on_idle() and cleanup
Use g_cancellable_connect(). That approach better handles the case where the
cancellable is already cancelled. Theoretically, we could extend that
approach further and make it thread-safe, but in the current form is
nm_utils_invoke_on_idle() not thread-safe.

While at it, also cleanup duplicate code during completion.
2021-03-18 10:23:46 +01:00
Thomas Haller
b4c25f9131
tests/client: increase timeout to wait for process
We now get unit test failures hitting this timeout. That is
likely a new bug introduced somewhere, but to rule out that
the timeout is simply too short, increase it.
2021-03-17 10:57:52 +01:00
Beniamino Galvani
0f8fe3c76b initrd: fix crash parsing empty rd.znet argument
Ignore a rd.znet argument without subchannels. When using net.ifnames
(the default), subchannels are used to build the interface name, which
is required to match the right connection.

With net.ifnames=0 the interface name is build using a prefix and a
global counter and therefore in theory it is possible to omit
subchannels. However, without subchannels there won't be a udev rule
that renames the interface and so it can't work.

https://bugzilla.redhat.com/show_bug.cgi?id=1931284
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/783
2021-03-17 10:02:09 +01:00
Thomas Haller
9c0c0ac966
man: split NetworkManager-dispatcher(8) manual page out of NetworkManager(8)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/784
2021-03-16 17:01:53 +01:00
Thomas Haller
ed6621bdcd
CONTRIBUTING: style fixes and improve text 2021-03-16 14:29:08 +01:00
Thomas Haller
fb66bb2bcb
CONTRIBUTING: rename file to have .md extension
We should write our CONTRIBUTING files in markdown syntax, because
it's nice to read a plain text and gets nicely rendered.

However, if the file doesn't have a ".md" extension, gitlab's
web interface shows it as plain text file.

Rename the file.

This possibly breaks links like [1], but referring to a branch name
(and not a commit ID or a tag) is anyway fragile. Hence, I don't try
to fix that by adding a symlink or similar, because I think that just
makes it more confusing.

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/master/CONTRIBUTING
2021-03-16 14:00:01 +01:00
Thomas Haller
aaf2c5c2dd
man: document NOZEROCONF in man nm-settings-ifcfg-rh 2021-03-16 13:45:39 +01:00
Thomas Haller
e91acb2806
libnm/s390: Merge branch 'th/s390-option-bridge-role'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/782
2021-03-16 13:17:56 +01:00
Thomas Haller
c91dfb850e
initrd: avoid cloning string in reader_parse_rd_znet()
The code did:

   key    = g_strndup(tmp, val - tmp);
   val[0] = '\0';

That is pointless. If we strndup the key, we don't need to truncate
the string at the '='. It might be nicer not to mutate the input string,
however, the entire code with "argument" parsing is about mutating the
input string, so that is something we apparently are fine with.

As such, don't clone the string anymore.
2021-03-16 11:58:09 +01:00
Thomas Haller
bb132cd6de
libnm: verify ethernet.s390-options.bridge_role value
I don't want to fix this for all "ethernet.s390-options" options,
but at least strictly validate the newly introduced option.
2021-03-16 11:56:31 +01:00
Thomas Haller
a9e4d020cb
shared/tests: add nmtst_rand_select_str() helper 2021-03-16 11:56:29 +01:00
Thomas Haller
b377a7d0c9
trivial: fix whitespace for comments in "libnm-glib-aux/nm-macros-internal.h" 2021-03-16 09:58:48 +01:00
Thomas Haller
6e4cdae256
all: split "range" variant of nm_utils_ptrarray_find_binary_search()
nm_utils_ptrarray_find_binary_search() had two additional output
arguments: the first and last index -- in case the sorted list contains
duplicates.

That's nice, and was used in the past. But now, those output arguments
are no longer used.

So drop them from nm_utils_ptrarray_find_binary_search().

Actually, we could now also drop the previous variant
nm_utils_ptrarray_find_binary_search_range(), as it's only used by unit
tests. However, although not rocket science, getting this right is not
entirely trivial, so lets keep the code in case we need it again.
2021-03-16 09:55:49 +01:00
Thomas Haller
7fde244ed2
libnm: don't assert against valid s390-option keys in nm_setting_wired_add_s390_option()
Asserting against user input is not nice, because it always requires the
caller to check the value first. Don't do that.

Also, don't even check. You can set NM_SETTING_WIRED_S390_OPTIONS
property to any values (except duplicated keys). The C add function
should not be more limited than that. This is also right because
we have verify() which checks for valid settings. And it does so beyond
only checking the keys.

So you could set NM_SETTING_WIRED_S390_OPTIONS properties to invalid
keys. And you could use nm_setting_wired_add_s390_option() to set
invalid values. No need to let nm_setting_wired_add_s390_option() check
for valid keys.
2021-03-16 09:55:49 +01:00
Thomas Haller
74a4ee16f5
initrd: silently ignore invalid "ethernet.s390-options" 2021-03-16 09:55:48 +01:00
Thomas Haller
e25c458b6f
libnm: add _nm_setting_wired_is_valid_s390_option_value() validation function 2021-03-16 09:55:48 +01:00
Thomas Haller
ddc41d427a
libnm: add internal _nm_setting_wired_is_valid_s390_option() helper 2021-03-16 09:55:48 +01:00
Thomas Haller
fb0ac2e700
libnm: cleanup nm_setting_wired_add_s390_option()
- integers are unsigned. Mark the constants as such.

- assert that we don't overflow G_MAXUINT32. Note that
  nm_setting_wired_get_s390_option()'s index argument
  is of type guint32. So with that API you cannot track
  more than G_MAXUINT32 elements.

- use nm_utils_strdup_reset(). It's less code, but it's
  also self-assignment safe (contrary to the previous code).
2021-03-16 09:55:48 +01:00
Thomas Haller
9f93b0495b
libnm: improve error message for verify() failure for ethernet.s390-options 2021-03-16 09:55:48 +01:00
Thomas Haller
1794d80028
libnm: mark option parameters for nm_setting_wired_get_num_s390_options() as (allow-none) 2021-03-16 09:55:48 +01:00
Thomas Haller
dccfe1df34
libnm: use nm_utils_strv_find_binary_search() in valid_s390_opts_check() 2021-03-16 09:55:48 +01:00
Thomas Haller
b9d73cfb2d
libnm: only check once for valid static array in valid_s390_opts_check()
No need to check every time. The buffer is a const global buffer,
so checking it once is enough.
2021-03-16 09:55:48 +01:00
Thomas Haller
80c98b60da
libnm: make list of valid s390s options const
A const global variable is stored in immutable memory.
You thus get a crash trying to modify it, which is desirable.

The user is really not supposed to modify this buffer,
even if nm_setting_wired_get_valid_s390_options() wrongly
returns a non-const pointer.
2021-03-16 09:55:48 +01:00
Thomas Haller
ec6e9f0cac
core: minor cleanup in NMDeviceEthernet:update_connection() to set s390 options
We should have variables of the correct type and cast where necessary,
and not use void pointers.
2021-03-16 09:55:47 +01:00
Thomas Haller
07610da4ca
shared: add mutable union field NMUtilsNamedValue.{name,value_str}_mutable
NMUtilsNamedValue is a generic tuple that we use for different purposes.
Often we require a mutable string, so add a union alias for that case.
2021-03-16 09:55:47 +01:00
Thomas Haller
ca869bff9f
shared: add nm_utils_strv_find_binary_search() helper 2021-03-16 09:55:47 +01:00
Thomas Haller
e4aa3f4b2d
libnm: add "bridge_role" option to "ethernet.s390-options"
https://bugzilla.redhat.com/show_bug.cgi?id=1935842
2021-03-16 09:02:07 +01:00
Jagadeesh Kotra
3df607f3c2
examples: use python3 compatible exception syntax
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/781
2021-03-16 07:55:12 +01:00
Wen Liang
ec3e2561a8
libnm/doc: document the type of each LLDP attribute of libnm
Signed-off-by: Wen Liang <liangwen12year@gmail.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/777
2021-03-15 17:40:14 +01:00
Thomas Haller
48c0305bb2
all: merge branch 'th/initrd-move'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/778
2021-03-15 17:11:25 +01:00
Thomas Haller
60c90f4410
build: fix dependencies for building src/libnm-platform/wifi/*
CC       src/libnm-platform/wifi/libnm_platform_la-nm-wifi-utils-wext.lo
    In file included from ../src/libnm-platform/wifi/nm-wifi-utils-wext.c:7:
    In file included from ../src/libnm-glib-aux/nm-default-glib-i18n-lib.h:13:
    In file included from ../src/libnm-glib-aux/nm-default-glib.h:11:
    ../src/libnm-std-aux/nm-default-std.h:30:10: fatal error: config-extra.h file not found
    #include "config-extra.h"
             ^~~~~~~~~~~~~~~~
      ...
      GEN      config-extra.h
2021-03-15 17:10:57 +01:00
Thomas Haller
e643703418
tests/client: run "test-client.py" also for meson 2021-03-15 17:10:56 +01:00
Thomas Haller
019bc3233a
client/tests: move "clients/tests/test-client.py" to "src/tests/client/"
Note that "test-client.py" currently only tests nmcli. But what it does
is to spawn test-networkmanager-service.py and run nmcli against it.

As such, it could really be used to test any NetworkManager client
against the stub service. Hence this test is not under
"src/nmcli/tests", but under "src/tests/client/" where it is more
general.
2021-03-15 17:10:55 +01:00
Thomas Haller
d8dd6e94e6
tui: move from "clients/tui/" to "src/nmtui/" 2021-03-15 17:10:54 +01:00
Thomas Haller
61f99307c6
cli: move from "clients/cli/" to "src/nmcli/" 2021-03-15 17:10:54 +01:00
Thomas Haller
71f0511b1f
cloud-setup: move from "clients/cloud-setup/" to "src/nm-cloud-setup/" 2021-03-15 17:10:53 +01:00
Thomas Haller
9fc1bf90fa
initrd: move "src/core/initrd/" to "src/nm-initrd-generator/" 2021-03-15 17:10:53 +01:00
Thomas Haller
9d647cbcbc
initrd: don't include headers of the daemon from src/core/ 2021-03-15 17:10:53 +01:00
Thomas Haller
0033da8f61
config: add "nm-base/nm-config-base.h"
Note that we take defines from "src/core/nm-config.h" which
are GPL-2.0-or-later licensed.

libnm-base we want to include in other LGPL licensed sources,
we it must also be LGPL.

"relicense" the code that I take. I don't think it's a problem, because:

- these are only plain defines. To which extend is that even
  copyrightable?

- as far as I see, all the code was contributed by people who agreed
  to such relicensing. See RELICENSE.md file.
2021-03-15 17:10:52 +01:00
Thomas Haller
5235ea3bf4
tests: move nmtst_init_with_logging() to "libnm-glib-aux/nm-test-utils.h" 2021-03-15 17:10:52 +01:00
Thomas Haller
e08a0a3a68
build/meson: fix test name for "test-dispatcher-envp" 2021-03-15 17:10:52 +01:00
Thomas Haller
2b37659c62
build/meson: don't try to buildlibnmt-newt without libnewt 2021-03-15 17:10:52 +01:00
Thomas Haller
10b4d10c9b
build: fix setting CFLAGS when building "libnm-vpn-plugin-utils-test.la"
Internally we set CPPFLAGS, because setting CFLAGS disables inheriting AM_CFLAGS --
which we use for example for "-Wno-pragmas" from the configure script.
2021-03-15 17:10:52 +01:00
Thomas Haller
0d856432b7
initrd/tests: avoid variable declaration in for loop in test_if_off()
src/core/initrd/tests/test-cmdline-reader.c: In function test_if_off:
    src/core/initrd/tests/test-cmdline-reader.c:564:5: error: for loop initial declarations are only allowed in C99 mode
        for (int i = 0; i < G_N_ELEMENTS(conn_expected); ++i) {
        ^
    src/core/initrd/tests/test-cmdline-reader.c:564:5: note: use option -std=c99 or -std=gnu99 to compile your code
2021-03-15 17:10:52 +01:00
Thomas Haller
c96a21e3cf
wwan/ofono: merge branch 'pr/771'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/771
2021-03-15 13:33:20 +01:00
Bhushan Shah
0daea018c6
wwan/ofono: use gs_unref_variant instead of g_variant_unref 2021-03-15 13:32:47 +01:00
Tony Espy
e4941696be
wwan/modem: do not mark connection as failed when connection drops
If the modem is connected, and registrations drops, and then is restored, the
connection isn't re-activated.

The fix was simply to change modem_state_cb to not return after setting the
state to failed, which allows nm_device_queue_recheck_available to be called,
which queues a state transition to UNAVAILABLE.
2021-03-15 13:32:47 +01:00