summaryrefslogtreecommitdiff
path: root/src/nmcli
Commit message (Collapse)AuthorAgeFilesLines
* cli: connection: check for deprecated features on "add"/"modify"lr/wep-cliLubomir Rintel2022-03-131-0/+5
| | | | | If the user happens to create a WiMax or Wi-Fi WEP connection they get a warning.
* cli: connection: check for warnings after "modify"Lubomir Rintel2022-03-131-0/+2
| | | | | | Run the same checks after "nmcli c modify" as we do for "nmcli c add". That is -- warn if the resulting connection has a connection ID collision.
* cli: connection: factor out warning from "add" callbackLubomir Rintel2022-03-131-25/+36
| | | | | | | | | We sometimes emit warnings after a connection is added. Currently there's a warning when the connection ID collides with another one (and a suggestion to use an UUID instead). Let's move the check into a separate routine, so that we can reuse it elsewhere, such as on connection "modify" (in a following commit).
* cli: connection: check for deprecated featuresLubomir Rintel2022-03-131-4/+36
| | | | | | | | | Check if a connection uses something that is likely not to work -- either now or in future. The ultimate decision on whether it's going to work is up to the daemon. We just use the result to color the connection differently to provide slight visual cue to the user.
* cli: device: color WEP APs differently in "wifi list"Lubomir Rintel2022-03-131-0/+5
| | | | | Provide a visual cue suggesting that an attempt to associate with an WEP access point might not work. Whether it actually will work up to the daemon.
* cli: device: factor out checking whether an AP is a WEP oneLubomir Rintel2022-03-131-21/+35
| | | | | This is going to be useful elsewhere. We're going to mark WEP APs as deprecated.
* cli: add color codes for deprecated featuresLubomir Rintel2022-03-131-1/+5
| | | | | | | Follow-up commits are going color Wi-Fi networks and connections that rely on deprecated features differently, to provide a visual cue. Add color definitions for those.
* all: prefer nm wrappers to automatically attach GSource to default contextThomas Haller2022-03-132-10/+7
| | | | | | | | | 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.
* libnm/docs: add reference to secret-key in description for stable-idThomas Haller2022-03-111-1/+1
|
* cli: don't ignore errors from setting property aliasesLubomir Rintel2022-03-081-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Before, we would just ignore the errors when we passed an invalid value to a property alias: $ nmcli c add type ethernet mac Hello Connection 'ethernet-1' (242eec76-7147-411a-a50b-336cf5bc8137) successfully added. $ nmcli c show 242eec76-7147-411a-a50b-336cf5bc8137 |grep 802-3-ethernet.mac-address: 802-3-ethernet.mac-address: -- ...or crash, because the GError would still be around: $ nmcli c add type ethernet mac Hello ethernet.mac-address World (process:734670): GLib-WARNING **: 14:52:51.436: GError set over the top of a previous GError or uninitialized memory. This indicates a bug in someone's code. You must ensure an error is NULL before it's set. The overwriting error message was: Error: failed to modify 802-3-ethernet.mac-address: 'World' is not a valid Ethernet MAC. Error: failed to modify 802-3-ethernet.mac-address: 'Hello' is not a valid Ethernet MAC. Now we catch it early enough: $ nmcli c add type ethernet mac Hello Error: failed to modify 802-3-ethernet.mac-address: 'Hello' is not a valid Ethernet MAC. Fixes: 40032f461415 ('cli: fix resetting values via property alias') https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1134
* cli: make APInfo parameter to fill_output_access_point() constThomas Haller2022-03-041-20/+27
| | | | | | | | | | | | | | | It's helpful to control when data/state gets mutated. In particular, when passing on a pointer via several hops. C can help with that at compile time via "const". But the "index" field of APInfo is actually mutable, as it counts the lines. So most of the data is immutable, but the index. Make APInfo const. But to do that, the mutable part must be moved to a separate place. Also, start with the counter initialized to zero instead of one. It is just nicer.
* cli: change "IN-USE" property to only honor the exact access pointThomas Haller2022-03-041-28/+16
| | | | | | | | | | | | | | | | | On the D-Bus API, the current access point is referred exactly, by its D-Bus path. Likewise, in libnm's NMClient cache, the access point instance is unique in representing the D-Bus object (meaning, we can directly use pointer equality). Let's not compare the active AP based on the BSSID. It can happen that the scan list contains the same BSSID multiple times (for example on different bands). In that case, the output should only highlight one AP as in-use: $ nmcli device wifi list IN-USE BSSID SSID MODE CHAN RATE SIGNAL BARS SECURITY * E4:0f:4b:2a:c3:d1 MYSSID1 Infra 6 270 Mbit/s 100 ▂▄▆█ WPA2 * E4:0f:4b:2a:c3:d1 MYSSID1 Infra 6 270 Mbit/s 87 ▂▄▆█ WPA2
* cli: minor cleanup initializing APInfo in "devices.c"Thomas Haller2022-03-041-12/+11
|
* cli: don't reset default values in interactive addBeniamino Galvani2022-02-211-3/+4
| | | | | | | | | | | | | | Since commit 40032f461415 ('cli: fix resetting values via property alias'), nmcli sets NULL properties during interactive add (nmcli -a connection add) when the user leaves the field blank. This can lead to an invalid connection for properties that can't be empty like infiniband.transport-mode; they should be left to the default value in case of no value entered. Fixes: 40032f461415 ('cli: fix resetting values via property alias') Fixes-test: @inf_create_port_novice_mode https://bugzilla.redhat.com/show_bug.cgi?id=2053603 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1111
* style: fix clang-formatThomas Haller2022-02-171-1/+1
|
* nmcli: do not save/restore terminal attrsLubomir Rintel2022-02-161-6/+0
| | | | | | | | | | | | This is vestigal. It has been in place, because we'd be turning off echo ourselves when asking for password and needed to make sure we'd still terminal in original state upon unexpected termination. This shouldn't be necessary since commit 9d95e1f1753a ('clients/cli: use a nicer password prompt') we let readline take care of this and also clean up after itself in nmc_cleanup_readline(). https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1100
* openvswitch: Add ovs-dpdk n_rxq propertyAna Cabral2022-01-101-0/+2
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=2001563
* cli: correct active connection details header in nmcli outputSam Morris2022-01-031-1/+1
| | | | | | | [thaller@redhat.com: update translation strings and regenerate expected output for nmcli tests] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1046
* nmcli: fix "remove" command to really remove the propertyFernando Fernandez Mancera2021-12-011-2/+3
| | | | | | | | | | | | | | | | | | | | When using the "remove" command on nmcli edit mode it will reset the value to the default when no property value is specified. If the property value is specified it will remove that specific property. Example: ``` nmcli> set ethernet.wake-on-lan phy nmcli> print ethernet.wake-on-lan 802-3-ethernet.wake-on-lan: phy, default nmcli> remove ethernet.wake-on-lan default nmcli> print ethernet.wake-on-lan 802-3-ethernet.wake-on-lan: phy nmcli> remove ethernet.wake-on-lan nmcli> print ethernet.wake-on-lan 802-3-ethernet.wake-on-lan: default ```
* nmcli: introduce "add" command to edit modeFernando Fernandez Mancera2021-12-011-0/+9
| | | | | | | | | | | | This patch introduces "add" command to nmcli edit mode. When using "add" it will append the value to the ones already set. This is doing the same thing than the "set" command does right now. Example: ``` nmcli> add ipv4.addresses 192.168.1.1/24 ```
* format: reformat source tree with clang-format 13.0Thomas Haller2021-11-2915-1155/+1170
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* libnm: change default value for "dcb.app-fcoe-mode" propertyThomas Haller2021-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | String properties in libnm's NMSetting really should have NULL as a default value. The only property that didn't, was "dcb.app-fcoe-mode". Change the default so that it is also NULL. Changing a default value is an API change, but in this case probably no issue. For one, DCB is little used. But also, it's not clear who would care and notice the change. Also, because previously verify() would reject a NULL value as invalid. That means, there are no existing, valid profiles that have this value set to NULL. We just make NULL the default, and define that it means the same as "fabric". Note that when we convert integer properties to D-Bus/GVariant, we often omit the default value. For string properties, they are serialized as "s" variant type. As such, NULL cannot be expressed as "s" type, so we represent NULL by omitting the property. That makes especially sense if the default value is also NULL. Otherwise, it's rather odd. We change that, and we will now always express non-NULL value on D-Bus and let NULL be encoded by omitting the property.
* cli: add support for connection.dns-over-tlsRobin Ebert2021-10-151-0/+2
|
* 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
* all: prefer g_snprintf() over snprintf()Thomas Haller2021-08-261-7/+7
| | | | | | While both functions are basically the same, the majority of the time we use g_snprintf(). There is no strong reason to prefer one or the other, but let's keep using one variant.
* bond: add support of queue_id of bond portGris Ge2021-08-262-13/+23
| | | | | | | | | | | | | | | | Introduced `NMSettingBondPort` to hold the new setting class with single property `NM_SETTING_BOND_PORT_QUEUE_ID`. For dbus interface, please use `bond-port` as setting name and `queue-id` as property name. Unit test cases for ifcfg reader and writer included. Signed-off-by: Gris Ge <fge@redhat.com> https://bugzilla.redhat.com/show_bug.cgi?id=1949127 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/952
* all: add some README.md files describing the purpose of our sourcesThomas Haller2021-08-191-0/+13
|
* nmcli/docs: fix address order in ipv46.addresses documentation for `man ↵Thomas Haller2021-08-191-1/+1
| | | | | | | | nm-settings-nmcli` For IPv4, the order is not like for IPv6. Of course not. Fixes: 7aa4ad0fa22c ('nmcli/docs: better describe ipv[46].addresses in `man nm-settings-nmcli`')
* nmcli/docs: better describe ipv[46].addresses in `man nm-settings-nmcli`Thomas Haller2021-08-171-2/+2
|
* nmcli: edit output of nmcli so it shows more inormation about routesVojtech Bubela2021-08-021-6/+15
| | | | | | | | Edit nmcli command to show additional information about the routes (both route4 and route6). If there is information about next hop or metric in the route structure it will be shown in addition to destination and prefix.
* all: rename nm_utils_strdict_*() to nm_strdict_*()Thomas Haller2021-08-021-1/+1
|
* all: rename nm_utils_strsplit_set*() to nm_strsplit_set*()Thomas Haller2021-08-023-4/+4
|
* all: rename nm_utils_strdup_reset*() to nm_strdup_reset*()Thomas Haller2021-08-023-5/+4
|
* cli: fix leak of text for libreadlineThomas Haller2021-07-293-15/+13
| | | | | | | | | | | | | | | | | | | | | | | | Coverity warns about this: Error: RESOURCE_LEAK (CWE-772): NetworkManager-1.32.4/src/nmcli/agent.c:87: alloc_fn: Storage is returned from allocation function "g_strdup". NetworkManager-1.32.4/src/nmcli/agent.c:87: var_assign: Assigning: "pre_input_deftext" = storage returned from "g_strdup(secret->value)". NetworkManager-1.32.4/src/nmcli/agent.c:87: overwrite_var: Overwriting "pre_input_deftext" in "pre_input_deftext = g_strdup(secret->value)" leaks the storage that "pre_input_deftext" points to. # 85| /* Prefill the password if we have it. */ # 86| rl_startup_hook = set_deftext; # 87|-> pre_input_deftext = g_strdup(secret->value); # 88| } # 89| if (secret->no_prompt_entry_id) Error: RESOURCE_LEAK (CWE-772): NetworkManager-1.32.4/src/nmcli/common.c:712: alloc_fn: Storage is returned from allocation function "g_strdup". NetworkManager-1.32.4/src/nmcli/common.c:712: var_assign: Assigning: "nmc_rl_pre_input_deftext" = storage returned from "g_strdup(secret->value)". NetworkManager-1.32.4/src/nmcli/common.c:712: overwrite_var: Overwriting "nmc_rl_pre_input_deftext" in "nmc_rl_pre_input_deftext = g_strdup(secret->value)" leaks the storage that "nmc_rl_pre_input_deftext" points to. # 710| /* Prefill the password if we have it. */ # 711| rl_startup_hook = nmc_rl_set_deftext; # 712|-> nmc_rl_pre_input_deftext = g_strdup(secret->value); # 713| } # 714| }
* all: unify and rename strv helper APIThomas Haller2021-07-293-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* cli: Provide optional support for libedit instead of readlineLukasz Majewski2021-07-145-4/+42
| | | | | | | | | | | | | | | | | The libreadline starting from version 6 is licensed as GPLv3. For some use cases it is not acceptable to use this license. In the NetworkManager the libreadline is used by nmcli. This change allows using libedit instead of libreadline. Following adjustments were made: 1. The history_set_history_state() is not supported in the libedit. Instead, the where_history() with remove_history() were used to remove the history content if needed. 2. rl_complete_with_tilde_expansion - it is the binary flag used only when one wants to have the expansion support. The libedit is not supporting and hence exporting this flag.
* cli: Provide rl_completion_display_matches_hook function only for libreadlineLukasz Majewski2021-07-141-0/+4
| | | | | | When one wants to compile the nmcli with libedit (GPLv2 replacement of libreadline) the rl_completion_display_matches_hook hook shall be left untouched (as NULL) as it is not supported in libedit.
* cli: Fix for rl_startup_hook function signatures mismatch (-lreadline vs -ledit)Lukasz Majewski2021-07-143-5/+11
| | | | | | | | The rl_startup_hook function has different prototype in libreadline and in the libedit. To fix this issue, arguments of hook function has been wrapped to C preprocessor macro and properly adjusted.
* nmcli: include 'searches' field for nmcli device showAna Cabral2021-07-092-0/+14
| | | | Merge Request !919
* cli: reorder command list in nmc_command_func_device()Thomas Haller2021-07-091-1/+1
| | | | | Sort asciibetically, at least as long as there is no conflicting prefix that should be preferred.
* cli: sort entries in src/nmcli/devices.c by alphabetical orderVojtech Bubela2021-07-091-7/+7
| | | | | | | | | Sort entries in src/nmcli/devices.c (on line 5023 - 5036) by alphabetical order. The Order is violated in cases where the sort would affect previous behaviour. Example: `nmcli d d` is still shortcut for `nmcli device disconnect` instead of `nmcli device delete`.
* cli: fix list of commands in nmc_command_func_device()Thomas Haller2021-07-091-1/+1
|
* cli: add alias to nmcli device connect|disconnectVojtech Bubela2021-07-091-0/+2
| | | | | | | nmcli now accepts `nmcli device up|down` which works the same way as `nmcli device connect|disconnect` I also edited man pages of nmcli with new options.
* clang-format: use "IndentPPDirectives:None" instead of "BeforeHash"Thomas Haller2021-07-091-2/+2
| | | | Subjectively, I think this looks better.
* cli: fail `nmcli connection up $PROFILE ifname $DEVICE` for non-existing ↵Thomas Haller2021-07-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | virtual device $ nmcli connection add type dummy con-name x autoconnect no ipv4.method disabled ipv6.method disabled ifname d0 $ mcli connection up x ifname bogus Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/12) This is not right. A non-existing ifname argument was simply ignored and nmcli would tell NetworkManager to activate the profile (on any device). Instead, if the user specifies a device argument, also for a virtual type, it must exist. Note that usually for virtual devices (like 'dummy'), the device in fact does not exist, so passing `ifname` is likely to fail. If the device already exists, then the command is no going to work as expected, with $ mcli connection up x ifname d0 succeeding, while $ mcli connection up x ifname d1 fails (as intended) with Error: device 'd1' not compatible with connection 'x': The interface names of the device and the connection didn't match..
* cli: improve error message for device not foundThomas Haller2021-07-081-8/+19
| | | | | | | | | | $ nmcli connection add type ethernet con-name x autoconnect no ipv4.method disabled ipv6.method disabled $ nmcli connection up x ifname bogus Error: device 'bogus' not compatible with connection 'x'. Better would be: Error: device 'bogus' not found for connection 'x'.
* cli: replace strcmp() uses with nm_streq()/NM_IN_STRSET()Thomas Haller2021-07-081-43/+42
|
* all: add a new ipv{4,6}.required-timeout propertyBeniamino Galvani2021-07-051-0/+4
| | | | | | | | | | | | | Add a new property to specify the minimum time interval in milliseconds for which dynamic IP configuration should be tried before the connection succeeds. This property is useful for example if both IPv4 and IPv6 are enabled and are allowed to fail. Normally the connection succeeds as soon as one of the two address families completes; by setting a required timeout for e.g. IPv4, one can ensure that even if IP6 succeeds earlier than IPv4, NetworkManager waits some time for IPv4 before the connection becomes active.
* build: fix linking libnm-log-null into different test programsThomas Haller2021-07-051-0/+2
| | | | | We require these, otherwise we can get a linker error about _nm_utils_monotonic_timestamp_initialized symbol being undefined.
* libnm: better document "ethernet.s390-options" propertyThomas Haller2021-07-021-1/+1
|