summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* libnm: use "libnm-systemd-shared.a" in "libnm-core.la" (and "libnm.so")th/shared-systemdThomas Haller2019-01-028-2/+100
| | | | | | | | | | | | It's not yet used, but it will be. We will need nm_sd_utils_unbase64mem() to validate WireGuard settings, which contain keys in base64 encoding. Note that we also need a stub implementation for logging. This just does nothing for all logging from "libnm-systemd-shared.a". This makes sense because "libnm.so" as a library should not log directly. Also, "libnm.so" will only use a small portion of "libnm-systemd-shared.a" which does not log. Thus this code is anyway unused and dropped by the linker with "--gc-sections".
* systemd: expose unbase64mem() as nm_sd_utils_unbase64mem()Thomas Haller2019-01-024-0/+98
| | | | | | | | | | | | | | | 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-02145-380/+561
| | | | | | | | | | | 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.
* shared/trivial: add comment about compat macro _NM_CC_SUPPORT_GENERIC w.r.t. C11Thomas Haller2019-01-021-0/+4
| | | | | | | | | | | C11 provides _Generic(). Until now we used it when the compiler supports it (in extended --std=gnu99 mode). In practice, now that we require C11 it should always be present. We will drop compatibility code in the future. For now, just add a comment and keep it. The reason is, that "shared/nm-utils/nm-macros-internal.h" may be used by VPN plugins or applet, which may or may not yet bump to C11. Keeping it for now, allows for an easier update.
* systemd: drop workaround for missing C11 header <uchar.h>Thomas Haller2019-01-026-14/+17
| | | | Now as we build as C11, we can us it.
* build: bump C standard to (gcc's) C11Thomas Haller2019-01-021-2/+5
| | | | | | | | | | | | | | We already import systemd code which is C11. To get this even to build, we need workaround like patching import of <uchar.h>. Also, the libraries from c-util and nettools are C11. We cannot even compile them in C99 mode (and didn't do that either). It's time to bump the version. We need C11 from now on (or better: gcc's dialect of it). Also, note that since nettools/nacd is not optional, we could not even build NetworkManager without a C11 compiler. So, just use it everywhere.
* shared,core: move logging enums to header "shared/nm-utils/nm-logging-fwd.h"Thomas Haller2019-01-024-82/+121
| | | | | | | | | | | | | In core ("src/"), we use "nm-logging.h" for all logging. This dispatches for logging to syslog, glog or systemd-journald. If we want to log from a shared component under "shared/", we need to use a common logging function. Add "nm-utils/nm-logging-fwd.h" for forward declaring the used logging mechaism. The shared library will still need to link with "src/nm-logging.c" or an alternative implementation, depending on whether it is used inside core or not.
* all: merge branch 'th/various-fixes'Thomas Haller2019-01-029-142/+193
|\ | | | | | | https://github.com/NetworkManager/NetworkManager/pull/272
| * keyfile: various refactoring and restructure nm_keyfile_read()Thomas Haller2019-01-024-125/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | - in nm_keyfile_read(), unify _read_setting() and _read_setting_vpn_secret() in they way they are called (that is, they no longer return any value and don't accept any arguments aside @info). - use cleanup attributes - use nm_streq() instead of strcmp(). - wrap lines that have multiple statements or conditions.
| * keyfile: ensure array lengths are always initializedThomas Haller2019-01-022-9/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several callers access the length output argument, expecting it to be zero also on failure. That is a bug, because glib does not guarantee that. Fix that by making a stronger promise from our wrappers: the output argument should also be set on failure. Also ensure that calls to g_keyfile_get_groups() and g_keyfile_get_keys() don't rely on the length output to be valid, when the function call fails. Actually, these issues were not severe because: - `g_key_file_get_*_list()`'s implementation always sets the output length even on failure (undocumented). - `g_key_file_get_groups()` cannot fail and always set the length. - `g_key_file_get_keys()` is called under circumstances where it won't fail. Still, be explicit about it.
| * contrib: adjust NM-log for changes to platform loggingThomas Haller2018-12-301-1/+1
| | | | | | | | Fixes: 8f107f5c00258c7a4fb780a25f299af6f116f575
| * checkpatch: warn if there is a file "TODO.txt"Thomas Haller2018-12-301-3/+17
| | | | | | | | | | | | | | | | This allows us to add a file "TODO.txt" in the top level directory. This file is not intended to be merged to master, but keep track of stuff that is still to do before merging a branch. Let checkpatch.pl warn about the presence of such a file.
| * checkpatch: warn about suspicious gtk-doc annotationsThomas Haller2018-12-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | It's (allow-none): and (transfer none): That's confusing enough. Add a check.
| * libnm/gtk-doc: fix transfer-none annotation for nm_settings_get_connections()Thomas Haller2018-12-301-1/+1
| | | | | | | | Fixes: 6e54057bf754d9311e42d92956feb9b1036ca654
| * platform: fix nm_platform_wireguard_peer_to_string()Thomas Haller2018-12-301-1/+2
| | | | | | | | Fixes: 62d14e188489fab4ea8b20527925b47dc2c15f40
| * systemd: fix nm-logging domain for systemd loggingThomas Haller2018-12-301-1/+1
| | | | | | | | Fixes: c75c51d50545a56888aa6c35244fcee5510c5697
| * keyfile: fix memleak in nm_keyfile_read()Thomas Haller2018-12-301-2/+1
|/ | | | Fixes: 04df4edf48e55478d0f360ea566f5f398aa76268
* core: merge branch 'th/nm-error'Thomas Haller2018-12-2734-851/+903
|\ | | | | | | https://github.com/NetworkManager/NetworkManager/pull/267
| * platform: use nm_steal_fd() in nmp_utils_sysctl_open_netdir()Thomas Haller2018-12-271-5/+2
| |
| * platform: return platform-error from link-add functionThomas Haller2018-12-274-39/+38
| | | | | | | | | | | | | | | | We need more information what failed. Don't only return success/failure, but an error number. Note that we still don't actually return an error number. Only the link_add() function is changed to return an nm-error integer.
| * platform: merge NMPlatformError with nm-errorThomas Haller2018-12-2726-618/+591
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * shared: declare error numbers as enum and minor cleanupThomas Haller2018-12-272-36/+46
| |
| * trivial: rename nl-errno to nm-errnoThomas Haller2018-12-276-136/+137
| |
| * shared: move nm_errno() function to nm-errno.hThomas Haller2018-12-272-14/+22
| | | | | | | | No other changes (yet).
| * core: move netlink errors to nm-errno.hThomas Haller2018-12-277-90/+100
| | | | | | | | No other changes (yet).
| * shared,core: add "nm-errno.h"Thomas Haller2018-12-274-0/+54
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | This will be our extension on top of <errno.h>. We want to use (integer) error numbers, that can both contain native errors from <errno.h> and our own defines, both merge in one domain. That is, we will reserve a small range of integers for our own defines (that hopefully won't clash with errors from <errno.h>). We can use this at places where GError is too cumbersome to use. The advantage is, that our error numbers extend <errno.h> and can be mixed. This is what "src/platform/nm-netlink.h" already does with nl_errno(). Next, the netlink errors from there will be merged into "nm-errno.h". Also, platform has NMPlatformError, which are a distinct set of error numbers. But these work differently in the sense that negative values represent codes from <errno.h> and positive numbers are our own platform specific defines. NMPlatformError will also be merged into "nm-errno.h". "nm-errno.h" will unify the error handling of platform and netlink, making it more similar to what we are used to from systemd, and give room to extend it for our own purpose.
* systemd: merge branch systemd into masterThomas Haller2018-12-2368-1505/+2088
|\
| * systemd: update code from upstream (2018-12-22)Thomas Haller2018-12-2364-1522/+2288
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a direct dump from systemd git. ====== SYSTEMD_DIR=../systemd COMMIT=8eab766804ef4fa21d26c00fd0baab3f1a47bb5c ( cd "$SYSTEMD_DIR" git checkout "$COMMIT" git reset --hard git clean -fdx ) git ls-files :/src/systemd/src/ \ :/shared/nm-utils/unaligned.h | \ xargs -d '\n' rm -f nm_copy_sd() { mkdir -p "./src/systemd/$(dirname "$1")" cp "$SYSTEMD_DIR/$1" "./src/systemd/$1" } nm_copy_sd_shared() { mkdir -p "./shared/nm-utils/" cp "$SYSTEMD_DIR/$1" "./shared/nm-utils/${1##*/}" } nm_copy_sd "src/basic/alloc-util.c" nm_copy_sd "src/basic/alloc-util.h" nm_copy_sd "src/basic/async.h" nm_copy_sd "src/basic/env-file.c" nm_copy_sd "src/basic/env-file.h" nm_copy_sd "src/basic/env-util.c" nm_copy_sd "src/basic/env-util.h" nm_copy_sd "src/basic/escape.c" nm_copy_sd "src/basic/escape.h" nm_copy_sd "src/basic/ether-addr-util.c" nm_copy_sd "src/basic/ether-addr-util.h" nm_copy_sd "src/basic/extract-word.c" nm_copy_sd "src/basic/extract-word.h" nm_copy_sd "src/basic/fd-util.c" nm_copy_sd "src/basic/fd-util.h" nm_copy_sd "src/basic/fileio.c" nm_copy_sd "src/basic/fileio.h" nm_copy_sd "src/basic/fs-util.c" nm_copy_sd "src/basic/fs-util.h" nm_copy_sd "src/basic/hash-funcs.c" nm_copy_sd "src/basic/hash-funcs.h" nm_copy_sd "src/basic/hashmap.c" nm_copy_sd "src/basic/hashmap.h" nm_copy_sd "src/basic/hexdecoct.c" nm_copy_sd "src/basic/hexdecoct.h" nm_copy_sd "src/basic/hostname-util.c" nm_copy_sd "src/basic/hostname-util.h" nm_copy_sd "src/basic/in-addr-util.c" nm_copy_sd "src/basic/in-addr-util.h" nm_copy_sd "src/basic/io-util.c" nm_copy_sd "src/basic/io-util.h" nm_copy_sd "src/basic/list.h" nm_copy_sd "src/basic/log.h" nm_copy_sd "src/basic/macro.h" nm_copy_sd "src/basic/mempool.c" nm_copy_sd "src/basic/mempool.h" nm_copy_sd "src/basic/parse-util.c" nm_copy_sd "src/basic/parse-util.h" nm_copy_sd "src/basic/path-util.c" nm_copy_sd "src/basic/path-util.h" nm_copy_sd "src/basic/prioq.c" nm_copy_sd "src/basic/prioq.h" nm_copy_sd "src/basic/process-util.c" nm_copy_sd "src/basic/process-util.h" nm_copy_sd "src/basic/random-util.c" nm_copy_sd "src/basic/random-util.h" nm_copy_sd "src/basic/refcnt.h" nm_copy_sd "src/basic/set.h" nm_copy_sd "src/basic/signal-util.h" nm_copy_sd "src/basic/siphash24.h" nm_copy_sd "src/basic/socket-util.c" nm_copy_sd "src/basic/socket-util.h" nm_copy_sd "src/basic/sparse-endian.h" nm_copy_sd "src/basic/stat-util.c" nm_copy_sd "src/basic/stat-util.h" nm_copy_sd "src/basic/stdio-util.h" nm_copy_sd "src/basic/string-table.c" nm_copy_sd "src/basic/string-table.h" nm_copy_sd "src/basic/string-util.c" nm_copy_sd "src/basic/string-util.h" nm_copy_sd "src/basic/strv.c" nm_copy_sd "src/basic/strv.h" nm_copy_sd "src/basic/time-util.c" nm_copy_sd "src/basic/time-util.h" nm_copy_sd "src/basic/tmpfile-util.c" nm_copy_sd "src/basic/tmpfile-util.h" nm_copy_sd "src/basic/umask-util.h" nm_copy_sd "src/basic/utf8.c" nm_copy_sd "src/basic/utf8.h" nm_copy_sd "src/basic/util.c" nm_copy_sd "src/basic/util.h" nm_copy_sd "src/libsystemd-network/arp-util.c" nm_copy_sd "src/libsystemd-network/arp-util.h" nm_copy_sd "src/libsystemd-network/dhcp-identifier.c" nm_copy_sd "src/libsystemd-network/dhcp-identifier.h" nm_copy_sd "src/libsystemd-network/dhcp-internal.h" nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h" nm_copy_sd "src/libsystemd-network/dhcp-network.c" nm_copy_sd "src/libsystemd-network/dhcp-option.c" nm_copy_sd "src/libsystemd-network/dhcp-packet.c" nm_copy_sd "src/libsystemd-network/dhcp-protocol.h" nm_copy_sd "src/libsystemd-network/dhcp6-internal.h" nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h" nm_copy_sd "src/libsystemd-network/dhcp6-network.c" nm_copy_sd "src/libsystemd-network/dhcp6-option.c" nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h" nm_copy_sd "src/libsystemd-network/lldp-internal.h" nm_copy_sd "src/libsystemd-network/lldp-neighbor.c" nm_copy_sd "src/libsystemd-network/lldp-neighbor.h" nm_copy_sd "src/libsystemd-network/lldp-network.c" nm_copy_sd "src/libsystemd-network/lldp-network.h" nm_copy_sd "src/libsystemd-network/network-internal.c" nm_copy_sd "src/libsystemd-network/network-internal.h" nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c" nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c" nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c" nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c" nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c" nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c" nm_copy_sd "src/libsystemd-network/sd-lldp.c" nm_copy_sd "src/libsystemd/sd-event/event-source.h" nm_copy_sd "src/libsystemd/sd-event/event-util.c" nm_copy_sd "src/libsystemd/sd-event/event-util.h" nm_copy_sd "src/libsystemd/sd-event/sd-event.c" nm_copy_sd "src/libsystemd/sd-id128/id128-util.c" nm_copy_sd "src/libsystemd/sd-id128/id128-util.h" nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c" nm_copy_sd "src/shared/dns-domain.c" nm_copy_sd "src/shared/dns-domain.h" nm_copy_sd "src/systemd/_sd-common.h" nm_copy_sd "src/systemd/sd-dhcp-client.h" nm_copy_sd "src/systemd/sd-dhcp-lease.h" nm_copy_sd "src/systemd/sd-dhcp6-client.h" nm_copy_sd "src/systemd/sd-dhcp6-lease.h" nm_copy_sd "src/systemd/sd-event.h" nm_copy_sd "src/systemd/sd-id128.h" nm_copy_sd "src/systemd/sd-ipv4acd.h" nm_copy_sd "src/systemd/sd-ipv4ll.h" nm_copy_sd "src/systemd/sd-lldp.h" nm_copy_sd "src/systemd/sd-ndisc.h" nm_copy_sd_shared "src/basic/unaligned.h"
* | systemd: merge branch 'thom311/dhcp-set-client-id-no-inval'Thomas Haller2018-12-214-22/+27
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | We use sd_dhcp_client_set_client_id() and sd_dhcp6_client_set_duid() with the aim to set arbitrary client identifiers and DUIDs. Adjust systemd DHCP library to not reject certain values. https://github.com/systemd/systemd/pull/11210 https://github.com/systemd/systemd/commit/5848a9eb4d4c937012461d440eb798db265a65f9
| * | dhcp6: don't enforce DUID content for sd_dhcp6_client_set_duid()Thomas Haller2018-12-214-6/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are various functions to set the DUID of a DHCPv6 client. However, none of them allows to set arbitrary data. The closest is sd_dhcp6_client_set_duid(), which would still do validation of the DUID's content via dhcp_validate_duid_len(). Relax the validation and only log a debug message if the DUID does not validate. Note that dhcp_validate_duid_len() already is not very strict. For example with DUID_TYPE_LLT it only ensures that the length is suitable to contain hwtype and time. It does not further check that the length of hwaddr is non-zero or suitable for hwtype. Also, non-well-known DUID types are accepted for extensibility. Why reject certain DUIDs but allowing clearly wrong formats otherwise? The validation and failure should happen earlier, when accepting the unsuitable DUID. At that point, there is more context of what is wrong, and a better failure reason (or warning) can be reported to the user. Rejecting the DUID when setting up the DHCPv6 client seems not optimal, in particular because the DHCPv6 client does not care about actual content of the DUID and treats it as opaque blob. Also, NetworkManager (which uses this code) allows to configure the entire binary DUID in binary. It intentionally does not validate the binary content any further. Hence, it needs to be able to set _invalid_ DUIDs, provided that some basic constraints are satisfied (like the maximum length). sd_dhcp6_client_set_duid() has two callers: both set the DUID obtained from link_get_duid(), which comes from configuration. `man networkd.conf` says: "The configured DHCP DUID should conform to the specification in RFC 3315, RFC 6355.". It does not not state that it MUST conform. Note that dhcp_validate_duid_len() has another caller: DHCPv4's dhcp_client_set_iaid_duid_internal(). In this case, continue with strict validation, as the callers are more controlled. Also, there is already sd_dhcp_client_set_client_id() which can be used to bypass this check and set arbitrary client identifiers. https://github.com/systemd/systemd/commit/ab4a88bc29e31754ec50c4a865058ee36f6284a6
| * | dhcp: don't enforce hardware address length for sd_dhcp_client_set_client_id()Thomas Haller2018-12-211-18/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sd_dhcp_client_set_client_id() is the only API for setting a raw client-id. All other setters are more restricted and only allow to set a type 255 DUID. Also, dhcp4_set_client_identifier() is the only caller, which already does: r = sd_dhcp_client_set_client_id(link->dhcp_client, ARPHRD_ETHER, (const uint8_t *) &link->mac, sizeof(link->mac)); and hence ensures that the data length is indeed ETH_ALEN. Drop additional input validation from sd_dhcp_client_set_client_id(). The client-id is an opaque blob, and if a caller wishes to set type 1 (ethernet) or type 32 (infiniband) with unexpected address length, it should be allowed. The actual client-id is not relevant to the DHCP client, and it's the responsibility of the caller to generate a suitable client-id. For example, in NetworkManager you can configure all the bytes of the client-id, including such _invalid_ settings. I think it makes sense, to allow the user to fully configure the identifier. Even if such configuration would be rejected, it would be the responsibility of the higher layers (including a sensible error message to the user) and not fail later during sd_dhcp_client_set_client_id(). Still log a debug message if the length is unexpected. https://github.com/systemd/systemd/commit/bfda0d0f09666e2476c9abd0280c4b9fa82b968c
| * | dhcp: fix sd_dhcp_client_set_client_id() for infiniband addressesThomas Haller2018-12-211-1/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Infiniband addresses are 20 bytes (INFINIBAND_ALEN), but only the last 8 bytes are suitable for putting into the client-id. This bug had no effect for networkd, because sd_dhcp_client_set_client_id() has only one caller which always uses ARPHRD_ETHER type. I was unable to find good references for why this is correct ([1]). Fedora/RHEL has patches for ISC dhclient that also only use the last 8 bytes ([2], [3]). RFC 4390 (Dynamic Host Configuration Protocol (DHCP) over InfiniBand) [4] does not discuss the content of the client-id either. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1658057#c29 [2] https://bugzilla.redhat.com/show_bug.cgi?id=660681 [3] https://src.fedoraproject.org/rpms/dhcp/blob/3ccf3c8d815df4b8e11e1a04850975f099273d5d/f/dhcp-lpf-ib.patch [4] https://tools.ietf.org/html/rfc4390 https://github.com/systemd/systemd/commit/b9d80714583bf40e354ad0fc364ebfb35a0b3d76
* | device: ensure IP configuration is restored when link goes upBeniamino Galvani2018-12-211-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | When the link is up and goes down link_changed_cb() schedules device_link_changed() to be run later. If the function is dispatched when the link is already up again, it does not detect that the link was down. Fix this by storing in the device state that we saw the link down so that device_link_changed() can properly restore the IP configuration. https://bugzilla.redhat.com/show_bug.cgi?id=1636715 https://github.com/NetworkManager/NetworkManager/pull/264
* | build/meson: merge branch 'inigomartinez/meson-review'Thomas Haller2018-12-2064-293/+275
|\ \ | | | | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/23
| * | build: meson: Remove unnecessary auxiliary variableIñigo Martínez2018-12-201-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | The variable containing the list of compiler arguments to be checked can be removed without any harm to readibility. The variable has been removed by appending directly to the list of common compiler arguments, those that are supported.
| * | build: meson: Add trailing commasIñigo Martínez2018-12-2062-264/+264
| | | | | | | | | | | | | | | | | | | | | 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
| * | build: meson: Use variables present in pkg-config filesIñigo Martínez2018-12-202-20/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although some paths related to DBus and PolicyKit are present in their pkg-config files, those paths might not be writable for the user. To solve this issue, some build options are present that can be used to choose a different location. However, usually these paths are relative to some other variables such as `prefix`, `datadir`, etc. Using the `define_variable` option the relative path can be change to point to a directory under prefix. These paths are now using relative paths based on the installation `prefix` and their related options have been removed as they are unnecessary now. Only `dbus_conf_dir` option has been left because it must be modified depending on the distribution[0]. [0] contrib/fedora/rpm/NetworkManager.spec
| * | build: meson: Remove polkit_dir optionIñigo Martínez2018-12-203-5/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | meson is able to get variables defined in pkg-config files such as directory paths. PolicyKit defines in its pkg-config file the path to the directory where `policy` files are present. This removes the `polkit_dir` option to ease the move to start using those variables. The `polkit` variable has also been converted to boolean. Fedora spec script has also been updated accordingly.
* | device: fix method check in IPvLL codeBeniamino Galvani2018-12-201-5/+2
| | | | | | | | | | | | | | | | The check condition was inverted. Anyway, we should receive IPv4LL events only when the method is LINK_LOCAL so turn this into an assertion. Fixes: b16e09a707fd836cf1ea4ed34422158c8408d94f
* | dhcp: merge branch 'th/internal-dhcp-routes-rh1634657'Thomas Haller2018-12-1928-393/+651
|\ \ | | | | | | | | | | | | | | | https://bugzilla.redhat.com/show_bug.cgi?id=1634657 https://github.com/NetworkManager/NetworkManager/pull/256
| * | core: allow addresses with zero prefix lengthThomas Haller2018-12-193-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is really no problem here, allow it. Previously we would assert against a non-zero prefix length. But I am not sure that all callers really ensured that this couldn't happen. Anyway, there is no problem we such addresses, really. Only we need to make sure that nm_ip4_config_add_dependent_routes() and nm_ip6_config_add_dependent_routes() don't add prefix routes for such addresses (which is the case now).
| * | dhcp: fix static-route handling for intenal client and support multiple ↵Thomas Haller2018-12-192-57/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | default routes Preface: RFC 3442 (The Classless Static Route Option for Dynamic Host Configuration Protocol (DHCP) version 4) states: If the DHCP server returns both a Classless Static Routes option and a Router option, the DHCP client MUST ignore the Router option. Similarly, if the DHCP server returns both a Classless Static Routes option and a Static Routes option, the DHCP client MUST ignore the Static Routes option. Changes: - sd_dhcp_lease_get_routes() returns the combination of both option 33 (static routes) and 121 (classless static routes). If classless static routes are provided, the state routes must be ignored. - we collect the options hash that we expose on D-Bus. For that purpose, we must not merge both option types as classless static routes. Instead, we want to expose the values like we received them originally: as two different options. - we continue our deviation from RFC 3442, when receiving classless static routes with option 3 (Router), we only ignore the router if we didn't already receive a default route via classless static routes. - in the past, NetworkManager treated the default route specially, and one device could only have one default route. That limitation was already (partly) lifted by commit 5c299454b49b165f645c25fd3e083c0bb747ad91 (core: rework tracking of gateway/default-route in ip-config). However, from DHCP we still would only accept one default route. Fix that for internal client. Installing multiple default routes might make sense, as kernel apparently can skip unreachable routers (as it notes via ICMP messages) (rh#1634657). https://bugzilla.redhat.com/show_bug.cgi?id=1634657
| * | dhcp: request classless-static-route option first according to RFC 3442Thomas Haller2018-12-191-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In ip4_start(), we iterate over @dhcp4_requests array and add the options that are to be included. We do so, by calling sd_dhcp_client_set_request_option(). Note that sd_dhcp_client_set_request_option() only appends the options to a list, not taking special care about the order in which options are added. RFC 3442 (The Classless Static Route Option for Dynamic Host Configuration Protocol (DHCP) version 4) says: DHCP clients that support this option and send a parameter request list MAY also request the Static Routes option, for compatibility with older servers that don't support Classless Static Routes. The Classless Static Routes option code MUST appear in the parameter request list prior to both the Router option code and the Static Routes option code, if present. Compare to RFC 2132 (DHCP Options and BOOTP Vendor Extensions) which says about the parameter request list: The client MAY list the options in order of preference. Note, with RFC 7844 (Anonymity Profiles for DHCP Clients), the order should be randomized. But since we don't follow RFC 7844 (yet), let's follow at least RFC 3442.
| * | network: add sd_dhcp_route_get_option() accessorThomas Haller2018-12-192-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since sd_dhcp_lease_get_routes() returns the list of all routes, the caller may need to differenciate whether the route was option 33 (static-routes) or 121 (classless-static-route). Add an accessor for the internal field. systemd-pull-request: #10951
| * | dhcp: minor cleanup parsing default route for internal clientThomas Haller2018-12-191-10/+6
| | | | | | | | | | | | Combine same code.
| * | dhcp: cleanup parsing of DHCP lease for internal clientThomas Haller2018-12-191-108/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - check errors when accessing the lease. Some errors, like a failure from sd_dhcp_lease_get_address() are fatal. - while parsing the individual options, don't incrementally build the NMPlatformIP4Address instance (and similar). Instead, parse the options to individual variales, and only package them as platform structure at the point where they are needed. It makes the code simpler, because all individual bits (like "r_plen" variable) are only initialized and used at one place. That is clearer than incrementally building a platform structure, where you have to follow the code to see how the structure mutates. - drop redundant comments that only serve as a visual separator for structuring the code. Instead, structure the code.
| * | dhcp: let lease_to_ip4_config() allocate option hashThomas Haller2018-12-191-16/+26
| | | | | | | | | | | | | | | | | | | | | lease_to_ip4_config() can fail, if the lease is broken. As such, a function that fails should not modifiy an in/out parameter. Avoid that, by not having the caller pre-allocate the options hash, but instead allocate it by the lease_to_ip*_config() functions, and return it only on success.
| * | dhcp: fix signedness of loop variable in lease_to_ip4_config()Thomas Haller2018-12-191-2/+2
| | | | | | | | | | | | | | | The loop variable should have the same type as the variable that holds the number of elements ("num", in this case).
| * | dhcp: cleanup static option list for internal clientThomas Haller2018-12-191-56/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - use proper data types "guint16" and "bool" in static option list. It saves a few bytes, but also it's the appropriate type. Well, at least, it's the appropriate type for DHCPv6, not for DHCPv4 (which is guint8). - assert against failure of sd_dhcp_client_set_request_option() and sd_dhcp6_client_set_request_option().
| * | dhcp: don't request DHCP6 client-id option with internal clientThomas Haller2018-12-192-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sd_dhcp6_client_set_request_option() only accepts a white-listed set of options. Unexpected options are rejected with -EINVAL. Currently supported are only: - SD_DHCP6_OPTION_DNS_SERVERS - SD_DHCP6_OPTION_DOMAIN_LIST - SD_DHCP6_OPTION_SNTP_SERVERS - SD_DHCP6_OPTION_NTP_SERVER - SD_DHCP6_OPTION_RAPID_COMMIT As such, SD_DHCP6_OPTION_CLIENTID is not accepted and requesting it was silently ignored. Fixes: d2dd3b2c90221fdfa40ca81a9fcffe6a777d95de