Commit graph

83 commits

Author SHA1 Message Date
Ana Cabral
74c08c7084 openvswitch: Add ovs-dpdk n_rxq property
https://bugzilla.redhat.com/show_bug.cgi?id=2001563
2022-01-10 22:48:30 +00:00
Ana Cabral
f0cb75f669 trivial: fix typos 2022-01-10 22:48:30 +00:00
Thomas Haller
615221a99c format: reformat source tree with clang-format 13.0
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
2021-11-29 09:31:09 +00:00
Lubomir Rintel
065fa15a0a libnm.pc: plugindir & configdir
Carry them over from NetworkManager.pc, they're potentially useful.
2021-11-03 12:19:36 +01:00
Robin Ebert
5582f658cd
libnm-core: Add connection.dns-over-tls property 2021-10-15 10:00:20 +02:00
Fernando Fernandez Mancera
74dfc86aa4 libnm: introduce nm_device_get_ports() to NMDevice
This patch is introducing a "ports" property to NMDevice. In addition it
is introducing nm_device_get_ports() and deprecating
nm_device_bond_get_slaves(), nm_device_bridge_get_slaves(),
nm_device_ovs_bridge_get_slaves(), nm_device_ovs_interface_get_slaves()
and nm_device_team_get_slaves().

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-11 09:38:24 +02:00
Fernando Fernandez Mancera
cf867e8ff5 dbus-metadata: make 'extra' available from NML_DBUS_META_PROPERTY_INIT_FCN()
Currently a NML_DBUS_META_PROPERTY_INIT_FCN() property does not have
'extra' field available. In order to be able to call
'nml_dbus_property_ao_notify()' from the callback, the 'extra' field
must be available.

The patch is also dropping 'use_notify_update_prop' field as it only
existed to differentiate the union.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-11 09:35:15 +02:00
Fernando Fernandez Mancera
05c062fc80 libnm-utils: let nml_dbus_property_ao_clear() return changed_prop
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-11 09:35:15 +02:00
Fernando Fernandez Mancera
d36d1f83c2 libnm-utils: expose nml_dbus_property_ao_notify()
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-11 09:35:15 +02:00
Fernando Fernandez Mancera
866ce41be8 nm-device: introduce property_ao array
This patch is introducing the property_ao array of type
NMLDBusPropertyAO.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-10 13:06:45 +02:00
Thomas Haller
f918fc3c82
libnm: drop unnecessary code from "nm-device-bond.c" for "hw_address" 2021-10-06 18:02:30 +02:00
Fernando Fernandez Mancera
ec8df200f6 libnm: add NMIPAddress and NMIPRoute dups backported symbols from 1.30.8
The nm_ip_address_dup() and nm_ip_route_dup() symbols were exposed in
libnm 1.32 and then backported to 1.30.8.

Export it also with version @libnm_1_30_8; this allows a program build
against libnm 1.30.8 to keep working with later versions of the library.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-10-05 14:09:15 +02:00
Beniamino Galvani
57c1982867 libnm: add required-timeout backported symbol from 1.30.8
The nm_setting_ip_config_get_required_timeout() symbol was introduced
in libnm 1.32.4 and then backported to 1.30.8.

Export it also with version @libnm_1_30_8; this allows a program built
against libnm 1.30.8 to keep working with later versions of the
library.
2021-09-23 09:01:10 +02:00
gaoxingwang
2a36f8c2f1
libnm: fix leak and return "failures" from nm_client_load_connections()
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: 4af6219226 ('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
2021-09-13 08:32:45 +02:00
Thomas Haller
c39859d240
libnm/tests: replace NM_PRAGMA_WARNING_DISABLE() by _nm_unused 2021-08-31 16:34:02 +02:00
Thomas Haller
10e0c4261e
format: reformat code with clang-format-12.0.1-1.fc34
The formatting produced by clang-format depends on the version of the
tool. The version that we use is the one of the current Fedora release.

Fedora 34 recently updated clang (and clang-tools-extra) from version
12.0.0 to 12.0.1. This brings some changes.

Update the formatting.
2021-08-30 13:14:00 +02:00
Gris Ge
9958510f28
bond: add support of queue_id of bond port
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
2021-08-26 23:04:31 +02:00
Thomas Haller
ea49b50651
all: add some README.md files describing the purpose of our sources 2021-08-19 17:51:11 +02:00
Thomas Haller
3f6365f5d0
all: use G_CALLBACK() macro instead of plain cast 2021-08-05 14:59:11 +02:00
Thomas Haller
593cb57eb6
all: rename nm_utils_strdict_*() to nm_strdict_*() 2021-08-02 09:26:48 +02:00
Thomas Haller
4ac66a4215
all: rename nm_utils_strdup_reset*() to nm_strdup_reset*() 2021-08-02 09:26:47 +02:00
Thomas Haller
4c3aac899e
all: unify and rename strv helper API
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.
2021-07-29 10:26:50 +02:00
Thomas Haller
3775f4395a
all: drop unnecessary casts from nm_utils_strv_find_first()
And, where the argument is a GPtrArray, use
nm_strv_ptrarray_find_first() instead.
2021-07-29 09:33:50 +02:00
Thomas Haller
fb3e6cb0dc
libnm: use nm_ascii_is_ctrl_or_del() in nm_utils_fixup_product_string() to preserve UTF-8
On architectures where "char" is signed, the check "ch < ' '" is also
TRUE for characters greater than 127 (that is, UTF-8 characters).

Let's preserve valid UTF-8 characters and don't clear them.

Also note that already before we filtered out invalid UTF-8 sequences,
so if we encounter here a character > 127, it is part of a valid UTF-8
sequence.
2021-07-19 09:04:49 +02:00
Thomas Haller
17bdd3a40d
libnm: fix clearing parentheses in nm_utils_fixup_product_string()
Previously, once in_parent was TRUE it was never reset, thus the
remainder of the string was cleared. That was most likely not intended.

If the intent really was to clear all the remainder, then the code could
have simply truncated the string at the first '('.
2021-07-19 09:04:49 +02:00
Thomas Haller
c2e46b7786
libnm: fix documentation for nm_device_wifi_get_last_scan() 2021-07-12 09:39:55 +02:00
Thomas Haller
4e109bacab
clang-format: use "IndentPPDirectives:None" instead of "BeforeHash"
Subjectively, I think this looks better.
2021-07-09 08:49:06 +02:00
Thomas Haller
94a5ae58ae
cli: drop duplicate dot in error message
$ nmcli connection add type dummy con-name x autoconnect no ipv4.method disabled ipv6.method disabled ifname d0
  $ ip link add d1 type dummy
  $ nmcli connection up x ifname d1
  Error: device 'd1' not compatible with connection 'x': The interface names of the device and the connection didn't match..
2021-07-08 17:20:16 +02:00
Beniamino Galvani
bb9c72a543 libnm: adjust symbol version after backporting ipvx.required-timeout to 1.32.4
libnm symbol 'nm_setting_ip_config_get_required_timeout' was
backported to branch 1.32 in commit 08ce20481c ('all: add a new
ipv{4,6}.required-timeout property') in anticipation of 1.32.4. Add
the same symbol version so that an application linked against 1.32.4
also works with 1.34.0. We don't need a duplicate symbol version
because 1.34 is not yet released.
2021-07-05 21:18:35 +02:00
Beniamino Galvani
cb5960cef7 all: add a new ipv{4,6}.required-timeout property
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.
2021-07-05 15:15:44 +02:00
Thomas Haller
114228f8b2
libnm: add NM_OBJECT_CLIENT property
We have nm_object_get_client() property that returns a reference
to the NMClient instance. This is actually useful, because if
the function returns %NULL, it means that the object was removed
from the cache.

On the other hand, the user cannot subscribe to notifications when this
happens. Well, there are otherwise pointless signals like
NM_CLIENT_DEVICE_REMOVED, which we wouldn't need if we had a general
mechanism for NMObject instances.

Add a GObject property "client", which is just that mechanism.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/902
2021-06-23 14:55:05 +02:00
Thomas Haller
06296f7c3c
libnm: belatedly export nm_ip_routing_rule_[gs]et_uid_range() symbols 2021-06-21 10:00:20 +02:00
Thomas Haller
05f2a0b024
libnm: expose nm_ip_address_dup(), nm_ip_route_dup() API in libnm
This fixes commit 21c8a6b20e ('libnm-core, all: merge IPv4 and IPv6
address/route types'), which introduced this API but didn't export it
in the library. In practice this API is thus only usable since 1.32.0.
2021-06-15 19:11:57 +02:00
Thomas Haller
ddd6587a6f
libnm: assert initialization in _NM_OBJECT_CLASS_INIT_FIELD_INFO()
_NM_OBJECT_CLASS_INIT_FIELD_INFO() is a bit odd, because it defines a
static variable and initialized it at the moment when being "called".
This is in fact correct, because this code only gets called from inside
the _class_init() function, which is executed at most once.

Add an assertion to ensure that the static variables is not yet
initialized.
2021-06-07 17:33:02 +02:00
Thomas Haller
5d50e7d78d
Revert "libnm: introduce the new get_ports() in bridge/bond API"
Let's instead add a generic nm_device_get_ports() function.
Also, only adding new API is maybe not sufficient. We should
at the same time deprecate and alias the D-Bus API, like was done
for commit 067a3d6c08 ('nm-device: expose via D-Bus the 'hw-address'
property').

This reverts commit 754143f4e8.
2021-06-02 12:05:26 +02:00
Fernando Fernandez Mancera
754143f4e8
libnm: introduce the new get_ports() in bridge/bond API
This patch is introducing get_ports() in bridge and bond API. In
addition, the existing get_slaves() functions are being marked as
deprecated.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/878
2021-06-02 09:20:29 +02:00
Thomas Haller
bbe39ed095
libnm: use cleanup attribute in NMVpnPluginOld's _connect_generic() 2021-05-26 15:45:59 +02:00
Thomas Haller
e56f126071
libnm: fix error handling in NMVpnPluginOld's _connect_generic()
Also Coverity found that something is wrong here:

   Error: FORWARD_NULL (CWE-476): [#def361]
   NetworkManager-1.31.5/src/libnm-client-impl/nm-vpn-plugin-old.c:441: var_compare_op: Comparing "connection" to null implies that "connection" might be null.
   NetworkManager-1.31.5/src/libnm-client-impl/nm-vpn-plugin-old.c:489: var_deref_model: Passing null pointer "connection" to "g_object_unref", which dereferences it.
   #  487|       }
   #  488|
   #  489|->     g_object_unref(connection);
   #  490|   }
   #  491|

Fixes: 6793a32a8c ('libnm: port to GDBus')
2021-05-26 15:45:59 +02:00
Thomas Haller
f305a411cf
libnm: abort read in nm_vpn_service_plugin_read_vpn_details() on '\0'
We expect to read NUL terminated strings. Upon NUL, we should do
something. Assume this is EOF.
2021-05-26 15:45:58 +02:00
Thomas Haller
6bf7908d05
libnm: abort huge read in nm_vpn_service_plugin_read_vpn_details()
There is no need to accept such a huge read. Abort.
2021-05-26 15:45:58 +02:00
Thomas Haller
4a9fcb0fc3
libnm: buffer reads in nm_vpn_service_plugin_read_vpn_details()
It seems very ugly to read one byte at a time. Use a naive buffered
reader, so that we can read multiple bytes at a time, and return them
one by one.

Also, this now keeps state of any error/EOF. Once we reach EOF, we won't
read again. The previous code did that too, but I think this code is
easier to read.
2021-05-26 15:45:58 +02:00
Thomas Haller
1338a2ef96
libnm: avoid sleep in nm_vpn_service_plugin_read_vpn_details()
Polling with sleep() is really ugly. Use poll() instead.
2021-05-26 15:45:58 +02:00
Thomas Haller
ddf1942bfb
libnm: avoid g_warning() in nm_vpn_service_plugin_read_vpn_details()
g_warning() and printing to stdout/stderr are not suitable actions
for a library. If there is something important, find a way to report the
condition to the caller. If it's not important, stay quiet.
2021-05-26 15:45:58 +02:00
Thomas Haller
f0dc95e517
libnm: avoid strcmp in nm_vpn_service_plugin_read_vpn_details() 2021-05-26 15:45:57 +02:00
Thomas Haller
62c1944e7d
libnm: fix logic and double free in nm_vpn_service_plugin_read_vpn_details()
"val" and "key" are now marked as nm_auto. They are freed at the end,
and we should not free them before breaking the loop (at least not,
without also clearing the variables).

Fixes: 02dbba49d6 ('libnm: fix leak in nm_vpn_service_plugin_read_vpn_details()')
2021-05-26 15:45:57 +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
02dbba49d6
libnm: fix leak in nm_vpn_service_plugin_read_vpn_details()
Found by Coverity:

  Error: RESOURCE_LEAK (CWE-772):
  NetworkManager-1.31.3/src/libnm-client-impl/nm-vpn-service-plugin.c:814: alloc_fn: Storage is returned from allocation function "g_string_new".
  NetworkManager-1.31.3/src/libnm-client-impl/nm-vpn-service-plugin.c:814: var_assign: Assigning: "key" = storage returned from "g_string_new(line->str + strlen("DATA_KEY="))".
  NetworkManager-1.31.3/src/libnm-client-impl/nm-vpn-service-plugin.c:815: var_assign: Assigning: "str" = "key".
  NetworkManager-1.31.3/src/libnm-client-impl/nm-vpn-service-plugin.c:855: leaked_storage: Variable "str" going out of scope leaks the storage it points to.
  NetworkManager-1.31.3/src/libnm-client-impl/nm-vpn-service-plugin.c:855: leaked_storage: Variable "key" going out of scope leaks the storage it points to.
  #  853|           NM_SET_OUT(out_secrets, g_steal_pointer(&secrets));
  #  854|       }
  #  855|->     return success;
  #  856|   }
  #  857|

Fixes: 3dfb72b926 ('service-plugin: allow continuations in the auth-dialog protocol')
2021-05-11 13:56:45 +02:00
Wen Liang
86dcb31ab3
build: replace ./tools/generate-docs-nm-property-infos.pl with python script
In order to have more structured settings in man page and make it more
manageable to generate the docbook, it is recommended to use python
script to replace `./tools/generate-docs-nm-property-infos.pl` (this
tool is used to parse the comment section starting with `---nmcli---`,
`---dbus---`, `---keyfile---`, `---ifcfg-rh---`).

Signed-off-by: Wen Liang <liangwen12year@gmail.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/824
2021-05-05 15:28:17 +02:00
Thomas Haller
21321ac736
clang-format: reformat code with clang 12
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).
2021-05-04 13:56:26 +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