summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* initrd: reword warnings when parsing "rd.ethtool=" optionth/initrd-ethtoolThomas Haller2021-09-162-36/+20
| | | | | | | | | | | | | | "Impossible to set rd.ethtool options: invalid format" is not very clear. Try to explain what is invalid about the format (the interface name is missing). "Invalid value for rd.ethtool.autoneg, rd.ethtool.autoneg was not set" is also confusing. The message gets printed if the autoneg value was specified on the command line, so "was not set" seems wrong. Maybe the message meant that the profile value is left at the default (FALSE), but that isn't very clear. Reword.
* initrd: only reset autoneg/speed if specifiedThomas Haller2021-09-162-13/+14
| | | | | | | | | | | | | | The idea of positional arguments is that they might be extended in the future. That means, there might be an option "rd.ethtool:eth0:::foo". Also, if multiple "rd.ethtool:eth0" options are specified on the command line, then the autoneg/speed settings should only be set if present. That means "rd.ethtool:eth0:on:100 rd.ethtool:eth0:::foo" should work as expected and first set autoneg/speed options, but the second argument only sets "foo" (without resetting autoneg/speed).
* initrd: warn about disabling autoneg without setting speedThomas Haller2021-09-162-0/+23
| | | | | | | | | | | | | | | To NetworkManager, "autoneg=FALSE && speed=0" has the meaning to not configure these options and leave whatever is configured previously. That is also the default. Explicitly configuring "rd.ethtool=eth0:off:0" is thus likely a misconfiguration, because it tells NetworkManager to not configure the interface. Note that the user can configure that, via "rd.ethtool=eth0::", that is by omitting all parameters. That is a valid configuration and causes no warning. The reason to support this silently, is so that we can add in the future more positional arguments that the user can set without changing autoneg/speed.
* initrd: refactor parsing of "rd.ethtool=" to accept zero positional argumentsThomas Haller2021-09-162-12/+3
| | | | | | | | | The point of positional arguments is that you can omit them, and that should be treated as the parameter being set to the default. So, don't treat "rd.ethtool=eth0" (or "rd.ethtool=eth0:") special. Just continue the parsing and take all following positional arguments as unset.
* initrd: refactor parsing of "rd.ethtool=" to not return after autonegThomas Haller2021-09-162-31/+33
| | | | | | | | | | | | | | | | | | | | | | | | | Don't return early from parsing "autoneg", if there are not additional arguments. The behavior should be exactly the same, whether a positional argument is missing, empty, or set to the default. That is, - "rd.ethtool=eth0:on" - "rd.ethtool=eth0:on:" - "rd.ethtool=eth0:on::" - "rd.ethtool=eth0:on:0:" should all evaluate the same thing. That was already the case in practice, but that was hard to see. So don't treat missing positional arguments special and don't return early. Parse all parameters regardless. The change is visible when parsing "rd.ethtool=eth0:off:100 rd.ethtool=eth0:on". Autoneg and speed really belongs together, so when we parse the second argument, we should reset the speed too -- even if it's not present.
* initrd/tests: add more tests for "rd.ethtool" (test_rd_ethtool())Thomas Haller2021-09-161-0/+31
|
* initrd/tests: refactor tests for "rd.ethtool" (test_rd_ethtool())Thomas Haller2021-09-161-153/+63
| | | | | It tests the same input as before (except, dropping the duplicate test for "rd.ethtool=eth0:on:100:bogus").
* l3cfg: fix leak of ObjStateData's os_plobjThomas Haller2021-09-161-1/+2
| | | | Fixes: 6b92c8948656 ('l3cfg: track platform object in NML3Cfg's object state')
* contrib: reformat by default from "nm-code-format.sh" scriptThomas Haller2021-09-161-5/+5
| | | | | | | | | The majority of times when I call this script, I want it to do the reformatting, not the check-only mode. This is also because we use git, so I start with a clean working directory and run the reformatting code. In the best case, there is nothing to reformat, and all is good. I seldom want to only check. Change the default of the script.
* contrib: explicitly pass "-n" to "nm-code-format.sh" in gitlab-ci check-tree jobThomas Haller2021-09-162-7/+7
| | | | | | "nm-code-format.sh" is going to change the default behavior from "-n" to "-i", that is, from check-only to reformat. Explicitly pass "-n" where we want it.
* contrib: explicitly pass "-n" to "nm-code-format.sh" in ↵Thomas Haller2021-09-161-1/+1
| | | | | | | | "code-style-git-post-commit-hook" "nm-code-format.sh" is going to change the default behavior from "-n" to "-i", that is, from check-only to reformat. Explicitly pass "-n" where we want it.
* device: suppress warning for external device if it is down (!IFF_UP)Thomas Haller2021-09-161-1/+2
| | | | | External devices are not to be touched by NetworkManager. If it is down, that is not something to warn about.
* device: set up device also while "assuming"Thomas Haller2021-09-161-1/+1
| | | | | | | | | "assuming" means to gracefully take over after restart. The result should be a working configuration with a device fully managed by NetworkManager. If we are assuming, and the interface is down we still want to set it up.
* ifupdown: downgrade warning about missing /etc/network/interfaces fileThomas Haller2021-09-161-1/+1
| | | | | | | | I don't think this warrants a warning. It's important to keep the number of warnings and errors in the log low, and only print such messages if there is really something that requires attention by the user. If you run without /etc/network/interfaces, then this is pretty much expected and the warning isn't going to tell you anything useful.
* l3cfg: track platform object in NML3Cfg's object stateThomas Haller2021-09-151-26/+31
| | | | | | | | | | | | NML3Cfg tracks the state of each object (that is addresses and routes). Previously, it had a boolean flag "os_in_platform", that should be true if (and only if) we have a corresponding NMPObject in the platform cache. But NMPObjects are immutable and ref-counted. That means, we can just as well track the reference to the NMPObject from the cache. The advantage is that we have an index (dictionary) to find the object state, and by tracking the platform object, we have it easily accessible.
* l3cfg/ipv6ll: add NM_L3_IPV6LL_STATE_DEFUNCT enumThomas Haller2021-09-152-5/+12
| | | | | This is not used by NML3IPv6LL, but is useful for the callers to have an additional pseudo value at their disposal.
* l3cfg: allow injecting default dns-priority for NML3ConfigDataThomas Haller2021-09-157-1/+43
| | | | | | | | NML3ConfigData is supposed to be immutable. It can be initialized from a NMConnection, and its DNS priority property might be zero. For the DNS priority, the value can be overwritten by global defaults. We thus need to inject the default value at the right place.
* core: move NM_DNS_PRIORITY_DEFAULT_{NORMAL,VPN} to libnm-baseThomas Haller2021-09-152-5/+5
| | | | | | | | | We will use these values from NML3Cfg, and it seems wrong that NML3Cfg would include "dns/nm-dns-manager.h" for this. Enums are very "static". They have no logic, and there is less need to separate the code well. Meaning, it doesn't hurt to define this enum in "libnm-base/nm-base.h" which can be included by (almost) anybody.
* contrib: improve nm-in-container.sh script (4)Thomas Haller2021-09-151-4/+26
|
* gitignore: fix ignore file for nm-in-container.dThomas Haller2021-09-151-1/+1
|
* contrib: fix "nm-code-format.sh" to select files to formatThomas Haller2021-09-151-21/+44
| | | | | | | | | | | | | | There was always the idea that you could pass paths and filenames to "nm-code-format.sh" to format only a subset. However, the script also needs to honor files that should be excluded and don't need formatting. Previously, what was implemented via `git ls-files -- ':(exclude)...'` command, but git-ls-files has a bug ([1]) and might not list all files. Refactor and do the filtering ourselves. [1] https://www.spinics.net/lists/git/msg397982.html
* nm-active-connection: Emit device-metered-changed if device changesPhilip Withnall2021-09-151-0/+7
| | | | | | | | | | The new device might have a different metered status from the old one. Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: 04d5804dd582 ('nm-manager: add 'metered' property') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/982
* contrib: improve nm-in-container.sh scriptThomas Haller2021-09-151-10/+21
|
* contrib: improve nm-in-container.sh scriptThomas Haller2021-09-143-32/+56
|
* contrib: improve nm-in-container.sh scriptThomas Haller2021-09-142-27/+58
|
* ovs: avoid asking nm-sudo if ovsdb socket does not existThomas Haller2021-09-131-0/+5
| | | | | | | | | | | | Starting with OVS plugin installed but OVS service stopped, would lead to <trace> [1631531732.8896] ovsdb: connect: opening /run/openvswitch/db.sock failed ("error connecting socket (No such file or directory)"). Retry with nm-sudo ... <trace> [1631531732.9751] ovsdb: connect: failure to get FD from nm-sudo: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code1: error connecting socket (No such file or directory) If we already know that the socket file does not exist, we don't need to ask nm-sudo. That would only make sense, if nm-sudo somehow saw a different file systemd than NetworkManager, but that is (currently) not the case.
* contrib: improve nm-in-container.sh scriptThomas Haller2021-09-133-2/+59
|
* contrib: add nm-in-container.sh script to build a (podman) container for testingThomas Haller2021-09-133-0/+315
| | | | Only a first attempt. It needs more improvements.
* core: fix typo in function name nmp_object_ip_route_is_best_default_route()Vojtech Bubela2021-09-133-5/+5
|
* platform/tests: fix test failure for "platform_ip_address_pretty_sort_cmp"Thomas Haller2021-09-131-79/+79
| | | | | | | The memory layout of the NMPlatformIPAddress structure changed. The unit test needs to be adjusted. Fixes: 9ec9a92f1724 ('platform: avoid bitfield at end of __NMPlatformIPAddress_COMMON macro')
* nmcli: make relatives path for `nmcli connection load` absoluteThomas Haller2021-09-131-5/+23
| | | | | | | | | | | | | | NetworkManager (the daemon) has no defined working directory, so it can only handle absolute path names. This is in general and also for the LoadConnections() D-Bus call. That means, nmcli should make relative paths absolute. We don't use g_canonicalize_filename() because that also cleans up double slash and "/./". I don't think we should do that in this case, we should only prepend $PWD to make the path absolute. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/794
* core/trivial: fix spelling in commentThomas Haller2021-09-131-1/+1
|
* core/trivial: fix small typo Ipv vs IPvjosef radinger2021-09-131-1/+1
| | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/978
* libnm: fix leak and return "failures" from nm_client_load_connections()gaoxingwang2021-09-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Due to this, `nmcli connection load` would also not print a warning about failure to load obviously bogus files: $ nmcli connection load /bogus Note that load is also used to unload files, so if the file name is a possibly valid name for a non-existing file, there is no failure. For example, we get no warning for $ nmcli connection load /etc/NetworkManager/system-connections/bogus Even if currently no such file is loaded, then the operation would still silently succeed, instead of succeeding the first time only. That is because load should be idempotent. [thaller@redhat.com: rewrote commit message] Fixes: 4af6219226e0 ('libnm: implement nm_client_load_connections_async() by using GDBusConnection directly') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/794 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/979
* platform: avoid bitfield at end of __NMPlatformIPAddress_COMMON macroThomas Haller2021-09-101-4/+3
| | | | | | | | | | | | | | | | NMPlatformIPAddress, NMPlatformIP4Address and NMPlatformIP6Address are supposed to have a common first part, which is address family agnostic. For that, the is the macro __NMPlatformIPAddress_COMMON which defines the first fields. Something similar is also done for routes and object types that have an ifindex. Anyway, __NMPlatformIPAddress_COMMON used to have a bitfield as last element. In particular NMPlatformIP4Address then has a bitfield as first IPv4 specific field. With this it's not clear to me that the alignment is guaranteed to be the same for all structs. Avoid the trailing bitfield at __NMPlatformIPAddress_COMMON to workaround this potential problem.
* l3cfg: merge branch 'th/l3cfg-ipv6ll'Thomas Haller2021-09-1029-442/+2095
|\ | | | | | | https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/976
| * core: add NML3IPv6LL helperThomas Haller2021-09-108-1/+1103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This helper class is supposed to encapsulate most logic about configuring IPv6 link local addresses and exposes a simpler API in order to simplify NMDevice. Currently this logic is spread out in NMDevice. Also, NML3IPv6LL directly uses NML3Cfg, thereby freeing NMDevice to care about that too much. For several reasons, NML3IPv6LL works different than NML3IPv4LL. For one, with IPv6 we need to configure the address in kernel, which does DAD for us. So, NML3IPv6LL will tell NML3Cfg to configure those addresses that it wants to probe. For IPv4, it only tells NML3Cfg to do ACD, without configuring anything yet. That is left to the caller.
| * l3cfg: implement NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE and rework object ↵Thomas Haller2021-09-101-309/+561
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | state NML3Cfg tracks state about all addresses/routes. It needs that (at least) for the following reaons: 1) if a address/route gets added by NetworkManager and then gets externally removed then it is presumed that the user did this. In this case, we remember that ("externally-removed") to not re-add the address/route, until we do a full reapply. This was previously tracked as "externally_removed_objs_hash". 2) when NML3Cfg configures a address/route in kernel, and later the address/route is no longer to be configured, then NML3Cfg needs to delete it again. It thus needs to remember which addresses/routes it configured earlier to remove them. This was previously tracked via "last_addresses_x" and "last_routes_x". 3) kernel rejects configuring certain routes while a related IPv6 address is still tentative. That means, NML3Cfg needs to detect that, remember it, and retry later. That is previously tracked as "routes_temporary_not_available_hash". 4) during NM_L3_CFG_COMMIT_TYPE_ASSUME, we don't remove extraneous and don't add missing addresses/routes. This commit mode is done while assuming a device, that is, gracefully taking over after a restart. However, sometimes while assuming a device we forcefully want to configure an address/route. That happens for example if we do IPv6 link local addressing. Then we really want to add that address/route, even in assume mode. That is what the NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE flag does, and to implement that we need to track whether we already tried to add the address/route previously. This is something new. Consolidate these various states in a new "obj_state_hash" and "ObjStateData" structure. This solves above points the following way: 1) to track externally removed objects, we have a flag in ObjStateData that indicates whether the object was every configured and whether it currently is configured. Based on that we make decisions to configure (or not) an address. See "_obj_states_sync_filter()". 2) we now mark objects that NML3Cfg configured, which are still in platform and which are no longer to be configured as "zombies". 3) this is now tracked via ObjStateData's "os_temporary_not_available_lst". 4) with the available ObjStateData we can make appropriate decisions in "_obj_states_sync_filter()".
| * l3cfg: add NM_L3CFG_CONFIG_FLAGS_ASSUME_CONFIG_ONCE flagThomas Haller2021-09-084-4/+55
| | | | | | | | | | | | | | | | | | | | It's a bit tricky how this flag works. It's needed for IPv6 link local addresses, which commits changes in %NM_L3_CFG_COMMIT_TYPE_ASSUME mode. See the code comments how it works. This commit only adds the flags and let's the NMPlatformIP{Address,Route} properly track it. What is still needed is to actually implement any meaning to that during the sync.
| * platform: move ip4acd_not_ready flag to NMPlatformIP4AddressThomas Haller2021-09-084-12/+12
| | | | | | | | | | | | | | This flag is only relevant for IPv4. That is, because the way we do ACD/DAD is fundamentally different between IPv4 and IPv6. For IPv4, we use libn-acd while IPv6 we configure the address in kernel and wait for the tentative flag to go away.
| * platform: add assume_config_once flags to NMPlatformIP{Address,Route}Thomas Haller2021-09-083-13/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | NMPlatformIP{Address,Route} are mainly the structs that we receive via netlink and get cached in the NMPlatform cache. However, the same structures are also used by the upper layers to track which addresses to add. Add a flag to addresses and routes, for a certain behavior, relevant during NML3Cfg commit. The idea is that during commits for NML3Cfg of type NM_L3_CFG_COMMIT_TYPE_ASSUME, no new addresses are added that are not already configured. In some cases, we want to override that, and need a flag to track that. More about that later.
| * l3cfg: refactor modification of address in nm_l3_config_data_merge()Thomas Haller2021-09-081-12/+29
| |
| * l3cfg: also call nm_l3_config_data_merge()'s add-obj-hook for routesThomas Haller2021-09-082-26/+45
| |
| * l3cfg: add a "result" structure to nm_l3_config_data_merge()'s add-obj-hookThomas Haller2021-09-083-21/+29
| |
| * l3cfg: change NM_L3_CONFIG_MERGE_FLAGS_ONLY_FOR_ACD to be a ↵Thomas Haller2021-09-084-18/+22
| | | | | | | | | | | | | | NML3CfgConfigFlags value It's really not related to NML3ConfigMergeFlags, but fits better to NML3CfgConfigFlags.
| * l3cfg: add config_flags argument to nm_l3cfg_add_config()Thomas Haller2021-09-084-0/+15
| | | | | | | | | | We will need to present additional options for tracking the configuration. Add a flags argument.
| * core/tests: add nmtst_utils_host_id_{push,pop}() helpers to stub the host-idThomas Haller2021-09-082-1/+101
| | | | | | | | | | | | | | | | | | | | | | | | The host-id gets read from /var/lib/NetworkManager/secret_key, and cached in a global variable. Other parts of the code can get the host ID using a singleton function. For testing, we need to inject a different host-id. Add two push/pop functions for that. Unlike nm_utils_host_id_get(), these functions are not thread-safe (nor is it possible to make them thread-safe in a reasonable manner).
| * glib-aux/tests: add NMTST_COPY() helperThomas Haller2021-09-081-0/+13
| |
| * glib-aux: add nm_g_array_{first,last}() helpersThomas Haller2021-09-081-0/+22
| | | | | | | | | | A GArray can commonly used like a stack or a fifo list. Add convenience accessors to get the first/last element.
| * all: rename nmtst_* functions that are used by the daemonThomas Haller2021-09-0810-27/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The name prefix "nmtst_*" is reserved for test helpers and stub function. Such functions should not be in the actual build artifacts, like the NetworkManager binary. Instead, nmtst_connection_assert_unchanging() is not a test helper. It is a assertion function that is only enabled with NM_MORE_ASSERTS builds. That's different. Rename. In other words, $ nm src/core/NetworkManager src/libnm-client-impl/.libs/libnm.so | grep nmtst should give no results.