summaryrefslogtreecommitdiff
path: root/src/NetworkManagerUtils.h
Commit message (Collapse)AuthorAgeFilesLines
* device: add "indicated" argument to nm_utils_match_connection()Thomas Haller2017-11-301-0/+1
| | | | | | | | | | | | | | The matching works fuzzy and is not reliable. That is why we store which connection should be assumed after restart in the state file of NetworkManager. In that case, we don't need to do a full check (with the possibility of a false-reject). Just check for the minimum required properties: the type and slave-type. Yes, if the user modifies the connection while restarting NM, then we might wrongly assume a connection that no longer would match. But NM should not read minds, it should do as indicated.
* manager: simplify searching assumed connectionThomas Haller2017-03-161-1/+1
| | | | | | 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.
* utils: inject platform into nm_utils_complete_generic()Thomas Haller2016-03-151-1/+2
|
* core: split "nm-core-utils.h" out of "NetworkManagerUtils.h"Thomas Haller2016-03-011-386/+4
| | | | | | | | | | | | | | | | "NetworkManagerUtils.h" contains a bunch of helper tools for core daemon ("src/"). Unfortunately, it has dependencies to other parts of core, such as "nm-device.h" and "nm-platform.h". Split out a part of tools that are independent so that they can be used without dragging in other dependencies. "nm-core-utils.h" should only use libnm-core, "nm-logging.h" and shared. "NetworkManagerUtils.h" should provide all "nm-core-utils.h" and possibly other utilities that have larger dependencies.
* utils: add nm_utils_strbuf_init() macroThomas Haller2016-02-291-0/+13
|
* utils: add nm_utils_parse_debug_string() to replace g_parse_debug_string()Thomas Haller2016-02-211-0/+3
| | | | | g_parse_debug_string() interprets the string "help" special and accepts an "all" tag to invert the result. We don't want that.
* utils: fix NM_UTILS_ENUM2STR_DEFINE() which always returned the last elementThomas Haller2016-02-171-1/+1
| | | | Fixes: 174b25d98c3ae395f5b41fc2e7d5c222cb6369cf
* core: fix matching of default metric value for static routesBeniamino Galvani2016-02-111-0/+2
| | | | | | | | | | | | | | | | | When NM tries to match a generated connection to a persistent one, it considers also the metric of static routes. However, if the field is set to -1 (use default value for the device) on the persistent connection, the comparison will always fail because the generated connection contains the actual value read from kernel. To fix the issue, modify check_possible_match() to deal correctly with -1 and translate it to the expected value for the current device when performing the comparison. This allows connections with static routes and default metric to properly be re-assumed when NM is restarted. https://bugzilla.redhat.com/show_bug.cgi?id=1302532
* utils: reimplement NM_UTILS_ENUM2STR_DEFINE() without helper functionThomas Haller2016-02-011-23/+22
| | | | | | The compiler might be able to optimize the switch better. But more importantly, it has the type information of the enum and can give warnings about unmentioned enum values.
* utils: pass entire return statement to NM_UTILS_LOOKUP_DEFINE()Thomas Haller2016-02-011-1/+3
|
* utils: change _NM_UTILS_LOOKUP_DEFINE() to generate compiler warning about ↵Thomas Haller2016-02-011-3/+3
| | | | | | | missing enum values Don't implement a "default" case so that we get a compiler warning about unused enum values.
* core/trivial: rename NM_UTILS_STRING_LOOKUP_TABLE* to NM_UTILS_LOOKUP*Thomas Haller2016-01-241-9/+9
| | | | | Due to using a switch stetement, it is no longer only useful for looking up strings, and it certainly doesn't use a table anymore.
* utils: implement NM_UTILS_STRING_LOOKUP_TABLE_DEFINE() as switch() statementThomas Haller2016-01-241-6/+7
| | | | | | The compiler will likely optimize a switch() statement also to a table lookup, but it also works for negative values and values with large gaps.
* utils: add NM_UTILS_STRING_LOOKUP_TABLE_ITEM() macroThomas Haller2016-01-241-0/+3
|
* utils: fix out-of-bound access for negative indexes in ↵Thomas Haller2016-01-241-1/+1
| | | | _NM_UTILS_STRING_LOOKUP_TABLE_DEFINE()
* core: add nm_utils_enum2str()Thomas Haller2016-01-181-0/+31
|
* utils: add NM_UTILS_STRING_LOOKUP_TABLE() macroThomas Haller2015-12-071-0/+36
|
* utils: minor refactoring of NM_UTILS_FLAGS2STR_DEFINE() macroThomas Haller2015-12-071-4/+9
|
* utils: add NM_UTILS_FLAGS2STR_DEFINE() macroThomas Haller2015-12-041-0/+15
| | | | Make it neater to implement a nm_utils_flags2str() function.
* utils: add @filter_func argument to nm_utils_g_value_set_object_path_array()Dan Williams2015-12-041-1/+14
|
* core: fix builds with older gcc (like 4.4.x)Dan Williams2015-11-101-1/+1
|
* core: add support for RFC7217 stable privacy addressingLubomir Rintel2015-11-021-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | RFC7217 introduces an alternative mechanism for creating addresses during stateless IPv6 address configuration. It's supposed to create addresses whose host part stays stable in a particular network but changes when the hosts enters another network to mitigate possibility of tracking the host movement. It can be used alongside RFC 4941 privacy extensions (temporary addresses) and replaces the use of RFC 4862 interface identifiers. The address creation mode is controlld by ip6.addr_gen_mode property (ADDR_GEN_MODE in ifcfg-rh), with values of "stable-privacy" and "eui-64", defaulting to "eui-64" if unspecified. The host part of an address is computed by hashing a system-specific secret salted with various stable values that identify the connection with a secure hash algorithm: RID = F(Prefix, Net_Iface, Network_ID, DAD_Counter, secret_key) For NetworkManager we use these parameters: * F() SHA256 hash function. * Prefix This is a network part of the /64 address * Net_Iface We use the interface name (e.g. "eth0"). This ensures the address won't change with the change of interface hardware. * Network_ID We use the connection UUID here. This ensures the salt is different for wireless networks with a different SSID as suggested by RFC7217. * DAD_Counter A per-address counter that increases with each DAD failure. * secret_key We store the secret key in /var/lib/NetworkManager/secret_key. If it's shorter than 128 bits then it's rejected. If the file is not present we initialize it by fetching 256 pseudo-random bits from /dev/urandom on first use. Duplicate address detection uses IDGEN_RETRIES = 3 and does not utilize the IDGEN_DELAY delay (despite it SHOULD). This is for ease of implementation and may change in future. Neither parameter is currently configurable.
* utils: add flags2str utility functionsThomas Haller2015-11-021-0/+17
|
* core: add nm_utils_to_string_buffer global bufferThomas Haller2015-11-021-0/+5
| | | | | | | | | | | | Having a static string buffer for convenience is useful not only for platform. Define the string buffer in NetworkManagerUtils.h, so that all to-string functions can reuse *one* buffer. Of course, this has the potential danger, that different to-string method might reuse the same buffer. Hence, low-level library functions are adviced to use their own buffer, because an upper level might already use the global buffer for another string.
* config: allow to enable/disable configuration snippetsThomas Haller2015-10-051-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support a new configuration option [.config] enable=<ENABLED> for configuration snippets. This new [.config] section is only relevant within the snippet itself and it is not merged into the combined configuration. Currently only the "enable" key is supported. If the "enable" key is missing, it obviously defaults to being enabled. It allows snippets to be skipped from loading. The main configuration "NetworkManager.conf" cannot be skipped. <ENABLED> can be a boolean value (false), to skip a configuration snippet from loading. It can also be a string to match against the NetworkManager version, like "enable=nm-version-min:1.1,nm-version-min:1.0.6" There are several motivations for this: - the user can disable an entire configuration snippet by toggeling one entry. This generalizes the functionality of the global-dns.enable setting, but in a way that applies to configuration on a per-file basis. - for developing, we often switch between different versions of NetworkManager. Thus, we might want to use different configuration. E.g. before global-dns options, I want to use "dns=none" and manage resolv.conf myself. Now, I can use global-dns setting to do that. That can be achieved with something like the following (not exactly, it's an example only): [.config] enable=nm-version-min:1.1 [main] dns=default [global-dns-domain-*] nameserver=127.0.0.1 Arguably, this would be more awesome, if we would bump our micro devel version (1.1.0) more often while developing 1.2.0 (*hint*). - in principle, packages could drop configuration snippets and enable them based on the NetworkManager version. - with the "env:" spec, you can enable/disable snippets by configuring an environment variable. Again, useful for testing and developing.
* core: add nm_utils_ascii_str_to_bool()Thomas Haller2015-10-051-0/+5
| | | | | | | | | | | | This is effectively the same as nm_config_parse_boolean(). The difference is, that "nm-config.c" is not available to the interface-helper, thus any code used by interface-helper (like "NetworkManager.c") cannot use this function. Still don't drop nm_config_parse_boolean() entirely, because it's better to have the explicit notion of parsing a string in the config-context. I ended up not using the function. But I'd still keep this patch.
* core: add NM_UTILS_ERRORThomas Haller2015-09-251-0/+25
|
* core/utils: add NM_UTILS_KEEP_ALIVE() utilityThomas Haller2015-08-131-0/+11
|
* utils: add nm_utils_is_valid_path_component()Thomas Haller2015-08-111-0/+1
|
* core: final gdbus portingDan Winship2015-08-101-3/+0
| | | | | | | | | | Port remaining bits to gdbus and remove stray dbus-glib references Drop the dbus-glib version check from configure, since nothing depends on new dbus-glib any more. Move nm-dbus-glib-types.h and nm-gvaluearray-compat.h from include/ to libnm-util/ since they are now only used by libnm-util and libnm-glib.
* core: port IP/DHCP config to gdbusDan Winship2015-08-101-0/+1
|
* utils: use (void) for empty argumentsColin Walters2015-08-051-1/+1
| | | | | | In C, `()` doesn't do what you want by default. Fixes: 2cf274c03eb93877f835113d8429b938495b9091
* all: make use of new header file "nm-default.h"Thomas Haller2015-08-051-2/+1
|
* core: order destruction of singleton instancesThomas Haller2015-08-051-17/+7
| | | | | | | | | | | | | | | | | | Previously, the order of destructing singleton instances was undefined. Now, have singleton instances register their destruction via nm_singleton_instance_register(). Objects that are registered later, will be destructed earlier. IOW, they will be destroyed in reverse order of construction. This is only a crude method to get the lifetime of singleton instances right by default. Having singletons ref other singletons to keep them alive gives more control over the lifetimes of singletons. This change of having a defined order of destruction does not conflict with taking references to singletons (and thus extending their lifetime). Note that previously, NMPlatform was not registered for destruction. We don't change that yet and intenionally leak a reference.
* core: move D-Bus export/unexport into NMExportedObjectDan Winship2015-07-241-0/+3
| | | | | | | | | | | Move D-Bus export/unexport handling into NMExportedObject and remove type-specific export/get_path methods (export paths are now specified at the class level, and NMExportedObject handles the counters for all exported types automatically). Since all exportable objects now use the same get_path() method, we can also add some helper methods to simplify get_property() implementations for object-path and object-path-array properties.
* all: rename nm-glib-compat.h to nm-glib.h, use everywhereDan Winship2015-07-241-1/+1
| | | | | | | | | | | | | | | | Rather than randomly including one or more of <glib.h>, <glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include "nm-glib-compat.h" most of the time), rename nm-glib-compat.h to nm-glib.h, include <gio/gio.h> from there, and then change all .c files in NM to include "nm-glib.h" rather than including the glib headers directly. (Public headers files still have to include the real glib headers, since nm-glib.h isn't installed...) Also, remove glib includes from header files that are already including a base object header file (which must itself already include the glib headers).
* core: move NM_DEFINE_SINGLETON macros to src/NetworkManagerUtils.hThomas Haller2015-07-241-0/+60
| | | | | NM_DEFINE_SINGLETON is used only by core and makes use of nm-logging. It does not belong to "include/nm-macros-internal.h". Move it to "src/".
* Revert "core: move NM_DEFINE_SINGLETON macros to src/NetworkManagerUtils.h"Thomas Haller2015-07-241-60/+0
| | | | | | This reverts commit 1bca45986561ab6fa6ca3e624ef9ac84d98cdce9. I accidentely pushed that commit. Revert.
* core: move NM_DEFINE_SINGLETON macros to src/NetworkManagerUtils.hThomas Haller2015-07-241-0/+60
| | | | | NM_DEFINE_SINGLETON is used only by core and makes use of nm-logging. It does not belong to "include/nm-macros-internal.h". Move it to "src/".
* core: add nm_match_spec_join() functionThomas Haller2015-07-021-0/+1
| | | | | | We have a special implemenation nm_match_spec_split() to split a string. We also need the reverse operation to be able to convert a list of specs to string without loss.
* core: return parent pid from nm_utils_get_start_time_for_pid()Thomas Haller2015-06-301-1/+1
|
* core: add @max_wait_msec argument to nm_utils_kill_process_sync()Thomas Haller2015-06-301-1/+1
|
* core: fix nm_utils_kill_process_sync() not to hang for a zombie processThomas Haller2015-06-301-1/+1
| | | | | | | kill(pid,sig) can return success for zombie processes. This caused nm_utils_kill_process_sync() to hang indefinitely. Fix it by also checking the process state.
* core: add option to suppress error logging if nm_utils_modprobe() failsThomas Haller2015-06-051-1/+1
| | | | | | We don't want error logging for nm_platform_link_add() which tries to load the bonding module. Later we will run tests as non-root, where modprobe will fail. Logging an error would break the tests.
* device: add device-spec "type:"Thomas Haller2015-06-051-0/+1
| | | | | | | Support a device-spec to match by device-type. This matches on the value as shown by nmcli -f GENERAL.TYPE device show
* utils: move NM_FLAGS_*() macros to header file "include/nm-utils-internal.h"Thomas Haller2015-05-291-9/+0
|
* keyfile: readd owner check of files (bgo #701112)Thomas Haller2015-05-191-0/+3
| | | | | | | | Commit 5dc4be54e62aa0168478a3c9d6cf45c551c5ace8 dropped the owner check for keyfiles to allow running `make check` as root. Re-add it, but disable the check for tests. https://bugzilla.gnome.org/show_bug.cgi?id=701112
* core/tests: add nm_utils_get_testing() functionThomas Haller2015-05-191-0/+17
| | | | | | | | | | | | | | | | Code that is testable often needs special hooks to work both for unit-tests and production. Add a function nm_utils_get_testing() that returns whether the code is run as part of a unit-test. For non-testing mode, nm_utils_get_testing() will return zero (NM_UTILS_TEST_NONE). For unit tests, the test should call _nm_utils_set_testing() to configure tested functions. By specifing the @flags attribute, the test can enable/disable specific behaviors. https://bugzilla.gnome.org/show_bug.cgi?id=701112
* core: capture DNS options from resolv.confBeniamino Galvani2015-05-131-0/+1
|
* core: remove G_GNUC_WARN_UNUSED_RESULT from ASSERT_VALID_PATH_COMPONENT()Thomas Haller2015-05-011-1/+1
| | | | | | ASSERT_VALID_PATH_COMPONENT() always returns the input argument -- unless it fails an assertion and terminates the program. No need to require the user to use the return value.