summaryrefslogtreecommitdiff
path: root/shared
Commit message (Collapse)AuthorAgeFilesLines
* n-dhcp4: fallback to CLOCK_MONOTONIC for timerfd (resync with upstream)Thomas Haller2020-03-182-29/+28
| | | | | | | | | | The upstream merge request [1] was solved differently from commit f49ce4121407 ('client: fallback to CLOCK_MONOTONIC for timerfd'). Resync with upstream. [1] https://github.com/nettools/n-dhcp4/pull/13 [2] https://github.com/nettools/n-dhcp4/commit/a0bb7c69a11a0db31fce5572c43ad7888694bf9e
* shared: add nm_g_variant_is_of_type() helperThomas Haller2020-03-171-0/+8
|
* shared: expose size of nm_ethtool_data array in headerThomas Haller2020-03-061-1/+1
|
* shared: move assertion in _NM_UTILS_STRING_TABLE_LOOKUP_DEFINE()Thomas Haller2020-03-021-2/+2
| | | | | | | Move the assertion for valid LIST first. It only checks static data, and regardless of the entry_cmd, it should be done first. Fixes: f4d12f7b59b6 ('shared: add NM_UTILS_STRING_TABLE_LOOKUP_STRUCT_DEFINE() macro for lookup of structs')
* shared: fix handling %NULL argument in nm_ref_string_equals_str()Thomas Haller2020-03-021-1/+1
| | | | Fixes: 190a8ed425c1 ('shared: add nm_ref_string_equals_str() helper')
* shared: add NMU_IFACE_OVS_OR_KERNEL for nm_utils_ifname_valid()Thomas Haller2020-02-262-0/+4
| | | | | | | | | | Depending on the type, OVS interfaces also have a corresponding netdev in kernel (e.g. type "internal" does, type "patch" does not). Such a case is neither NMU_IFACE_OVS nor NMU_IFACE_KERNEL (alone). There should be a special type to represent those cases. Add NMU_IFACE_OVS_OR_KERNEL for that.
* shared: add NMU_IFACE_ANY for nm_utils_ifname_valid()Thomas Haller2020-02-262-1/+13
| | | | | | | | | | | nm_utils_ifname_valid() is to validate "connection.interface-name" property. But the exact validation depends on the connection type. Add "NMU_IFACE_ANY" to validate the name to check whether it would be valid for any connection type. This is for completeness and for places where the caller might not know the connection type.
* shared: reject reserved names from "connection.interface-name"Thomas Haller2020-02-261-0/+13
| | | | | | | | | "all" and "default" never works. "bonding_masters" works if you unload the bonding module. Well, that should not really be called working... Reject these names.
* shared: reject '%' from nm_utils_ifname_valid() for kernel namesThomas Haller2020-02-261-2/+28
| | | | | | | | | | | | | | Generally, it's dangerous to reject values that were accepted previously. This will lead to NetworkManager being unable to load a profile from disk, which was loadable previously. On the other hand, kernel would not have treated this setting as it was intended. So, I would argue that the such a setting was not working (as intended) anyway. We can only hope that users don't configure arbitrary interface names. It generally isn't a good idea to do, so "breaking" such things is less of a concern.
* n-dhcp4: keep trying after a failure in send()Beniamino Galvani2020-02-241-12/+13
| | | | | | | | | | | | | | | | | | | | Currently if an error is encountered during a send() of a message, the client fails and there is no possibility of recover, since no timers are armed after a failed event dispatch. An easy way to reproduce a failure is to add a firewall rule like: iptables -A OUTPUT -p udp --dport 67 -j REJECT which makes the send() fail with EPERM during the renew. In such case, the client should continue (failing) until it reaches the rebind phase at T2, when it will be able to renew the lease using the packet socket. In general, a failure to send a packet should not cause the failure of the client. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/419 https://bugzilla.redhat.com/show_bug.cgi?id=1806516
* n-dhcp4: fix logging macroBeniamino Galvani2020-02-241-2/+3
| | | | | The level can be a complex expression, don't use it directly in the macro.
* shared: fix suffix for NM_GOBJECT_PROPERTIES_DEFINE_BASE*() for multiple ↵Thomas Haller2020-02-241-6/+9
| | | | | | | | | | | | definitions To really use multiple NM_GOBJECT_PROPERTIES_DEFINE_BASE*() defines in the same source file, several fixes to the suffix handling are necessary. This fixes commit f13c7e3bbd87 ('shared: extend NM_GOBJECT_PROPERTIES_DEFINE*() macros to append suffix to defined names') to really work. Fixes: f13c7e3bbd87 ('shared: extend NM_GOBJECT_PROPERTIES_DEFINE*() macros to append suffix to defined names')
* shared: add more debug messages to nm_utils_parse_inaddr_bin_full()Beniamino Galvani2020-02-211-5/+31
| | | | | | Log the reason for the assertion failure to debug the crash in [1]. [1] https://bugzilla.redhat.com/show_bug.cgi?id=1797915
* shared: extend NM_GOBJECT_PROPERTIES_DEFINE*() macros to append suffix to ↵Thomas Haller2020-02-211-16/+22
| | | | | | | defined names This way, we will be able to use the macro multiple times in the same source file by using different suffixes.
* shared: add nm_utils_named_values_from_str_dict_full() to allow different ↵Thomas Haller2020-02-192-3/+18
| | | | sort order (or none)
* shared: add NM_UTILS_STRING_TABLE_LOOKUP_STRUCT_DEFINE() macro for lookup of ↵Thomas Haller2020-02-191-18/+41
| | | | structs
* shared: add NM_MORE_ASSERT_ONCE() macroThomas Haller2020-02-191-0/+18
|
* shared/trivial: add code comment to nm_utils_ifname_valid_kernel()Thomas Haller2020-02-181-0/+4
|
* shared: check for valid UTF-8 in nm_utils_ifname_valid()Thomas Haller2020-02-181-1/+5
| | | | | | | | The interface name might come from the command line or from a filename (like during nm_vpn_wireguard_import()). It's not clear that this is valid UTF-8. Asserting against that requires the caller to ensure that the encoding is valid. That is cumbersome, especially since we anyway check. Just report a regular error.
* nm-shared-utils: relax ovs ifname check to accept any (non-space) ASCII ↵Antonio Cardace2020-02-181-2/+5
| | | | | | | | | | | | | | | | printable char quoting 'man ovs-vswitchd.conf.db': "The name must be alphanumeric and must not contain forward or backward slashes." OVS actually accepts a wider range of chars (all printable UTF-8 chars), NetworkManager restricts this to ASCII char as it's a safer option for now since OVS is not well documented on this matter. https://bugzilla.redhat.com/show_bug.cgi?id=1788432 Fixes: e7d72a14f6 ('libnm-core: use different ifname validation function for OVS bridges, ports and interfaces')
* n-dhcp4: request previous address after expirationBeniamino Galvani2020-02-172-4/+10
| | | | | If the lease expires and the client start again sending a discover, request the previous address.
* shared: fix returning out_len from nm_utils_hash_values_to_array()Thomas Haller2020-02-171-0/+1
| | | | | | | | The only affected caller is nm_modem_manager_get_modems(), which is used by NMDeviceBt for DUN connections. This is rather bad. Fixes: 4154d9618c90 ('bluetooth: refactor BlueZ handling and let NMBluezManager cache ObjectManager data') Fixes: e688e70b372a ('shared: add nm_utils_hash_values_to_array() helper')
* nm-shared-utils: add nm_utils_ifname_valid*() to shared utilsAntonio Cardace2020-02-172-0/+102
| | | | | | Move the body of nm_utils_is_valid_iface_name() to nm_utils_ifname_valid_kernel() so that it's shared between NM and clients.
* shared: add LOGD_DHCP_from_addr_family() helperThomas Haller2020-02-171-0/+8
|
* license: relicense "shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h" ↵Thomas Haller2020-02-161-1/+1
| | | | | | | | | | | | | | | | | | | under LGPL-2.1+ $ git shortlog -n -s a3e75f329446a93a61ca4c458a7657bd919f4fe6 -- shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h src/systemd/sd-adapt-core/nm-sd-adapt-core.c src/systemd/sd-adapt/nm-sd-adapt.'[hc]' src/systemd/nm-sd-adapt.'[hc]' src/dhcp-manager/systemd-dhcp/nm-sd-adapt.'[hc]' 46 Thomas Haller 7 Beniamino Galvani 3 Lubomir Rintel 2 Dan Williams 2 Dan Winship 1 Glenn Washburn 1 Jiří Klimeš Note that the contribution to the file by Glenn was removed in commit e27b15c00d23 ('all: remove CLOCK_BOOTTIME defintions'), so it is no longer relevant. All other contributors agreed to the relicensing according to "RELICENSE.md".
* license: relicense "shared/nm-utils/nm-vpn-editor-plugin-call.h" under LGPL-2.1+Thomas Haller2020-02-161-1/+1
| | | | | | | $ git shortlog -n -s a3e75f329446a93a61ca4c458a7657bd919f4fe6 -- shared/nm-utils/nm-vpn-editor-plugin-call.h shared/nm-vpn-editor-plugin-call.h 5 Thomas Haller All contributors agreed to the relicensing according to "RELICENSE.md".
* license: relicense "shared/nm-libnm-core-intern-aux/nm-auth-subject.[hc]" ↵Thomas Haller2020-02-162-2/+2
| | | | | | | | | | | | | under LGPL-2.1+ $ git shortlog -n -s a3e75f329446a93a61ca4c458a7657bd919f4fe6 -- shared/nm-libnm-core-intern/nm-auth-subject.'[hc]' src/nm-auth-subject.'[hc]' 28 Thomas Haller 7 Dan Winship 1 Beniamino Galvani 1 Dan Williams 1 Jiří Klimeš All contributors agreed to the relicensing according to "RELICENSE.md".
* license: relicense "shared/nm-glib-aux/nm-jansson.h" under LGPL-2.1+Thomas Haller2020-02-161-1/+1
| | | | | | | | | | $ git shortlog -n -s a3e75f329446a93a61ca4c458a7657bd919f4fe6 -- shared/nm-glib-aux/nm-jansson.h shared/nm-utils/nm-jansson.h 7 Thomas Haller 1 Lubomir Rintel 1 Beniamino Galvani 1 Francesco Giudici All contributors agreed to the relicensing according to "RELICENSE.md".
* license: relicense "shared/nm-glib-aux/nm-glib.h" under LGPL-2.1+Thomas Haller2020-02-161-1/+1
| | | | | | | | | | | | | | | | $ git shortlog -n -s a3e75f329446a93a61ca4c458a7657bd919f4fe6 -- shared/nm-glib-aux/nm-glib.h shared/nm-utils/nm-glib.h shared/nm-glib.h include/nm-glib.h include/nm-glib-compat.h 35 Thomas Haller 12 Dan Winship 5 Dan Williams 3 Lubomir Rintel 2 Beniamino Galvani 1 Jan Kantert 1 Thomas Bechtold The last two contributions by Thomas and Jan are no longer present in any form, because they were for an older version of glib which is no longer supported. All other contributors agree to the licences change according to "RELICENSE.md" file.
* all: drop explicit casts from _GET_PRIVATE() macro callsThomas Haller2020-02-141-2/+2
| | | | | | | | | The _GET_PRIVATE() macros are all implemented based on _NM_GET_PRIVATE(). That macro tries to be more type safe and uses _Generic() to do the right thing. Explicitly casting is not only unnecessary, it defeats these (static) type checks. Don't do that.
* shared: don't require callback argument to nm_dbus_connection_call_set()Thomas Haller2020-02-141-2/+0
| | | | It's fine to call propery-set without caring about the result.
* shared: drop compat implementation for G_DEFINE_QUARK()th/define-fcn-macros-cleanupThomas Haller2020-02-131-16/+0
| | | | | | | | For one, we by now require glib >= 2.34.0, so this is not used. Also, I think G_DEFINE_QUARK() is rather ugly because it constructs the defined function name (so you cannot grep for it). We should use NM_CACHED_QUARK_FCN() instead.
* shared: drop _STATIC variant of macros that define functionsThomas Haller2020-02-134-31/+18
| | | | | | | | | | | | | | | | | | Several macros are used to define function. They had a "_STATIC" variant, to define the function as static. I think those macros should not try to abstract entirely what they do. They should not accept the function scope as argument (or have two variants per scope). This also because it might make sense to add additional __attribute__(()) to the function. That only works, if the macro does not pretend to *not* define a plain function. Instead, embrace what the function does and let the users place the function scope as they see fit. This also follows what is already done with static NM_CACHED_QUARK_FCN ("autoconnect-root", autoconnect_root_quark)
* shared: explicitly implement binary search in ↵Thomas Haller2020-02-131-11/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*() When looking at nm_utils_array_find_binary_search(), we see that binary search really isn't complicated. In nm_utils_array_find_binary_search() it looks complicated, because that is our general purpose function which accepts arbitrary lists, uses an opaque compare function, accepts a user data argument, and returns the insertion position. This is unnecessary for the narrow purpose in NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*(). When we inline the binary search, it can be simplified, and the remaining parts is simple enough to prefer this duplication of binary search over using our general purpose function. Also, this gives the compiler more chance for optimization. For example, we can use "unsigned" as index type instead of gssize, because we know (at compile time), that this type will always be large enough for our LIST. Also, we can directly call strcmp(). The result is that the macro's implementation is also fast in the best case (where the needle is found with only one strcmp()) and in the cases where there is a small number of items to search. It thus alleviates concerns that using the macro might be slower than an optimized implementation. The binary size of the defined function increases slightly (from 112 bytes to 192 bytes, on x86_64, GCC, -O2). But according to my tests it is slightly and measurably faster.
* shared/tests: add test for NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*()Thomas Haller2020-02-131-0/+30
|
* shared: add entry_cmd argument to NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*() macroThomas Haller2020-02-131-16/+24
| | | | This extra argument allows to tweak whether to assert for the input argument name.
* n-dhcp4: avoid double free of NDhcp4OutgoingBeniamino Galvani2020-02-111-2/+3
| | | | | | | | n_dhcp4_c_connection_start_request() should take ownership of the request only on success. On failure the request is freed by the caller. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/355
* shared/tests: add nmtst_get_rand_uint64() utilThomas Haller2020-02-101-0/+9
|
* shared: add nm_ref_string_equals_str() helperThomas Haller2020-02-101-0/+12
|
* shared: rename local variable in _NM_GET_PRIVATE_PTR() macroThomas Haller2020-02-101-2/+2
| | | | | | The _NM_GET_PRIVATE_PTR() macro is possibly used from other macros. And "_self" is a pretty good name to use. Don't let the lower layer macro use this name.
* shared: drop nm_utils_dbus_normalize_object_path() in favor of ↵Thomas Haller2020-02-101-12/+0
| | | | | | nm_dbus_path_not_empty() They do the same thing. Unify and drop one.
* shared: add nm_g_variant_lookup() and nm_g_variant_lookup_value() helpersThomas Haller2020-02-101-0/+18
| | | | It's often convenient to accept %NULL as dictionary argument.
* shared: add nm_utils_strdup_reset() helperThomas Haller2020-02-101-0/+14
|
* shared: add NM_FLAGS_ASSIGN_MASK() helperThomas Haller2020-02-101-0/+8
|
* shared: add nm_dbus_connection_call_set() utilThomas Haller2020-02-102-2/+43
|
* shared: add NM_PRINT_FMT_QUOTE_REF_STRING() macroThomas Haller2020-02-101-0/+1
|
* shared: add NM_UTILS_STRING_TABLE_LOOKUP_DEFINE() macro to simplify defining ↵Thomas Haller2020-02-101-0/+50
| | | | string lookup functions
* shared: add nm_utils_get_monotonic_timestamp_msec_cached() helperThomas Haller2020-02-101-0/+7
|
* shared/trivial: rename time related functions to use "nsec"/"msec" ↵Thomas Haller2020-02-102-9/+10
| | | | | | | abbreviation instead of "ns"/"ms" The "ns" abbreviation doesn't look too nice. We mostly use "nsec" at other places. Rename.
* all: add nm_utils_error_is_cancelled() and ↵Thomas Haller2020-02-102-8/+12
| | | | | | | | nm_utils_error_is_cancelled_or_disposing() Most callers would pass FALSE to nm_utils_error_is_cancelled(). That's not very useful. Split the two functions and have nm_utils_error_is_cancelled() and nm_utils_error_is_cancelled_is_disposing().