summaryrefslogtreecommitdiff
path: root/src/tests
Commit message (Collapse)AuthorAgeFilesLines
* all: SPDX header conversionLubomir Rintel2019-09-1011-154/+11
| | | | | $ find * -type f |xargs perl contrib/scripts/spdx.pl $ git rm contrib/scripts/spdx.pl
* core/tests: avoid deprecated g_main_run()/g_main_loop_unref() in testThomas Haller2019-09-031-3/+2
| | | | | | | | | These are deprecated. Also, they are nowadays implemented as macros that expand to #define g_main_run(loop) g_main_loop_run(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_run) This can cause compilation failure (in some environments).
* core: fix adding objects to NMIPConfig with @append_forceBeniamino Galvani2019-08-281-3/+1
| | | | | | | If the @append_force argument is set and the object is already in the list, it must be moved at the end. Fixes: 22edeb5b691b ('core: track addresses for NMIP4Config/NMIP6Config via NMDedupMultiIndex')
* core: add test to show nm_ipX_config_replace() bugBeniamino Galvani2019-08-281-0/+44
| | | | | | | | Add test to show a wrong result of ip_ipX_config_replace() due to a bug in _nm_ip_config_add_obj(). When an address is added to the tail of the index and another address with the same id already exists, the existing object is left at the same place, breaking the order of addresses.
* src/tests: show exit status in test failure of test_nm_utils_kill_child()Thomas Haller2019-06-131-1/+6
| | | | | This test keeps randomly failing. Rework is, so that we see the actual exit status in the output of the failed test.
* all: drop emacs file variables from source filesThomas Haller2019-06-1112-12/+0
| | | | | | | | | | | | | | | | | | | | | | We no longer add these. If you use Emacs, configure it yourself. Also, due to our "smart-tab" usage the editor anyway does a subpar job handling our tabs. However, on the upside every user can choose whatever tab-width he/she prefers. If "smart-tabs" are used properly (like we do), every tab-width will work. No manual changes, just ran commands: F=($(git grep -l -e '-\*-')) sed '1 { /\/\* *-\*- *[mM]ode.*\*\/$/d }' -i "${F[@]}" sed '1,4 { /^\(#\|--\|dnl\) *-\*- [mM]ode/d }' -i "${F[@]}" Check remaining lines with: git grep -e '-\*-' The ultimate purpose of this is to cleanup our files and eventually use SPDX license identifiers. For that, first get rid of the boilerplate lines.
* tests/trivial: rename nmtst_get_rand_int() to nmtst_get_rand_uint32()Thomas Haller2019-06-113-16/+16
| | | | | | | | nmtst_get_rand_int() was originally named that way, because it calls g_rand_int(). But I think if a function returns an uint32, it should also be named that way. Rename.
* src/tests: rename core's "test-general*" to "test-core*"Thomas Haller2019-05-193-5/+5
|
* logging: use static buffer in nm_logging_all_domains_to_string()Thomas Haller2019-05-171-0/+13
| | | | | | | | | | | | | | | | | | | | | Don't create a heap allocated GString to hold the static result of nm_logging_all_domains_to_string(). Instead, use a static buffer of the exactly required size. The main reason to do this, is to get the exact size of "_all_logging_domains_to_str" buffer. This is the upper boundary for the size of a string buffer to hold all domain names. We will need that boundary in the next commit. The attractive thing here is that we will have a unit-test failure if this boundery no longer matches (--with-more-asserts). That means, this boundary is guarded by unit tests and we don't accidentally get it wrong when the domains change. Also, take care to initialize the buffer in a thread-safe manner. It's easy enough to get right, so there is no excuse for having non-thread-safe code in logging.
* build/meson: rename "nm_core_dep" to "libnm_core_dep"Thomas Haller2019-04-181-1/+1
| | | | | | | The library is called "libnm_core". So the dependency should be called "libnm_core_dep", like in all other cases. (cherry picked from commit c27ad37c278461fd783b6db56844683ab3088345)
* libnm,shared: bzero secrets on failure in nm_utils_base64secret_decode()Thomas Haller2019-04-121-3/+3
| | | | | Now that unbase64mem_full() understands a secure flag, we can get this right.
* core: assert for valid NM_DEVICE_DEVICE_TYPE settingThomas Haller2019-03-111-0/+1
| | | | (cherry picked from commit 7dd44d6dc894ac262f6825d1b992376a92f9f1e5)
* build/meson: increase timeouts for some testsThomas Haller2019-02-232-0/+2
| | | | | | | | | | | | | | | | | | The defaults for test timeouts in meson is 30 seconds. That is not long enough when running $ NMTST_USE_VALGRIND=1 ninja -C build test Note that meson supports --timeout-multiplier, and automatically increases the timeout when running under valgrind. However, meson does not understand that we are running tests under valgrind via NMTST_USE_VALGRIND=1 environment variable. Timeouts are really not expected to be reached and are a mean of last resort. Hence, increasing the timeout to a large value is likely to have no effect or to fix test failures where the timeout was too rigid. It's unlikely that the test indeed hangs and the increase of timeout causes a unnecessary increase of waittime before aborting.
* all: move nm_utils_bin2hexstr_full() to sharedBeniamino Galvani2019-02-211-5/+5
| | | | reuse++
* systemd: define strerror() in sd-adapt header to nm_strerror_native()Thomas Haller2019-02-121-0/+6
| | | | | Systemd uses strerror() extensively. Patch the function to use the thread-safe nm_strerror_native().
* all: cache errno in local variable before using itThomas Haller2019-02-121-1/+2
|
* all: drop unnecessary includes of <errno.h> and <string.h>Thomas Haller2019-02-127-12/+0
| | | | | "nm-macros-interal.h" already includes <errno.h> and <string.h>. No need to include it everywhere else too.
* tests: avoid "-Wmissing-braces" warning in ↵Thomas Haller2019-02-081-2/+2
| | | | | | | | | | | | | test_nm_utils_dhcp_client_id_systemd_node_specific() [1/2] Compiling C object 'src/tests/a4ccf2d@@test-general@exe/test-general.c.o'. ../src/tests/test-general.c: In function ‘test_nm_utils_dhcp_client_id_systemd_node_specific’: ../src/tests/test-general.c:2056:16: warning: missing braces around initializer [-Wmissing-braces] } d_array[] = { ^ ../src/tests/test-general.c:2058:20: .machine_id = { 0xcb, 0xc2, 0x2e, 0x47, 0x41, 0x8e, 0x40, 0x2a, 0xa7, 0xb3, 0x0d, 0xea, 0x92, 0x83, 0x94, 0xef }, {
* tests: avoid "-Wduplicate-decl-specifier" warning in ↵Thomas Haller2019-02-081-1/+1
| | | | | | | | | | | | | | | test_duplicate_decl_specifier() The test should check the behavior with "const typeof(a)" in a macro, where "a" itself is const. For that we don't need a double const declaration of v2. Also, that fixes an actual compiler warning: ../src/tests/test-general.c: In function ‘test_duplicate_decl_specifier’: ../src/tests/test-general.c:1669:8: warning: duplicate ‘const’ declaration specifier [-Wduplicate-decl-specifier] const const int v2 = 3; ^~~~~
* logging: make nm-logging thread-safeThomas Haller2019-02-051-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | NetworkManager is single-threaded and uses a mainloop. However, sometimes we may need multiple threads. For example, we will need to write sysctl values asynchronously, using the glib thread-pool. For that to work, we also need to switch the network-namespace of the thread-pool thread. We want to use NMPNetns for that. Hence it's better to have NMPNetns thread-safe, instead of coming up with a duplicate implementation. But NMPNetns may want to log, so we also need nm-logging thread-safe. In general, code under "shared/nm-utils" and nm-logging should be usable from multiple threads. It's simpler to make this code thread-safe than re-implementing it. Also, it's a bad limitation to be unable to log from other threads. If there is an error, the best we can often do is to log about it. Make nm-logging thread-safe. Actually, we only need to be able to log from multiple threads. We don't need to setup or configure logging from multiple threads. This restriction allows us to access logging from the main-thread without any thread-synchronization (because all changes in the logging setup are also done from the main-thread). So, while logging from other threads requires a mutex, logging from the main-thread is lock-free.
* tests: don't use alloca() in testsThomas Haller2019-01-151-2/+2
| | | | | | | | | | | | The only purpose of using alloca() to avoid the overhead of heap-allocation and possible save a line in source code for managing/freeing the heap allocation. For tests we don't care about performance, and (in this case) the code does not get any shorter. Avoid alloca() in tests, because alloca() is something to search for when reviewing code for stack overflows. No need to have such false positives show up in tests.
* shared: add nm_utils_strbuf_append_bin() helperThomas Haller2019-01-141-4/+80
| | | | | | Add a version of nm_utils_strbuf_append_*() that does not care about NUL terminate strings, but accept any binary data. That makes it useful for writing a binary buffer.
* systemd: expose unbase64mem() as nm_sd_utils_unbase64mem()Thomas Haller2019-01-021-0/+96
| | | | | | | | | | | | | | | glib has an base64 implementation, but g_base64_decode() et al. gives no way to detect invalid encodings. All invalid codes are silently ignored. That is not suitable for strictly validating user input. Instead of reimplementing of copy-pasting the code from somewhere, reuse systemd's unbase64mem(). But don't use "hexdecoct.h" directly. Instead, add a single accessor function to our "nm-sd-utils-shared.h" gateway. We want to be careful about which bits from systemd we use, because otherwise re-importing systemd code becomes fragile as you don't know which relevant parts changed.
* systemd: move basic systemd library to shared/nm-utilsThomas Haller2019-01-023-3/+13
| | | | | | | | | | | | | | | | For better or worse, we already pull in large parts of systemd sources. I need a base64 decode implementation (because glib's g_base64_decode() cannot reject invalid encodings). Instead of coming up with my own or copy-paste if from somewhere, reuse systemd's unbase64mem(). But for that, make systemd's basic bits an independent static library first because I will need it in libnm-core. This doesn't really change anything except making "libnm-systemd-core.la" an indpendent static library that could be used from "libnm-core". We shall still be mindful about which internal code of systemd we use, and only access functionality that is exposed via "systemd/nm-sd-utils-shared.h".
* build: meson: Add trailing commasIñigo Martínez2018-12-202-7/+7
| | | | | | | Add missing trailing commas that avoids getting noise when another file/parameter is added and eases reviewing changes[0]. [0] https://gitlab.gnome.org/GNOME/dconf/merge_requests/11#note_291585
* core: fix match spec behavior for a list of all "except:"Thomas Haller2018-12-111-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the spec specifies only negative matches (and none of them matches), then the result shall be positive. Meaning: [connection*] match-device=except:dhcp-plugin:dhclient [connection*] match-device=except:interface-name:eth0 [.config] enabled=except:nm-version:1.14 should be the same as: [connection*] match-device=*,except:dhcp-plugin:dhclient [connection*] match-device=*,except:interface-name:eth0 [.config] enabled=*,except:nm-version:1.14 and match by default. Previously, such specs would never yield a positive match, which seems wrong. Note that "except:" already has a special meaning. It is not merely "not:". That is because we don't support "and:" nor grouping, but all matches are combined by an implicit "or:". With such a meaning, having a "not:" would be unclear to define. Instead it is defined that any "except:" match always wins and makes the entire condition to explicitly not match. As such, it makes sense to treat a match that only consists of "except:" matches special. This is a change in behavior, but the alternative meaning makes little sense.
* src/tests: add test for except match specThomas Haller2018-12-111-0/+4
|
* libnm: add nm_connectivity_state_cmp() helperThomas Haller2018-12-111-0/+57
|
* all: make use of NM_MAKE_STRV() macroThomas Haller2018-12-012-37/+44
|
* core: add checks on connection default propertiesBeniamino Galvani2018-12-013-22/+35
| | | | | | | | | | Add a new CON_DEFAULT() macro that places a property name into a special section used at runtime to check whether it is a supported connection default. Unfortunately, this mechanism doesn't work for plugins so we have to enumerate the connection defaults from plugins in the daemon using another CON_DEFAULT_NOP() macro.
* config: warn about unknown keys in config filesBeniamino Galvani2018-12-012-5/+49
| | | | | Emit a warning when we find an unsupported option in a configuration file.
* core: add nm_utils_create_dhcp_iaid() utilThomas Haller2018-11-291-0/+4
| | | | | Split out nm_utils_create_dhcp_iaid(), we will need it later. This is also a re-implementation of systemd's dhcp_identifier_set_iaid().
* all: add "${MAC}" substituion for "connection.stable-id"Thomas Haller2018-11-131-1/+2
| | | | | | | | | | | | | | | We already had "${DEVICE}" which uses the interface name. In times of predictable interface naming, that works well. It allows the user to generate IDs per device which don't change when the hardware is replaced. "${MAC}" is similar, except that is uses the permanent MAC address of the device. The substitution results in the empty word, if the device has no permanent MAC address (like software devices). The per-device substitutions "${DEVICE}" and "${MAC}" are especially interesting with "connection.multi-connect=multiple".
* dhcp: reimplement node-specific DHCP client-id generation from systemdThomas Haller2018-11-131-83/+67
| | | | | | | | | | | | | | | | | | | | | Our internal DHCP client (from systemd) defaults to a particular client ID. It is currently exposed as nm_sd_utils_generate_default_dhcp_client_id() and is based on the systemd implementation. One problem with that is, that it internally looks up the interface name with if_indextoname() and reads /etc/machine-id. Both makes it harder for testing. Another problem is, that this way of generating the client-id is currently limited to internal client. Why? If you use dhclient plugin, you may still want to use the same algorithm. Also, there is no explict "ipv4.dhcp-client-id" mode to select this client-id (so that it could be used in combination with "dhclient" plugin). As such, this code will be useful also aside systemd DHCP plugin. Hence, the function should not be obviously tied to systemd code. The implementation is simple enough, and since we already have a unit-test, refactor the code to our own implementation.
* dhcp: test systemd's default DHCP client identifier generationThomas Haller2018-11-131-0/+98
| | | | | | | | | | | | | | | | | | | | | | | | Internal DHCP client generates a default client ID. For one, we should ensure that this algorithm does not change without us noticing, for example, when upgrading systemd code. Add a test, that the generation algorithm works as we expect. Also note, that the generation algorithm uses siphash24(). That means, siphash24() implementation also must not change in the future, to ensure the client ID doesn't change. As we patch systemd sources to use shared/c-siphash, this is not obviously the case. Luckily c-siphash and systemd's siphash24 do agree, so all is good. The test is here to ensure that. Also, previously the generation algorithm is not exposed as a function, sd_dhcp_client will just generate a client-id when it needs it. However, later we want to know (and set) the client id before starting DHCP and not leave it unspecified to an implementation detail. This patch only adds a unit-test for the existing DHCP client ID generation to have something for comparison. In the next commit this will change further.
* core: don't persist secret-key for testsThomas Haller2018-11-131-6/+2
| | | | | | | | | | Tests might access the secret-key. For CI builds we may very well build NM as root and also run unit tests. In such a situation it's bad to persist the secret key. For example, the SELinux label may be wrong, and subsequently starting NetworkManager may cause errors. Avoid persisting the secret key for tests.
* core: refactor loading machine-id and cache itThomas Haller2018-11-131-0/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, whenever we needed /etc/machine-id we would re-load it from file. The are 3 downsides of that: - the smallest downside is the runtime overhead of repeatedly reading the file and parse it. - as we read it multiple times, it may change anytime. Most code in NetworkManager does not expect or handle a change of the machine-id. Generally, the admin should make sure that the machine-id is properly initialized before NetworkManager starts, and not change it. As such, a change of the machine-id should never happen in practice. But if it would change, we would get odd behaviors. Note for example how generate_duid_from_machine_id() already cached the generated DUID and only read it once. It's better to pick the machine-id once, and rely to use the same one for the remainder of the program. If the admin wants to change the machine-id, NetworkManager must be restarted as well (in case the admin cares). Also, as we now only load it once, it makes sense to log an error (once) when we fail to read the machine-id. - previously, loading the machine-id could fail each time. And we have to somehow handle that error. It seems, the best thing what we anyway can do, is to log an error once and continue with a fake machine-id. Here we add a fake machine-id based on the secret-key or the boot-id. Now obtaining a machine-id can no longer fail and error handling is no longer necessary. Also, ensure that a machine-id of all zeros is not valid. Technically, a machine-id is not an RFC 4122 UUID. But it's the same size, so we also use NMUuid data structure for it. While at it, also refactor caching of the boot-id and the secret key. In particular, fix the thread-safety of the double-checked locking implementations.
* build: avoid header conflict for <linux/if.h> and <net/if.h> with ↵Thomas Haller2018-11-121-0/+1
| | | | | | | | | | | | | | | | | | | | | "nm-platform.h" In the past, the headers "linux/if.h" and "net/if.h" were incompatible. That means, we can either include one or the other, but not both. This is fixed in the meantime, however the issue still exists when building against older kernel/glibc. That means, including one of these headers from a header file is problematic. In particular if it's a header like "nm-platform.h", which itself is dragged in by many other headers. Avoid that by not including these headers from "platform.h", but instead from the source files where needed (or possibly from less popular header files). Currently there is no problem. However, this allows an unknowing user to include <net/if.h> at the same time with "nm-platform.h", which is easy to get wrong.
* dns: avoid truncation of searches list due to 256 char limit in glibcThomas Haller2018-11-121-1/+1
| | | | | | | | | | | | | | | | | | Before glibc 2.26, glibc's resolver would only honor 6 search entries and a character limit of 256. This was lifted recently ([1], [2], [3]). We also lift this limitation in NetworkManager ([4], [5]). However, older glibc versions would just truncate the string at 255 characters. In particular, it would not only tuncate the list to 6 entries, but the entry which crosses the 256th character boundary would be mangled. Avoid that, by adding spaces. [1] https://sourceware.org/ml/libc-alpha/2017-08/msg00010.html [2] https://sourceware.org/bugzilla/show_bug.cgi?id=19569 [3] https://sourceware.org/bugzilla/show_bug.cgi?id=21475 [4] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/47 [5] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/80
* dns/tests: add test for writing resolv.confThomas Haller2018-11-121-0/+48
|
* device: add "dhcp-plugin" match spec for deviceThomas Haller2018-11-012-3/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The need for this is the following: "ipv4.dhcp-client-id" can be specified via global connection defaults. In absence of any configuration in NetworkManager, the default depends on the DHCP client plugin. In case of "dhclient", the default further depends on /etc/dhcp. For "internal" plugin, we may very well want to change the default client-id to "mac" by universally installing a configuration snippet [connection-use-mac-client-id] ipv4.dhcp-client-id=mac However, if we the user happens to enable "dhclient" plugin, this also forces the client-id and overrules configuration from /etc/dhcp. The real problem is, that dhclient can be configured via means outside of NetworkManager, so our defaults shall not overwrite defaults from /etc/dhcp. With the new device spec, we can avoid this issue: [connection-dhcp-client-id] match-device=except:dhcp-plugin:dhclient ipv4.dhcp-client-id=mac This will be part of the solution for rh#1640494. Note that merely dropping a configuration snippet is not yet enough. More fixes for DHCP will follow. Also, bug rh#1640494 may have alternative solutions as well. The nice part of this new feature is that it is generally useful for configuring connection defaults and not specifically for the client-id issue. Note that this match spec is per-device, although the plugin is selected globally. That makes some sense, because in the future we may or may not configure the DHCP plugin per-device or per address family. https://bugzilla.redhat.com/show_bug.cgi?id=1640494
* core: add nm_utils_file_is_in_path() for checking pathsThomas Haller2018-10-231-0/+21
| | | | | | | | Add a helper function for the common check whether a file is inside a path. Also, this function handles special cases like repeated file separators. However, as it is still entirely text based, it also cannot recognize if two (literally) different paths reference the same inode/file.
* systemd: fix handling special cases kill_dots and path_simplify()Thomas Haller2018-10-231-6/+6
| | | | | | | Previously, paths like ".", "./", ./." would all result in an empty path. That is wrong, one dot must be kept. https://github.com/systemd/systemd/commit/afbae3e9f23dc6682d48a1cc3585e8429ef07d8b
* core: add "nm-sd-utils.h" to access system internal helperThomas Haller2018-10-231-0/+46
| | | | | | | | | | | | | | | | | | We have a fork of a lot of useful systemd helper code. However, until now we shyed away from using it aside from the bits that we really need. That means, although we have some really nice implementations in our source-tree, we didn't use them. Either we were missing them, or we had to re-implement them. Add "nm-sd-utils.h" header to very carefully make internal systemd API accessible to the rest of core. This is not intended as a vehicle to access all of internal API. Instead, this must be used with care, and only a hand picked selection of functions must be exposed. Use with caution, but where it makes sense.
* docs: misc. typosluz.paz2018-09-152-2/+2
| | | | | | Found via `codespell -q 3 --skip="*.po"` https://github.com/NetworkManager/NetworkManager/pull/203
* shared: change nm_utils_strbuf_seek_end() handling truncated stringsThomas Haller2018-09-071-17/+15
| | | | | | | | | | Ok, I changed my mind. The new behavior seems to make more sense to me. Not that it matters, because we always use nm_utils_strbuf*() API with buffers that we expect to be large enough to contain the result. And when truncation occurs, we usually don't care much about it. That is, there is no code that uses nm_utils_strbuf*() API and handles string truncation in particular.
* shared: add nm_utils_strbuf_seek_end() helperThomas Haller2018-09-071-1/+42
|
* core: add test for nm_wildcard_match_check()Beniamino Galvani2018-09-051-0/+75
| | | | https://github.com/NetworkManager/NetworkManager/pull/181
* settings: use delegation instead of inheritance for NMSettingsConnection and ↵Thomas Haller2018-08-281-9/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NMConnection NMConnection is an interface, which is implemented by the types NMSimpleConnection (libnm-core), NMSettingsConnection (src) and NMRemoteConnection (libnm). NMSettingsConnection does a lot of things already: 1) it "is-a" NMDBusObject and exports the API of a connection profile on D-Bus 2) it interacts with NMSettings and contains functionality for tracking the profiles. 3) it is the base-class of types like NMSKeyfileConnection and NMIfcfgConnection. These handle how the profile is persisted on disk. 4) it implements NMConnection interface, to itself track the settings of the profile. 3) and 4) would be better implemented via delegation than inheritance. Address 4) and don't let NMSettingsConnection implemente the NMConnection interface. Instead, a settings-connection references now a NMSimpleConnection instance, to which it delegates for keeping the actual profiles. Advantages: - by delegating, there is a clearer separation of what NMSettingsConnection does. For example, in C we often required casts from NMSettingsConnection to NMConnection. NMConnection is a very trivial object with very little logic. When we have a NMConnection instance at hand, it's good to know that it is *only* that simple instead of also being an entire NMSettingsConnection instance. The main purpose of this patch is to simplify the code by separating the NMConnection from the NMSettingsConnection. We should generally be aware whether we handle a NMSettingsConnection or a trivial NMConnection instance. Now, because NMSettingsConnection no longer "is-a" NMConnection, this distinction is apparent. - NMConnection is implemented as an interface and we create NMSimpleConnection instances whenever we need a real instance. In GLib, interfaces have a performance overhead, that we needlessly pay all the time. With this change, we no longer require NMConnection to be an interface. Thus, in the future we could compile a version of libnm-core for the daemon, where NMConnection is not an interface but a GObject implementation akin to NMSimpleConnection. - In the previous implementation, we cannot treat NMConnection immutable and copy-on-write. For example, when NMDevice needs a snapshot of the activated profile as applied-connection, all it can do is clone the entire NMSettingsConnection as a NMSimpleConnection. Likewise, when we get a NMConnection instance and want to keep a reference to it, we cannot do that, because we never know who also references and modifies the instance. By separating NMSettingsConnection we could in the future have NMConnection immutable and copy-on-write, to avoid all unnecessary clones.
* build: create "config-extra.h" header instead of passing directory variables ↵Thomas Haller2018-07-171-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | via CFLAGS 1) the command line gets shorter. I frequently run `make V=1` to see the command line arguments for the compiler, and there is a lot of noise. 2) define each of these variables at one place. This makes it easy to verify that for all compilation units, a particular define has the same value. Previously that was not obvious or even not the case (see commit e5d1a71396e107d1909744d26ad401f206c0c915 and commit d63cf1ef2faba57595112a82e962b9643cce4718). The point is to avoid redundancy. 3) not all compilation units need all defines. In fact, most modules would only need a few of these defines. We aimed to pass the necessary minium of defines to each compilation unit, but that was non-obvious to get right and often we set a define that wasn't used. See for example "src_settings_plugins_ibft_cppflags" which needlessly had "-DSYSCONFDIR". This question is now entirely avoided by just defining all variables in a header. We don't care to find the minimum, because every component gets anyway all defines from the header. 4) this also avoids the situation, where a module that previously did not use a particular define gets modified to require it. Previously, that would have required to identify the missing define, and add it to the CFLAGS of the complation unit. Since every compilation now includes "config-extra.h", all defines are available everywhere. 5) the fact that each define is now available in all compilation units could be perceived as a downside. But it isn't, because these defines should have a unique name and one specific value. Defining the same name with different values, or refer to the same value by different names is a bug, not a desirable feature. Since these defines should be unique accross the entire tree, there is no problem in providing them to every compilation unit. 6) the reason why we generate "config-extra.h" this way, instead of using AC_DEFINE() in configure.ac, is due to the particular handling of autoconf for directory variables. See [1]. With meson, it would be trivial to put them into "config.h.meson". While that is not easy with autoconf, the "config-extra.h" workaround seems still preferable to me. [1] https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Installation-Directory-Variables.html