Commit graph

21 commits

Author SHA1 Message Date
Beniamino Galvani
a48edd0410 core,libnm: don't touch device TC configuration by default
NetworkManager supports a very limited set of qdiscs. If users want to
configure a unsupported qdisc, they need to do it outside of
NetworkManager using tc.

The problem is that NM also removes all qdiscs and filters during
activation if the connection doesn't contain a TC setting. Therefore,
setting TC configuration outside of NM is hard because users need to
do it *after* the connection is up (for example through a dispatcher
script).

Let NM consider the presence (or absence) of a TC setting in the
connection to determine whether NM should configure (or not) qdiscs
and filters on the interface. We already do something similar for
SR-IOV configuration.

Since new connections don't have the TC setting, the new behavior
(ignore existing configuration) will be the default. The impact of
this change in different scenarios is:

 - the user previously configured TC settings via NM. This continues
   to work as before;

 - the user didn't set any qdiscs or filters in the connection, and
   expected NM to clear them from the interface during activation.
   Here there is a change in behavior, but it seems unlikely that
   anybody relied on the old one;

 - the user didn't care about qdiscs and filters; NM removed all
   qdiscs upon activation, and so the default qdisc from kernel was
   used. After this change, NM will not touch qdiscs and the default
   qdisc will be used, as before;

 - the user set a different qdisc via tc and NM cleared it during
   activation. Now this will work as expected.

So, the new default behavior seems better than the previous one.

https://bugzilla.redhat.com/show_bug.cgi?id=1928078
2021-06-03 09:01:57 +02:00
Thomas Haller
ea60f273af
cli: minor cleanup of code in "devices.c"
- declare each variable on a separate line.

- use nm_auto_free_gstring instead of explicit free.
2021-05-27 10:42:10 +02:00
Thomas Haller
550434a026
cli: workaround coverity false positive in "devices.c"
Error: RESOURCE_LEAK (CWE-772): [#def268] [important]
    NetworkManager-1.31.5/src/nmcli/devices.c:1367: alloc_fn: Storage is returned from allocation function "g_string_free".
    NetworkManager-1.31.5/src/nmcli/devices.c:1367: leaked_storage: Ignoring storage allocated by "g_string_free(security_str, 0)" leaks it.
    # 1365|       g_ptr_array_add(info->output_data, arr);
    # 1366|
    # 1367|->     g_string_free(security_str, FALSE);
    # 1368|   }
    # 1369|

    Error: RESOURCE_LEAK (CWE-772): [#def269] [important]
    NetworkManager-1.31.5/src/nmcli/devices.c:1451: alloc_fn: Storage is returned from allocation function "g_string_free".
    NetworkManager-1.31.5/src/nmcli/devices.c:1451: leaked_storage: Ignoring storage allocated by "g_string_free(slaves_str, 0)" leaks it.
    # 1449|       print_data(&nmc->nmc_config, &nmc->pager_data, out_indices, NULL, 0, &out);
    # 1450|
    # 1451|->     g_string_free(slaves_str, FALSE);
    # 1452|
    # 1453|       return TRUE;

    Error: RESOURCE_LEAK (CWE-772): [#def270] [important]
    NetworkManager-1.31.5/src/nmcli/devices.c:1517: alloc_fn: Storage is returned from allocation function "g_string_free".
    NetworkManager-1.31.5/src/nmcli/devices.c:1517: leaked_storage: Ignoring storage allocated by "g_string_free(slaves_str, 0)" leaks it.
    # 1515|       print_data(&nmc->nmc_config, &nmc->pager_data, out_indices, NULL, 0, &out);
    # 1516|
    # 1517|->     g_string_free(slaves_str, FALSE);
    # 1518|
    # 1519|       return TRUE;
2021-05-27 10:34:41 +02:00
Thomas Haller
ca6d30cb24
libnm: comment "olpc-mesh.dhcp-anycast-address" only working with dhclient 2021-05-18 09:41:52 +02:00
Gris Ge
652ddca04c
ethtool: Introducing PAUSE support
Introducing ethtool PAUSE support with:

 * ethtool.pause-autoneg on/off
 * ethtool.pause-rx on/off
 * ethtool.pause-tx on/off

Limitations:
 * When `ethtool.pause-autoneg` is set to true, the `ethtool.pause-rx`
   and `ethtool.pause-tx` will be ignored. We don't have warning for
   this yet.

Unit test case included.

Signed-off-by: Gris Ge <fge@redhat.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/829
2021-05-12 18:04:46 +02:00
Thomas Haller
e5f37477c0
cli: fix leak in print_wifi_connection()
Found by Coverity:

  Error: RESOURCE_LEAK (CWE-772): [#def297] [important]
  NetworkManager-1.31.3/src/nmcli/devices.c:4610: alloc_fn: Storage is returned from allocation function "nm_utils_ssid_to_utf8".
  NetworkManager-1.31.3/src/nmcli/devices.c:4610: var_assign: Assigning: "ssid" = storage returned from "nm_utils_ssid_to_utf8(g_bytes_get_data(ssid_bytes, NULL), g_bytes_get_size(ssid_bytes))".
  NetworkManager-1.31.3/src/nmcli/devices.c:4612: noescape: Resource "ssid" is not freed or pointed-to in "g_print".
  NetworkManager-1.31.3/src/nmcli/devices.c:4642: noescape: Resource "ssid" is not freed or pointed-to in "string_append_mecard".
  NetworkManager-1.31.3/src/nmcli/devices.c:4654: leaked_storage: Variable "ssid" going out of scope leaks the storage it points to.
  # 4652|
  # 4653|       g_print("\n");
  # 4654|-> }
  # 4655|
  # 4656|   static gboolean

Fixes: 7061341a41 ('cli: add "nmcli d wifi show"')
2021-05-11 13:56:50 +02:00
Jonas Dreßler
e06f9508d1
libnm-core: Rewrite comment of key-mgmt property
The key-mgmt property of NMSettingWirelessSecurity is slightly confusing
when you know there's also a wpa_supplicant configuration option called
"key_mgmt". Our property is not the same as that supplicant option even
though they do have things in common. NMs key-mgmt is not exactly meant
to configure which AKM suites you want to use, but rather which method
of wifi security is being used (so "wpa2+wpa3 personal", "wpa3 personal
only" or "wpa3 enterprise only").

Try to make this a bit clearer in the documentation of the property by
rewriting it and listing those security methods.
2021-05-06 22:23:28 +02:00
Beniamino Galvani
a0aa727af2 nmcli: remove nmc_dbus_call_sync()
The function is unused now. All operations should be asynchronous so
that nmcli keeps running the main loop.
2021-05-03 22:22:01 +02:00
Beniamino Galvani
9d0aca6757 nmcli: invoke ReloadConnections() D-Bus method asynchronously 2021-05-03 22:22:01 +02:00
Beniamino Galvani
1d82c39bfa nmcli: invoke Reload() D-Bus method asynchronously
Invoke Reload() asynchronously and run the main loop. In this way, the
polkit agent built into nmcli can be used to authenticate the reload
request.

Fixes: 5afcf9c045 ('cli: add 'general reload' command')
2021-05-03 22:22:01 +02:00
Beniamino Galvani
43fc984989 man: document the 'nmcli general reload' command 2021-05-03 22:13:36 +02:00
Thomas Haller
40032f4614
cli: fix resetting values via property alias
Property aliases should really just be shortcuts for one fully spelled
out property (sometimes, they do more like "master").

Anyway, we must also handle resetting the value, otherwise:

  $ nmcli connection add type gsm apn ""

will still result in "gsm.apn=internet", unlike

  $ nmcli connection add type gsm gsm.apn ""
2021-05-03 10:11:23 +02:00
Thomas Haller
f62ecc97c8
cli: use proper GError codes in "nm-client-utils.c"
g_set_error(error, 1, 0, ...) is not right. "1" is not a valid GQuark,
we should initialize proper error instances.

Use nm_utils_error_set() for that.

Also, the code previously hacked the numeric value "1" to indicate
ambiguous text. Add and use a new error code NM_UTILS_ERROR_AMBIGUOUS
for that.
2021-05-03 10:11:21 +02:00
Thomas Haller
1f33a59a0f
cli: use const argument for nmc_string_is_valid()
With a const argument, we can make variables static const,
which means the linker loads the memory as read only.

Also, use NM_CAST_STRV_CC() macro, which casts the argument
accordingly.
2021-05-03 10:11:20 +02:00
Fernando Fernandez Mancera
d946aa0c50 wired-setting: add support to accept-all-mac-addresses
This patch is introducing the wired setting accept-all-mac-addresses
property. The value corresponds to the kernel flag IFF_PROMISC.

When accept-all-mac-address is enabled, the interface will accept all
the packets without checking the destination mac address.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-04-22 18:57:30 +00:00
Fernando Fernandez Mancera
27e37a4b17 interface-flags: expose NM_DEVICE_INTERFACE_FLAG_PROMISC
This patch is introducing NM_DEVICE_INTERFACE_FLAG_PROMISC in
interface_flags. The flag represents IFF_PROMISC kernel flag.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-04-22 18:57:30 +00:00
Thomas Haller
a55c10c6cb
nmcli/trivial: add comment about stability of connection-add success message 2021-04-17 08:36:55 +02:00
Thomas Haller
f34841e196
all: use nm_g_variant_new_ay() helper 2021-04-16 11:44:19 +02:00
Andrew Zaborowski
f0fe7384e1
all: Replace deprecated NM_CONNECTION_SERIALIZE_* flags
Review and replace usages of the two nm_connection_to_dbus() flags
marked deprecated in commit 84648e562c98 ('libnm: Refactor
NM_CONNECTION_SERIALIZE_* flags'):

NM_CONNECTION_SERIALIZE_NO_SECRETS and
NM_CONNECTION_SERIALIZE_ONLY_SECRETS.
2021-04-01 17:19:15 +02:00
Thomas Haller
8f138e6bc1
libnm/docs: improve wording for documentation of [match] setting options 2021-03-24 16:50:26 +01:00
Thomas Haller
61f99307c6
cli: move from "clients/cli/" to "src/nmcli/" 2021-03-15 17:10:54 +01:00