Thomas Haller
eef6c3f88e
core: add nm_auth_is_invocation_in_acl_set_error() helper
2020-09-29 11:51:14 +02:00
Thomas Haller
e8f72a2e4b
gitlab-ci: combine tests for checkpatch/black/msgfmt and nm-code-format.sh
...
There is no need spawn up two containers (and install similar packages, doing so is
resource intensive), to run two different tests. We can run them in the same
container.
At this point Fedora 33 is not yet fully released. But it will happen soon, so the
image is stable enough for these kinds of tests (and will only get more
stable in the following weeks).
Also no longer collect an artifact with the test output. The test output
is already nicely visible in the gitlab-ci UI. No need to collect it
separately.
2020-09-29 09:46:02 +02:00
Thomas Haller
0e71236d08
contributing: update CONTRIBUTING file with new style guide
2020-09-29 09:19:29 +02:00
Thomas Haller
12823f60af
format: replace tabs with spaces in sheell scripts
2020-09-29 09:19:29 +02:00
Thomas Haller
8841d529e1
format: manually replace remaining tabs with spaces and reformat
2020-09-29 09:12:27 +02:00
Thomas Haller
89ed75df16
format: use spaces instead of indentation for manually formatted parts in "nm-meta-setting-desc.c"
2020-09-29 08:58:11 +02:00
Thomas Haller
2bc3588c1d
all/systemd: reformat ./{shared,src}/systemd/ with new clang-format style
...
./contrib/scripts/nm-code-format.sh -i
2020-09-28 20:01:29 +02:00
Thomas Haller
8435deecfa
contrib: let "nm-code-format.sh" handle files under ./{shared,src}/systemd/
...
Only the files under ./{shared,src}/systemd/src are copied from systemd.
The other files should be reformatted too.
2020-09-28 20:01:23 +02:00
Antonio Cardace
e284a23d8c
all: merge branch 'ac/clang-format'
...
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/617
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 18:20:54 +02:00
Thomas Haller
740b092fda
format: replace tabs for indentation in code comments
...
sed -i \
-e 's/^'$'\t'' \*/ */g' \
-e 's/^'$'\t\t'' \*/ */g' \
-e 's/^'$'\t\t\t'' \*/ */g' \
-e 's/^'$'\t\t\t\t'' \*/ */g' \
-e 's/^'$'\t\t\t\t\t'' \*/ */g' \
-e 's/^'$'\t\t\t\t\t\t'' \*/ */g' \
-e 's/^'$'\t\t\t\t\t\t\t'' \*/ */g' \
$(git ls-files -- '*.[hc]')
2020-09-28 16:07:52 +02:00
Antonio Cardace
328fb90f3e
all: reformat all with new clang-format style
...
Run:
./contrib/scripts/nm-code-format.sh -i
./contrib/scripts/nm-code-format.sh -i
Yes, it needs to run twice because the first run doesn't yet produce the
final result.
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 16:07:51 +02:00
Antonio Cardace
b4d8e69cd4
cli: use C comment to not break clang-formatting
...
clang-format will re-format this in multiple lines, use C comment
to not break compilation after applying code-style with clang-format.
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 16:01:23 +02:00
Antonio Cardace
e8b54b9ddf
libnm-core: turn off clang-format for 'glib-mkenums'
...
glib-mkenums doesn't work with enums on single line
or with enums entries that span multiple lines, turn off
automatic formatting for these special cases to not break
docs generation.
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 15:46:32 +02:00
Antonio Cardace
059c144afb
clients: exclude code region of nm-meta-setting-desc.c from formatting
...
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 15:08:42 +02:00
Antonio Cardace
471c5b7c1d
tools: update script for new code-style
...
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 15:08:42 +02:00
Antonio Cardace
faa8053802
gitlab-ci: add clang-format test on fedora 33 which run clang-format 11
...
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 15:08:41 +02:00
Thomas Haller
419be5d0e7
checkpatch.pl: adjust checking for indentation/tabs
...
Our new format gets enforced by clang-format, and we now only use
four space indentation, instead of tabs.
Adjust the checkpatch script to account for that.
Also, now there are probably no cases left where we want to see any
tabs in our sources. Complain about any tabs we find.
2020-09-28 15:08:41 +02:00
Antonio Cardace
76bb1f91a5
clang-format: add clang-format proposed code-style file
...
Signed-off-by: Antonio Cardace <acardace@redhat.com>
2020-09-28 15:08:41 +02:00
Thomas Haller
40e4c0d60e
all: merge branch 'th/getpwuid'
...
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/635
2020-09-28 10:04:28 +02:00
Thomas Haller
99abd397d0
all: use nm_utils_name_to_uid() instead of getpwnam()
2020-09-25 21:03:28 +02:00
Thomas Haller
714955c3b5
all: use nm_utils_uid_to_name() instead of getpwuid()
...
We shouldn't use non-threadsafe API. We don't really know what
other threads (e.g. GDBus' helper thread or GResolver) are doing.
2020-09-25 21:03:28 +02:00
Thomas Haller
39b52d0fd0
shared: add nm_utils_uid_to_name()/nm_utils_name_to_uid() helpers
...
These are inspired by systemd.
We should replace our calls to getpwuid() and getpwnam() with
their thread safe variants.
We run possibly multiple threads (e.g. helper threads from GDBus and
GResolver). It's hard to be sure that they don't also access the
functions.
2020-09-25 21:03:27 +02:00
Thomas Haller
0efa507265
systemd: merge branch systemd into master
2020-09-24 11:32:37 +02:00
Thomas Haller
3aca45ed55
shared,libnm: avoid mixing signed and unsigned integers in netmask_to_prefix()/prefix_to_netmask()
2020-09-24 11:07:36 +02:00
Thomas Haller
d4d0c696f9
systemd: update code from upstream (2020-09-24)
...
This is a direct dump from systemd git.
======
SYSTEMD_DIR=../systemd
COMMIT=960b585ba116cc09055d3f5540a0c73e088d37e4
(
cd "$SYSTEMD_DIR"
git checkout "$COMMIT"
git reset --hard
git clean -fdx
)
git ls-files -z :/src/systemd/src/ \
:/shared/systemd/src/ \
:/shared/nm-std-aux/unaligned.h | \
xargs -0 rm -f
nm_copy_sd_shared() {
mkdir -p "./shared/systemd/$(dirname "$1")"
cp "$SYSTEMD_DIR/$1" "./shared/systemd/$1"
}
nm_copy_sd_core() {
mkdir -p "./src/systemd/$(dirname "$1")"
cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}
nm_copy_sd_stdaux() {
mkdir -p "./shared/nm-std-aux/"
cp "$SYSTEMD_DIR/$1" "./shared/nm-std-aux/${1##*/}"
}
nm_copy_sd_core "src/libsystemd-network/arp-util.c"
nm_copy_sd_core "src/libsystemd-network/arp-util.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-network.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-option.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd_core "src/libsystemd-network/lldp-internal.h"
nm_copy_sd_core "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd_core "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd_core "src/libsystemd-network/lldp-network.c"
nm_copy_sd_core "src/libsystemd-network/lldp-network.h"
nm_copy_sd_core "src/libsystemd-network/network-internal.c"
nm_copy_sd_core "src/libsystemd-network/network-internal.h"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd_core "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd_core "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd_core "src/libsystemd-network/sd-lldp.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-source.h"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.h"
nm_copy_sd_core "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd_core "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd_core "src/systemd/_sd-common.h"
nm_copy_sd_core "src/systemd/sd-dhcp-client.h"
nm_copy_sd_core "src/systemd/sd-dhcp-lease.h"
nm_copy_sd_core "src/systemd/sd-dhcp-option.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-client.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-option.h"
nm_copy_sd_core "src/systemd/sd-event.h"
nm_copy_sd_core "src/systemd/sd-id128.h"
nm_copy_sd_core "src/systemd/sd-ipv4acd.h"
nm_copy_sd_core "src/systemd/sd-ipv4ll.h"
nm_copy_sd_core "src/systemd/sd-lldp.h"
nm_copy_sd_core "src/systemd/sd-ndisc.h"
nm_copy_sd_shared "src/basic/alloc-util.c"
nm_copy_sd_shared "src/basic/alloc-util.h"
nm_copy_sd_shared "src/basic/async.h"
nm_copy_sd_shared "src/basic/cgroup-util.h"
nm_copy_sd_shared "src/basic/env-file.c"
nm_copy_sd_shared "src/basic/env-file.h"
nm_copy_sd_shared "src/basic/env-util.c"
nm_copy_sd_shared "src/basic/env-util.h"
nm_copy_sd_shared "src/basic/errno-util.h"
nm_copy_sd_shared "src/basic/escape.c"
nm_copy_sd_shared "src/basic/escape.h"
nm_copy_sd_shared "src/basic/ether-addr-util.c"
nm_copy_sd_shared "src/basic/ether-addr-util.h"
nm_copy_sd_shared "src/basic/extract-word.c"
nm_copy_sd_shared "src/basic/extract-word.h"
nm_copy_sd_shared "src/basic/fd-util.c"
nm_copy_sd_shared "src/basic/fd-util.h"
nm_copy_sd_shared "src/basic/fileio.c"
nm_copy_sd_shared "src/basic/fileio.h"
nm_copy_sd_shared "src/basic/format-util.c"
nm_copy_sd_shared "src/basic/format-util.h"
nm_copy_sd_shared "src/basic/fs-util.c"
nm_copy_sd_shared "src/basic/fs-util.h"
nm_copy_sd_shared "src/basic/hash-funcs.c"
nm_copy_sd_shared "src/basic/hash-funcs.h"
nm_copy_sd_shared "src/basic/hashmap.c"
nm_copy_sd_shared "src/basic/hashmap.h"
nm_copy_sd_shared "src/basic/hexdecoct.c"
nm_copy_sd_shared "src/basic/hexdecoct.h"
nm_copy_sd_shared "src/basic/hostname-util.c"
nm_copy_sd_shared "src/basic/hostname-util.h"
nm_copy_sd_shared "src/basic/in-addr-util.c"
nm_copy_sd_shared "src/basic/in-addr-util.h"
nm_copy_sd_shared "src/basic/io-util.c"
nm_copy_sd_shared "src/basic/io-util.h"
nm_copy_sd_shared "src/basic/list.h"
nm_copy_sd_shared "src/basic/log.h"
nm_copy_sd_shared "src/basic/macro.h"
nm_copy_sd_shared "src/basic/memory-util.c"
nm_copy_sd_shared "src/basic/memory-util.h"
nm_copy_sd_shared "src/basic/mempool.c"
nm_copy_sd_shared "src/basic/mempool.h"
nm_copy_sd_shared "src/basic/missing_fcntl.h"
nm_copy_sd_shared "src/basic/missing_random.h"
nm_copy_sd_shared "src/basic/missing_socket.h"
nm_copy_sd_shared "src/basic/missing_stat.h"
nm_copy_sd_shared "src/basic/missing_syscall.h"
nm_copy_sd_shared "src/basic/missing_type.h"
nm_copy_sd_shared "src/basic/parse-util.c"
nm_copy_sd_shared "src/basic/parse-util.h"
nm_copy_sd_shared "src/basic/path-util.c"
nm_copy_sd_shared "src/basic/path-util.h"
nm_copy_sd_shared "src/basic/prioq.c"
nm_copy_sd_shared "src/basic/prioq.h"
nm_copy_sd_shared "src/basic/process-util.c"
nm_copy_sd_shared "src/basic/process-util.h"
nm_copy_sd_shared "src/basic/random-util.c"
nm_copy_sd_shared "src/basic/random-util.h"
nm_copy_sd_shared "src/basic/set.h"
nm_copy_sd_shared "src/basic/signal-util.c"
nm_copy_sd_shared "src/basic/signal-util.h"
nm_copy_sd_shared "src/basic/siphash24.h"
nm_copy_sd_shared "src/basic/socket-util.c"
nm_copy_sd_shared "src/basic/socket-util.h"
nm_copy_sd_shared "src/basic/sort-util.h"
nm_copy_sd_shared "src/basic/sparse-endian.h"
nm_copy_sd_shared "src/basic/stat-util.c"
nm_copy_sd_shared "src/basic/stat-util.h"
nm_copy_sd_shared "src/basic/stdio-util.h"
nm_copy_sd_shared "src/basic/string-table.c"
nm_copy_sd_shared "src/basic/string-table.h"
nm_copy_sd_shared "src/basic/string-util.c"
nm_copy_sd_shared "src/basic/string-util.h"
nm_copy_sd_shared "src/basic/strv.c"
nm_copy_sd_shared "src/basic/strv.h"
nm_copy_sd_shared "src/basic/strxcpyx.c"
nm_copy_sd_shared "src/basic/strxcpyx.h"
nm_copy_sd_shared "src/basic/time-util.c"
nm_copy_sd_shared "src/basic/time-util.h"
nm_copy_sd_shared "src/basic/tmpfile-util.c"
nm_copy_sd_shared "src/basic/tmpfile-util.h"
nm_copy_sd_shared "src/basic/umask-util.h"
nm_copy_sd_shared "src/basic/user-util.h"
nm_copy_sd_shared "src/basic/utf8.c"
nm_copy_sd_shared "src/basic/utf8.h"
nm_copy_sd_shared "src/basic/util.c"
nm_copy_sd_shared "src/basic/util.h"
nm_copy_sd_shared "src/shared/dns-domain.c"
nm_copy_sd_shared "src/shared/dns-domain.h"
nm_copy_sd_shared "src/shared/web-util.c"
nm_copy_sd_shared "src/shared/web-util.h"
nm_copy_sd_stdaux "src/basic/unaligned.h"
2020-09-24 10:57:24 +02:00
Beniamino Galvani
613f74b545
initrd: merge branch 'bg/initrd-mac-iface'
...
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/632
2020-09-24 10:55:13 +02:00
Thomas Haller
c17468665d
l3cfg: merge branch 'th/l3cfg-10'
...
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/629
2020-09-24 09:44:45 +02:00
Thomas Haller
7141537097
l3cfg/tests: add unit test for NML3Cfg
2020-09-24 09:44:04 +02:00
Thomas Haller
3695949151
l3cfg/device: drop NML3Cfg references from NMDevice for now
...
Adding NML3Cfg support is a large effort that is done in parallel.
While already parts of the code is merged, it is not actually used
yet. Remove the parts from NMDevice that interact with NML3Cfg
before we actually start using it.
The point is that we might want to do a release before switching
over to the new way. For that release, we should not have the unused
code in NMDevice.
This patch will later be restored and extended.
2020-09-24 09:44:03 +02:00
Thomas Haller
441de0f0f8
l3cfg: fix leaking l3_config_datas array in NML3Cfg
...
But also take a reference whenever we have any configurations
registered. Registering a configuration means to automatically
keep the instance alive.
Any user must take care to unregister again when it no longer requires
the configuration.
2020-09-24 09:44:02 +02:00
Thomas Haller
042112ea2d
l3cfg: various fixes for l3cfg
2020-09-24 09:44:01 +02:00
Thomas Haller
d627ec7075
platform/tests: add nmtstp_platform_ip_addresses_assert() test helper
2020-09-24 09:44:00 +02:00
Thomas Haller
9f91e0b26d
platform/tests: add nmtstp_platform_ip_address_find() test util
2020-09-24 09:43:59 +02:00
Thomas Haller
e232ce93d0
platform: add NM_PLATFORM_IP[46]_ADDRESS_INIT() helper macros
2020-09-24 09:43:58 +02:00
Thomas Haller
6efd4e2efa
tests: use in_addr_t type for IPv4 addresses in test helpers
2020-09-24 09:43:58 +02:00
Thomas Haller
adb78bd471
tests: mark static variables in test helpers as thread local
...
We should avoid static variables in general, but for test helpers they
are often convenient.
Mark them as thread local to make them safer to use. The only downsides
may only be some runtime overhead, which is negligible for unit tests.
2020-09-24 09:43:57 +02:00
Thomas Haller
23a6965ce2
l3cfg: add nm_l3_config_data_log() function
2020-09-24 09:43:56 +02:00
Thomas Haller
7ff1beabdb
l3cfg: let l3cfg emit signal on idle handler for platform changes
...
Currently all NMDevice instance register to the platform change signals,
then if a signal for their IP ifindex appears, they schedule a task on
an idle handler. That is wasteful.
NML3Cfg already gets a notification on an idle handler and can just re-emit
it to the respective listeners.
With this, there is only one subscriber to the platform signals (NMNetns)
which then multiplexes the signals to the right NML3Cfg instances, and
further.
2020-09-24 09:43:55 +02:00
Thomas Haller
000ad171e3
l3cfg: add nm_l3cfg_has_commited_ipv6_pending_dad() function
...
This will be used for tracking IPv6 addresses that still have DAD pending.
Currently, NMDevice does it differently (see "dad6").
2020-09-24 09:43:55 +02:00
Thomas Haller
dbfb7fe2d7
l3cfg: add nm_l3_config_data_lookup_address_6() helper
2020-09-24 09:43:54 +02:00
Thomas Haller
62f2c5a879
platform: refactor nm_platform_ip6_address_get() function to accept pointer instead of "struct in6_addr"
...
While C is fine with accepting structs as function arguments,
we usually don't do that for IPv6 addresses. Accept a pointer
instead.
2020-09-24 09:43:54 +02:00
Thomas Haller
1215b6cc30
l3cfg: track both the commited and the currently merged l3cd instance
...
The caller may want to know the merge NML3ConfigData as it would be used
for the next commit, without already committing it.
Track both the NML3ConfigData instance that is merged from the
registered items, and the one that was used the last time during
commit.
2020-09-24 09:43:54 +02:00
Thomas Haller
79913fb446
l3cfg: allow %NULL argument for nm_l3_config_data_ref()
...
It's often convenient not to require the caller to check for
%NULL. On the other hand, there are cases where having a %NULL instance
is a bug, so gracefully accepting %NULL might hide bugs.
Still, change it.
2020-09-24 09:43:53 +02:00
Thomas Haller
1b79b33206
shared: add NM_PRINT_FMT_QUOTED2() helper macro
2020-09-24 09:43:53 +02:00
Thomas Haller
417737934e
license: add Daniel to RELICENSE.md
...
https://mail.gnome.org/archives/networkmanager-list/2020-September/msg00010.html
2020-09-24 09:35:00 +02:00
Thomas Haller
0ad2d4d96d
libnm, shared: merge branch 'th/hwaddr-cleanup'
2020-09-23 13:58:05 +02:00
Thomas Haller
2fdc713e92
libnm: relax asserting argument for nm_utils_hwaddr_len()
...
nm_utils_hwaddr_len() isn't very useful. It's documented to
only accept two possible input values (ARPHRD_ETHER and ARPHRD_INFINIBAND)
for which the respective return values are well known.
In particular, asserting that the input value is one of the two values
means it becomes harder to extend the function (and make it more useful).
Because, then the user would need to call:
#if NM_VERSION > NM_VERSION_1_XX
len = nm_utils_hwaddr_len (ARPHDR_FOO);
#else
len = 0
#endif
and then it would introduce an unnecessary run time dependency on
NM_VERSION_1_XX.
Instead, just document to return 0 if the value is not supported.
2020-09-23 13:57:38 +02:00
Thomas Haller
2d360d8293
cloud-setup: add code comment to nmcs_utils_hwaddr_normalize()
2020-09-23 13:57:38 +02:00
Thomas Haller
dea59122e7
shared: move nm_utils_hwaddr_ntoa_buf() to shared/ as _nm_utils_hwaddr_ntoa()
...
The name is better as it mirrors nm_utils_hwaddr_aton(). Also, move
it to shared/ so it can be reused (and inlined).
2020-09-23 13:57:37 +02:00
Thomas Haller
74c03da086
shared: move _nm_utils_hwaddr_aton() to shared/
...
_nm_utils_hwaddr_aton() is only a wrapper around nm_utils_hexstr2bin_full().
But it abstracts the "right" parameters for what we consider a valid MAC
address and what not. As such, this function is useful.
Move it to "shared/" and replace the dupicate macro hwaddr_aton() with
it.
2020-09-23 13:57:04 +02:00