Commit graph

30 commits

Author SHA1 Message Date
Thomas Haller
4e109bacab
clang-format: use "IndentPPDirectives:None" instead of "BeforeHash"
Subjectively, I think this looks better.
2021-07-09 08:49:06 +02:00
Beniamino Galvani
6ac21ba916 core: add infrastructure for spawning a helper process 2021-06-11 21:43:12 +02:00
Thomas Haller
07002f7320
core: remove _nul_sentinel from UuidData struct
The user really must not treat UuidData.bin as a NUL terminated string.
The _nul_sentinel is not necessary. And if by chance the user makes this
fatal mistake, then UuidData.str will still be there to NUL terminate the
buffer, the content is garbage either way.

Remove the sentinel.
2021-06-08 08:24:14 +02:00
Thomas Haller
2b2c818e03
glib-aux/uuid: use NMUuid typed argument for nm_uuid_generate_from_string*()
nm_uuid_generate_from_string*() accepts an optional namespace parameter,
to seed the hashing. This previously was a UUID in string format, so it
first had to be parsed.

Rework the code to pass a NMUuid instance that can be used directly.
Also, as the type_args parameter is always of the same type, change
the argument from a void pointer to "const NMUuid *" pointer.
2021-06-08 08:24:14 +02:00
Thomas Haller
8327312c51
wifi: fix parsing Microsoft Network Cost IE
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/734

Fixes: 5307b1ed73 ('wifi: guess metered flag based on Network Cost information element')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/879
2021-06-02 08:44:52 +02:00
Thomas Haller
bc05f4b750
core: avoid lgtm warning in _sleep_duration_convert_ms_to_us()
return x < G_MAXULONG ? (gulong) x : G_MAXULONG;
  ^^^ Comparison is always true because x <= 4294967295000.
2021-06-01 17:39:28 +02:00
Thomas Haller
90818b5391
core: minor cleanup of integer multiplication in _sleep_duration_convert_ms_to_us()
Cast to unsigned int64. Also add parenthesis, even if not strictly
necessary.
2021-05-27 09:02:45 +02:00
Thomas Haller
2fcabf5699
all: only include "libnm-glib-aux/nm-uuid.h" where needed
Don't let "nm-core-internal.h" (which is a very popular header itself)
drag in "nm-uuid.h".
2021-05-04 15:51:51 +02:00
Thomas Haller
995c78245e
glib-aux/trivial: rename NMUuid API 2021-05-04 15:51:49 +02:00
Thomas Haller
dd1a618745
libnm,glib-aux: move nm_utils_uuid_is_null() to "nm-uuid.h" 2021-05-04 15:51:45 +02:00
Thomas Haller
7a15144f75
glib-aux: use nm_uuid_generate_random() helper 2021-05-04 15:51:43 +02:00
Thomas Haller
42d67415b4
glib-aux: use nm_uuid_parse() helper 2021-05-04 15:51:42 +02:00
Thomas Haller
596bf4b91b
glib-aux: use nm_uuid_unparse() 2021-05-04 15:51:42 +02:00
Thomas Haller
21321ac736
clang-format: reformat code with clang 12
The format depends on the version of the tool. Now that Fedora 34 is
released, update to clang 12 (clang-tools-extra-12.0.0-0.3.rc1.fc34.x86_64).
2021-05-04 13:56:26 +02:00
Andrew Zaborowski
38ac64ba62
glib-aux: Set file timestamps in nm_utils_file_set_contents
Extend nm_utils_file_set_contents to be able to optionally set the last
access + last modification times on the file being created, in addition
to the mode.
2021-04-19 18:11:11 +02:00
Thomas Haller
420784e342
core: fix crash in nm_wildcard_match_check()
It's not entirely clear how to treat %NULL.
Clearly "match.interface-name=eth0" should not
match with an interface %NULL. But what about
"match.interface-name=!eth0"? It's now implemented
that negative matches still succeed against %NULL.
What about "match.interface-name=*"? That probably
should also match with %NULL. So we treat %NULL really
like "".

Against commit 11cd443448 ('iwd: Don't call IWD methods when device
unmanaged'), we got this backtrace:

    #0  0x00007f1c164069f1 in __strnlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62
    #1  0x00007f1c1637ac9e in __fnmatch (pattern=<optimized out>, string=<optimized out>, string@entry=0x0, flags=flags@entry=0) at fnmatch.c:379
            p = 0x0
            res = <optimized out>
            orig_pattern = <optimized out>
            n = <optimized out>
            wpattern = 0x7fff8d860730 L"pci-0000:03:00.0"
            ps = {__count = 0, __value = {__wch = 0, __wchb = "\000\000\000"}}
            wpattern_malloc = 0x0
            wstring_malloc = 0x0
            wstring = <optimized out>
            alloca_used = 80
            __PRETTY_FUNCTION__ = "__fnmatch"
    #2  0x0000564484a978bf in nm_wildcard_match_check (str=0x0, patterns=<optimized out>, num_patterns=<optimized out>) at src/core/nm-core-utils.c:1959
            is_inverted = 0
            is_mandatory = 0
            match = <optimized out>
            p = 0x564486c43fa0 "pci-0000:03:00.0"
            has_optional = 0
            has_any_optional = 0
            i = <optimized out>
    #3  0x0000564484bf4797 in check_connection_compatible (self=<optimized out>, connection=<optimized out>, error=0x0) at src/core/devices/nm-device.c:7499
            patterns = <optimized out>
            device_driver = 0x564486c76bd0 "veth"
            num_patterns = 1
            priv = 0x564486cbe0b0
            __func__ = "check_connection_compatible"
            device_iface = <optimized out>
            local = 0x564486c99a60
            conn_iface = 0x0
            klass = <optimized out>
            s_match = 0x564486c63df0 [NMSettingMatch]
    #4  0x0000564484c38491 in check_connection_compatible (device=0x564486cbe590 [NMDeviceVeth], connection=0x564486c6b160, error=0x0) at src/core/devices/nm-device-ethernet.c:348
            self = 0x564486cbe590 [NMDeviceVeth]
            s_wired = <optimized out>

Fixes: 3ced486f41 ('libnm/match: extend syntax for match patterns with '|', '&', '!' and '\\'')

https://bugzilla.redhat.com/show_bug.cgi?id=1942741
2021-03-24 21:18:54 +01:00
Thomas Haller
9113a672cf
platform: move nm_utils_modprobe() to libnm-platform 2021-03-05 11:27:15 +01:00
Thomas Haller
7b18e15481
platform: move nm_utils_lifetime_*() to libnm-platform 2021-03-05 11:27:15 +01:00
Thomas Haller
690105c616
platform: move nm_utils_new_{vlan,infiniband}_name() to libnm-platform 2021-03-05 11:27:15 +01:00
Thomas Haller
2d9a9d0ded
core: move NM_PLATFORM_LIFETIME_PERMANENT to libnm-platform/nmp-base.h 2021-03-05 11:27:15 +01:00
Thomas Haller
a016f24353
glib-aux: move NMIcmpv6RouterPref to libnm-glib-aux 2021-03-05 11:09:15 +01:00
Thomas Haller
3c733cc32e
glib-aux: move nm_utils_sysctl_ip_conf_*() helpers 2021-03-05 11:09:14 +01:00
Thomas Haller
ec22551ce9
glib-aux: move NMUtilsIPv6IfaceId struct to libnm-glib-aux 2021-03-05 11:09:14 +01:00
Thomas Haller
2b6baccff8
core: use _NM_UTILS_HWADDR_LEN_MAX instead of NM_UTILS_HWADDR_LEN_MAX 2021-03-05 11:09:14 +01:00
Thomas Haller
b3f5113503
glib-aux: move nm_utils_exp10() from core to libnm-glib-aux 2021-03-05 11:09:12 +01:00
Thomas Haller
a8c34b9dcf
build: move "shared/nm-std-aux" to "src/libnm-std-aux" 2021-02-24 12:48:24 +01:00
Thomas Haller
9dc84b32b0
build: move "shared/nm-{glib-aux,log-null,log-core}" to "src/libnm-{glib-aux,log-null,log-core}" 2021-02-24 12:48:20 +01:00
Thomas Haller
fdf9614ba7
build: move "libnm-core/" to "src/" and split it
"libnm-core/" is rather complicated. It provides a static library that
is linked into libnm.so and NetworkManager. It also contains public
headers (like "nm-setting.h") which are part of public libnm API.

Then we have helper libraries ("libnm-core/nm-libnm-core-*/") which
only rely on public API of libnm-core, but are themself static
libraries that can be used by anybody who uses libnm-core. And
"libnm-core/nm-libnm-core-intern" is used by libnm-core itself.

Move "libnm-core/" to "src/". But also split it in different
directories so that they have a clearer purpose.

The goal is to have a flat directory hierarchy. The "src/libnm-core*/"
directories correspond to the different modules (static libraries and set
of headers that we have). We have different kinds of such modules because
of how we combine various code together. The directory layout now reflects
this.
2021-02-18 19:46:51 +01:00
Thomas Haller
dc2afc9b77
all: add "src/core/nm-default-daemon.h" as replacement for "nm-default.h" 2021-02-09 12:38:18 +01:00
Thomas Haller
ac1a9e03e4
all: move "src/" directory to "src/core/"
Currently "src/" mostly contains the source code of the daemon.
I say mostly, because that is not true, there are also the device,
settings, wwan, ppp plugins, the initrd generator, the pppd and dhcp
helper, and probably more.

Also we have source code under libnm-core/, libnm/, clients/, and
shared/ directories. That is all confusing.

We should have one "src" directory, that contains subdirectories. Those
subdirectories should contain individual parts (libraries or
applications), that possibly have dependencies on other subdirectories.
There should be a flat hierarchy of directories under src/, which
contains individual modules.

As the name "src/" is already taken, that prevents any sensible
restructuring of the code.

As a first step, move "src/" to "src/core/". This gives space to
reorganize the code better by moving individual components into "src/".

For inspiration, look at systemd's "src/" directory.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/743
2021-02-04 09:45:55 +01:00
Renamed from src/nm-core-utils.c (Browse further)