summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* core/trivial: add code comment about DHCP client-id/DUIDth/dhcp-client-id-mac-rh1640494Thomas Haller2018-11-131-0/+26
|
* dhcp: add "ipv4.dhcp-client-id=duid" settingThomas Haller2018-11-133-1/+10
| | | | | | | | | | | | | | | Add a new mode for the DHCPv4 client identifier. "duid" is what the internal (systemd) DHCP client already does by default. It is also the same as used by systemd-networkd's "ClientIdentifier=duid" setting. What we still lack (compared to networkd) are a way to overwrite IAID and the DUID. Previously, this mode was used by the internal DHCP plugin by default. However, it could not be explicitly configured. In general, our default values should also be explicitly selectable. Now the "duid" client identifier can also be used with the "dhclient" plugin.
* dhcp: always require hwaddr in internal DHCP clint ip6_start()Thomas Haller2018-11-131-19/+16
| | | | | | Note how client_start() in NMDhcpManager already asserts that we have a MAC address. It's always present, like for the IPv6 case.
* doc: add hint about ipv4.dhcp-client-id=stableThomas Haller2018-11-133-4/+7
|
* all: add "${MAC}" substituion for "connection.stable-id"Thomas Haller2018-11-136-4/+17
| | | | | | | | | | | | | | | We already had "${DEVICE}" which uses the interface name. In times of predictable interface naming, that works well. It allows the user to generate IDs per device which don't change when the hardware is replaced. "${MAC}" is similar, except that is uses the permanent MAC address of the device. The substitution results in the empty word, if the device has no permanent MAC address (like software devices). The per-device substitutions "${DEVICE}" and "${MAC}" are especially interesting with "connection.multi-connect=multiple".
* dhcp: cleanup error handling in internal DHCP client's startThomas Haller2018-11-131-77/+79
| | | | | | | | | | | - use nm_auto to return early when something goes wrong - don't modify NMDhcpClient's state until the end, when it looks like we are (almost) started successfully. - for IPv4, only attempt to load the lease if we actually are interested in the address. Also, reduce the scope of the lease variable, to the one place where we need it.
* dhcp: don't load IPv4 client-id from lease fileThomas Haller2018-11-133-18/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The client-id is something that we want to determine top-down. Meaning, if the user specifies it via ipv4.dhcp-client-id, then it should be used. If the user leaves it unspecified, we choose a default stable client-id. For the internal DHCP plugin, this is a node specific client-id based on - the predictable interface name - and /etc/machine-id It's not clear, why we should allow specifying the client-id in the lease file as a third source of configuration. It really pushes the configuration first down (when we do DHCP without lease file), to store an additional bit of configuration for future DHCP attempts. If the machine-id or the interface-name changes, then so does the default client-id. In this case, also "ipv4.dhcp-client-id=stable" changes. It's fair to require that the user keeps the machine-id stable, if the machine identity doesn't change. Also, the lease files are stored in /var/lib/NetworkManager, which is more volatile than /etc/machine-id. So, if we think that machine-id and interface-name is not stable, why would we assume that we have a suitable lease file? Also, if you do: nmcli connection add con-name "$PROFILE" ... ipv4.dhcp-client-id '' nmcli connection up $PROFILE nmcli connection modify "$PROFILE" ipv4.dhcp-client-id mac nmcli connection up $PROFILE nmcli connection modify "$PROFILE" ipv4.dhcp-client-id '' nmcli connection up $PROFILE wouldn't you expect that the original (default) client-id is used again? Also, this works badly with global connection defaults in NetworkManager.conf. If you configure a connection default, previously already this would always force the client-id and overrule the lease. That is reasonable, but in which case would you ever want to use the client-id from the lease?
* dhcp: cleanup initializing IPv4 client-id for internal DHCPThomas Haller2018-11-133-74/+84
| | | | | | | | | | | | | | | | | | | | | | | | | - if we leave the client-id of sd_dhcp_client unset, it will anyway generate a node-specific client-id (and may fail if "/etc/machine-id" is invalid). Anticipate that, and don't let the client-id unset. In case we have no client-id from configuration or lease, just generate the id ourself (using the same algorithm). The advantage is, that we know it upfront and can store the client-id in the NMDhcpClient instance. We no longer need to peel it out from the lease later. - to generate the IPv4 client-id, we need a valid MAC address. Also, sd_dhcp_client needs a MAC address for dhcp_network_bind_raw_socket() as well. Just require that a MAC address is always needed. Likewise, we need a valid ifindex and ifname set. - likewise for IPv6 and IPv4, cleanup detecting the arptype and checking MAC address length. sd_dhcp_client_set_mac() is overly strict at asserting input arguments, so we must validate them anyway. - also, now that we always initialize the client-id when starting the DHCP client, there is no need to retroactively extract it again when we receive the first lease.
* dhcp/trivial: wrap lines in calling client_start()Thomas Haller2018-11-132-10/+54
| | | | | | | | | | | A possible issue is that client_start() has about 136 arguments. It doesn't get simpler by saving lines of code and writing them all in the same line. Wrap the lines. While at it, use "FALSE" for "enforce_duid" argument, instead of "0". It's a boolean.
* dhcp: minor refactoring return paths in NMDhcpDhclient.get_duid()Thomas Haller2018-11-132-13/+12
|
* dhcp: use cleanup attribute for get_dhclient_leasefile()Thomas Haller2018-11-131-15/+10
|
* dhcp: don't pass duid to client ip6_start() and stop()Thomas Haller2018-11-136-29/+24
| | | | | | | | | | | | | | | | | We don't do that for ip4_start() either. The duid/client-id is stored inside the NMDhcpClient instance, and the function can access it from there. Maybe, it is often preferable to have stateless objects and not relying on ip4_start() to obtain the client ID from the client's state. However, the purpose of the NMDhcpClient object is to hold state about DHCP. To simplify the complexity of objects that inherrently have state, we should be careful about mutating the state. It adds little additional complexity of only reading the state when needed anyway. In fact, it adds complexity, because previously it wasn't enough to check all callers of nm_dhcp_client_get_client_id() to see where the client-id is used. Instead, one would also need to follow the @duid argument several layers of the call stack.
* dhcp: refactor nm_dhcp_dhclient_save_duid() to accept original DUIDThomas Haller2018-11-134-38/+49
| | | | | | | | | There should be lower layers that are concerned with writing and reading dhclient configuration files. It's wrong to have a nm_dhcp_dhclient_save_duid() function which requires the caller to pre-escape the string to write. The caller shouldn't be concerned with the file format, that's why the function is used in the first place.
* dhcp: merge "duid" and "client_id" field in NMDhcpClientThomas Haller2018-11-131-19/+12
| | | | | | | We only used "client_id" for IPv4 and "duid" for IPv6. Merge them. Another advantage is, that we can share the logging functionality of _set_client_id().
* dhcp: drop unused nm_dhcp_dhclient_get_client_id_from_config_file()Thomas Haller2018-11-132-26/+0
| | | | | | | | Drop unused function. Aside from that, dhclient configuration files support a very complex syntax. The parser was very naive and insufficient in parsing such files. It's good we can just drop it.
* dhcp: don't re-read DHCP client ID from configuration file for dhclientThomas Haller2018-11-134-40/+2
| | | | | | | | | | | | | | | | | | | | Why would we do this? The configuration file we are reading back was written by NetworkManager in the first place. Maybe when assuming a connection after restart, this information could be interesting. It however is not actually relevant. Note how nm_dhcp_client_get_client_id() has only very few callers. - nm_device_spawn_iface_helper() in 'nm-device.c'. In this case, we either should use the client-id which we used when starting DHCP, or none at all. - ip4_start() in 'nm-dhcp-dhclient.c', but this is before starting DHCP client and before it was re-read from configuration file. - in "src/dhcp/nm-dhcp-systemd.c", but this has no effect for the dhclient plugin.
* dhcp: reimplement node-specific DHCP client-id generation from systemdThomas Haller2018-11-135-135/+177
| | | | | | | | | | | | | | | | | | | | | Our internal DHCP client (from systemd) defaults to a particular client ID. It is currently exposed as nm_sd_utils_generate_default_dhcp_client_id() and is based on the systemd implementation. One problem with that is, that it internally looks up the interface name with if_indextoname() and reads /etc/machine-id. Both makes it harder for testing. Another problem is, that this way of generating the client-id is currently limited to internal client. Why? If you use dhclient plugin, you may still want to use the same algorithm. Also, there is no explict "ipv4.dhcp-client-id" mode to select this client-id (so that it could be used in combination with "dhclient" plugin). As such, this code will be useful also aside systemd DHCP plugin. Hence, the function should not be obviously tied to systemd code. The implementation is simple enough, and since we already have a unit-test, refactor the code to our own implementation.
* dhcp: test systemd's default DHCP client identifier generationThomas Haller2018-11-133-1/+152
| | | | | | | | | | | | | | | | | | | | | | | | Internal DHCP client generates a default client ID. For one, we should ensure that this algorithm does not change without us noticing, for example, when upgrading systemd code. Add a test, that the generation algorithm works as we expect. Also note, that the generation algorithm uses siphash24(). That means, siphash24() implementation also must not change in the future, to ensure the client ID doesn't change. As we patch systemd sources to use shared/c-siphash, this is not obviously the case. Luckily c-siphash and systemd's siphash24 do agree, so all is good. The test is here to ensure that. Also, previously the generation algorithm is not exposed as a function, sd_dhcp_client will just generate a client-id when it needs it. However, later we want to know (and set) the client id before starting DHCP and not leave it unspecified to an implementation detail. This patch only adds a unit-test for the existing DHCP client ID generation to have something for comparison. In the next commit this will change further.
* core: cleanup generating DUID in nm-device.cThomas Haller2018-11-131-57/+60
| | | | | | | | | | | | | - use NMUuid type where appropriate. - no error handling for generate_duid_from_machine_id(). It cannot fail anymore. - add thread-safety to generate_duid_from_machine_id() with double-checked locking. - use unions for converting the sha256 digest to the target type.
* core: pass boot-id to nm_utils_stable_id_parse()Thomas Haller2018-11-132-2/+2
| | | | | | | | | For testing purpose, it's bad to let nm_utils_stable_id_parse() directly access nm_utils_get_boot_id_str(). Instead, the function should have no side-effects. Since the boot-id is anyway cached, accessing it is cheap. Even if it likely won't be needed.
* core: don't persist secret-key for testsThomas Haller2018-11-132-6/+8
| | | | | | | | | | Tests might access the secret-key. For CI builds we may very well build NM as root and also run unit tests. In such a situation it's bad to persist the secret key. For example, the SELinux label may be wrong, and subsequently starting NetworkManager may cause errors. Avoid persisting the secret key for tests.
* core: refactor loading machine-id and cache itThomas Haller2018-11-138-92/+265
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, whenever we needed /etc/machine-id we would re-load it from file. The are 3 downsides of that: - the smallest downside is the runtime overhead of repeatedly reading the file and parse it. - as we read it multiple times, it may change anytime. Most code in NetworkManager does not expect or handle a change of the machine-id. Generally, the admin should make sure that the machine-id is properly initialized before NetworkManager starts, and not change it. As such, a change of the machine-id should never happen in practice. But if it would change, we would get odd behaviors. Note for example how generate_duid_from_machine_id() already cached the generated DUID and only read it once. It's better to pick the machine-id once, and rely to use the same one for the remainder of the program. If the admin wants to change the machine-id, NetworkManager must be restarted as well (in case the admin cares). Also, as we now only load it once, it makes sense to log an error (once) when we fail to read the machine-id. - previously, loading the machine-id could fail each time. And we have to somehow handle that error. It seems, the best thing what we anyway can do, is to log an error once and continue with a fake machine-id. Here we add a fake machine-id based on the secret-key or the boot-id. Now obtaining a machine-id can no longer fail and error handling is no longer necessary. Also, ensure that a machine-id of all zeros is not valid. Technically, a machine-id is not an RFC 4122 UUID. But it's the same size, so we also use NMUuid data structure for it. While at it, also refactor caching of the boot-id and the secret key. In particular, fix the thread-safety of the double-checked locking implementations.
* core: minor cleanup of initializing nm_utils_get_testing()Thomas Haller2018-11-131-6/+17
| | | | | | | | | - add a commnt about thread-safety. - minor refactoring initializing the value in nm_utils_get_testing(). Instead of returning the flags we just set, go back to the begin and re-read the value (which must be initialized by now). No big difference, but feels a bit nicer to me.
* all: cleanup GChecksum handlingThomas Haller2018-11-137-116/+55
| | | | | | | - prefer nm_auto_free_checksum over explicit free. - use nm_utils_checksum_get_digest*(). - prefer defines for digest length. - assume g_checksum_new() cannot fail.
* shared: add nm_utils_checksum_get_digest*() helperThomas Haller2018-11-131-0/+40
| | | | | | | | | | | | | | | The GChecksum API is cumbersome to use. For example, g_checksum_get_digest() requires a length input/output argument. At the same time, GChecksum does not allow you to query its checksum-type nor the desired digest-length. When you have a GChecksum at hand, you must always know the digest-length you are going to use. So, the length parameter is only good for asserting. Add a macro to make that more convenient. Benefits: it's less lines of code, and we always do all the asserts that are due.
* shared: use atomic operation for accessing global hash seedThomas Haller2018-11-131-19/+32
| | | | | | | | | | - fix thread-safety by adding a memory barrier (g_atomic_pointer_get()) to the double-checked locking pattern when initializing the hash key. - generate the random data outside the lock. Calling nm_utils_random_bytes() within the lock is ugly, because we don't want to assume that the function has no side effects which are prone to dead-lock. There is no problem attempting to generate the random data without lock, and only use it when the race is won.
* man: fix generate settings-docs.h text for 'ipv4.dns-priority'Thomas Haller2018-11-131-2/+2
| | | | Fixes: 207a9a2223ffaf9635aa3809888a252fb319ddda
* man: document global connection default for "ipv4.dns-priority"Thomas Haller2018-11-133-4/+15
| | | | | | ... and "ipv6.dns-priority". Fixes: 77ded12da46457848e86561b0e9460f03302e6e8
* man: clarify blocking autoconnect during `nmcli connection down`Thomas Haller2018-11-131-3/+4
| | | | | | | | | | | | | | Manually disconnecting a profile of course blocks autoconnect of the same profile. Otherwise, the profile would likely re-activate right away, which is clearly against the users intention. If the users just want to re-activate the profile, they should issue `nmcli connection up` instead, with does a full down and up cycle. This is more interesting for profiles that have 'connection.multi-connect' set to 'multiple'. Would you expect that manually deactivating such a profile blocks autoconnect of the profile on all devices? Maybe yes, maybe not. Currently that is indeed the case and autoconnect gets blocked regardless of multi-connect.
* build: avoid header conflict for <linux/if.h> and <net/if.h> with ↵Thomas Haller2018-11-1216-12/+29
| | | | | | | | | | | | | | | | | | | | | "nm-platform.h" In the past, the headers "linux/if.h" and "net/if.h" were incompatible. That means, we can either include one or the other, but not both. This is fixed in the meantime, however the issue still exists when building against older kernel/glibc. That means, including one of these headers from a header file is problematic. In particular if it's a header like "nm-platform.h", which itself is dragged in by many other headers. Avoid that by not including these headers from "platform.h", but instead from the source files where needed (or possibly from less popular header files). Currently there is no problem. However, this allows an unknowing user to include <net/if.h> at the same time with "nm-platform.h", which is easy to get wrong.
* build: merge branch 'th/build-libnm-shared'Thomas Haller2018-11-121-131/+171
|\ | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/43
| * build: create intermediate libraries of shared/nm-utilsThomas Haller2018-11-121-76/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we would compile source files from shared/nm-utils multiple times. That not only slows down compilation, but it makes it confusing which project require exactly what. Most of the files in shared/nm-utils are a mixed bag of utility functions. Just build one libnm-utils-base library. Since the linker will throw away unused parts, there is no problem that not every user of libnm-utils-base needs everything. Also add libnm-utils-udev, which cannot be part of libnm-utils-base as it has an additional dependency on libudev.
| * build: move code for shared libs in Makefile.am aroundThomas Haller2018-11-121-62/+62
|/ | | | | Let's sort the code by the dependencies. The shared/ projects have the least dependencies. Move to the beginning.
* libnm: fix GObject Introspection annotations for functions returning a GPtrArrayCorentin Noël2018-11-123-3/+3
| | | | | | The GPtrArray owns the element so it is a (transfer full). https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/46
* dns: merge branch 'resolv-search-increase'Thomas Haller2018-11-124-31/+136
|\ | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/47
| * dns: remove the resolv.conf 6 entry limitKyle Walker2018-11-121-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | The resolv.conf used to have a limit of 6 entries for the search option. With later versions of glibc, this limit has been removed. As a result, remove the limit here so that all search entries set will be applied to the resolv.conf. If there is a limit imposed by older versions of glibc, it should be imposed there as opposed to within NetworkManager. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/80 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/47
| * dns: avoid truncation of searches list due to 256 char limit in glibcThomas Haller2018-11-122-2/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before glibc 2.26, glibc's resolver would only honor 6 search entries and a character limit of 256. This was lifted recently ([1], [2], [3]). We also lift this limitation in NetworkManager ([4], [5]). However, older glibc versions would just truncate the string at 255 characters. In particular, it would not only tuncate the list to 6 entries, but the entry which crosses the 256th character boundary would be mangled. Avoid that, by adding spaces. [1] https://sourceware.org/ml/libc-alpha/2017-08/msg00010.html [2] https://sourceware.org/bugzilla/show_bug.cgi?id=19569 [3] https://sourceware.org/bugzilla/show_bug.cgi?id=21475 [4] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/47 [5] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/80
| * dns/tests: add test for writing resolv.confThomas Haller2018-11-123-0/+62
| |
| * dns: make strv arguments of create_resolv_conf() constThomas Haller2018-11-121-18/+41
| |
| * shared: add NM_MAKE_STRV() macroThomas Haller2018-11-121-0/+3
|/
* ci: use common script for tests on travis and gitlabThomas Haller2018-11-124-143/+164
| | | | | | | | | | | | | | For one, it's not unreasonable that we want to run the same tests both for gitlab and travis. Move the actual tests into a script, which is called by both CI environments. We still can do something different, based on the environment. The advantage here is, that the common part will be shared, and the places where we differ can easily be spot. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/44
* rpm: disable ebpf support on RHELBeniamino Galvani2018-11-091-0/+4
| | | | | | | The ebpf syscall doesn't work on RHEL even if the linux/bpf.h header is available: let's explicitly disable it. On Fedora explicitly enable eBPF instead of autodetecting it.
* build: meson: fix wrong man page linkBeniamino Galvani2018-11-081-1/+1
| | | | | | Fixes: 98b4a19a536ddb9f75611deaa272ae5661c5df4d https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/78
* libnm-core: don't serialize synthetic properties in nm_setting_to_string()Lubomir Rintel2018-11-073-4/+19
| | | | | | Fixes: f957ea2b343828ad1fa2014bc7a4dedaf854f3bc https://github.com/NetworkManager/NetworkManager/pull/245
* modemu: fall back to a virtual busLubomir Rintel2018-11-071-1/+9
| | | | | | | | This allows us to somehow work with no PCI (or USB for that matter), such as some virtual machines. Old ModemManager doesn't like this though, but there doesn't seem to be a way around it. https://github.com/NetworkManager/NetworkManager/pull/246
* modemu: fix subsystem hash endiannessLubomir Rintel2018-11-071-3/+4
| | | | | | | Tested on a really really big endian IBM POWER. Also turn an accompanying comment into a slightly more sensible one. https://github.com/NetworkManager/NetworkManager/pull/246
* rpm: add a bundled(systemd) provideLubomir Rintel2018-11-071-0/+12
| | | | | | | | Required by Fedora Packaging Standards [1] and also really useful. [1] https://fedoraproject.org/wiki/Bundled_Libraries?rd=Packaging:Bundled_Libraries#Requirement_if_you_bundle https://github.com/NetworkManager/NetworkManager/pull/247
* ofono: fix crash when disconnectingBeniamino Galvani2018-11-061-1/+1
| | | | Fixes: 9b935fad9b108ee10299f2bd56f27db59ee34637
* modem: fix crash when disconnectingBeniamino Galvani2018-11-061-1/+1
| | | | Fixes: 9b935fad9b108ee10299f2bd56f27db59ee34637
* man: merge branch 'bg/man'Beniamino Galvani2018-11-055-141/+153
|\ | | | | | | | | | | Some small improvements to man pages and program help https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/41