Commit graph

16269 commits

Author SHA1 Message Date
Thomas Haller
bdeaf0ebb0
c-siphash: re-import git-subtree for 'src/c-siphash'
git subtree pull --prefix src/c-siphash git@github.com:c-util/c-siphash.git main --squash
2022-11-23 18:00:33 +01:00
Thomas Haller
571ba5a824 Squashed 'src/c-siphash/' changes from 04187aa367ee..4a8b5f42f0be
4a8b5f42f0be c-siphash: support SipHash variants other than SipHash24
60dd3c423a13 build: update AUTHORS
be0cd29ad7c9 c-siphash: fix typo
ad372ccd75f1 build: use module-definition files with MSVC
8ae0b4ca1a0c c-siphash: avoid empty initializers
fd2ae696dab3 ci: enable macos+windows builds

git-subtree-dir: src/c-siphash
git-subtree-split: 4a8b5f42f0be0248d2f1ebc19c5d053c9862f823
2022-11-23 18:00:33 +01:00
Thomas Haller
3ab5642d24
c-rbtree: re-import git-subtree for 'src/c-rbtree'
git subtree pull --prefix src/c-rbtree git@github.com:c-util/c-rbtree.git main --squash
2022-11-23 18:00:31 +01:00
Thomas Haller
25a5bb49a6 Squashed 'src/c-rbtree/' changes from edec411b3c1c..a4144785ab77
a4144785ab77 docs: include ./src in include path
efd6619234cd docs: use c-apidocs glob

git-subtree-dir: src/c-rbtree
git-subtree-split: a4144785ab77ecc0627898c7c60523b2368c6ecb
2022-11-23 18:00:31 +01:00
Thomas Haller
2afadee27f
platform: workaround build error in nm_platform_ip4_route_hash_update() with old clang
clang-3.4.2-9.el7 does not like nesting NM_MAX() macro inside nm_hash_update_vals() macro.
Workaround by using MAX() instead. NM_MAX() uses an expression statement and NM_UNIQ()
to evaluate the arguments only once. We don't need that here and glib's MAX() suffices.

    CC       src/libnm-platform/src_libnm_platform_libnm_platform_la-nm-platform.lo
  ../src/libnm-platform/nm-platform.c:8247:53: error: in-class initializer for static data member is not a constant expression
                                      (guint8) NM_MAX(obj->weight, 1u));
                                                      ^
  ../src/libnm-std-aux/nm-std-aux.h:399:40: note: expanded from macro 'NM_MAX'
  #define NM_MAX(a, b) __NM_MAX(NM_UNIQ, a, NM_UNIQ, b)
                                         ^
  ../src/libnm-std-aux/nm-std-aux.h:402:39: note: expanded from macro '__NM_MAX'
          typeof(a) NM_UNIQ_T(A, aq) = (a);                                              \
                                        ^
  ../src/libnm-glib-aux/nm-hash-utils.h:124:36: note: expanded from macro 'nm_hash_update_vals'
          NM_HASH_COMBINE_VALS(_val, __VA_ARGS__);      \
                                     ^

Fixes: 8cc41d41fe ('platform: add NM_PLATFORM_IP_ROUTE_CMP_TYPE_ECMP_ID for comparing ECMP base route')
2022-11-23 16:28:34 +01:00
Thomas Haller
3fb8c0f614
clang-format: reformat code with clang-format 15.0.4-1.fc37
This is the version shipped in Fedora 37. As Fedora 37 is now out, the
core developers switch to it. Our gitlab-ci will also use that as base
image for the check-{patch.tree} tests and to generate the pages. There
is a need that everybody agrees on which clang-format version to use,
and that version should be the one of the currently used Fedora release.

Also update the used Fedora image in "contrib/scripts/nm-code-format-container.sh"
script.

The gitlab-ci still needs update in the following commit. The change
in isolation will break the "check-tree" test.
2022-11-23 09:17:21 +01:00
Thomas Haller
48d7d1d78e
platform: drop inline cmp() wrappers around "full" versions
We sometimes have functions foo() and foo_full(), in which case
foo() has fewer arguments and just calls foo_full(). The "full"
function here is the more powerful one, and foo() is implemented
in terms of the former.

nm_platform_ip4_route_cmp_full() and m_platform_ip4_route_cmp() inverted
that pattern. The "_full" there stands for the full comparison, to not
allowing to select the comparison type.

That inconsistency is ugly. Also, these wrappers were used at only few
places. Let's drop them.

While at it, also drop nm_platform_qdisc_cmp() and rename
nm_platform_qdisc_cmp_full(). Here cmp()/cmp_full() followed the common
pattern foo()/foo_full(), but it's still hardly used and unnecessary.
2022-11-21 17:56:48 +01:00
Thomas Haller
8cc41d41fe platform: add NM_PLATFORM_IP_ROUTE_CMP_TYPE_ECMP_ID for comparing ECMP base route 2022-11-21 17:46:34 +01:00
Thomas Haller
9270bf611f platform: add nm_platform_ip4_route_hash() helper 2022-11-21 11:19:39 +01:00
Fernando Fernandez Mancera
151b2bed36 platform: pass extra_hops to ip_route_add function
When adding a new route we need to consider it contains extra nexthops
i.e it is a ECMP route. As we cannot modify the NMPObject once created,
we need to pass the extra nexthops as an argument.

We cannot use the original NMPObject because normalization is happening
during when adding the route.
2022-11-21 11:19:19 +01:00
Fernando Fernandez Mancera
1bbdecf5e1 platform: manage ECMP routes
When reading from netlink an ECMP IPv4 route, we need to parse the
multiple nexthops. In order to do that, we are introducing
NMPlatformIP4RtNextHop struct.

The first nexthop information will be kept at the original
NMPlatformIP4Route and the new property n_nexthops will indicate how
many nexthops we need to consider.
2022-11-21 11:18:03 +01:00
Thomas Haller
7f218e6ac5
core/tests: relax timing in "/general/nm_utils_kill_child" test
This test is inherently fragile, as it depends on starting processes,
wait for something and kill the process. There are timings involved
that are out of control of the test. Try to adjust the timing.

  # NetworkManager-DEBUG: <debug> [1668755976.9741] kill child process test-s-4 (111487): sending SIGKILL...
  # NetworkManager-DEBUG: <debug> [1668755976.9753] kill child process test-s-4 (111487): waiting for process to terminate after sending SIGTERM (15) and SIGKILL...
  # NetworkManager-DEBUG: <debug> [1668755976.9758] kill child process test-s-4 (111487): after sending SIGTERM (15) and SIGKILL, process 111487 exited by signal 9 (5759 usec elapsed)
  Bail out! GLib:ERROR:../src/core/tests/test-core-with-expect.c:154:test_nm_utils_kill_child_sync_do: Did not see expected message NetworkManager-DEBUG: *<debug> [*] kill child process test-s-4 (*): waiting up to 1 milliseconds for process to terminate normally after sending SIGTERM (15)...
  Bail out! nm:ERROR:../src/core/tests/test-core-with-expect.c:457:test_nm_utils_kill_child: assertion failed (exit_status == 0): (6 == 0)
  --- stderr ---
  **
  GLib:ERROR:../src/core/tests/test-core-with-expect.c:154:test_nm_utils_kill_child_sync_do: Did not see expected message NetworkManager-DEBUG: *<debug> [*] kill child process test-s-4 (*): waiting up to 1 milliseconds for process to terminate normally after sending SIGTERM (15)...
  **
  nm:ERROR:../src/core/tests/test-core-with-expect.c:457:test_nm_utils_kill_child: assertion failed (exit_status == 0): (6 == 0)
  /builds/NetworkManager/NetworkManager/tools/run-nm-test.sh: line 337: 110662 Aborted                 "${NMTST_DBUS_RUN_SESSION[@]}" "${NMTST_LIBTOOL[@]}" "$NMTST_VALGRIND" --quiet --error-exitcode=$VALGRIND_ERROR --leak-check=full --gen-suppressions=all "${NMTST_SUPPRESSIONS[@]}" --num-callers=100 --log-file="$LOGFILE" "$TEST" "${TEST_ARGV[@]}"
2022-11-18 09:41:49 +01:00
Thomas Haller
a87fd2e4d2
libnm/tests: check assigning same setting in nm_connection_add_setting()
Fixes: 3e3b629586 ('libnm: fix leak with self assignment in nm_connection_add_setting()')
2022-11-17 16:12:54 +01:00
Thomas Haller
5c3b70a1b3
tests/client: increase timeout for nmcli command
Under normal circumstances, the timeout is not supposed to be hit.
I see it hit on gitlab-ci. Was that because the machine was very
busy? It's hard to say whether there was a legitimate problem here,
and more importantly, what that problem was.

Try to increase the timeout. If there is a real problem, we probably
will still hit the timeout.
2022-11-17 13:23:35 +01:00
Thomas Haller
3e3b629586
libnm: fix leak with self assignment in nm_connection_add_setting()
We must consume the reference, like we would in the other case.

Interestingly, I am unable to reproduce a case where valgrind would
complain about the leak. But it is there nonetheless.

Fixes: 0a22f4e490 ('libnm: refactor tracking of NMSetting in NMConnection')
2022-11-16 21:15:09 +01:00
Thomas Haller
3b2eb689f3
libnm: workaround crash in nm_vpn_editor_plugin_import() for plugin requiring GError
The "GError **error" parameter in GLib API should be optional. Due to a
bug in at least nm-vpnc ([1]), this is not the case. Workaround in
libnm.

[1] c7d197477c/properties/nm-vpnc-editor-plugin.c (L281)
2022-11-16 13:05:55 +01:00
Beniamino Galvani
dfe63d9eb3 macsec: document the format of CAK and CKN properties 2022-11-16 10:36:39 +01:00
Beniamino Galvani
df999d1fca macsec: allow CKN shorter than 64 characters
See wpa_supplicant commit [1]:

    macsec: Make pre-shared CKN variable length

    IEEE Std 802.1X-2010, 9.3.1 defines following restrictions for
    CKN:

    "MKA places no restriction on the format of the CKN, save that it
    comprise an integral number of octets, between 1 and 32
    (inclusive), and that all potential members of the CA use the same
    CKN. No further constraints are placed on the CKNs used with PSKs,
    ..."

    Hence do not require a 32 octet long CKN but instead allow a
    shorter CKN to be configured.

    This fixes interoperability with some Aruba switches, that do not
    accept a 32 octet long CKN (only support shorter ones).

[1] https://w1.fi/cgit/hostap/commit/?id=b678ed1efc50e8da4638d962f8eac13312a4048f
2022-11-16 10:36:39 +01:00
Beniamino Galvani
07bc5121a7 device: fix missing transition from UNAVAILABLE to DISCONNECTED
When called with update_carrier=TRUE, nm_device_bring_up_full() checks
for carrier changes and it may queue a transition to DISCONNECTED
through the following call chain:

 -> nm_device_bring_up_full()
   -> nm_device_set_carrier_from_platform()
     -> nm_device_set_carrier()
       -> carrier_changed()
         -> nm_device_queue_state()

In _set_state_full(state=UNAVAILABLE) after bringing the interface up
we also call nm_device_cleanup() which clears the enqueued state
change to DISCONNECTED. When this happens, the device remains in
UNAVAILABLE and never gets activated even if it was ready.

This was observed with macsec interfaces, but in theory can happen
with all those interfaces that get carrier immediately after being
brought up.

Avoid this issue by not checking the carrier synchronously from
_set_state_full(). The carrier change event will be processed in the
next asynchronous invocation of device_link_changed().

https://bugzilla.redhat.com/show_bug.cgi?id=2122564
2022-11-16 10:22:45 +01:00
Beniamino Galvani
9fd9eaf276 device: add "update_carrier" argument to nm_device_bring_up_full()
In some situations we need to avoid updating the carrier status
synchronously from nm_device_bring_up_full(). Add a flag for that.
2022-11-16 10:22:45 +01:00
Beniamino Galvani
861934a510 device: add nm_device_bring_up_full()
In the next commit nm_device_bring_up() will be extended with a new
argument. Most callers just want to bring up the device synchronously
and don't care about the "no_firmware" argument. Introduce a
nm_device_bring_up_full() for callers that need special behavior.
2022-11-16 10:22:44 +01:00
Beniamino Galvani
c4a7d6a06f vpn: honor the ipvX.method connection property
Currently VPNs always apply the configuration sent by the server for
both address families. So, even if users set e.g. ipv6.method=disabled,
they might end up with IPv6 configured.

Change that and apply the automatic configuration only when the method
is "auto".

This is a change in behavior and as such it might be disruptive for
users that had a method different from "auto" and expected to have the
interface configured. However, that scenario seems unlikely and can be
easily fixed by setting the right method.
2022-11-16 10:17:49 +01:00
Beniamino Galvani
b84faaefc9 vpn: remove unused variable 2022-11-16 10:17:49 +01:00
Fernando Fernandez Mancera
82009e21d2 core: set routing rule protocol properly
When creating NMPlatformRoutingRule from NMIPRouteRule object, the
protocol is being set to RTPROT_UNSPEC. According to linux kernel
documentation FRA_PROTOCOL indicates the originator of the rule.

In this case the route rule is coming from a connection and therefore
the originator of the rule is the user. The correct value is
RTPROT_STATIC which means the rule is installed by the administrator.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1457

Fixes: 3f9347745b ('core: add handling of IP routing rules to NMDevice')
2022-11-14 18:28:25 +01:00
Lubomir Rintel
5d851a3c9d merge: branch 'lr/gtk-doc'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1458
2022-11-14 16:18:33 +01:00
Thomas Haller
8942789bb6
glib-aux: use cleanup attribute in dbus_signal_meta_marshal()
and prefer alloca() allocation, for small sizes.
2022-11-14 08:06:34 +01:00
Thomas Haller
093ea4a10a
glib-aux: drop unused _nm_dbus_connection_call_finish()
This wasn't used. It also doesn't make much sense, because
g_dbus_connection_call() accepts a reply type argument. So if you want
to check the reply type, you can do so when making the call.

That differs from g_dbus_proxy_call(), where this might make some sense
and is actually used.

While at it, also drop _nm_dbus_typecheck_response() from the header
file. It seems not general purpose enough and is not necessarily a great
pattern. Because,

- for g_dbus_connection_call() you either specify the reply_type when making
  the call, or you do some more elaborate handling of the result -- not merely
  _nm_dbus_typecheck_response().

- for g_dbus_proxy_call(), you can use _nm_dbus_proxy_call_finish() to
  get it, or again, you want some non-trivial type checking.
2022-11-14 08:05:58 +01:00
Thomas Haller
6c9018a29e
glib-aux: rename _nm_dbus_signal_connect{,_data}() to _nm_dbus_proxy_*()
These are helpers for GDBusProxy. I think we should avoid GDBusProxy where possible,
and these functions too. Give the function a more specific name to show that this
is only for the proxy.
2022-11-14 08:05:47 +01:00
Thomas Haller
cf6d38177f
glib-aux: drop duplicate _nm_dbus_error_has_name() for nm_dbus_error_is() 2022-11-14 08:04:16 +01:00
Thomas Haller
a7fea45adf
libnm: move "nm-dbus-utils.c" from libnm-core to libnm-glib-aux
These are just general purpose D-Bus utils, based on glib and GDBus.
They fit perfectly to libnm-glib-aux. Move the code.

Also, there is already the file "src/core/nm-dbus-utils.c", having two
files with the same name on our source tree is just confusing.
2022-11-14 08:04:06 +01:00
Lubomir Rintel
422c9a4428 libnm/conn-utils: include a documentation string
This makes the index entry look nice.
2022-11-13 23:36:37 +01:00
Lubomir Rintel
07d06c196e libnm: include device-vrf.h in NetworkManager.h
Fixes: commit 667568d1b2 ('core,libnm: add VRF support')
2022-11-13 23:36:37 +01:00
Lubomir Rintel
d4053a83af libnm: move nm-errors.h include away from nm-connection.h
Most users included this by accident, by including nm-connection.h. That
is not too great, becuase stuff it contains is by no means specific to
NMConnection.

Anyways, it's not like it would matter too that. I mainly care about it
being included in NetworkManager.h, so that there's one less special
case in a test that makes sure useful stuff from NetworkManager.h ends up
in gtk-doc (a separate commit).
2022-11-13 23:36:37 +01:00
Lubomir Rintel
b913ccec9c libnm: fix a handful of misformatted gtk-doc blocks
libnm-core-impl/nm-setting-bond.c:1276: warning: Symbol name not found at the start of the comment block.
  libnm-core-impl/nm-setting-vpn.c:1135: warning: Symbol name not found at the start of the comment block.
  libnm-core-impl/nm-setting-vpn.c:1158: warning: Symbol name not found at the start of the comment block.
  libnm-core-impl/nm-setting-wired.c:1560: warning: Symbol name not found at the start of the comment block.
  libnm-client-impl/nm-dhcp-config.c:149: warning: Symbol name not found at the start of the comment block.
  libnm-client-impl/nm-secret-agent-old.c:967: warning: Symbol name not found at the start of the comment block.
  libnm-client-impl/nm-secret-agent-old.c:1010: warning: Symbol name not found at the start of the comment block.
  libnm-client-impl/nm-secret-agent-old.c:1037: warning: Symbol name not found at the start of the comment block.
2022-11-13 23:36:37 +01:00
Lubomir Rintel
c37fbd32ad libnm/bond: fix malformed property doc
libnm-core-impl/nm-setting-bond.c:602: warning: Parameter description
       for nm_setting_bond_validate_option::value (allow-none) is not used
       from source code comment block.
2022-11-13 23:36:37 +01:00
Lubomir Rintel
938c961353 libnm/utils: add some missing deprecation guards
Makes gtk-doc grumpy (but it likes getting grumpy too often for us to
actually pay attention, it seems):

  libnm-core-impl/nm-utils.c:4342: warning: nm_utils_is_uuid is deprecated
      in the inline comments, but no deprecation guards were found around
      the declaration. (See the --deprecated-guards option for gtkdoc-scan.)
  libnm-client-impl/nm-device-ovs-bridge.c:36: warning:
      nm_device_ovs_bridge_get_slaves is deprecated in the inline comments,
      ...
  libnm-client-impl/nm-device-ovs-port.c:36: warning:
      nm_device_ovs_port_get_slaves is deprecated in the inline comments,
      ...
  libnm-client-impl/nm-device-team.c:77: warning:
      nm_device_team_get_slaves is deprecated in the inline comments,
      ...
2022-11-13 23:36:37 +01:00
Lubomir Rintel
612c00529b libnm,docs: ignore NM_DEPRECATED_IN_..._GUARDS
gtk-doc gets confused by these, ignore them:

  common.py:ParseFunctionDeclaration:541:WARNING:Cannot parse args for
      function in "nm_device_get_hw_address) const char
      *nm_device_dummy_get_hw_address(NMDeviceDummy *device
  common.py:ParseFunctionDeclaration:541:WARNING:Cannot parse args for
      function in "nm_device_get_ports) const GPtrArray
      *nm_device_ovs_port_get_slaves(NMDeviceOvsPort *device

For some reason it's still confused if NM_AVAILABLE_* comes first.
I refuse to look into that, just reorder them.
2022-11-13 23:36:37 +01:00
Lubomir Rintel
59ac34976b dns-manager,client: rename struct NMDnsEntry
We got a typedef of the same name, and that causes gtk-doc to generate
invalid docbook and complain aloud:

  ../xml/nm-client.xml:4118: element refsect2: validity error : ID NMDnsEntry already defined
  <refsect2 id="NMDnsEntry" role="typedef" condition="since:1.6">
  Warning: multiple "IDs" for constraint linkend: NMDnsEntry.
2022-11-13 23:36:37 +01:00
Lubomir Rintel
f87bcac297 setting-ethtool: fix malformed doc comments
html/NMSettingEthtool.html:142: warning: no link for: "Returns" -> (<code class="literal">Returns</code>).
2022-11-13 23:36:37 +01:00
Lubomir Rintel
f78af299c5 setting-8021x: fix "PKCS#11" string in gtk-doc
gtk-doc (and perhaps other tools) treat pound sign in comments
specially:

  html/NMSetting8021x.html:1501: warning: no link for: "11" -> (<span class="type">11</span>).
2022-11-13 23:35:56 +01:00
Lubomir Rintel
aaa9a9cd25 libnm/client: don't reset properties when interface goes away
In case the D-Bus interfaces start dropping off (typically all off them go
one by one when the object is being deleted), don't reset all the properties.

In particular, keep most properties around, only tear down "o" and "ao",
so that the object dependencies get torn down, but we still get enough
properties around to identify what the dead object was its heyday.

One example of where this is not good is when the device-removed signal
is emmitted, the device no longer has the ifname:

  $ nmcli monitor
  <quit NetworkManager>
  (null): device removed
  (null): device removed
  ...
2022-11-13 15:25:19 +01:00
Lubomir Rintel
8b3cb0dabf libnm/client/test: test cleanup on service shutdown
Currently we assert that properties are reset on client teardown. That
is not the right thing to do and we're not going to do that in future.

However, what is important to test is that the properties are reset when
the daemon goes away. Test that.
2022-11-13 15:25:16 +01:00
Lubomir Rintel
d3490a92db libnm/client/test: always run the cleanup test
The part where a device was created and its cleanup on client
description was only run randomly.

This is silly and gave me hard time. No reason not to be always running
it.
2022-11-13 15:25:11 +01:00
Lubomir Rintel
253bb3579f tests/client: test nmcli monitor
Some basic tests for nmcli monitor. Note that they now assert against
behavior that I find incorrect. Will be fixed separately.
2022-11-13 15:25:01 +01:00
Lubomir Rintel
fe2eddd67c nmcli/monitor: always print running status on monitor startup
Previously we'd note if NM is stopped, but not if it's running.
I suppose it's nice for the user to know that the monitor started
running, but, it's also important for the monitor to be testable (so
that we know that we are ready to start adding mock objects, etc.)

This also gets rids of some duplication at expense of a little less
nuanced message.
2022-11-13 15:24:19 +01:00
Lubomir Rintel
777f31436c merge: branch 'lr/unbreak-gir'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1451
2022-11-11 16:08:17 +01:00
Thomas Haller
9ecb72ae4b
libnm/trivial: fix style
Fixes: 412a5d2d08 ('libnm: show ethtool options in "gen-metadata-nm-settings-libnm-core.xml"')
2022-11-10 14:41:38 +01:00
Thomas Haller
c593834842
core: filter out invalid Wake-On-Lan flags
NMSettingWired does not reject invalid flags. Filter them out in wake_on_lan_enable().
In practice, it makes no difference, the unknown flags were ignored anyway.
2022-11-10 13:46:35 +01:00
Thomas Haller
4303d33727
ifcfg-rh: fix persisting all-default NMSettingEthtool with autoneg/wol flags
Fixes: 26ed9e6714 ('ifcfg-rh: fix persisting all-default NMSettingEthtool settings')
2022-11-10 13:46:34 +01:00
Thomas Haller
21661c6f71
ifcfg-rh: fix persisting ethtool options
If there were any pause options and any non-pause options,
the created setting was invalid.

I don't think it's reasonably possible to parse the broken settings.
So there is no workaround trying to read the existing broken settings
from disk. Luckily, the broken setting was just silently ignored by
the parser, so you simply could not persist certain settings.

https://bugzilla.redhat.com/show_bug.cgi?id=2134569

Fixes: 652ddca04c ('ethtool: Introducing PAUSE support')
2022-11-10 13:45:43 +01:00