summaryrefslogtreecommitdiff
path: root/src/tests
Commit message (Collapse)AuthorAgeFilesLines
* tests/general: allow error margin on comparing floatsLubomir Rintel2017-03-281-1/+1
| | | | Fixes test on Fedora/i686.
* logging: log device and connection along with the messageLubomir Rintel2017-03-242-1/+3
|
* core/trivial: rename nm_utils_10pow() to nm_utils_exp10()Thomas Haller2017-03-241-24/+24
| | | | | | nm_utils_exp10() is a better name, because it reminds of the function exp10() from <math.h> which has a similar purpose (but whose argument is double, not gint16).
* core: add nm_utils_10pow() utilsThomas Haller2017-03-231-0/+52
|
* device: add spec "driver:" to match devicesThomas Haller2017-03-171-2/+31
| | | | | | | | Changing the MAC address of devices is known to fail with certain drivers. Add a device-spec to allow disabling it for for such devices. Related: https://bugzilla.gnome.org/show_bug.cgi?id=777523
* manager: simplify searching assumed connectionThomas Haller2017-03-161-21/+45
| | | | | | Now we only search for a candiate with matching UUID. No need to first lookup all activatable connections, just find the candidate by UUID and see if it is activatable.
* all: use "unsigned long" instead of "long unsigned"Thomas Haller2017-03-141-1/+1
|
* core/tests: add test for nm_match_spec_device() to match "except:*"Thomas Haller2017-03-081-0/+4
| | | | | We also allow negative matches for plain "*", meaning to explicitly not manage anything.
* platform: change signature of nm_platform_ip{4,6}_route_add()Beniamino Galvani2017-03-061-20/+18
| | | | | Change the functions to accept a platform route as argument. This will make it easier to add new route options.
* platform: support preferred source option for IPv6 routesBeniamino Galvani2017-03-062-5/+6
| | | | | Extend the support for the preferred source route option (RTA_PREFSRC) to IPv6.
* core: consolidate sorting of connections by autoconnect/timestampThomas Haller2017-02-101-1/+7
| | | | | | | | | | | | | | | | | NMPolicy's auto_activate_device() wants to sort by autoconnect-priority, nm_utils_cmp_connection_by_autoconnect_priority() but fallback to the default nm_settings_connection_cmp_default(), which includes the timestamp. Extend nm_settings_connection_cmp_default() to consider the autoconnect-priority as well. Thus change behavior so that nm_settings_connection_cmp_default() is the sort order that auto_activate_device() wants. That makes sense, as nm_settings_connection_cmp_default() already considered the ability to autoconnect as first. Hence, it should also honor the autoconnect priority. When doing that, rename nm_settings_connection_cmp_default() to nm_settings_connection_cmp_autoconnect_priority().
* core: add nm_utils_cmp_connection_by_autoconnect_priority_p_with_data() functionThomas Haller2017-02-101-2/+2
| | | | | | | | | | Have a proper cmp() function and a wrapper *_p_with_data() that can be used for g_qsort_with_data(). Thus, establish a naming scheme (*_p_with_data()) for these compare wrappers that we need all over the place. Note, we also have nm_strcmp_p_with_data() for the same reason and later more such functions will follow.
* all: cleanup switch fall-through comments for -Wimplicit-fallthrough warningThomas Haller2017-02-061-2/+2
| | | | | | | | | | The -Wimplicit-fallthrough=3 warning is quite flexible of accepting a fall-through warning. Some comments were missing or not detected correctly. Thereby, also change all other comments to follow the exact same pattern.
* core/tests: add test matching s390-subchannels device specThomas Haller2017-01-251-43/+63
| | | | (cherry picked from commit 0f7098b71bbfc6024b0f39ce858448d928af6ae5)
* src/tests: randomize device spec list for testThomas Haller2017-01-201-7/+7
| | | | (cherry picked from commit b0e58a982374c56d06961d88a0b1551a8d8937bd)
* core: refactor evaluation of device's match-specThomas Haller2017-01-201-154/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we would have different functions like - nm_match_spec_device_type() - nm_match_spec_hwaddr() - nm_match_spec_s390_subchannels() - nm_match_spec_interface_name() which all would handle one type of match-spec. So, to get the overall result whether the arguments match or not, nm_device_spec_match_list() had to stich them together and iterate the list multiple times. Refactor the code to have one nm_match_spec_device() function that gets all relevant paramters. The upside is: - the logic how to evaluate the match-spec is all at one place (match_device_eval()) instead of spread over multiple functions. - It requires iterating the list at most twice. Twice, because we do a fast pre-search for "*". One downside could be, that we have to pass all 4 arguments for the evaluation, even if the might no be needed. That is, because "nm-core-utils.c" shall be independend from NMDevice, it cannot receive a device instance to get the parameters as needed. As we would add new match-types, the argument list would grow. However, all arguments are cached and fetching them from the device's private data is very cheap. (cherry picked from commit b957403efd53ff7d826ac7a4f80487032c03824b)
* device: support dynamic "connection.stable-id" in form of text-substitutionThomas Haller2017-01-091-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Usecase: when connecting to a public Wi-Fi with MAC address randomization ("wifi.cloned-mac-address=random") you get on every re-connect a new IP address due to the changing MAC address. "wifi.cloned-mac-address=stable" is the solution for that. But that means, every time when reconnecting to this network, the same ID will be reused. We want an ID that is stable for a while, but at a later point a new ID should e generated when revisiting the Wi-Fi network. Extend the stable-id to become dynamic and support templates/substitutions. Currently supported is "${CONNECTION}", "${BOOT}" and "${RANDOM}". Any unrecognized pattern is treated verbaim/untranslated. "$$" is treated special to allow escaping the '$' character. This allows the user to still embed verbatim '$' characters with the guarantee that future versions of NetworkManager will still generate the same ID. Of course, a user could just avoid '$' in the stable-id unless using it for dynamic substitutions. Later we might want to add more recognized substitutions. For example, it could be useful to generate new IDs based on the current time. The ${} syntax is extendable to support arguments like "${PERIODIC:weekly}". Also allow "connection.stable-id" to be set as global default value. Previously that made no sense because the stable-id was static and is anyway strongly tied to the identity of the connection profile. Now, with dynamic stable-ids it gets much more useful to specify a global default. Note that pre-existing stable-ids don't change and still generate the same addresses -- unless they contain one of the new ${} patterns.
* core: add assertions for network_id/stable_typeThomas Haller2017-01-091-2/+2
| | | | | | | | | | | We require a network-id. Assert that it is set. Also, we encode the stable-id as uint8. Thus, add an assertion that we don't use more then 254 IDs. If we ever make use of stable-type 255, we must extend the encoding to allow for more values. The assertion is there to catch that.
* python: make test-secret-agent.py python3 readyThomas Haller2016-12-141-9/+8
| | | | Co-authored-by: Lubomir Rintel <lkundrak@v3.sk>
* all: use O_CLOEXEC for file descriptorsThomas Haller2016-12-131-1/+2
|
* ip6-config: add nm_ip6_config_set_privacy()Beniamino Galvani2016-12-051-3/+6
|
* config: drop nm_config_get_dhcp_client() and access config directlyThomas Haller2016-11-251-3/+14
| | | | | | | | | | | | Also, ifnet plugin would read the configuration value, which is just wrong because: - the configuration might not be set and ifnet would fail to fallback to the compile time default. - the configuration only is in effect if the plugin is also available. Otherwise, we fallback to the next plugin. Only the dhcp-manager knows which DHCP plugin is in use.
* config: optionally let nm_config_get_plugins() return compile time defaultThomas Haller2016-11-251-16/+9
| | | | | | | | | | | Instead of having the caller do the fallback to the compile time default plugins, let it be handled by nm_config_get_plugins(). The knowledge of fallback to a compile time default (and how to do that properly) should be inside NMConfig/NMConfigData alone. Also, as this function is only called once, let NMConfig not cache the string list but create it once as needed.
* build: don't add subdirectories to include search path but require qualified ↵Thomas Haller2016-11-218-10/+10
| | | | | | | | | | | | | | | include Keep the include paths clean and separate. We use directories to group source files together. That makes sense (I guess), but then we should use this grouping also when including files. Thus require to #include files with their path relative to "src/". Also, we build various artifacts from the "src/" tree. Instead of having individual CFLAGS for each artifact in Makefile.am, the CFLAGS should be unified. Previously, the CFLAGS for each artifact differ and are inconsistent in which paths they add to the search path. Fix the inconsistency by just don't add the paths at all.
* rdisc: rename to ndiscLubomir Rintel2016-11-092-3/+3
| | | | | | We'll soon not only do the router discovery, but announce ourselves as a reouter. "Neighbor discovery" sounds to be a more appropriate name for the class than "Router discovery".
* src/tests: relax assertion for test_nm_utils_monotonic_timestamp_as_boottime()Thomas Haller2016-10-241-1/+1
| | | | | | | | When running under load (e.g. with parallel make and valgrind enabled), the checked time interval might be too short. Relax the assertion NetworkManager:ERROR:src/tests/test-general-with-expect.c:65:test_nm_utils_monotonic_timestamp_as_boottime: assertion failed (now_boottime_2 - now_boottime <= NM_UTILS_NS_PER_SECOND / 1000): (15156494 <= 1000000)
* build: merge "src/tests/Makefile.am" into toplevel MakefileThomas Haller2016-10-212-182/+12
|
* build: merge "src/tests/config/Makefile.am" into toplevel MakefileThomas Haller2016-10-212-39/+0
|
* build: merge "src/platform/tests/Makefile.am" into toplevel MakefileThomas Haller2016-10-211-0/+2
|
* build/trivial: rename VALGRIND_RULES in Makefile.am to NM_LOG_COMPILERThomas Haller2016-10-192-2/+2
|
* device: make registration of internal device-factories more explicitThomas Haller2016-10-111-16/+0
| | | | | | | | | | | Internal device types are a static thing. Let's not do a constructor function to register the device factory. This gets rid of all attribute((constructor)) functions inside NetworkManager core. That is desired, because we don't want to run code before main(). For example, at that point logging is not yet initialized, but with code that runs before main() it is hard to ensure that we don't log anything yet.
* core: refactor private data in "src"Thomas Haller2016-10-042-21/+30
| | | | | | | | | | | | | | | | - use _NM_GET_PRIVATE() and _NM_GET_PRIVATE_PTR() everywhere. - reorder statements, to have GObject related functions (init, dispose, constructed) at the bottom of each file and in a consistent order w.r.t. each other. - unify whitespaces in signal and properties declarations. - use NM_GOBJECT_PROPERTIES_DEFINE() and _notify() - drop unused signal slots in class structures - drop unused header files for device factories
* all: modify line separator comments to be 80 chars wideThomas Haller2016-10-038-23/+23
| | | | sed 's#^/\*\{5\}\*\+/$#/*****************************************************************************/#' $(git grep -l '\*\{5\}' | grep '\.[hc]$') -i
* build: don't add systemd path the include search pathThomas Haller2016-09-272-7/+2
| | | | | | | | | | | | | | | | | | | | Our internal copy of systemd should not be in the search path. Instead, let users only #include "systemd/nm-sd.h" which then includes everything from systemd that we need. We want to avoid to accidentally include anything from our systemd-copy. Any user of that should only include "nm-sd.h", which then includes everything that is needed further. For example, "src/devices/wwan/nm-modem-manager.c" has #include <systemd/nm-daemon.h> which in turn includes #include "_sd-common.h" This works all correctly before, because #include "" will first look in the directory where sd-daemon.h is. However, our mixing of external systemd library and internal copy is rather dangerous. Try to avoid it further by keeping the include paths clean.
* all: cleanup includes in header filesThomas Haller2016-08-171-5/+1
| | | | | | | | | | | | - don't include "nm-default.h" in header files. Every source file must include as first header "nm-default.h", thus our headers get the default include already implicitly. - we don't support compiling NetworkManager itself with a C++ compiler. Remove G_BEGIN_DECLS/G_END_DECLS from internal headers. We do however support users of libnm to use C++, thus they stay in public headers. (cherry picked from commit f19aff89095ca192b8b2e37534b7a899aecd82f9)
* systemd: merge branch systemd into masterThomas Haller2016-08-121-0/+6
|\ | | | | | | | | | | | | | | Conflicts: src/systemd/src/basic/fd-util.c src/systemd/src/basic/fileio.c src/systemd/src/libsystemd/sd-event/sd-event.c src/systemd/src/libsystemd/sd-id128/sd-id128.c
* | systemd/tests: don't link test-systemd against libNetworkManagerBaseThomas Haller2016-08-122-1/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | One point of test-systemd is to see whether our internal systemd code can fully link without external systemd library. In fact, we want all symbols from the internal systemd code to resolve, because when we link against an external libsystemd library, we may mix differing APIs, resulting in subtle bugs. Currently, it may well be that libNetworkManagerBase.la already links against libsystemd, which would result in test-systemd to wrongly succeed resolving all names. Fix that, by don't link libNetworkManagerBase.la into test-systemd.
* | build: rename libNetworkManager-base.la to libNetworkManagerBase.laThomas Haller2016-08-111-1/+1
| | | | | | | | it matches libNetworkManagerTest.la.
* | bulid: don't link NMFakePlatform into NetworkManager binaryThomas Haller2016-08-112-2/+2
| | | | | | | | | | It's only used for testing. Add a new object libNetworkManagerTest.la that contains libNetworkManager.la including the test stubs.
* | systemd: merge branch systemd into masterThomas Haller2016-06-301-2/+1
|\ \ | |/ | | | | | | | | | | Conflicts: src/systemd/src/basic/siphash24.c src/systemd/src/basic/time-util.c src/systemd/src/basic/util.c
* | all: make MAC address randomization algorithm configurableThomas Haller2016-06-301-10/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For the per-connection settings "ethernet.cloned-mac-address" and "wifi.cloned-mac-address", and for the per-device setting "wifi.scan-rand-mac-address", we may generate MAC addresses using either the "random" or "stable" algorithm. Add new properties "generate-mac-address-mask" that allow to configure which bits of the MAC address will be scrambled. By default, the "random" and "stable" algorithms scamble all bits of the MAC address, including the OUI part and generate a locally- administered, unicast address. By specifying a MAC address mask, we can now configure to perserve parts of the current MAC address of the device. For example, setting "FF:FF:FF:00:00:00" will preserve the first 3 octects of the current MAC address. One can also explicitly specify a MAC address to use instead of the current MAC address. For example, "FF:FF:FF:00:00:00 68:F7:28:00:00:00" sets the OUI part of the MAC address to "68:F7:28" while scrambling the last 3 octects. Similarly, "02:00:00:00:00:00 00:00:00:00:00:00" will scamble all bits of the MAC address, except clearing the second-least significant bit. Thus, creating a burned-in address, globally administered. One can also supply a list of MAC addresses like "FF:FF:FF:00:00:00 68:F7:28:00:00:00 00:0C:29:00:00:00 ..." in which case a MAC address is choosen randomly. To fully scamble the MAC address one can configure "02:00:00:00:00:00 00:00:00:00:00:00 02:00:00:00:00:00". which also randomly creates either a locally or globally administered address. With this, the following macchanger options can be implemented: `macchanger --random` This is the default if no mask is configured. -> "" while is the same as: -> "00:00:00:00:00:00" -> "02:00:00:00:00:00 02:00:00:00:00:00" `macchanger --random --bia` -> "02:00:00:00:00:00 00:00:00:00:00:00" `macchanger --ending` This option cannot be fully implemented, because macchanger uses the current MAC address but also implies --bia. -> "FF:FF:FF:00:00:00" This would yields the same result only if the current MAC address is already a burned-in address too. Otherwise, it has not the same effect as --ending. -> "FF:FF:FF:00:00:00 <MAC_ADDR>" Alternatively, instead of using the current MAC address, spell the OUI part out. But again, that is not really the same as macchanger does because you explictly have to name the OUI part to use. `machanger --another` `machanger --another_any` -> "FF:FF:FF:00:00:00 <MAC_ADDR> <MAC_ADDR> ..." "$(printf "FF:FF:FF:00:00:00 %s\n" "$(sed -n 's/^\([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) \([0-9a-fA-F][0-9a-fA-F]\) .*/\1:\2:\3:00:00:00/p' /usr/share/macchanger/wireless.list | xargs)")"
* | device: extend MAC address handling including randomization for ethernet and ↵Thomas Haller2016-06-301-1/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | wifi Extend the "ethernet.cloned-mac-address" and "wifi.cloned-mac-address" settings. Instead of specifying an explicit MAC address, the additional special values "permanent", "preserve", "random", "random-bia", "stable" and "stable-bia" are supported. "permanent" means to use the permanent hardware address. Previously that was the default if no explict cloned-mac-address was set. The default is thus still "permanent", but it can be overwritten by global configuration. "preserve" means not to configure the MAC address when activating the device. That was actually the default behavior before introducing MAC address handling with commit 1b49f941a69af910b0e68530be7339e8053068e5. "random" and "random-bia" use a randomized MAC address for each connection. "stable" and "stable-bia" use a generated, stable address based on some token. The "bia" suffix says to generate a burned-in address. The stable method by default uses as token the connection UUID, but the token can be explicitly choosen via "stable:<TOKEN>" and "stable-bia:<TOKEN>". On a D-Bus level, the "cloned-mac-address" is a bytestring and thus cannot express the new forms. It is replaced by the new "assigned-mac-address" field. For the GObject property, libnm's API, nmcli, keyfile, etc. the old name "cloned-mac-address" is still used. Deprecating the old field seems more complicated then just extending the use of the existing "cloned-mac-address" field, although the name doesn't match well with the extended meaning. There is some overlap with the "wifi.mac-address-randomization" setting. https://bugzilla.gnome.org/show_bug.cgi?id=705545 https://bugzilla.gnome.org/show_bug.cgi?id=708820 https://bugzilla.gnome.org/show_bug.cgi?id=758301
* | device: let device specs match on permanent MAC addressThomas Haller2016-06-301-1/+1
| | | | | | | | | | | | | | | | | | Using the current, possibly non-permanent MAC address doesn't really make sense. Also, NM_DEVICE_HW_ADDRESS used to be writable and was set by NMDeviceBt to the bdaddr. That is wrong, because bdaddr should not be the current address, but the permanent one.
* | device: initialize NMDevice's hw_addr at end of object constructionThomas Haller2016-06-301-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | hw-addr is a constuct-only property. We should not do complex stuff in the property setter before the object is sufficiently initialized. For example, the logging macros access nm_device_get_iface(), which might be unset at that early point. Instead, initialize hw_addr and hw_addr_len later, at the end of the constructor() function. Also, ensure that @hw_addr_len is zero iff @hw_addr is unset. Also, ensure that we always log a message when changing/setting the hardware address -- except when clearing it during unrealize. It's implicit that unrealize clears the hardware address. Also, give all related logging messages a "hw-addr:" prefix.
* | core: prefer connection.stable-id to generate IPv6 stable privacy addressesThomas Haller2016-06-301-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Network_ID for generating RFC 7217 stable privacy IPv6 addresses is by default the UUID of the connection. Alternatively, prefer "connection.stable-id" as Network_ID to generate the stable addresses. This allows to configure a set of connections that all use the same Network_ID for generating stable addresses. Note that the stable-id and the UUID do no overlap, that is two connections [connection] uuid=uuid1 stable-id= and [connection] uuid=uuid2 stable-id=uuid1 generate distinct addresses.
* | dns: add reverse DNS IPv6 entries to dnsmasqBeniamino Galvani2016-06-071-2/+55
| | | | | | | | https://bugzilla.gnome.org/show_bug.cgi?id=767174
* | dns: add CIDR reverse DNS IPv4 entries to dnsmasqBeniamino Galvani2016-06-071-0/+68
| | | | | | | | | | | | | | | | When a reverse DNS entry must be added to dnsmasq, instead of considering IP addresses as classful use the prefix to compute one or more "in-addr.arpa" according to CIDR rules. https://bugzilla.gnome.org/show_bug.cgi?id=767174
* | config: unify logging line when reloading configurationThomas Haller2016-06-011-3/+3
| | | | | | | | | | Also when config_data changes, the logging line should start with "config: signal" like it does in the other cases.
* | config: refactor change-flags to be a cause/reason which triggered the changeThomas Haller2016-06-011-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For the most part, this patch just renames some change-flags, but doesn't change much about them. The new name should better express what they are. A config-change signal can be emitted for different reasons: when we receive a signal (SIGHUP, SIGUSR1, SIGUSR2) or for internal reasons like resetting of no-auto-default or setting internal values. Depending on the reason, we want to perform different actions. For example: - we reload the configuration from disk on SIGHUP, but not for SIGUSR1. - For SIGUSR1 and SIGHUP, we want to update-dns, but not for SIGUSR2. Another part of the change-flags encodes which part of the configuration actually changed. Often, these parts can only change when re-reading from disk (e.g. a SIGUSR1 will not change any configuration inside NMConfig). Later, we will have more causes, and accordingly more fine-grained effects of what should be done on reload.
* | device: use NMSettings directly instead of NMConnectionProvider in subclassesThomas Haller2016-05-241-4/+20
| | | | | | | | | | | | Instead of accessing the singleton getter nm_settings_get(), obtain the settings instance from the device instance itself via nm_device_get_settings().