summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* platform: print persistent-keepalive setting of WireGuard peersth/various-for-wireguard-3Thomas Haller2019-02-131-2/+7
|
* platform: add peer_flags argument to nm_platform_link_wireguard_change()Thomas Haller2019-02-134-52/+121
|
* platform: add flags for setting individual WireGuard options of linkThomas Haller2019-02-134-15/+32
|
* platform: add change-flags argument to platform's link_wireguard_change()Thomas Haller2019-02-134-11/+21
| | | | | | | | | We will need more flags. WireGuard internal tools solve this by embedding the change flags inside the structure that corresponds to NMPlatformLnkWireGuard. We don't do that, NMPlatformLnkWireGuard is only for containing the information about the link.
* device: add mechanism to invoke act_stage2_config() function also for ↵Thomas Haller2019-02-132-2/+10
| | | | | | | | | | external/assume case Usually, for external/assume we skip calling act_stage2_config(). Add a flag that allows the device to indicate that it always wants to be called. This is useful, if the device wants to do some initialization also for external/assume cases.
* device: split activate_stage2_device_config() steps for assumed/external checkThomas Haller2019-02-131-6/+11
| | | | | | | | | | | Instead of performing a series of steps inside one check for "!nm_device_sys_iface_state_is_external_or_assume (self)", perform all steps individually (under the same check). There is no change in behavior, but this is more logical to me. We perform a series of steps, depending on condition. Each step individually depends on a set of conditions, instead of checking for a set of conditions and doing a series of independent steps.
* device: abort device activation if tc_commit() fails in stage2Thomas Haller2019-02-131-0/+1
| | | | | | | After we change the device's state to NM_DEVICE_STATE_FAILED, we must abort processing the current stage. Fixes: e4bdb219091004f751706aadc39e4fed21e86368
* libnm: add internal _nm_utils_secret_flags_validate() utilThomas Haller2019-02-132-0/+62
|
* libnm/trivial: rename NM_SETTING_SECRET_FLAG_ALL flag (formerly ↵Thomas Haller2019-02-132-3/+3
| | | | | | NM_SETTING_SECRET_FLAGS_ALL) It should mirror the naming pattern of the flags.
* policy: treat WireGuard devices as VPN for DNSThomas Haller2019-02-134-13/+41
| | | | | | | 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().
* libnm: add NMSockAddrEndpoint APIThomas Haller2019-02-134-0/+446
| | | | | | | | | | | | | | | | | | | | | NMSockAddrEndpoint is an immutable structure that contains the endpoint string of a service. It also includes the (naive) parsing of the host and port/service parts. This will be used for the endpoint of WireGuard's peers. But since endpoints are not something specific to WireGuard, give it a general name (and purpose) independent from WireGuard. Essentially, this structure takes a string in a manner that libnm understands, and uses it for node and service arguments for getaddrinfo(). NMSockAddrEndpoint allows to have endpoints that are not parsable into a host and port part. That is useful because our settings need to be able to hold invalid values. That is for forward compatibility (server sends a new endpoint format) and for better error handling (have invalid settings that can be constructed without loss, but fail later during the NMSetting:verify() step).
* clients/secret-agent: allow suppressing prompting the entry-id when ↵Thomas Haller2019-02-133-7/+18
| | | | | | | | requesting secrets When asking for the preshared-key for WireGuard peers, the secret request will be very verbose with redundant information. Allow suppressing the entry id from the prompt.
* clients/secret-agent: split creation of secret-request dataThomas Haller2019-02-132-125/+123
|
* clients/secret-agent: fail request_secrets_from_ui() if there are no secrets ↵Thomas Haller2019-02-131-0/+3
| | | | | | to be requested From looking at the code above, this likely shouldn't actually happen.
* clients/secret-agent: keep setting-name in request-dataThomas Haller2019-02-131-0/+7
| | | | | | | | | | It's not really used, but we shouldn't just forget about it. Currently, we fill requests only based on the connection-type, ignoring the setting-name. I guess, the concept of requesting secrets for a setting is utterly broken. But equally broken it is to just look at the connection (type). At least, don't just throw parts of the request away but keep it.
* shared: add macros for initializing NMSecretPtrThomas Haller2019-02-131-0/+25
|
* shared: make nm_streq() and nm_streq0() inline functionsThomas Haller2019-02-131-2/+12
| | | | | | | | | | There is no advantage in having these as macros. Make them inline functions, compiler should be able to decide that they are in fact inlinable. Also, don't call g_strcmp0() for nm_streq0(). It means we first have to call glib function, only to call a glibc function. No need for this abstraction.
* shared: add NM_STR_HAS_SUFFIX()Thomas Haller2019-02-131-1/+12
| | | | | | | | Contrary to g_str_has_suffix(), it exploits the fact the the suffix length is known at compile time. No need to call a glib function, to find out what we already know, to call strcmp(). Instead just calculate the string length and call memcmp().
* libnm: fix usage of nm_streq() macroThomas Haller2019-02-131-7/+7
| | | | | | | | | | | | | | | | | Yes, C has a preprocessor and nm_streq() currently is a macro. Still, macros should very much behave like regular functions. For example, no unexpected side-effects aside what a regular function would have, evaluating all arguments exactly once, or no side-effects w.r.t. the order in which arguments are evaluated. In some cases, we deviate from that for good reasons. For example NM_IN_SET() may not evaluate all arguments. _LOGD() may not evaluate any arguments, and NM_UTILS_LOOKUP_STR_DEFINE() is not a function-like macro at all. Still, that is not the case here. We avoid to misuse macros to write code that does not look like C.
* wifi-p2p: merge branch 'th/wifi-p2p-wait-supplicant-fix'Thomas Haller2019-02-133-111/+94
|\ | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/80
| * wifi-p2p: add FIXME comment for handling group_owner in NMDeviceWifiP2PThomas Haller2019-02-131-0/+1
| |
| * wifi-p2p: rework setting pending action waiting for supplicantThomas Haller2019-02-131-49/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we might have a pending action 'waiting-for-supplicant' registered, although the device was not waiting: <info> [1549611177.5815] device (wlan0): supplicant interface state: starting -> ready <debug> [1549611177.5816] device[0x55d1781ae5d0] (p2p-dev-wlan0): P2P: Releasing WPA supplicant interfaces. <debug> [1549611177.5816] device[0x55d1781ae5d0] (p2p-dev-wlan0): P2P: WPA supplicant management interface changed to /fi/w1/wpa_supplicant1/Interfaces/1. <trace> [1549611177.5816] device[0x55d1781ae5d0] (p2p-dev-wlan0): remove_pending_action (0): 'waiting-for-supplicant' not pending (expected) <debug> [1549611177.5816] device[0x55d1781ae5d0] (p2p-dev-wlan0): constructed (NMDeviceWifiP2P) <debug> [1549611177.5816] device[0x55d1781ae5d0] (p2p-dev-wlan0): add_pending_action (1): 'waiting-for-supplicant' The previous commit already fixed this bug by dropping the constructor property for NM_DEVICE_WIFI_P2P_MGMT_IFACE. Still, refactor handling of pending actions to keep track of whether we have a pending action registered.
| * wifi-p2p: drop constructor property NM_DEVICE_WIFI_P2P_MGMT_IFACEThomas Haller2019-02-133-46/+19
| | | | | | | | | | | | | | | | | | | | We already have a setter function nm_device_wifi_p2p_set_mgmt_iface() as we may need to change the mgmt-iface later on. Use that to set the supplicant interface instead of a constructor property. That makes the object creation simpler, because nothing noteworthy happens, until the very last statement in constructed() to add the pending action.
| * wifi-p2p: don't use g_signal_connect_object()Thomas Haller2019-02-131-16/+12
|/ | | | | | We already explicitly take care of the lifetime of mgmt_iface and disconnect all signal handlers. No need to register an additional weak-reference.
* po: update Danish (da) translationscootergrisen2019-02-131-1382/+1925
| | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/82
* shared: fix nm_errno_from_native() for negative inputThomas Haller2019-02-122-1/+4
| | | | Fixes: 67130e67060b2bf28ce68c7714ea021227ece751
* all: merge branch 'th/errno'Thomas Haller2019-02-12303-871/+707
|\ | | | | | | https://github.com/NetworkManager/NetworkManager/pull/292
| * shared: use nm_strerror_native_r() in lower layersThomas Haller2019-02-122-23/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | Subsequent calls to nm_strerror_native() overwrite the previous buffer. That is potentially dangerious. At least functions in shared/nm-utils (which are lower-layer utilities) should not do that and instead use a stack-local buffer. That is because these functions should not make assumptions about the way they are called. On the other end, nmcli passing the return-value of nm_strerror_native() to g_print() is clearly OK because the higher layers are in control of when the call nm_strerror_native() -- by relying that lower layers don't interfere.
| * systemd: define strerror() in sd-adapt header to nm_strerror_native()Thomas Haller2019-02-122-0/+11
| | | | | | | | | | Systemd uses strerror() extensively. Patch the function to use the thread-safe nm_strerror_native().
| * all: replace strerror() calls with nm_strerror_native()Thomas Haller2019-02-1222-75/+75
| |
| * all: replace g_strerror() calls with nm_strerror_native()Thomas Haller2019-02-1226-84/+84
| |
| * all: include "nm-utils/nm-errno.h" via "nm-default.h"Thomas Haller2019-02-128-8/+1
| |
| * shared: add nm_strerror_native() to replace strerror() and g_strerror()Thomas Haller2019-02-122-1/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have various options for strerror(), with ups and downsides: - strerror() - returns pointer that is overwritten on next call. It's convenient to use, but dangerous. - not thread-safe. - not guaranteed to be UTF-8. - strerror_r() - takes input buffer and is less convenient to use. At least, we are in control of when the buffer gets overwritten. - there is a Posix/XSI and a glibc variant, making it sligthly inconvenient to used. This could be solved by a wrapper we implement. - thread-safe. - not guaranteed to be UTF-8. - g_strerror() - convenient and safe to use. Also the buffer is never released for the remainder of the program. - passing untrusted error numbers to g_strerror() can result in a denial of service, as the internal buffer grows until out-of-memory. - thread-safe. - guaranteed to be UTF-8 (depending on locale). Add our own wrapper nm_strerror_native(). It is: - convenient to use (returning a buffer that does not require management). - slightly dangerous as the buffer gets overwritten on the next call (like strerror()). - thread-safe. - guaranteed to be UTF-8 (depending on locale). - doesn't keep an unlimited cache of strings, unlike g_strerror(). You can't have it all. g_strerror() is leaking all generated error messages. I think that is unacceptable, because it would mean we need to keep track where our error numbers come from (and trust libraries we use to only set a restricted set of known error numbers).
| * all: assert that native errno numbers are positiveThomas Haller2019-02-125-19/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | Use the NM_ERRNO_NATIVE() macro that asserts that these errno numbers are indeed positive. Using the macro also serves as a documentation of what the meaning of these numbers is. That is often not obvious, whether we have an nm_errno(), an nm_errno_native() (from <errno.h>), or another error number (e.g. WaitForNlResponseResult). This situation already improved by merging netlink error codes (nle), NMPlatformError enum and <errno.h> as nm_errno(). But we still must always be careful about not to mix error codes from different domains or transform them appropriately (like nm_errno_from_native()).
| * shared: cleanup separation and transition between errno and nmerr numbersThomas Haller2019-02-123-65/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The native error numbers (from <errno.h>) and our nmerr extention on top of them are almost the same. But there are peculiarities. Both errno and nmerr must be positive values. That is because some API (systemd) like to return negative error codes. So, a positive errno and its negative counter part indicate the same error. We need normalization functions that make an error number positive (these are nm_errno() and nm_errno_native()). This means, G_MININT needs special treatment, because it cannot be represented as a positive integer. Also, zero needs special treatment, because we want to encode an error, and zero already encodes no-error. Take care of these special cases. On top of that, nmerr reserves a range within native error numbers for NetworkManager specific failure codes. So we need to transition from native numbers to nmerr numbers via nm_errno_from_native(). Take better care of some special cases and clean them up. Also add NM_ERRNO_NATIVE() macro. While nm_errno_native() coerces a value in the suitable range, NM_ERRNO_NATIVE() asserts that the number is already positive (and returns it as-is). It's use is only for asserting and implicitly documenting the requirements we have on the number passed to it.
| * shared: fix nm_errno_from_native() for negative valuesThomas Haller2019-02-121-3/+3
| | | | | | | | | | | | | | We first need to map negative values to their positive form, and then do the check for the reserved range. Fixes: 18732c349310fa84f2b565b7d4efa347b5f172d5
| * all: cache errno in local variable before using itThomas Haller2019-02-1234-147/+217
| |
| * libnm,core: use _nm_utils_ascii_str_to_uint64() instead of strtol()Thomas Haller2019-02-123-26/+11
| | | | | | | | | | | | | | Using strtol() correctly proves to be hard. Usually, we want to also check that the end pointer is points to the end of the string. Othewise, we silently accept trailing garbage.
| * all: drop unnecessary includes of <errno.h> and <string.h>Thomas Haller2019-02-12287-467/+56
| | | | | | | | | | "nm-macros-interal.h" already includes <errno.h> and <string.h>. No need to include it everywhere else too.
| * systemd/trivial: adjust naming of include guard defineThomas Haller2019-02-121-3/+3
|/
* all: minor coding style fixes (space before parentheses)Thomas Haller2019-02-115-14/+14
|
* platform: limit the maximum size of sysctl cacheBeniamino Galvani2019-02-101-15/+46
| | | | | | | | | | | | When the logging level is DEBUG or TRACE, we keep all the sysctl values we read in a cache to log how they change. Currently there is no limit on the size of this cache and it can take a large amount of memory. Implement a LRU cache where the oldest entries are deleted to make space for new ones. https://github.com/NetworkManager/NetworkManager/pull/294
* build,ci: merge branch 'th/missing-braces-warning'Thomas Haller2019-02-0921-164/+170
|\ | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/81
| * core: use NM_CMP_*() macro in route_compare()th/missing-braces-warningThomas Haller2019-02-091-24/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | nm_ip_route_get_prefix() and plen are guint type, hence the following is not correct: plen = nm_ip_route_get_prefix (route1); r = plen - nm_ip_route_get_prefix (route2); if (r) return r > 0 ? 1 : -1; Use the macro, it gets subtle cases like this right. Fixes: b32bb36c61c102e73d73cbc78c5fa412af706e0b
| * build/meson: build with c_std=gnu11Thomas Haller2019-02-091-1/+1
| | | | | | | | | | | | For autotools, we already updated to C11 (gnu11) with commit 066357aa4766315fe9b9ed83f6cf16d9b87c6944 ("build: bump C standard to (gcc's) C11").
| * gitlab-ci: rename build-jobs in gitlab-ciThomas Haller2019-02-091-4/+4
| | | | | | | | It just looks nicer.
| * build/ci: enable --werror for meson buildsThomas Haller2019-02-081-3/+16
| | | | | | | | | | | | | | | | | | This enables -Werror for meson builds on gitlab-ci and semaphore. Not on Travis, the compiler there is too old, giving too many bogus warnings. This reverts commit 928d68d04af20808f801f05f92ad83179d7b826e ("m4: disable -Wmissing-braces for newer clang").
| * contrib/rpm: enable warnings and fatal-warnings with meson buildThomas Haller2019-02-081-0/+4
| |
| * build: re-enable "-Wmissing-braces" warningThomas Haller2019-02-082-7/+0
| | | | | | | | | | | | | | We should always get the nesting in struct initializers right. Everyhing else is error-prone, and the warning is good. Enable it.
| * device: avoid "-Wmissing-braces" warning for initializing "struct in6_addr"Thomas Haller2019-02-081-3/+7
| | | | | | | | | | | | | | | | | | | | | | The right way is IN6_ADDR_INIT_ANY. While at it, don't initialize multiple variables in the same line. ../src/devices/nm-device-ip-tunnel.c:153:29: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces] struct in6_addr local6 = { 0 }, remote6 = { 0 }; ^ {}