summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* dhcp: support FQDN flags in the nettools backendbg/dhcp-fqdn-flagsBeniamino Galvani2019-11-281-22/+43
| | | | Make the nettools backed honor the ipv4.dhcp-hostname-flags property.
* dhcp: support FQDN flags in the dhclient backendBeniamino Galvani2019-11-2812-28/+169
| | | | Make the dhclient backend honor the ipv4.dhcp-fqdn-flags setting.
* ifcfg-rh: add support for DHCP hostname flagsBeniamino Galvani2019-11-286-13/+80
|
* libnm: add ipvx.dhcp-hostname-flags propertiesBeniamino Galvani2019-11-2811-652/+1154
| | | | | | | | | | | | When using the dhclient DHCP backend users can tweak the behavior in the dhclient configuration file. One of the options that was reported as useful in the past was the FQDN flags [1] [2]. Add native support for FQDN flags to NM by introducing new ipv{4,6}.dhcp-hostname-flags properties. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1684595 [2] https://bugzilla.redhat.com/show_bug.cgi?id=1255507
* all: merge branch 'th/scope-for-ipv4-route'Thomas Haller2019-11-2812-115/+265
|\ | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/349
| * all: add support for "scope" attribute for IPv4 routesThomas Haller2019-11-289-4/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - systemd-networkd and initscripts both support it. - it seems suggested to configure routes with scope "link" on AWS. - the scope is only supported for IPv4 routes. Kernel ignores the attribute for IPv6 routes. - we don't support the aliases like "link" or "global". Instead only the numeric value is supported. This is different from systemd-networkd, which accepts names like "global" and "link", but no numerical values. I think restricting ourself only to the aliases unnecessarily limits what is possible on netlink. The alternative would be to allow aliases and numbers both, but that causes multiple ways to define something and has thus downsides. So, only numeric values. - when setting rtm_scope to RT_SCOPE_NOWHERE (0, the default), kernel will coerce that to RT_SCOPE_LINK. This ambiguity of nowhere vs. link is a problem, but we don't do anything about it. - The other problem is, that when deleting a route with scope RT_SCOPE_NOWHERE, this acts as a wild care and removes the first route that matches (given the other route attributes). That means, NetworkManager has no meaningful way to delete a route with scope zero, there is always the danger that we might delete the wrong route. But this is nothing new to this patch. The problem existed already previously, except that NetworkManager could only add routes with scope nowhere (i.e. link).
| * ifcfg-rh: separately handle static information during parsing ip-route ↵Thomas Haller2019-11-271-84/+110
| | | | | | | | | | | | | | | | | | commandline There is an "info" part and a part with the data that we parsed. Don't track the static and mutable data in the same variable. Also, this allows to mark the static part as "const static".
| * libnm: lookup route attributes attribute spec via binary searchThomas Haller2019-11-275-25/+99
| |
| * ifcfg-rh: fix accepting onlink flag also for IPv6 routesThomas Haller2019-11-271-2/+1
|/ | | | | | | In the past, kernel (and NetworkManager) did not support the onlink flags for IPv6 routes. That is no longer the case. Fixes: f5e8bbc8e082 ('libnm,core: enable "onlink" flags also for IPv6 routes')
* dispatcher: use free() to free memory allocated with malloc()Thomas Haller2019-11-271-4/+5
| | | | | | | In practice, nowadays g_free() is the same as free(), so there is no difference. However, we still should not mix the two and use free() for data that was allocated with malloc() -- in this case, the memory was allocated by libc's realpath().
* dispatcher: fix detection of no-wait dispatcher scriptsThomas Haller2019-11-271-1/+1
| | | | | | While at it, use NM_STR_HAS_SUFFIX() with the string literal. Fixes: 35a428f16897 ('dispatcher: look for the scripts in /usr/lib as well')
* libnm: add nm_client_get_main_context() functionThomas Haller2019-11-263-0/+30
| | | | | | | | The NMClient is associated with a certain context. Add a getter function to give the context. The context is really not internal API of NMClient, that is because the user must iterate this context and be aware of it.
* libnm: fix assertion for cleaning up nml_dbus_property_o_notify()Thomas Haller2019-11-261-1/+1
| | | | | | | | | | | | | | | | | | | | | Usually, the nmobj never gets reused for one dbobj. That means, we really don't expect a nml_dbus_property_o_notify() for a property that was already cleared. However, that is for example not the case with NMClient itself. As NetworkManager gets restarted, the name owner gets lost, the property cleared but afterwards it might get notified again. That means, nml_dbus_property_o_notify() and nml_dbus_property_o_clear() must work well together, otherwise a sequence of nml_dbus_property_o_notify() nml_dbus_property_o_clear() nml_dbus_property_o_notify() leads to an assertion failure "nm_assert (!pr_o->is_ready)". Fixes: ce0e898fb476 ('libnm: refactor caching of D-Bus objects in NMClient')
* libnm: fix leaking internal GMainContext for synchronously initialized NMClientThomas Haller2019-11-263-44/+218
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NMClient makes asynchronous D-Bus calls via g_dbus_connection_call(). This references the current GMainContext to later invoke the asynchronous callback. Even when we cancel the asynchronous call, the callback will still be invoked (later) to complete the request. In particular this means when we destroy (unref) an NMClient, there are quite possibly pending requests in the GMainContext. Although they are cancelled, they keep the GMainContext alive. With synchronous initialization, we have an internal GMainContext. When we destroy the NMClient, we cannot just unhook the integrated source, instead, we need to keep it integrated in the caller's main context, as long as there are pending requests. Add a mechanism to track those pending requests and fix the leak for the internal GMainContext. Also expose the same mechanism to the user via a new API called nm_client_get_context_busy_watcher(). This allows the user to know when it can stop iterating the main context and when all resources are reclaimed. For example the following will lead to a crash: for i in range(1,2000): nmc = NM.Client.new(None) This creates a number of NMClient instances and destroys them again. Note that here the GMainContext is never iterated, because synchronous initialization does not iterate the caller's context. So, while we correctly unref and dispose the created NMClient instances, there are pending requests left in the inner GMainContext. These pile up and soon the program will crash because it runs out of file descriptors. We can have a similar problem with asynchronous initialization, when we create a new GMainContext per client, and don't iterate it after we are done with the client. Note that this patch does not avoid the problem in general. The problem cannot be avoided, the user must iterate the main contex at some point. Otherwise resources (memory and file descriptors) will be leaked. Fixes: ce0e898fb476 ('libnm: refactor caching of D-Bus objects in NMClient') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/347
* libnm: merge branch 'th/libnm-no-dbus-codegen-4'Thomas Haller2019-11-2567-6957/+8072
|\ | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/331
| * libnm: refactor caching of D-Bus objects in NMClientThomas Haller2019-11-2560-6916/+7451
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No longer use GDBusObjectMangaerClient and gdbus-codegen generated classes for the NMClient cache. Instead, use GDBusConnection directly and a custom implementation (NMLDBusObject) for caching D-Bus' ObjectManager data. CHANGES ------- - This is a complete rework. I think the previous implementation was difficult to understand. There were unfixed bugs and nobody understood the code well enough to fix them. Maybe somebody out there understood the code, but I certainly did not. At least nobody provided patches to fix those issues. I do believe that this implementation is more straightforward and easier to understand. It removes a lot of layers of code. Whether this claim of simplicity is true, each reader must decide for himself/herself. Note that it is still fairly complex. - There was a lingering performance issue with large number of D-Bus objects. The patch tries hard that the implementation scales well. Of course, when we cache N objects that have N-to-M references to other, we still are fundamentally O(N*M) for runtime and memory consumption (with M being the number of references between objects). But each part should behave efficiently and well. - Play well with GMainContext. libnm code (NMClient) is generally not thread safe. However, it should work to use multiple instances in parallel, as long as each access to a NMClient is through the caller's GMainContext. This follows glib's style and effectively allows to use NMClient in a multi threaded scenario. This implies to stick to a main context upon construction and ensure that callbacks are only invoked when iterating that context. Also, NMClient itself shall never iterate the caller's context. This also means, libnm must never use g_idle_add() or g_timeout_add(), as those enqueue sources in the g_main_context_default() context. - Get ordering of messages right. All events are consistently enqueued in a GMainContext and processed strictly in order. For example, previously "nm-object.c" tried to combine signals and emit them on an idle handler. That is wrong, signals must be emitted in the right order and when they happen. Note that when using GInitable's synchronous initialization to initialize the NMClient instance, NMClient internally still operates fully asynchronously. In that case NMClient has an internal main context. - NMClient takes over most of the functionality. When using D-Bus' ObjectManager interface, one needs to handle basically the entire state of the D-Bus interface. That cannot be separated well into distinct parts, and even if you try, you just end up having closely related code in different source files. Spreading related code does not make it easier to understand, on the contrary. That means, NMClient is inherently complex as it contains most of the logic. I think that is not avoidable, but it's not as bad as it sounds. - NMClient processes D-Bus messages and state changes in separate steps. First NMClient unpacks the message (e.g. _dbus_handle_properties_changed()) and keeps track of the changed data. Then we update the GObject instances (_dbus_handle_obj_changed_dbus()) without emitting any signals yet. Finally, we emit all signals and notifications that were collected (_dbus_handle_changes_commit()). Note that for example during the initial GetManagedObjects() reply, NMClient receive a large amount of state at once. But we first apply all the changes to our GObject instances before emitting any signals. The result is that signals are always emitted in a moment when the cache is consistent. The unavoidable downside is that when you receive a property changed signal, possibly many other properties changed already and more signals are about to be emitted. - NMDeviceWifi no longer modifies the content of the cache from client side during poke_wireless_devices_with_rf_status(). The content of the cache should be determined by D-Bus alone and follow what NetworkManager service exposes. Local modifications should be avoided. - This aims to bring no API/ABI change, though it does of course bring various subtle changes in behavior. Those should be all for the better, but the goal is not to break any existing clients. This does change internal (albeit externally visible) API, like dropping NM_OBJECT_DBUS_OBJECT_MANAGER property and NMObject no longer implementing GInitableIface and GAsyncInitableIface. - Some uses of gdbus-codegen classes remain in NMVpnPluginOld, NMVpnServicePlugin and NMSecretAgentOld. These are independent of NMClient/NMObject and should be reworked separately. - While we no longer use generated classes from gdbus-codegen, we don't need more glue code than before. Also before we constructed NMPropertiesInfo and a had large amount of code to propagate properties from NMDBus* to NMObject. That got completely reworked, but did not fundamentally change. You still need about the same effort to create the NMLDBusMetaIface. Not using generated bindings did not make anything worse (which tells about the usefulness of generated code, at least in the way it was used). - NMLDBusMetaIface and other meta data is static and immutable. This avoids copying them around. Also, macros like NML_DBUS_META_PROPERTY_INIT_U() have compile time checks to ensure the property types matches. It's pretty hard to misuse them because it won't compile. - The meta data now explicitly encodes the expected D-Bus types and makes sure never to accept wrong data. That would only matter when the server (accidentally or intentionally) exposes unexpected types on D-Bus. I don't think that was previously ensured in all cases. For example, demarshal_generic() only cared about the GObject property type, it didn't know the expected D-Bus type. - Previously GDBusObjectManager would sometimes emit warnings (g_log()). Those probably indicated real bugs. In any case, it prevented us from running CI with G_DEBUG=fatal-warnings, because there would be just too many unrelated crashes. Now we log debug messages that can be enabled with "LIBNM_CLIENT_DEBUG=trace". Some of these messages can also be turned into g_warning()/g_critical() by setting LIBNM_CLIENT_DEBUG=warning,error. Together with G_DEBUG=fatal-warnings, this turns them into assertions. Note that such "assertion failures" might also happen because of a server bug (or change). Thus these are not common assertions that indicate a bug in libnm and are thus not armed unless explicitly requested. In our CI we should now always run with LIBNM_CLIENT_DEBUG=warning,error and G_DEBUG=fatal-warnings and to catch bugs. Note that currently NetworkManager has bugs in this regard, so enabling this will result in assertion failures. That should be fixed first. - Note that this changes the order in which we emit "notify:devices" and "device-added" signals. I think it makes the most sense to emit first "device-removed", then "notify:devices", and finally "device-added" signals. This changes behavior for commit 52ae28f6e5bf ('libnm: queue added/removed signals and suppress uninitialized notifications'), but I don't think that users should actually rely on the order. Still, the new order makes the most sense to me. - In NetworkManager, profiles can be invisible to the user by setting "connection.permissions". Such profiles would be hidden by NMClient's nm_client_get_connections() and their "connection-added"/"connection-removed" signals. Note that NMActiveConnection's nm_active_connection_get_connection() and NMDevice's nm_device_get_available_connections() still exposes such hidden NMRemoteConnection instances. This behavior was preserved. NUMBERS ------- I compared 3 versions of libnm. [1] 962297f9085d, current tip of nm-1-20 branch [2] 4fad8c7c642e, current master, immediate parent of this patch [3] this patch All tests were done on Fedora 31, x86_64, gcc 9.2.1-1.fc31. The libraries were build with $ ./contrib/fedora/rpm/build_clean.sh -g -w test -W debug Note that RPM build already stripped the library. --- N1) File size of libnm.so.0.1.0 in bytes. There currently seems to be a issue on Fedora 31 generating wrong ELF notes. Usually, libnm is smaller but in these tests it had large (and bogus) ELF notes. Anyway, the point is to show the relative sizes, so it doesn't matter). [1] 4075552 (102.7%) [2] 3969624 (100.0%) [3] 3705208 ( 93.3%) --- N2) `size /usr/lib64/libnm.so.0.1.0`: text data bss dec hex filename [1] 1314569 (102.0%) 69980 ( 94.8%) 10632 ( 80.4%) 1395181 (101.4%) 1549ed /usr/lib64/libnm.so.0.1.0 [2] 1288410 (100.0%) 73796 (100.0%) 13224 (100.0%) 1375430 (100.0%) 14fcc6 /usr/lib64/libnm.so.0.1.0 [3] 1229066 ( 95.4%) 65248 ( 88.4%) 13400 (101.3%) 1307714 ( 95.1%) 13f442 /usr/lib64/libnm.so.0.1.0 --- N3) Performance test with test-client.py. With checkout of [2], run ``` prepare_checkout() { rm -rf /tmp/nm-test && \ git checkout -B test 4fad8c7c642e && \ git clean -fdx && \ ./autogen.sh --prefix=/tmp/nm-test && \ make -j 5 install && \ make -j 5 check-local-clients-tests-test-client } prepare_test() { NM_TEST_REGENERATE=1 NM_TEST_CLIENT_BUILDDIR="/data/src/NetworkManager" NM_TEST_CLIENT_NMCLI_PATH=/usr/bin/nmcli python3 ./clients/tests/test-client.py -v } do_test() { for i in {1..10}; do NM_TEST_CLIENT_BUILDDIR="/data/src/NetworkManager" NM_TEST_CLIENT_NMCLI_PATH=/usr/bin/nmcli python3 ./clients/tests/test-client.py -v || return -1 done echo "done!" } prepare_checkout prepare_test time do_test ``` [1] real 2m14.497s (101.3%) user 5m26.651s (100.3%) sys 1m40.453s (101.4%) [2] real 2m12.800s (100.0%) user 5m25.619s (100.0%) sys 1m39.065s (100.0%) [3] real 1m54.915s ( 86.5%) user 4m18.585s ( 79.4%) sys 1m32.066s ( 92.9%) --- N4) Performance. Run NetworkManager from build [2] and setup a large number of profiles (551 profiles and 515 devices, mostly unrealized). This setup is already at the edge of what NetworkManager currently can handle. Of course, that is a different issue. Here we just check how long plain `nmcli` takes on the system. ``` do_cleanup() { for UUID in $(nmcli -g NAME,UUID connection show | sed -n 's/^xx-c-.*:\([^:]\+\)$/\1/p'); do nmcli connection delete uuid "$UUID" done for DEVICE in $(nmcli -g DEVICE device status | grep '^xx-i-'); do nmcli device delete "$DEVICE" done } do_setup() { do_cleanup for i in {1..30}; do nmcli connection add type bond autoconnect no con-name xx-c-bond-$i ifname xx-i-bond-$i ipv4.method disabled ipv6.method ignore for j in $(seq $i 30); do nmcli connection add type vlan autoconnect no con-name xx-c-vlan-$i-$j vlan.id $j ifname xx-i-vlan-$i-$j vlan.parent xx-i-bond-$i ipv4.method disabled ipv6.method ignore done done systemctl restart NetworkManager.service sleep 5 } do_test() { perf stat -r 50 -B nmcli 1>/dev/null } do_test ``` [1] Performance counter stats for 'nmcli' (50 runs): 456.33 msec task-clock:u # 1.093 CPUs utilized ( +- 0.44% ) 0 context-switches:u # 0.000 K/sec 0 cpu-migrations:u # 0.000 K/sec 5,900 page-faults:u # 0.013 M/sec ( +- 0.02% ) 1,408,675,453 cycles:u # 3.087 GHz ( +- 0.48% ) 1,594,741,060 instructions:u # 1.13 insn per cycle ( +- 0.02% ) 368,744,018 branches:u # 808.061 M/sec ( +- 0.02% ) 4,566,058 branch-misses:u # 1.24% of all branches ( +- 0.76% ) 0.41761 +- 0.00282 seconds time elapsed ( +- 0.68% ) [2] Performance counter stats for 'nmcli' (50 runs): 477.99 msec task-clock:u # 1.088 CPUs utilized ( +- 0.36% ) 0 context-switches:u # 0.000 K/sec 0 cpu-migrations:u # 0.000 K/sec 5,948 page-faults:u # 0.012 M/sec ( +- 0.03% ) 1,471,133,482 cycles:u # 3.078 GHz ( +- 0.36% ) 1,655,275,369 instructions:u # 1.13 insn per cycle ( +- 0.02% ) 382,595,152 branches:u # 800.433 M/sec ( +- 0.02% ) 4,746,070 branch-misses:u # 1.24% of all branches ( +- 0.49% ) 0.43923 +- 0.00242 seconds time elapsed ( +- 0.55% ) [3] Performance counter stats for 'nmcli' (50 runs): 352.36 msec task-clock:u # 1.027 CPUs utilized ( +- 0.32% ) 0 context-switches:u # 0.000 K/sec 0 cpu-migrations:u # 0.000 K/sec 4,790 page-faults:u # 0.014 M/sec ( +- 0.26% ) 1,092,341,186 cycles:u # 3.100 GHz ( +- 0.26% ) 1,209,045,283 instructions:u # 1.11 insn per cycle ( +- 0.02% ) 281,708,462 branches:u # 799.499 M/sec ( +- 0.01% ) 3,101,031 branch-misses:u # 1.10% of all branches ( +- 0.61% ) 0.34296 +- 0.00120 seconds time elapsed ( +- 0.35% ) --- N5) same setup as N4), but run `PAGER= /bin/time -v nmcli`: [1] Command being timed: "nmcli" User time (seconds): 0.42 System time (seconds): 0.04 Percent of CPU this job got: 107% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.43 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 34456 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 6128 Voluntary context switches: 1298 Involuntary context switches: 1106 Swaps: 0 File system inputs: 0 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0 [2] Command being timed: "nmcli" User time (seconds): 0.44 System time (seconds): 0.04 Percent of CPU this job got: 108% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.44 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 34452 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 6169 Voluntary context switches: 1849 Involuntary context switches: 142 Swaps: 0 File system inputs: 0 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0 [3] Command being timed: "nmcli" User time (seconds): 0.32 System time (seconds): 0.02 Percent of CPU this job got: 102% Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.34 Average shared text size (kbytes): 0 Average unshared data size (kbytes): 0 Average stack size (kbytes): 0 Average total size (kbytes): 0 Maximum resident set size (kbytes): 29196 Average resident set size (kbytes): 0 Major (requiring I/O) page faults: 0 Minor (reclaiming a frame) page faults: 5059 Voluntary context switches: 919 Involuntary context switches: 685 Swaps: 0 File system inputs: 0 File system outputs: 0 Socket messages sent: 0 Socket messages received: 0 Signals delivered: 0 Page size (bytes): 4096 Exit status: 0 --- N6) same setup as N4), but run `nmcli monitor` and look at `ps aux` for the RSS size. USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND [1] me 1492900 21.0 0.2 461348 33248 pts/10 Sl+ 15:02 0:00 nmcli monitor [2] me 1490721 5.0 0.2 461496 33548 pts/10 Sl+ 15:00 0:00 nmcli monitor [3] me 1495801 16.5 0.1 459476 28692 pts/10 Sl+ 15:04 0:00 nmcli monitor
| * shared: add nm_utils_g_main_context_create_integrate_source() for ↵Thomas Haller2019-11-253-0/+562
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | integrating a GMainContext in another We will rework NMClient entirely. Then, the synchronous initialization will also use the asynchronous code paths. The difference will be that with synchronous initialization, all D-Bus interaction will be done with an internal GMainContext as current thread default, and that internal context will run until initialization completes. Note that even after initialization completes, it cannot be swapped back to the user's (outer) GMainContext. That is because contexts are essentially the queue for our D-Bus events, and we cannot swap from one queue to the other in a race free manner (or a full resync). In other words, the two contexts are not in sync, so after using the internal context NMClient needs to stick to that (at least, until the name owner gets lost, which gives an opportunity to resync and switch back to the user's main context). We thus need to hook the internal (inner) GMainContext with the user's (outer) context, so when the user iterates the outer context, events on the inner context get dispatched. Add nm_utils_g_main_context_create_integrate_source() to create such a GSource for integrating two contexts. Note that the use-case here is limited: the integrated, inner main context must not be explicitly iterated except from being dispatched by the integrating source. Otherwise, you'd get recursive runs, possible deadlocks and general ugliness. NMClient must show restrain how to use the inner context while it is integrated.
| * shared: make NM_STRUCT_OFFSET_ENSURE_TYPE() work with arraysThomas Haller2019-11-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some compilers don't convert arrays as _Generic() type selectors to their pointer type. That means, for those compilers the generic type would be an array and not a pointer. Work around that by adding zero to the pointer/array argument. Also, I cannot get this to work with "clang-3.4.2-9.el7". Disable it for that compiler. The value of the generic check is anyway that it only needs to work with some compiler combinations. That will trigger a compilation failure and we can fix the implementation also for compilers that don't support the macro. See-also: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1930.htm
| * shared: mark _notify() function as "_nm_unused"Thomas Haller2019-11-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two macros: NM_GOBJECT_PROPERTIES_DEFINE_BASE() and NM_GOBJECT_PROPERTIES_DEFINE(). The former just defines the property enums and the obj_properties array. The latter also defines the functions _notify() and _nm_gobject_notify_together_impl(). That means, depending on whether you actually use _notify(), you have to choose one of the macros. I think that is unnecessarily cumbersome. Let's mark the function as _nm_unused so that the compiler doesn't complain about the unused function. I don't think it's a problem to use NM_GOBJECT_PROPERTIES_DEFINE() even if you don't actually use _notify().
| * shared: add nm_auto_unref_gmaincontext macroThomas Haller2019-11-251-0/+3
| |
| * shared: add nm_pint_hash()/nm_pint_equals() utilsThomas Haller2019-11-252-0/+28
| |
| * sd: cleanup integrating systemd's event loop with GMainContextThomas Haller2019-11-251-38/+25
|/ | | | | Get rid of the default_source_id global for tracking the default event. It's not useful to track this.
* po: update Brazilian Portuguese (pt_BR) translationRafael Fontenelle2019-11-251-2420/+2672
| | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/346
* manager: don't activate device if the parent is missingBeniamino Galvani2019-11-253-9/+35
| | | | | | | | | | | | | | | | In multiple places we currently proceed to creating a virtual device even if the connection specifies a parent device which is missing. This can be easily reproduced with: nmcli con add type vxlan ifname vxlan1 \ vxlan.parent not-exists \ id 43 remote 172.25.1.1 which creates a vxlan1 interface without activating any connection. Add a check to prevent this. https://bugzilla.redhat.com/show_bug.cgi?id=1774074 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/344
* contrib/rpm: avoid warning in specfile about tokens after %endifThomas Haller2019-11-231-2/+2
| | | | | warning: extra tokens at the end of %endif directive in line 717: %endif # end autotools warning: extra tokens at the end of %endif directive in line 775: %endif # end autotools
* dhcp: switch IPv4 "internal" DHCP client to use "nettools" backend instead ↵Thomas Haller2019-11-232-1/+3
| | | | | | | | | | | | | | | | | | | | | | | of "systemd" Previously, our "internal" DHCPv4 client is based on a fork of systemd code. This manner of maintaining the fork is problematic. The solution is to use a proper library: n-dhcp4 from the nettools project. We already have these two as undocumented plugins available, by setting either "dhcp=systemd" or "dhcp=nettools". This is only for testing. Users are only supposed to use the "internal" plugin. Up until now, the "internal" DHCPv4 plugin was based on "systemd" code. Change that to use "nettools" instead. Possibly this breaks something, and we need to fix it. But do this early so we have time to test the nettools plugin and identify issues. For the user, this change should be entirely transparant. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/302
* iface-helper: accept new DHCP4 leasesBeniamino Galvani2019-11-231-0/+4
| | | | | The new lease must be accepted or the nettools client will not renew it.
* all: merge branch 'th/connectivity-cleanup'Thomas Haller2019-11-2318-334/+444
|\ | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/343
| * build/meson: cleanup "meson-post-install.sh"Thomas Haller2019-11-222-37/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | - the variables in meson.build and in the meson-post-install.sh script should have the same names. - the positional command line arguments should be assigned to variables, because the variable name acts like a documentation what the variable means (contrary to the argument number). - the boolean flags should not map to other special values, like "enable_docs ? 'install_docs' : ''". The name "enable_docs" is good already, it shall be either passed as 1 or 0 and use the name consistently.
| * build/meson: cleanup configuration_data() for pathsThomas Haller2019-11-228-38/+26
| | | | | | | | | | | | | | | | | | | | | | We don't need such data duplicated. The build setup should have only one configuration_data() for patching such values. Now we only have one global, immutable data_conf dictionary with configuration values. Note that none of the users of data_conf uses all entries, but as the entries are basically only dependent on the meson/configure option and valid for the entire project, this simplifies to handling.
| * build: create base directories for install-data-hook firstThomas Haller2019-11-221-9/+15
| | | | | | | | | | | | | | | | The dependencies of make are exectured in the order as they appear. We probably should start by creating the directories, before invoking other install hooks. Currently there is no difference, because none of the other hooks depend on the base directories. Still split it to a special target.
| * build: cleanup Makefile.am by moving "data_edit" firstThomas Haller2019-11-221-26/+32
| | | | | | | | | | | | | | | | | | $(data_edit) will be used later at an earlier place in the makefile (to edit "clients/cloud-setup/nm-cloud-setup.service", which will be handled earlier). Move it. Also minor cleanups, like allowing to incrementally build systemdsystemunit_DATA variable.
| * core: move _LOG*() macros to "shared/nm-glib-aux/nm-logging-fwd.h"Thomas Haller2019-11-222-108/+110
| | | | | | | | | | | | We preferably should use our convenience macros like _LOGD(). Since those macros expand to _NMLOG() (which needs to be defined separately), we can move it to "nm-logging-fwd.h" and reuse.
| * connectivity: fix using curl_multi_strerror() for CURLMcode error codeThomas Haller2019-11-221-2/+2
| |
| * connectivity: don't use the GIOChannel but poll the file descriptor directlyThomas Haller2019-11-221-15/+23
| | | | | | | | | | | | I guess, if you write portable applications, then GIOChannel makes a lot of sense. But we know that this is on Linux. We don't need to pretend that we cannot poll on the file descriptor directly.
| * connectivity: don't cancel curl timerfunction from timeoutThomas Haller2019-11-221-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | Curl documents about CURLMOPT_TIMERFUNCTION: The timer_callback will only be called when the timeout expire time is changed. That means, we should not cancel the timeout when it happend, but only when the callback is called again (or during cleanup). See-also: https://curl.haxx.se/libcurl/c/CURLMOPT_TIMERFUNCTION.html
| * shared: move nm_utils_ip._address_clear_host_address() helpers to sharedThomas Haller2019-11-223-96/+101
| |
| * shared: add nm_clear_g_source_inst()Thomas Haller2019-11-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | glib really likes the numeric source IDs. That is, g_idle_add(), g_timeout_add(), etc. return those IDs, that can then be destroyed with g_remove_source() (or nm_clear_g_source()). I think these numeric IDs are really not great. - API like g_idle_add() and g_remove_source() only works with the g_main_context_get_default() instance. That means, you cannot use this API for any other contexts. If you'd insist on using numeric IDs, you'd need to call g_main_context_find_source_by_id() on the right context first (but you'd also have to track the context alongside the ID). - g_remove_source() requires first a call to g_main_context_find_source_by_id(). This involves taking a mutex and doing an extra hash lookup. Instead, it often seems preferable to use the GSource instance directly. It works with any context, it can be referenced and unreferenced, and it can be destroyed, and avoids the overhead of g_main_context_find_source_by_id(). The only downside really is that keeping a GSource pointer takes one pointer size, while the guint source ID is usually only 4 bytes. Anyway, I think we should deal more with GSource instances directly. Hence, add this convenience macro, that works like nm_clear_g_source().
| * shared: add nm_g_*_source_new() and nm_g_source_attach() helpersThomas Haller2019-11-222-0/+76
| | | | | | | | | | Small utilities to make is more convenient to create and attach GSource instances.
| * shared/nm-glib: add compat implementation for G_SOURCE_FUNC()Thomas Haller2019-11-221-0/+6
| | | | | | | | G_SOURCE_FUNC() was only added in glib 2.58.
| * contrib/rpm: use proper check for nmtui conditional buildThomas Haller2019-11-221-1/+11
|/
* dhcp/nettools: fix format-nonliteral warning for printf in nettools_log()Thomas Haller2019-11-221-0/+1
| | | | | | | | ../src/dhcp/nm-dhcp-nettools.c:1048:27: error: format string is not a string literal [-Werror,-Wformat-nonliteral] msg = g_strdup_vprintf (fmt, ap); ^~~ Fixes: 97a8785148f9 ('nettools: enable logging')
* gitlab-ci: run tests on extra distributions only manuallyThomas Haller2019-11-221-0/+8
| | | | | | | | | | | For the moment, we use docker images from dockerhub, which require a lot of extra overhead to prepare and install the test environment. This should be improved, by using more suitable container images. Anyway, for now to alleviate the pressure on the freedesktop gitlab infrastructure, disable most test to only run manually. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/241#note_282521
* gitlab-ci: use Fedora 30 to build documentation and archived tarballThomas Haller2019-11-221-5/+5
|
* ifcfg: merge branch 'th/ifcfg-8021x-system-ca-certs'Thomas Haller2019-11-224-21/+34
|\
| * ifcfg: various cleanup in ifcfg writerThomas Haller2019-11-221-21/+18
| | | | | | | | | | | | | | | | | | | | | | svUnsetValue (ifcfg, KEY); if (condition) svSetValue* (ifcfg, KEY, ...); is not good. It requires first clearing the value, before setting it again. Various cleanup to fix such uses.
| * ifcfg: add support for "802-1x.system-ca-certs" settingThomas Haller2019-11-222-0/+9
| |
| * ifcfg: add svSetValueBoolean_cond_true() helperThomas Haller2019-11-222-0/+7
|/
* dhcp: merge branch 'bg/nettools-log'Beniamino Galvani2019-11-226-0/+142
|\ | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/337
| * nettools: enable loggingBeniamino Galvani2019-11-222-0/+35
| |