summaryrefslogtreecommitdiff
path: root/src/nm-cloud-setup
Commit message (Collapse)AuthorAgeFilesLines
* curl: use CURLOPT_PROTOCOLS_STR instead of deprecated CURLOPT_PROTOCOLSThomas Haller2023-01-181-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CURLOPT_PROTOCOLS [0] was deprecated in libcurl 7.85.0 with CURLOPT_PROTOCOLS_STR [1] as a replacement. Well, technically it was only deprecated in 7.87.0, and retroactively marked as deprecated since 7.85.0 [2]. But CURLOPT_PROTOCOLS_STR exists since 7.85.0, so that's what we want to use. This causes compiler warnings and build errors: ../src/core/nm-connectivity.c: In function 'do_curl_request': ../src/core/nm-connectivity.c:770:5: error: 'CURLOPT_PROTOCOLS' is deprecated: since 7.85.0. Use CURLOPT_PROTOCOLS_STR [-Werror=deprecated-declarations] 770 | curl_easy_setopt(ehandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS); | ^~~~~~~~~~~~~~~~ In file included from ../src/core/nm-connectivity.c:13: /usr/include/curl/curl.h:1749:3: note: declared here 1749 | CURLOPTDEPRECATED(CURLOPT_PROTOCOLS, CURLOPTTYPE_LONG, 181, | ^~~~~~~~~~~~~~~~~ This patch is largely taken from systemd patch [2]. Based-on-patch-by: Frantisek Sumsal <frantisek@sumsal.cz> [0] https://curl.se/libcurl/c/CURLOPT_PROTOCOLS.html [1] https://curl.se/libcurl/c/CURLOPT_PROTOCOLS_STR.html [2] https://github.com/curl/curl/commit/6967571bf20624bc4cfa68fb8f90cbc53a87c6f2 [3] https://github.com/systemd/systemd/pull/25982/commits/e61a4c0b7c79eabbe4eb50ff2e663734fde769f0 Fixes: 7a1734926a4d ('connectivity,cloud-setup: restrict curl protocols to HTTP and HTTPS')
* all: use _NM_G_TYPE_CHECK_INSTANCE_CAST() for internal usesThomas Haller2022-12-166-6/+7
| | | | | | | | | | | | | | | | | | | | G_TYPE_CHECK_INSTANCE_CAST() can trigger a "-Wcast-align": src/core/devices/nm-device-macvlan.c: In function 'parent_changed_notify': /usr/include/glib-2.0/gobject/gtype.h:2421:42: error: cast increases required alignment of target type [-Werror=cast-align] 2421 | # define _G_TYPE_CIC(ip, gt, ct) ((ct*) ip) | ^ /usr/include/glib-2.0/gobject/gtype.h:501:66: note: in expansion of macro '_G_TYPE_CIC' 501 | #define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) | ^~~~~~~~~~~ src/core/devices/nm-device-macvlan.h:13:6: note: in expansion of macro 'G_TYPE_CHECK_INSTANCE_CAST' 13 | (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_DEVICE_MACVLAN, NMDeviceMacvlan)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ Avoid that by using _NM_G_TYPE_CHECK_INSTANCE_CAST(). This can only be done for our internal usages. The public headers of libnm are not changed.
* nm-cloud-setup: simplify clearing variables in retry loopThomas Haller2022-12-141-2/+2
| | | | | | | | | | | | | | | | The label "try_again" is only reached by one goto. So it was correct and sufficient to reset the state only there. It is still error prone. The slighlty clearer approach is to clear the state at each begin of the "try_again" step. There should be no change in behavior. I didn't confirm, but an optimizing compiler should (could) be able to see that the cleanup is only necessary on retry, and generate the same code as before. In any case, we should write code that is easier to read, not optimize for something that a compiler should be able to optimize itself.
* nm-cloud-setup: refactor skipping reapply be checking for skip firstThomas Haller2022-12-141-20/+31
| | | | | | | | | | | | | | There should be no change in behavior, but this way seems nicer. Now _nmc_mangle_connection() doesn't return FALSE, it always will try to mangle the connection and requires the caller to first check whether that is appropriate. Just move some code outside of _nmc_mangle_connection() and let the caller check for the skip first. The point is consistency, as the caller already does some checks to whether skip the reapply. So it should do all the checks, so that "mangle" never fails/skips.
* nm-cloud-setup: set preserve-external-ip flag during reapplyThomas Haller2022-12-143-1/+24
| | | | | | | | | Externally added IP addresses/routes should be preserved by nm-cloud-setup. This allows other tools to also configure the interface and the Reapply() call from nm-cloud-setup would not interfere with those tools. https://bugzilla.redhat.com/show_bug.cgi?id=2132754
* cloud-setup,glib-aux: use NULL instead of g_direct_equal() for hash tablesThomas Haller2022-08-311-7/+6
|
* glib-aux: rename IP address related helpers from "nm-inet-utils.h"Thomas Haller2022-08-255-33/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - name things related to `in_addr_t`, `struct in6_addr`, `NMIPAddr` as `nm_ip4_addr_*()`, `nm_ip6_addr_*()`, `nm_ip_addr_*()`, respectively. - we have a wrapper `nm_inet_ntop()` for `inet_ntop()`. This name of our wrapper is chosen to be familiar with the libc underlying function. With this, also name functions that are about string representations of addresses `nm_inet_*()`, `nm_inet4_*()`, `nm_inet6_*()`. For example, `nm_inet_parse_str()`, `nm_inet_is_normalized()`. <<<< R() { git grep -l "$1" | xargs sed -i "s/\<$1\>/$2/g" } R NM_CMP_DIRECT_IN4ADDR_SAME_PREFIX NM_CMP_DIRECT_IP4_ADDR_SAME_PREFIX R NM_CMP_DIRECT_IN6ADDR_SAME_PREFIX NM_CMP_DIRECT_IP6_ADDR_SAME_PREFIX R NM_UTILS_INET_ADDRSTRLEN NM_INET_ADDRSTRLEN R _nm_utils_inet4_ntop nm_inet4_ntop R _nm_utils_inet6_ntop nm_inet6_ntop R _nm_utils_ip4_get_default_prefix nm_ip4_addr_get_default_prefix R _nm_utils_ip4_get_default_prefix0 nm_ip4_addr_get_default_prefix0 R _nm_utils_ip4_netmask_to_prefix nm_ip4_addr_netmask_to_prefix R _nm_utils_ip4_prefix_to_netmask nm_ip4_addr_netmask_from_prefix R nm_utils_inet4_ntop_dup nm_inet4_ntop_dup R nm_utils_inet6_ntop_dup nm_inet6_ntop_dup R nm_utils_inet_ntop nm_inet_ntop R nm_utils_inet_ntop_dup nm_inet_ntop_dup R nm_utils_ip4_address_clear_host_address nm_ip4_addr_clear_host_address R nm_utils_ip4_address_is_link_local nm_ip4_addr_is_link_local R nm_utils_ip4_address_is_loopback nm_ip4_addr_is_loopback R nm_utils_ip4_address_is_zeronet nm_ip4_addr_is_zeronet R nm_utils_ip4_address_same_prefix nm_ip4_addr_same_prefix R nm_utils_ip4_address_same_prefix_cmp nm_ip4_addr_same_prefix_cmp R nm_utils_ip6_address_clear_host_address nm_ip6_addr_clear_host_address R nm_utils_ip6_address_same_prefix nm_ip6_addr_same_prefix R nm_utils_ip6_address_same_prefix_cmp nm_ip6_addr_same_prefix_cmp R nm_utils_ip6_is_ula nm_ip6_addr_is_ula R nm_utils_ip_address_same_prefix nm_ip_addr_same_prefix R nm_utils_ip_address_same_prefix_cmp nm_ip_addr_same_prefix_cmp R nm_utils_ip_is_site_local nm_ip_addr_is_site_local R nm_utils_ipaddr_is_normalized nm_inet_is_normalized R nm_utils_ipaddr_is_valid nm_inet_is_valid R nm_utils_ipx_address_clear_host_address nm_ip_addr_clear_host_address R nm_utils_parse_inaddr nm_inet_parse_str R nm_utils_parse_inaddr_bin nm_inet_parse_bin R nm_utils_parse_inaddr_bin_full nm_inet_parse_bin_full R nm_utils_parse_inaddr_prefix nm_inet_parse_with_prefix_str R nm_utils_parse_inaddr_prefix_bin nm_inet_parse_with_prefix_bin R test_nm_utils_ip6_address_same_prefix test_nm_ip_addr_same_prefix ./contrib/scripts/nm-code-format.sh -F
* all: use internal _nm_utils_ip4_netmask_to_prefix()Thomas Haller2022-06-271-1/+1
| | | | | | We have two variants of the function: nm_utils_ip4_netmask_to_prefix() and _nm_utils_ip4_netmask_to_prefix(). The former only exists because it is public API in libnm. Internally, only use the latter.
* cloud-setup: only pass config-iface-data as user-data for async functionsThomas Haller2022-05-052-40/+34
| | | | | | | From config_iface_data->get_config_data we have access to the other pointer already. No need to allocate a user data. (cherry picked from commit 7d71aff24770ad8ba6c6bc16a83d4d9e2544bd45)
* cloud-setup: use union for NMCSProviderGetConfigIfaceData.privThomas Haller2022-05-052-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use a union, it makes more sense. Note that with union, C's struct initialization might not sufficiently set all fields to the default. In practice yes, but theoretically in C a NULL pointer and floats must not have all zero bits, so the following is not guaranteed to work: struct { int some_field; union { void *v_ptr; int v_int; }; } variable = { .some_field = 24, }; assert(variable.union.v_ptr == 0); assert(variable.union.v_int == 0); When initializing the variable, we should not rely on automatically initialize all union members correctly. It cannot at the same time set NULL pointers and zero integers -- well, on our architectures it probably can, but not as far as guaranteed by C language. We need to know which union field we are going to use and initialize it explicitly. As we know the provider type, we can do that. Also, maybe in the future we need special free/unref calls when destroying the type specific data in NMCSProviderGetConfigIfaceData. As we know the provider, we can. Note that having type specific data in NMCSProviderGetConfigIfaceData.priv is a layering violation. But it is still simpler than implementing type specific handlers (callbacks) or tracking the data somewhere else. After all, we know at compile time all the existing provider types. (cherry picked from commit 1e696c7e93c14bc2ea7bfdcf4a655621ceb4e862)
* cloud-setup: track config-task-data in iface-dataThomas Haller2022-05-056-26/+35
| | | | | | | | | | | | | | | | | | | | Let NMCSProviderGetConfigIfaceData.get_config_data have a pointer to the NMCSProviderGetConfigTaskData. This will allow two things: - at several places we pass on `nm_utils_user_data_pack(get_config_data, config_iface_data)` as user data. We can avoid that, by just letting config_iface_data have a pointer to get_config_data. - NMCSProviderGetConfigIfaceData contains a provider specific field "priv". That may also require special initialization or destruction, depending on the type. We thus need access to the provider type, which we have via iface_data->get_config_data->self. Also let NMCSProviderGetConfigTaskData have a pointer "self" to the NMCSProvider. While there was already the "task", which contains the provider as source-object, this is more convenient. (cherry picked from commit 069946cda14b2465d1eb5434402609fcd96f35ba)
* cloud-setup: reorder addresses to honor "primary_ip_address"Thomas Haller2022-05-052-1/+73
| | | | | | | | | | | | | | | | The order of IPv4 addresses matters, in particular if they are in the same subnet. Kernel will mark all but the first one as "secondary". In NetworkManager's ipv4.addresses, the first address is the primary. It seems that on aliyun cloud, "private-ipv4s" URL may give the addresses in arbitrary order. The primary can be fetched from "primary-ip-address". Fix that by also fetching "primary-ip-address". Then, resort the array so that the primary is the first one in the list. https://bugzilla.redhat.com/show_bug.cgi?id=2079849 (cherry picked from commit 191baf84e215177c66aa23182fcfeae1f66dc271)
* all: prefer nm wrappers to automatically attach GSource to default contextThomas Haller2022-03-132-14/+8
| | | | | | | | | We often create the source with default priority, no destroy function and attach it to the default context (g_main_context_default()). For that case, we have wrapper functions like nm_g_timeout_add_source() and nm_g_idle_add_source(). Use those. There should be no change in behavior.
* all: change scheduling priority for idle actions to G_PRIORITY_DEFAULT_IDLEThomas Haller2022-03-131-2/+2
| | | | | | | | | | | | g_idle_add() uses G_PRIORITY_DEFAULT_IDLE priority. Most of the time we don't care much about the priority. But at the places that this patch changes, I think that using G_PRIORITY_DEFAULT_IDLE (and following g_idle_add()) is more correct. The reason for this is not very strong, except that it's probably the better choice. And the old choice was made because I didn't realize that g_idle_add() uses another default priority. Hence, the old choice was not for good reasons either.
* connectivity,cloud-setup: restrict curl protocols to HTTP and HTTPSThomas Haller2022-02-241-0/+1
| | | | | | | See-also: https://fedoraproject.org/wiki/Changes/CurlMinimal_as_Default#Benefit_to_Fedora See-also: https://github.com/systemd/systemd/commit/55b90ee00b78a449c8f187a5e8141f8ccb100bf4 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1121
* format: reformat source tree with clang-format 13.0Thomas Haller2021-11-2912-307/+307
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We use clang-format for automatic formatting of our source files. Since clang-format is actively maintained software, the actual formatting depends on the used version of clang-format. That is unfortunate and painful, but really unavoidable unless clang-format would be strictly bug-compatible. So the version that we must use is from the current Fedora release, which is also tested by our gitlab-ci. Previously, we were using Fedora 34 with clang-tools-extra-12.0.1-1.fc34.x86_64. As Fedora 35 comes along, we need to update our formatting as Fedora 35 comes with version "13.0.0~rc1-1.fc35". An alternative would be to freeze on version 12, but that has different problems (like, it's cumbersome to rebuild clang 12 on Fedora 35 and it would be cumbersome for our developers which are on Fedora 35 to use a clang that they cannot easily install). The (differently painful) solution is to reformat from time to time, as we switch to a new Fedora (and thus clang) version. Usually we would expect that such a reformatting brings minor changes. But this time, the changes are huge. That is mentioned in the release notes [1] as Makes PointerAligment: Right working with AlignConsecutiveDeclarations. (Fixes https://llvm.org/PR27353) [1] https://releases.llvm.org/13.0.0/tools/clang/docs/ReleaseNotes.html#clang-format
* cloud-setup: use suppress_prefixlength rule to honor non-default-routes in ↵th/cloud-setup-fix-containersThomas Haller2021-09-161-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the main table Background ========== Imagine you run a container on your machine. Then the routing table might look like: default via 10.0.10.1 dev eth0 proto dhcp metric 100 10.0.10.0/28 dev eth0 proto kernel scope link src 10.0.10.5 metric 100 [...] 10.42.0.0/24 via 10.42.0.0 dev flannel.1 onlink 10.42.1.2 dev cali02ad7e68ce1 scope link 10.42.1.3 dev cali8fcecf5aaff scope link 10.42.2.0/24 via 10.42.2.0 dev flannel.1 onlink 10.42.3.0/24 via 10.42.3.0 dev flannel.1 onlink That is, there are another interfaces with subnets and specific routes. If nm-cloud-setup now configures rules: 0: from all lookup local 30400: from 10.0.10.5 lookup 30400 32766: from all lookup main 32767: from all lookup default and default via 10.0.10.1 dev eth0 table 30400 proto static metric 10 10.0.10.1 dev eth0 table 30400 proto static scope link metric 10 then these other subnets will also be reached via the default route. This container example is just one case where this is a problem. In general, if you have specific routes on another interface, then the default route in the 30400+ table will interfere badly. The idea of nm-cloud-setup is to automatically configure the network for secondary IP addresses. When the user has special requirements, then they should disable nm-cloud-setup and configure whatever they want. But the container use case is popular and important. It is not something where the user actively configures the network. This case needs to work better, out of the box. In general, nm-cloud-setup should work better with the existing network configuration. Change ====== Add new routing tables 30200+ with the individual subnets of the interface: 10.0.10.0/24 dev eth0 table 30200 proto static metric 10 [...] default via 10.0.10.1 dev eth0 table 30400 proto static metric 10 10.0.10.1 dev eth0 table 30400 proto static scope link metric 10 Also add more important routing rules with priority 30200+, which select these tables based on the source address: 30200: from 10.0.10.5 lookup 30200 These will do source based routing for the subnets on these interfaces. Then, add a rule with priority 30350 30350: lookup main suppress_prefixlength 0 which processes the routes from the main table, but ignores the default routes. 30350 was chosen, because it's in between the rules 30200+ and 30400+, leaving a range for the user to configure their own rules. Then, as before, the rules 30400+ again look at the corresponding 30400+ table, to find a default route. Finally, process the main table again, this time honoring the default route. That is for packets that have a different source address. This change means that the source based routing is used for the subnets that are configured on the interface and for the default route. Whereas, if there are any more specific routes in the main table, they will be preferred over the default route. Apparently Amazon Linux solves this differently, by not configuring a routing table for addresses on interface "eth0". That might be an alternative, but it's not clear to me what is special about eth0 to warrant this treatment. It also would imply that we somehow recognize this primary interface. In practise that would be doable by selecting the interface with "iface_idx" zero. Instead choose this approach. This is remotely similar to what WireGuard does for configuring the default route ([1]), however WireGuard uses fwmark to match the packets instead of the source address. [1] https://www.wireguard.com/netns/#improved-rule-based-routing
* cloud-setup: cleanup configuring addresses/routes/rules in ↵Thomas Haller2021-09-161-29/+23
| | | | _nmc_mangle_connection()
* cloud-setup: limit number of supported interfaces to avoid overlapping table ↵Thomas Haller2021-09-161-0/+8
| | | | | | | | numbers The table number is chosen as 30400 + iface_idx. That is, the range is limited and we shouldn't handle more than 100 devices. Add a check for that and error out.
* cloud-setup: process iface-datas in sorted orderThomas Haller2021-09-161-15/+13
| | | | | | | | The routes/rules that are configured are independent of the order in which we process the devices. That is, because they use the "iface_idx" for cases where there is ambiguity. Still, it feels nicer to always process them in a defined order.
* cloud-setup: track sorted list of NMCSProviderGetConfigIfaceDataThomas Haller2021-09-162-1/+56
| | | | | | Sorted by iface_idx. The iface_idx is probably something useful and stable, provided by the provider. E.g. it's the order in which interfaces are exposed on the meta data.
* cloud-setup: add "hwaddr" to NMCSProviderGetConfigIfaceData structThomas Haller2021-09-166-66/+68
| | | | | | | | | | get-config() gives a NMCSProviderGetConfigResult structure, and the main part of data is the GHashTable of MAC addresses and NMCSProviderGetConfigIfaceData instances. Let NMCSProviderGetConfigIfaceData also have a reference to the MAC address. This way, I'll be able to create a (sorted) list of interface datas, that also contain the MAC address.
* cloud-setup: skip configuring policy routing if there is only one ↵Thomas Haller2021-09-161-8/+33
| | | | | | | | | | | | | | | | | | | | | | interface/address nm-cloud-setup automatically configures the network. That may conflict with what the user wants. In case the user configures some specific setup, they are encouraged to disable nm-cloud-setup (and its automatism). Still, what we do by default matters, and should play as well with user's expectations. Configuring policy routing and a higher priority table (30400+) that hijacks the traffic can cause problems. If the system only has one IPv4 address and one interface, then there is no point in configuring policy routing at all. Detect that, and skip the change in that case. Note that of course we need to handle the case where previously multiple IP addresses were configured and an update gives only one address. In that case we need to clear the previously configured rules/routes. The patch achieves this.
* cloud-setup: count numbers of valid IPv4 addresses in get-config resultThomas Haller2021-09-162-1/+8
| | | | Will be used next.
* cloud-setup: cache number of valid interfaces in get-config resultThomas Haller2021-09-163-23/+17
| | | | | | | | | Now that we return a struct from get_config(), we can have system-wide properties returned. Let it count and cache the number of valid iface_datas. Currently that is not yet used, but it will be.
* cloud-setup: return structure for get_config() result instead of generic ↵Thomas Haller2021-09-163-30/+72
| | | | | | | | | | hash table Returning a struct seems easier to understand, because then the result is typed. Also, we might return additional results, which are system wide and not per-interface.
* all: add some README.md files describing the purpose of our sourcesThomas Haller2021-08-191-0/+8
|
* aliyun: reuse ipv4 gateway address returned by metadata serverWen Liang2021-08-093-6/+50
| | | | | | | | | | | | | The default ipv4 gateway address of the VPC in Aliyun cloud is not the first IP address in the CIDR subnet block, we should instead use the ipv4 gateway address retrieved from the metadata server in `_nmc_mangle_connection()`. https://bugzilla.redhat.com/show_bug.cgi?id=1823315 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/958 Signed-off-by: Wen Liang <liangwen12year@gmail.com>
* all: rename nm_utils_strsplit_set*() to nm_strsplit_set*()Thomas Haller2021-08-022-6/+6
|
* all: unify and rename strv helper APIThomas Haller2021-07-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Naming is important, because the name of a thing should give you a good idea what it does. Also, to find a thing, it needs a good name in the first place. But naming is also hard. Historically, some strv helper API was named as nm_utils_strv_*(), and some API had a leading underscore (as it is internal API). This was all inconsistent. Do some renaming and try to unify things. We get rid of the leading underscore if this is just a regular (internal) helper. But not for example from _nm_strv_find_first(), because that is the implementation of nm_strv_find_first(). - _nm_utils_strv_cleanup() -> nm_strv_cleanup() - _nm_utils_strv_cleanup_const() -> nm_strv_cleanup_const() - _nm_utils_strv_cmp_n() -> _nm_strv_cmp_n() - _nm_utils_strv_dup() -> _nm_strv_dup() - _nm_utils_strv_dup_packed() -> _nm_strv_dup_packed() - _nm_utils_strv_find_first() -> _nm_strv_find_first() - _nm_utils_strv_sort() -> _nm_strv_sort() - _nm_utils_strv_to_ptrarray() -> nm_strv_to_ptrarray() - _nm_utils_strv_to_slist() -> nm_strv_to_gslist() - nm_utils_strv_cmp_n() -> nm_strv_cmp_n() - nm_utils_strv_dup() -> nm_strv_dup() - nm_utils_strv_dup_packed() -> nm_strv_dup_packed() - nm_utils_strv_dup_shallow_maybe_a() -> nm_strv_dup_shallow_maybe_a() - nm_utils_strv_equal() -> nm_strv_equal() - nm_utils_strv_find_binary_search() -> nm_strv_find_binary_search() - nm_utils_strv_find_first() -> nm_strv_find_first() - nm_utils_strv_make_deep_copied() -> nm_strv_make_deep_copied() - nm_utils_strv_make_deep_copied_n() -> nm_strv_make_deep_copied_n() - nm_utils_strv_make_deep_copied_nonnull() -> nm_strv_make_deep_copied_nonnull() - nm_utils_strv_sort() -> nm_strv_sort() Note that no names are swapped and none of the new names existed previously. That means, all the new names are really new, which simplifies to find errors due to this larger refactoring. E.g. if you backport a patch from after this change to an old branch, you'll get a compiler error and notice that something is missing.
* glib-aux,cloud-setup: add _nm_logging_enabled*() helper APIThomas Haller2021-07-232-28/+1
| | | | Will also be used outside of nm-cloud-setup.
* cloud-setup: link with libnm-log-nullThomas Haller2021-07-231-6/+0
|
* cloud-setup: use _nm_log_simple_printf() for plain loggingThomas Haller2021-07-232-44/+2
|
* cloud-setup: configure secondary ip in Aliyun cloudWen Liang2021-07-195-0/+503
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a tool for automatically configuring networking in Aliyun cloud environment. This add a provider implementation for Aliyun that when detected fetches the private ip addressess and the subnet prefix of IPv4 CIDR block. Once this information is fetched from the metadata server, it instructs NetworkManager to add private ip addressess and subnet prefix for each interface detected. It is inspired by SuSE's cloud-netconfig ([1], [2]) and Aliyun Instance Metadata [3]. [1] https://www.suse.com/c/multi-nic-cloud-netconfig-ec2-azure/ [2] https://github.com/SUSE-Enceladus/cloud-netconfig [3] https://www.alibabacloud.com/help/doc-detail/49122.htm It is also intended to work without configuration. The main point is that you boot an image with NetworkManager and nm-cloud-setup enabled, and it just works. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/885 Signed-off-by: Wen Liang <liangwen12year@gmail.com>
* cloud-setup: add nmcs_utils_uri_complete_interned() for constructing URI for ↵Thomas Haller2021-07-123-16/+17
| | | | _ec2_base()
* cloud-setup: fix constructing URL from NM_CLOUD_SETUP_EC2_HOST in _ec2_base()Thomas Haller2021-07-121-3/+4
|
* cloud-setup: drop unnecessary check in_detect_get_meta_data_done_cb()Thomas Haller2021-07-121-9/+1
|
* clang-format: use "IndentPPDirectives:None" instead of "BeforeHash"Thomas Haller2021-07-091-1/+1
| | | | Subjectively, I think this looks better.
* build: fix linking libnm-log-null into different test programsThomas Haller2021-07-051-0/+1
| | | | | We require these, otherwise we can get a linker error about _nm_utils_monotonic_timestamp_initialized symbol being undefined.
* cloud-setup: preserve IPv4 addresses/routes/rules from profileThomas Haller2021-06-301-9/+40
| | | | | | | | | | | | | | | | | | | | | nm-cloud-setup automatically detects routes, addresses and rules and configures them on the device using the emphermal Reapply() API. That is, it does not modify the existing profile (on disk), but changes the runtime configuration only. As such, it used to wipe otherwise statically configured IP addresses, routes and rules. That seems unnecessary. Let's keep the configuration from the (persistent) configuration. There is of course the problem that nm-cloud-setup doesn't really understand the existing IP configuration, and it can only hope that it can be meaningfully combined with what nm-cloud-setup wants to configure. This should cover most simple cases, for more complex setups, the user probably should disable nm-cloud-setup and configure the network explicitly to their liking. https://bugzilla.redhat.com/show_bug.cgi?id=1971527 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/893
* clang-format: reformat code with clang 12Thomas Haller2021-05-041-1/+1
| | | | | The format depends on the version of the tool. Now that Fedora 34 is released, update to clang 12 (clang-tools-extra-12.0.0-0.3.rc1.fc34.x86_64).
* cloud-setup/azure: fix detecting the gateway addressThomas Haller2021-04-201-0/+45
| | | | | | | | | | | | | | | | The code never set "iface_get_config->cidr_addr", despite setting "cidr_prefix" and "has_cidr". As a result, cloud-setup would think that the subnet is "0.0.0.0/$PLEN", and calculate the gateway as "0.0.0.1". As a result it would add a default route to table 30400 via 0.0.0.1, which is obviously wrong. How to detect the right gateway? Let's try obtain the subnet also via the meta data. That seems mostly correct, except that we only access subnet at index 0. What if there are multiple ones? I don't know. https://bugzilla.redhat.com/show_bug.cgi?id=1912236
* cloud-setup/azure: refactor callback for _get_config_ips_prefix_list_cb()Thomas Haller2021-04-201-25/+40
|
* cloud-setup/azure: cleanup constructing URI in _get_config_ips_prefix_list_cb()Thomas Haller2021-04-201-31/+27
|
* cloud-setup/trivial: rename variables in Azure's _get_config_fetch_done_cb()Thomas Haller2021-04-201-13/+13
| | | | | The previous name seem not very expressive/fitting. Naming is hard, but I think these are better names.
* cloud-setup: use _nm_utils_ascii_str_to_int64_bin() in Azure's ↵Thomas Haller2021-04-201-8/+2
| | | | _get_config_fetch_done_cb()
* cloud-setup: remove redundant check in Azure's _get_net_ifaces_list_cb()Thomas Haller2021-04-201-1/+1
| | | | This condition always true, because there is a check above.
* cloud-setup: move from "clients/cloud-setup/" to "src/nm-cloud-setup/"Thomas Haller2021-03-1519-0/+4713