summaryrefslogtreecommitdiff
path: root/src/vpn
Commit message (Collapse)AuthorAgeFilesLines
* all: use nm_clear_pointer() instead of g_clear_pointer()Thomas Haller2020-03-231-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | g_clear_pointer() would always cast the destroy notify function pointer to GDestroyNotify. That means, it lost some type safety, like GPtrArray *ptr_arr = ... g_clear_pointer (&ptr_arr, g_array_unref); Since glib 2.58 ([1]), g_clear_pointer() is also more type safe. But this is not used by NetworkManager, because we don't set GLIB_VERSION_MIN_REQUIRED to 2.58. [1] https://gitlab.gnome.org/GNOME/glib/-/commit/f9a9902aac826ab4aecc25f6eb533a418a4fa559 We have nm_clear_pointer() to avoid this issue for a long time (pre 1.12.0). Possibly we should redefine in our source tree g_clear_pointer() as nm_clear_pointer(). However, I don't like to patch glib functions with our own variant. Arguably, we do patch g_clear_error() in such a manner. But there the point is to make the function inlinable. Also, nm_clear_pointer() returns a boolean that indicates whether anything was cleared. That is sometimes useful. I think we should just consistently use nm_clear_pointer() instead, which does always the preferable thing. Replace: sed 's/\<g_clear_pointer *(\([^;]*\), *\([a-z_A-Z0-9]\+\) *)/nm_clear_pointer (\1, \2)/g' $(git grep -l g_clear_pointer) -i
* all: use nm_clear_g_free() instead of g_clear_pointer()Thomas Haller2020-03-231-5/+5
| | | | | | | | | I think it's preferable to use nm_clear_g_free() instead of g_clear_pointer(, g_free). The reasons are not very strong, but I think it is overall preferable to have a shorthand for this frequently used functionality. sed 's/\<g_clear_pointer *(\([^;]*\), *\(g_free\) *)/nm_clear_g_free (\1)/g' $(git grep -l g_clear_pointer) -i
* all: unify spelling of "fall-through" comment for switch statementsThomas Haller2020-02-211-2/+2
| | | | | We used "/* fall through */" and "/* fall-through */" inconsistently. Rename to use only one variant.
* all: drop explicit casts from _GET_PRIVATE() macro callsThomas Haller2020-02-142-5/+5
| | | | | | | | | The _GET_PRIVATE() macros are all implemented based on _NM_GET_PRIVATE(). That macro tries to be more type safe and uses _Generic() to do the right thing. Explicitly casting is not only unnecessary, it defeats these (static) type checks. Don't do that.
* shared: drop _STATIC variant of macros that define functionsThomas Haller2020-02-131-3/+6
| | | | | | | | | | | | | | | | | | Several macros are used to define function. They had a "_STATIC" variant, to define the function as static. I think those macros should not try to abstract entirely what they do. They should not accept the function scope as argument (or have two variants per scope). This also because it might make sense to add additional __attribute__(()) to the function. That only works, if the macro does not pretend to *not* define a plain function. Instead, embrace what the function does and let the users place the function scope as they see fit. This also follows what is already done with static NM_CACHED_QUARK_FCN ("autoconnect-root", autoconnect_root_quark)
* all: add nm_utils_error_is_cancelled() and ↵Thomas Haller2020-02-101-1/+1
| | | | | | | | nm_utils_error_is_cancelled_or_disposing() Most callers would pass FALSE to nm_utils_error_is_cancelled(). That's not very useful. Split the two functions and have nm_utils_error_is_cancelled() and nm_utils_error_is_cancelled_is_disposing().
* all: use _nm_utils_inet4_ntop() instead of nm_utils_inet4_ntop()Thomas Haller2020-01-281-14/+14
| | | | | | | | | | | | | | | | | | | | | | | | and _nm_utils_inet6_ntop() instead of nm_utils_inet6_ntop(). nm_utils_inet4_ntop()/nm_utils_inet6_ntop() are public API of libnm. For one, that means they are only available in code that links with libnm/libnm-core. But such basic helpers should be available everywhere. Also, they accept NULL as destination buffers. We keep that behavior for potential libnm users, but internally we never want to use the static buffers. This patch needs to take care that there are no callers of _nm_utils_inet[46]_ntop() that pass NULL buffers. Also, _nm_utils_inet[46]_ntop() are inline functions and the compiler can get rid of them. We should consistently use the same variant of the helper. The only downside is that the "good" name is already taken. The leading underscore is rather ugly and inconsistent. Also, with our internal variants we can use "static array indices in function parameter declarations" next. Thereby the compiler helps to ensure that the provided buffers are of the right size.
* shared: move nm-dbus-auth-subject to shared/nm-libnm-core-internAntonio Cardace2019-12-241-1/+1
| | | | | | | | Move it to shared as it's useful for clients as well. Move and rename nm_dbus_manager_new_auth_subject_from_context() and nm_dbus_manager_new_auth_subject_from_message() in nm-dbus-manager.c as they're needed there.
* all: manually drop code comments with file descriptionThomas Haller2019-10-014-8/+4
|
* all: SPDX header conversionLubomir Rintel2019-09-104-56/+4
| | | | | $ find * -type f |xargs perl contrib/scripts/spdx.pl $ git rm contrib/scripts/spdx.pl
* firewall: refactor "nm-firewall-manager.c" to not use GDBusProxyThomas Haller2019-08-071-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | - Don't use GDBusProxy but plain GDBusConnection. NMFirewallManager is very simple, it doesn't use any of the features that GDBusProxy provides. - make NMFirewallManagerCallId typedef a pointer to the opaque call-id struct, instead of the struct itself. It's confusing to have a variable that does not look like a pointer and assigning %NULL to it. - internally drop the CBInfo typename and name the call-id variable constsistantly as "call_id". - no need to keep the call-id struct alive after cancelling it. That simplifies the lifetime managment of the pending call because the completion callback is always invoked shortly before destroying the call-id. - note that the caller is no longer allowed to cancel a call-id from inside the completion callback. That just complicates the implementation and is not necessary. Assert against that. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/230
* all: drop emacs file variables from source filesThomas Haller2019-06-114-4/+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.
* dispatcher: replace guint call-id by opaque NMDispatcherCallIdThomas Haller2019-05-271-9/+13
| | | | | | | | | A guint value can wrap, so we would need to check that we don't allocate duplicate IDs (which we currently don't, and it's likely never to actually hit). Just expose the (opaque) pointer of the call-id. We still keep a "request_id", but that is only for logging purpose.
* pacrunner: refactor pacrunner to use GDBusConnectionThomas Haller2019-05-131-19/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - use GDBusConnection instead of GDBusProxy. - rename "call-id" to "conf-id". It's really not a "call" but configuration that gets added and NMPacrunnerManager ensures that the configuration is send to pacrunner. - let "conf-id" keep a reference to NMPacrunnerManager. For one, when we remove configurations we need to call DestroyProxyConfiguration to remove it again. We cannot just abort the requests but must linger around until our configuration is properly cleaned up. Hence, we anyway cannot destroy the NMPacrunnerManager earlier. With respect to fixing shutdown not to leak anything, this merely means that we must wait (and iterate the main loop) as long as NMPacrunnerManager singleton still exits (that is anyway the plan how to fix shutdown). With these considerations it's also clear that our D-Bus calls must have a stricter timeout: NM_SHUTDOWN_TIMEOUT_MS. This is also nice because nm_pacrunner_manager_remove() no longer needs a manager parameter, it can just rely on having a reference to the manager. - for logging the configuration IDs, don't log pointer values. Logging pointer values should be avoided as it defeats ASLR. Instead, give them a "log_id" number. - pacrunner is a D-Bus activatable service. D-Bus activatable services needs special care. We don't want to start it over and over again. Instead, we only try to "StartServiceByName" if - we have any configuration to add - if pacrunner is currently confirmed not to be running (by watching name owner changes) - we didn't try to start it already. That means, only start it at the beginning and afterwards set a flag to block it. When we see pacrunner appear on D-Bus we always clear that flag, that means if pacrunner drops of, we will try to restart it (once).
* core: use nm_connection_get_setting_ip_config() helperThomas Haller2019-03-051-5/+1
| | | | (cherry picked from commit 2be022ad68158acd544704244a7d3193aa6545a7)
* policy: treat WireGuard devices as VPN for DNSThomas Haller2019-02-141-2/+0
| | | | | | | WireGuard devices are (will be) regular NMDevice implementations, but NMDnsManager should treat them like VPN. For that, reuse the device's type and nm_device_get_route_metric_default().
* all: drop unnecessary includes of <errno.h> and <string.h>Thomas Haller2019-02-122-4/+0
| | | | | "nm-macros-interal.h" already includes <errno.h> and <string.h>. No need to include it everywhere else too.
* vpn: add route to vpn gw when parent has a default device routeBeniamino Galvani2019-02-041-12/+28
| | | | | | | | | | | When the parent device has a device default route (i.e. without gateway) and we establish a VPN on top of it, 'ip route get' for the VPN gateway returns a device route, which is the same result we get for an unreachable VPN gateway. However it is necessary to add the route to the gateway or otherwise it will possibly become unreachable once the VPN gets activated. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/93
* all/trivial: rename NM_UTILS_LOOKUP_STR() to have "_A" suffixThomas Haller2019-01-151-7/+10
| | | | | | | | | | | | | | | | | NM_UTILS_LOOKUP_STR() uses alloca(). Partly to avoid the overhead of malloc(), but more important because it's convenient to use. It does not require to declare a varible to manage the lifetime of the heap allocation. It's quite safe, because the stack allocation is of a fixed size of only a few bytes. Overall, I think the convenience that we get (resulting in simpler code) outweighs the danger of stack allocation in this case. It's still worth it. However, as it uses alloca(), it still must not be used inside a (unbound) loop and it is obviously a macro. Rename the macros to have a _A() suffix. This should make the peculiarities more apparent.
* platform: merge NMPlatformError with nm-errorThomas Haller2018-12-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Platform had it's own scheme for reporting errors: NMPlatformError. Before, NMPlatformError indicated success via zero, negative integer values are numbers from <errno.h>, and positive integer values are platform specific codes. This changes now according to nm-error: success is still zero. Negative values indicate a failure, where the numeric value is either from <errno.h> or one of our error codes. The meaning of positive values depends on the functions. Most functions can only report an error reason (negative) and success (zero). For such functions, positive values should never be returned (but the caller should anticipate them). For some functions, positive values could mean additional information (but still success). That depends. This is also what systemd does, except that systemd only returns (negative) integers from <errno.h>, while we merge our own error codes into the range of <errno.h>. The advantage is to get rid of one way how to signal errors. The other advantage is, that these error codes are compatible with all other nm-errno values. For example, previously negative values indicated error codes from <errno.h>, but it did not entail error codes from netlink.
* all: don't use static buffer for nm_utils_inet*_ntop()Thomas Haller2018-12-191-15/+16
| | | | | | | | | | While nm_utils_inet*_ntop() accepts a %NULL buffer to fallback to a static buffer, don't do that. I find the possibility of using a static buffer here error prone and something that should be avoided. There is of course the downside, that in some cases it requires an additional line of code to allocate the buffer on the stack as auto-variable.
* core: improve and fix keeping connection active based on ↵Thomas Haller2018-12-092-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "connection.permissions" By setting "connection.permissions", a profile is restricted to a particular user. That means for example, that another user cannot see, modify, delete, activate or deactivate the profile. It also means, that the profile will only autoconnect when the user is logged in (has a session). Note that root is always able to activate the profile. Likewise, the user is also allowed to manually activate the own profile, even if no session currently exists (which can easily happen with `sudo`). When the user logs out (the session goes away), we want do disconnect the profile, however there are conflicting goals here: 1) if the profile was activate by root user, then logging out the user should not disconnect the profile. The patch fixes that by not binding the activation to the connection, if the activation is done by the root user. 2) if the profile was activated by the owner when it had no session, then it should stay alive until the user logs in (once) and logs out again. This is already handled by the previous commit. Yes, this point is odd. If you first do $ sudo -u $OTHER_USER nmcli connection up $PROFILE the profile activates despite not having a session. If you then $ ssh guest@localhost nmcli device you'll still see the profile active. However, the moment the SSH session ends, a session closes and the profile disconnects. It's unclear, how to solve that any better. I think, a user who cares about this, should not activate the profile without having a session in the first place. There are quite some special cases, in particular with internal activations. In those cases we need to decide whether to bind the activation to the profile's visibility. Also, expose the "bind" setting in the D-Bus API. Note, that in the future this flag may be modified via D-Bus API. Like we may also add related API that allows to tweak the lifetime of the activation. Also, I think we broke handling of connection visiblity with 37e8c53eeed "core: Introduce helper class to track connection keep alive". This should be fixed now too, with improved behavior. Fixes: 37e8c53eeed579fe34a68819cd12f3295d581394 https://bugzilla.redhat.com/show_bug.cgi?id=1530977
* core: add checks on connection default propertiesBeniamino Galvani2018-12-011-1/+1
| | | | | | | | | | 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.
* vpn: disconnect signal handlers from proxy in NMVpnConnection::dispose()Thomas Haller2018-09-141-0/+3
| | | | | | | | We cannot be sure who holds a reference to the proxy, and who is gonna call us back after the VPN connection instance is destroyed. (cherry picked from commit 6ebb9091d272c7af4e1eaab4a110f7de37fb2b4d)
* vpn: fix assertion during "SecretsRequired" in unexpected stateThomas Haller2018-09-141-3/+7
| | | | | | | | | | | | | | | | | | Got this assertion: NetworkManager[12939]: <debug> [1536917977.4868] active-connection[0x563d8fd34540]: set state deactivated (was deactivating) ... NetworkManager[12939]: nm-openvpn[1106] <info> openvpn[1132]: send SIGTERM NetworkManager[12939]: nm-openvpn[1106] <info> wait for 1 openvpn processes to terminate... NetworkManager[12939]: nm-openvpn[1106] <warn> openvpn[1132] exited with error code 1 NetworkManager[12939]: <info> [1536917977.5035] vpn-connection[0x563d8fd34540,2fdeaea3-975f-4325-8305-83ebca5eaa26,"my-openvpn-Red-Hat",0]: VPN plugin: requested secrets; state disconnected (9) NetworkManager[12939]: plugin_interactive_secrets_required: assertion 'priv->vpn_state == STATE_CONNECT || priv->vpn_state == STATE_NEED_AUTH' failed Meaning. We should either ensure that secrets_required_cb() signal callback is disconnected from proxy's signal, or we gracefully handle callbacks at unexpected moments. Do the latter. (cherry picked from commit 92344dd0848f2353b81eab5b0b294eb92aaf59c0)
* core: add support for connection.llmnrBeniamino Galvani2018-09-061-0/+1
|
* core: add nm_config_data_get_connection_default_int64()Beniamino Galvani2018-09-061-7/+4
|
* settings: use delegation instead of inheritance for NMSettingsConnection and ↵Thomas Haller2018-08-281-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* all: don't use gchar/gshort/gint/glong but C typesThomas Haller2018-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We commonly don't use the glib typedefs for char/short/int/long, but their C types directly. $ git grep '\<g\(char\|short\|int\|long\|float\|double\)\>' | wc -l 587 $ git grep '\<\(char\|short\|int\|long\|float\|double\)\>' | wc -l 21114 One could argue that using the glib typedefs is preferable in public API (of our glib based libnm library) or where it clearly is related to glib, like during g_object_set (obj, PROPERTY, (gint) value, NULL); However, that argument does not seem strong, because in practice we don't follow that argument today, and seldomly use the glib typedefs. Also, the style guide for this would be hard to formalize, because "using them where clearly related to a glib" is a very loose suggestion. Also note that glib typedefs will always just be typedefs of the underlying C types. There is no danger of glib changing the meaning of these typedefs (because that would be a major API break of glib). A simple style guide is instead: don't use these typedefs. No manual actions, I only ran the bash script: FILES=($(git ls-files '*.[hc]')) sed -i \ -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>\( [^ ]\)/\1\2/g' \ -e 's/\<g\(char\|short\|int\|long\|float\|double\)\> /\1 /g' \ -e 's/\<g\(char\|short\|int\|long\|float\|double\)\>/\1/g' \ "${FILES[@]}"
* all: use the elvis operator wherever possibleLubomir Rintel2018-05-101-3/+3
| | | | | | | | | | | | | | | | | | | | | Coccinelle: @@ expression a, b; @@ -a ? a : b +a ?: b Applied with: spatch --sp-file ternary.cocci --in-place --smpl-spacing --dir . With some manual adjustments on spots that Cocci didn't catch for reasons unknown. Thanks to the marvelous effort of the GNU compiler developer we can now spare a couple of bits that could be used for more important things, like this commit message. Standards commitees yet have to catch up.
* all: remove consecutive empty linesBeniamino Galvani2018-04-301-1/+0
| | | | | | | Normalize coding style by removing consecutive empty lines from C sources and headers. https://github.com/NetworkManager/NetworkManager/pull/108
* manager: ensure valid specific_object path is passed to _new_active_connection()Thomas Haller2018-04-181-0/+1
| | | | | | From the D-Bus layer, no specific-object is represented by "/". We should early on normalize such values to NULL, and not expect or handle them later (like during _new_active_connection()).
* core: specify an activation reason for active connectionsBeniamino Galvani2018-04-082-0/+3
| | | | | | Specify a reason when creating active connections. The reason will be used in the next commit to tell whether slaves must be reconnected or not if a master has autoconnect-slaves=yes.
* core/dbus: rework D-Bus implementation to use lower layer GDBusConnection APIThomas Haller2018-03-122-42/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we used the generated GDBusInterfaceSkeleton types and glued them via the NMExportedObject base class to our NM types. We also used GDBusObjectManagerServer. Don't do that anymore. The resulting code was more complicated despite (or because?) using generated classes. It was hard to understand, complex, had ordering-issues, and had a runtime and memory overhead. This patch refactors this entirely and uses the lower layer API GDBusConnection directly. It replaces the generated code, GDBusInterfaceSkeleton, and GDBusObjectManagerServer. All this is now done by NMDbusObject and NMDBusManager and static descriptor instances of type GDBusInterfaceInfo. This adds a net plus of more then 1300 lines of hand written code. I claim that this implementation is easier to understand. Note that previously we also required extensive and complex glue code to bind our objects to the generated skeleton objects. Instead, now glue our objects directly to GDBusConnection. The result is more immediate and gets rid of layers of code in between. Now that the D-Bus glue us more under our control, we can address issus and bottlenecks better, instead of adding code to bend the generated skeletons to our needs. Note that the current implementation now only supports one D-Bus connection. That was effectively the case already, although there were places (and still are) where the code pretends it could also support connections from a private socket. We dropped private socket support mainly because it was unused, untested and buggy, but also because GDBusObjectManagerServer could not export the same objects on multiple connections. Now, it would be rather straight forward to fix that and re-introduce ObjectManager on each private connection. But this commit doesn't do that yet, and the new code intentionally supports only one D-Bus connection. Also, the D-Bus startup was simplified. There is no retry, either nm_dbus_manager_start() succeeds, or it detects the initrd case. In the initrd case, bus manager never tries to connect to D-Bus. Since the initrd scenario is not yet used/tested, this is good enough for the moment. It could be easily extended later, for example with polling whether the system bus appears (like was done previously). Also, restart of D-Bus daemon isn't supported either -- just like before. Note how NMDBusManager now implements the ObjectManager D-Bus interface directly. Also, this fixes race issues in the server, by no longer delaying PropertiesChanged signals. NMExportedObject would collect changed properties and send the signal out in idle_emit_properties_changed() on idle. This messes up the ordering of change events w.r.t. other signals and events on the bus. Note that not only NMExportedObject messed up the ordering. Also the generated code would hook into notify() and process change events in and idle handle, exhibiting the same ordering issue too. No longer do that. PropertiesChanged signals will be sent right away by hooking into dispatch_properties_changed(). This means, changing a property in quick succession will no longer be combined and is guaranteed to emit signals for each individual state. Quite possibly we emit now more PropertiesChanged signals then before. However, we are now able to group a set of changes by using standard g_object_freeze_notify()/g_object_thaw_notify(). We probably should make more use of that. Also, now that our signals are all handled in the right order, we might find places where we still emit them in the wrong order. But that is then due to the order in which our GObjects emit signals, not due to an ill behavior of the D-Bus glue. Possibly we need to identify such ordering issues and fix them. Numbers (for contrib/rpm --without debug on x86_64): - the patch changes the code size of NetworkManager by - 2809360 bytes + 2537528 bytes (-9.7%) - Runtime measurements are harder because there is a large variance during testing. In other words, the numbers are not reproducible. Currently, the implementation performs no caching of GVariants at all, but it would be rather simple to add it, if that turns out to be useful. Anyway, without strong claim, it seems that the new form tends to perform slightly better. That would be no surprise. $ time (for i in {1..1000}; do nmcli >/dev/null || break; echo -n .; done) - real 1m39.355s + real 1m37.432s $ time (for i in {1..2000}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects > /dev/null || break; echo -n .; done) - real 0m26.843s + real 0m25.281s - Regarding RSS size, just looking at the processes in similar conditions, doesn't give a large difference. On my system they consume about 19MB RSS. It seems that the new version has a slightly smaller RSS size. - 19356 RSS + 18660 RSS
* core: implement setting MDNS setting for systemdThomas Haller2018-01-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | The connection.mdns setting is a per-connection setting, so one might expect that one activated device can only have one MDNS setting at a time. However, with certain VPN plugins (those that don't have their own IP interface, like libreswan), the VPN configuration is merged into the configuration of the device. So, in this case, there might be multiple settings for one device that must be merged. We already have a mechanism for that. It's NMIP4Config. Let NMIP4Config track this piece of information. Although, stricitly speaking this is not tied to IPv4, the alternative would be to introduce a new object to track such data, which would be a tremendous effort and more complicated then this. Luckily, NMDnsManager and NMDnsPlugin are already equipped to handle multiple NMIPConfig instances per device (IPv4 vs. IPv6, and Device vs. VPN). Also make "connection.mdns" configurable via global defaults in NetworkManager.conf.
* all: get rid of a handful of unused-but-set variablesLubomir Rintel2017-12-181-2/+0
|
* core: refactor NMSettingsConnectionCallId typedef not to be a pointer to structThomas Haller2017-11-271-2/+2
| | | | | Typedefs to structs are fine, but a typedef for a pointer seems confusing to me. Let's avoid it.
* core/vpn: mark secret hints as constThomas Haller2017-11-231-14/+18
|
* vpn: avoid adding unneeded routes when ipvx.ignore-auto-routes=yesBeniamino Galvani2017-11-171-6/+10
| | | | | | Instead of adding routes and then let nm_ipx_config_merge_setting() remove them, don't add them in the first place when ipvx.ignore-auto-routes=yes.
* vpn: avoid coverity warning in print_vpn_config()Thomas Haller2017-11-151-2/+2
| | | | | coverity thinks that @address4 might be NULL. Maybe it can. We have an nm_assert(), but to be sure, check the value.
* vpn: consider the never-default connection propertyBeniamino Galvani2017-10-251-5/+11
| | | | | | | | | | | After commit 5c299454b49b ("core: rework tracking of gateway/default-route in ip-config") NM set a default route for VPNs only based on the "never-default" option reported by the plugin. It should also consider the connection setting. Fixes: 5c299454b49b165f645c25fd3e083c0bb747ad91 https://bugzilla.redhat.com/show_bug.cgi?id=1505886
* core,clients: use our own string hashing function nm_str_hash()Thomas Haller2017-10-181-1/+1
| | | | | | | | | | | | | | | | | | | | Replace the usage of g_str_hash() with our own nm_str_hash(). GLib's g_str_hash() uses djb2 hashing function, just like we do at the moment. The only difference is, that we use a diffrent seed value. Note, that we initialize the hash seed with random data (by calling getrandom() or reading /dev/urandom). That is a change compared to before. This change of the hashing function and accessing the random pool might be undesired for libnm/libnm-core. Hence, the change is not done there as it possibly changes behavior for public API. Maybe we should do that later though. At this point, there isn't much of a change. This patch becomes interesting, if we decide to use a different hashing algorithm.
* core: rework tracking of gateway/default-route in ip-configThomas Haller2017-10-101-32/+19
| | | | | | | | | | | | | | | | | | | | | | Instead of having 3 properties @gateway, @never_default and @has_gateway on NMIP4Config/NMIP6Config that determine the default-route, track the default-route as a regular route. The gateway setting is the configuration knob for the default-route. Since an NMIP4Config/NMIP6Config instance only has one gateway property, it cannot track more then one default-routes (see related bug rh#1445417). Especially with policy routing, it might be interesting to configure a default-route in multiple tables. Also, later it might be interesting to allow adding default-routes as regular static routes in a connection, so that the user can configure additional route parameters for the default-route or add default-routes in multiple tables. With this patch, default-routes now have a rt_source property according to their origin. Also, the previous commits of this branch broke handling of the default-route :) . That should be working now again.
* core: don't track route MSS in ip-configThomas Haller2017-10-091-6/+6
| | | | | | | | | | | | | | | | | The MSS is only set for VPN connections (by merging it in the respective NMIP4Config/NMIP6Config). It is also only used when setting the MSS of the default route. Don't track that property in NMIP4Config/NMIP6Config, instead, set the mss of the route directly in nm_vpn_connection_ip4_config_get() and nm_vpn_connection_ip6_config_get(). There is a potential change in behavior here: NMDevice also consisdered the MSS for the default route, but that would only be set if the MSS gets merged from an vpn-ip-config. Which at most is the case for iterface-less VPN types (libreswan). But even in that case, it doesn't seem right to me to use the VPN's MSS for the device's default-route.
* core: use ipv6.route-table setting for other IPv6 routesThomas Haller2017-10-091-4/+10
| | | | Including device-routes, default-route, SLAAC.
* core: use ipv4.route-table setting for other IPv4 routesThomas Haller2017-10-091-3/+9
| | | | Including device-routes, default-route, DHCPv4, IPv4LL.
* all: rework configuring route table support by adding "route-table" settingThomas Haller2017-10-091-11/+17
| | | | | | | | | | | | | | | | | | | | | | | | | We added "ipv4.route-table-sync" and "ipv6.route-table-sync" to not change behavior for users that configured policy routing outside of NetworkManager, for example, via a dispatcher script. Users had to explicitly opt-in for NetworkManager to fully manage all routing tables. These settings were awkward. Replace them with new settings "ipv4.route-table" and "ipv6.route-table". Note that this commit breaks API/ABI on the unstable development branch by removing recently added API. As before, a connection will have no route-table set by default. This has the meaning that policy-routing is not enabled and only the main table will be fully synced. Once the user sets a table, we recognize that and NetworkManager manages all routing tables. The new route-table setting has other important uses: analog to "ipv4.route-metric", it is the default that applies to all routes. Currently it only works for static routes, not DHCP, SLAAC, default-route, etc. That will be implemented later. For static routes, each route still can explicitly set a table, and overwrite the per-connection setting in "ipv4.route-table" and "ipv6.route-table".
* device/trivial: rename nm_device_get_ip_route_metric() to ↵Thomas Haller2017-10-061-2/+2
| | | | | | nm_device_get_route_metric() Brevity!
* device: remove wrappers for nm_device_get_ip_route_metric()Thomas Haller2017-10-061-2/+2
|
* libnm,core: add TABLE attribute for routes settingsThomas Haller2017-09-261-1/+31
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=1436531