Commit graph

15951 commits

Author SHA1 Message Date
Lubomir Rintel
8080aceb0f libnm: actually export a lot of routines that were supposed to be public
Add them to @libnm_1_40_4 as opposed to @libnm_1_42_0 because we now know
this is going to be backported to 1.40.4 first.

(cherry picked from commit 45d9f1c01c)

Compared to version in main branch, the Since tags and
NM_AVAILABLE_IN_* macros indicate the branched version.
2022-11-11 16:49:39 +01:00
Lubomir Rintel
78e94e63b6 libnm: export nm_utils_ip_{address,rout}es_{from,to}_variant
These are present in a public header yet are not properly commented,
versioned or exported.

Export them now. Another option would be to move them to a private
header; but I suspect someone has intended them to be exported at some
point.

Add them to @libnm_1_40_4 as opposed to @libnm_1_42_0 because we now know
this is going to be backported to 1.40.4 first.

(cherry picked from commit d78000d921)

Compared to version in main branch, the Since tags and
NM_AVAILABLE_IN_* macros indicate the branched version.
2022-11-11 16:49:39 +01:00
Lubomir Rintel
af6be92033 libnm/connection: fix a handful of versioning tags
These are marked as being available sooner than they actually appear in
libnm.ver.

(cherry picked from commit c0b2b5e3a8)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
e401307bec libnm: fix a large amount of Since tags
Some comments are malformed, some are missing altogether.

(cherry picked from commit 117a440cd9)

Compared to version in main branch, the Since tags document the
branched version as well.

The backport omits changes to nm_client_wait_shutdown(), since that one
is not yet present in 1.40.
2022-11-11 16:49:39 +01:00
Lubomir Rintel
41306668e3 libnm: drop nm_vpn_plugin_old_set_{,ip6_}config()
Remove the functions from a public header. They were missing from
libnm.ver and thus never actually exported.

There's no point in salvaging them now as the whole NMVpnPluginOld has
been replaced NMVpnServicePlugin and new uses are discouraged.

(cherry picked from commit 1c6b0edb30)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
8fb4da584c libnm: remove nm_device_wpan_get_hw_address()
Remove the function from a public header. It was missing from libnm.ver
and thus never actually exported.

There's no point in salvaging it now as it nm_device_get_hw_address()
exists as a better option.

(cherry picked from commit ecb9a48040)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
ec500391d6 libnm: remove nm_device_6lowpan_get_hw_address()
Remove the function from a public header. It was missing from libnm.ver
and thus never actually exported.

There's no point in salvaging it now as it nm_device_get_hw_address()
exists as a better option.

(cherry picked from commit bd3239cf6c)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
3c1471d9ca libnm: export nm_setting_ip_config_get_dhcp_iaid
The export was left out when the symbol was added; apparently by
accident.

Let's also bump the documented version of when is the symbol supposed to
be available, because it actually wasn't.

Fixes: 56a1a5426a ('all: add ipvX.dhcp-iaid properties')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1447
(cherry picked from commit 941e8b70f8)

Compared to version in main branch, the Since tags and
NM_AVAILABLE_IN_* macros indicate the branched version.

Backport also includes commit c7f6a506ef ('libnm: move
nm_setting_ip_config_get_dhcp_iaid() to @libnm_1_40_4 version node'),
it wouldn't be possible to backport both separately.
2022-11-11 16:49:39 +01:00
Lubomir Rintel
310b5c66bb libnm: add NM_VERSION_1_40_4 2022-11-11 16:49:39 +01:00
Thomas Haller
f0203ba8ac nm-setting: fix static assertions for NM_SETTING_PARAM_* flags and numeric values
- the static assertions were wrong, there was a "," instead of "==".

- the numeric values were wrong, as shown by the static assertions.

- move the code comment to the implementation. This does not seem
  relevant for the library user and should not be in the public header.

Fixes: 08e845f651 ('nm-setting: mangle public constant to make g-ir-scanner happy')
(cherry picked from commit c884d4d347)
2022-11-11 16:49:39 +01:00
Lubomir Rintel
bf9a1bedb8 nm-setting: mangle public constant to make g-ir-scanner happy
Some versions of g-ir-scanner's C parser silently coerce unrecognized
symbols into zeroes [1]. Let's avoid that so that we don't end up with
wrong constants in our Gir data.

[1] https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/366

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1446
(cherry picked from commit 08e845f651)
2022-11-11 16:49:39 +01:00
Thomas Haller
ee6bf84559
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.

(cherry picked from commit c593834842)
2022-11-10 13:49:30 +01:00
Thomas Haller
40564c5d6a
ifcfg-rh: fix persisting all-default NMSettingEthtool with autoneg/wol flags
Fixes: 26ed9e6714 ('ifcfg-rh: fix persisting all-default NMSettingEthtool settings')
(cherry picked from commit 4303d33727)
2022-11-10 13:49:30 +01:00
Thomas Haller
553e037220
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')
(cherry picked from commit 21661c6f71)
2022-11-10 13:49:29 +01:00
Thomas Haller
3b3ed9f1cc
ifcfg-rh/tests: add test checking persisting ethtool settings to ifcfg-rh
There are still various failures. That will be fixed next.

(cherry picked from commit 3755e6b175)
2022-11-10 13:49:29 +01:00
Thomas Haller
a14aa08a43
ethtool: add and use nm_ethtool_id_get_variant_type() helper
(cherry picked from commit a0370e0efa)
2022-11-10 13:49:17 +01:00
Ratchanan Srirattanamet
a8813ff6fe
wwan/ofono: fix memory leak in handle_settings()
[thaller@redhat.com: modified original patch.]

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
(cherry picked from commit 61e99ed715)
2022-11-10 09:16:13 +01:00
Thomas Haller
0797b26846
platform: fix nmp_object_copy(id_only) for object that don't implement cmd_plobj_id_copy()
The if-else-if was wrong. It meant that if an object did not implement
cmd_plobj_id_copy(), nothign was copied (for id-only).

I think this code path was not actually hit, because we never clone
an object only by ID.

Fixes: c91a4617a1 ('nmp-object: allow missing implementations for certain virtual functions')
(cherry picked from commit ee34eeafb9)
2022-11-10 08:05:13 +01:00
Lubomir Rintel
a18ec9df72
client: add_and_activate*() allow NULL device
Fix up the doc comment so that the gir data gets that right.

Fixes: 90d0ae0faf ('libnm: implement nm_client_activate_connection()/nm_client_add_and_activate_connection*() by using GDBusConnection directly')
(cherry picked from commit a0373a72db)
2022-11-10 08:02:38 +01:00
Beniamino Galvani
3fd8116646 std-aux: fix NM_LIKELY()/NM_UNLIKELY() macros
Fix this compile error when "defined(__GNUC__) && (__GNUC__ > 2) &&
defined(__OPTIMIZE__)" doesn't match:

  In file included from ../src/libnm-std-aux/nm-default-std.h:102,
                   from ../src/libnm-std-aux/nm-std-utils.c:3:
  ../src/libnm-std-aux/nm-std-aux.h: In function ‘NM_ALIGN_TO’:
  ../src/libnm-std-aux/nm-std-aux.h:160:6: error: expected expression before ‘{’ token
    160 |     ({                                 \
        |      ^
  ../src/libnm-std-aux/nm-std-aux.h:169:31: note: in expansion of macro ‘_NM_BOOLEAN_EXPR_IMPL’
    169 | #define NM_BOOLEAN_EXPR(expr) _NM_BOOLEAN_EXPR_IMPL(NM_UNIQ, expr)
        |                               ^~~~~~~~~~~~~~~~~~~~~
  ../src/libnm-std-aux/nm-std-aux.h:175:27: note: in expansion of macro ‘NM_BOOLEAN_EXPR’
    175 | #define NM_LIKELY(expr)   NM_BOOLEAN_EXPR(expr)
        |                           ^~~~~~~~~~~~~~~
  ../src/libnm-std-aux/nm-std-aux.h:238:19: note: in expansion of macro ‘NM_LIKELY’
    238 |         } else if NM_LIKELY (cond) {                                  \
        |                   ^~~~~~~~~
  ../src/libnm-std-aux/nm-std-aux.h:449:5: note: in expansion of macro ‘nm_assert’
    449 |     nm_assert(nm_utils_is_power_of_two(ali));
        |     ^~~~~~~~~

Fixes: 030d68aef7 ('shared: add nm_assert() to "nm-std-aux.h"')
(cherry picked from commit 8bd72d5f2e)
2022-11-04 09:19:08 +01:00
Thomas Haller
de7696789e
tests: add tests for generating stable UUIDs for keyfile/initrd
(cherry picked from commit dc26e65928)
2022-11-03 21:05:36 +01:00
Thomas Haller
6de49febc3
initrd/tests: add unit test for autoconnect-priority setting
Fixes: 98575bd513 ('initrd: generate initrd generator profiles with autoconnect-priority -100')
(cherry picked from commit 28ab535617)
2022-11-03 20:55:15 +01:00
Thomas Haller
9c5d413f3f
build/meson fix "gen-metadata-nm-settings-nmcli.xml.in" without enable_docs
Fixes: ab8fdb73e6 ('build: commit pre-generated "generate-docs-nm-settings-nmcli.xml" to git')
(cherry picked from commit 489f65bf9c)
2022-11-03 20:54:47 +01:00
Beniamino Galvani
7a73431608
core: fix setting IPv6 retrans timer
Fixes: 5c48c5d5d6 ('l3cfg: set IPv6 sysctls during NML3Cfg commit')
(cherry picked from commit 50b6f3d6d3)
2022-11-03 20:54:12 +01:00
Michael Catanzaro
1ebef6cabf
core: don't restrict DNS interface when performing connectivity check
Currently, when performing DNS resolution with systemd-resolved,
NetworkManager tells systemd-resolved to consider only DNS configuration
for the network interface that the connectivity check request will be
routed through. But this is not correct because DNS and routing are
configured entirely separately. For example, say we have a VPN that
receives all DNS but only a subset of routing. NetworkManager will
configure systemd-resolved with no DNS servers on any interface except
for the VPN interface, but will still route traffic through other
interfaces. This is entirely legitimate and works fine in practice,
except for the connectivity check.

To fix this, we just drop the restriction and allow systemd-resolved to
consider its full configuration, which is what gets used normally
anyway. This allows our connectivity check to match the real
configuration instead of failing spuriously.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1107

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1415
(cherry picked from commit e6dac4f0b6)
2022-10-19 21:03:58 +02:00
Beniamino Galvani
30b6c75e74 nmcli: fix crash in "nmcli device monitor"
Fix the following crash:

  $ nmcli device monitor a
  Error: Device 'a' not found.
  Segmentation fault (core dumped)

Found by coverity:

  1. NetworkManager-1.41.3/src/nmcli/devices.c:0: scope_hint: In function 'do_devices_monitor'
  2. NetworkManager-1.41.3/src/nmcli/devices.c:2932:28: warning[-Wanalyzer-null-dereference]: dereference of NULL 'devices'
     2930|       }
     2931|
     2932|->     for (i = 0; i < devices->len; i++)
     2933|           device_watch(nmc, g_ptr_array_index(devices, i));
     2934|

Fixes: 2074b28976 ('nmcli/devices: return GPtrArray instead of GSList from get_device_list()')
(cherry picked from commit 40897db056)
2022-10-19 16:13:41 +02:00
Beniamino Galvani
f9db4f4604 Revert "device: restart DHCP when the MAC changes"
The commit causes problems with bridges. When a new port is attached
the MAC of the bridge possibly changes and if we restart DHCP the
bridge will get a different IP address.

Revert the change until a better solution to the original problem is
found.

This reverts commit 905adabdba.

https://bugzilla.redhat.com/show_bug.cgi?id=2124443
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1401
(cherry picked from commit 9819738607)
2022-10-19 14:01:00 +02:00
Fernando Fernandez Mancera
310e0d259f policy: track the autoconnect retries in devices for multi-connect
For connections with multi-connect property set to "multiple", the
autoconnect-retries should be tracked per device and not per connection.
That means, if autoconnect-retries is set to 2, each device using that
connection should retry to autoconnect 2 times.

The device autoconnect retries is -2 by default. This is a special
value, in NMPolicy context, if the connection used is multi-connect the
device value will be set to match the connection retries. Each time the
device picks a different connection, it will reset the device
autoconnect retries to -2 and if needed, sync. with the connection
retries.

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

https://bugzilla.redhat.com/show_bug.cgi?id=2039734
(cherry picked from commit 1656d82045)
2022-10-17 16:28:19 +02:00
Thomas Haller
64f6c0ae31 initrd: generate initrd generator profiles with autoconnect-priority -100
... and profiles from firmware with autoconnect-priority -200.

In general, after switch root we remember the still activated profile in
/run, and NetworkManager would take over the device with the same
profile as before. In that case, autoconnect and autoconnect-priority
doesn't matter.

Autoconnect only matters when having a device in disconnected state and
not being blocked from autoconnect. For example, if you unplug and
replug the cable. In that case, it does make sense to me that
user-provided profiles from real-root are preferred.

To me the reasons for this change is not very strong (but neither are
the reasons against it). Read the discussion on rhbz #2089707.

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

Co-authored-by: Lubomir Rintel <lkundrak@v3.sk>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1376
(cherry picked from commit 98575bd513)
2022-10-17 16:26:01 +02:00
Beniamino Galvani
a0cd931bef platform: set custom netlink buffer size when adding SR-IOV VFs
When there are many VFs the default buffer size of 1 memory page is
not enough. Each VF can take up to ~120 bytes and so when the page
size is 4KiB at most ~34 VFs can be added.

Specify the buffer size when allocating the message.

(cherry picked from commit f7ac887502)
2022-10-17 10:32:52 +02:00
Beniamino Galvani
88d9836a67 platform: add length argument to _nl_msg_new_link_full()
Add a new argument to specify the netlink buffer length.

(cherry picked from commit a4767ad771)
2022-10-17 10:32:52 +02:00
Beniamino Galvani
a228e06d99 platform: change nlmsg_alloc*() functions
Add a len argument to nlmsg_alloc() and nlmsg_alloc_simple(). After
that, nlmsg_alloc_size() can be dropped. Also, rename
nlmsg_alloc_simple() to nlmsg_alloc_new().

(cherry picked from commit f12d96f0fa)
2022-10-17 10:32:52 +02:00
Beniamino Galvani
f702be2992 ovs: wait that links disappear during initial cleanup
At startup, we remove from ovsdb any existing interface created by NM
and later an interface with the same name might be readded. This can
cause race conditions. Consider this series of events:

1. at startup NM removes the entry from ovsdb;
2. ovsdb reports success;
3. NM inserts an interface with the same name again;
4. ovs-vswitch monitors ovsdb changes, and gets events for removal and
   insertion. Depending on how those events are split in different
   batches, it might decide:
   4a. to delete the link and add it back, or
   4b. to keep the existing link because the delete and insertion
       cancel out each other.

When NM sees the link staying in platform, it doesn't know if it's
because of 4b or because 4a will happen eventually.

To avoid this ambiguity, after ovsdb reports the successful deletion
NM should also wait that the link disappears from platform.

Unfortunately, this means that ovsdb gets a dependency to the platform
code.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1386
(cherry picked from commit 4f60fe293c)
2022-10-14 11:25:59 +02:00
Beniamino Galvani
1673e3f051 core: wait for carrier before resolving hostname via DNS
If there is no carrier on a device, don't try to resolve the hostname
on it. Instead, subscribe to carrier change notifications and retry
again once carrier goes up.

https://bugzilla.redhat.com/show_bug.cgi?id=2118817
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1402
(cherry picked from commit e3cf5083fb)
2022-10-14 11:20:45 +02:00
Beniamino Galvani
db4c55c8d3 dns: sort the ip-data list when a new element is added
In nm_dns_manager_set_ip_config() we try to avoid calling update_dns()
unless something changes, because updating DNS is expensive and can
trigger other actions such as a new hostname resolution.

When we add a new ip_data, even if the new element is equivalent to
the old one that was removed, we need to sort the list again.

Fixes: ce0a36d20f ('dns: better track l3cd changes')
https://bugzilla.redhat.com/show_bug.cgi?id=2098574
(cherry picked from commit 3cc7801779)
2022-10-14 10:46:31 +02:00
Beniamino Galvani
01b4040a7a dns: add comment explaining the purpose of any_removed
(cherry picked from commit 4d1ecd8d6d)
2022-10-14 10:46:31 +02:00
Beniamino Galvani
324838bee1 dhcp: implement decline on IPv6 DAD failure with dhclient
The dhclient plugin already supports sending a decline when IPv4 ACD
fails. Also implement support for IPv6 DAD.

See-also: 156d84217c ("dhcp/dhclient: implement accept/decline (ACD) for dhclient plugin")
(cherry picked from commit e4aefbc556)
2022-10-11 21:51:27 +02:00
Beniamino Galvani
b671c36189 dhcp: decline IPv6 lease if all adresses fail DAD
Currently we accept the DHCPv6 just after addresses are configured on
kernel, without waiting DAD result. Instead, wait that DAD completes
and decline the lease if all addresses are detected as duplicate.

Note that when an address has non-infinite lifetime and fails DAD,
kernel removes it automatically. With iproute2 we see something like:

602: testX6    inet6 2620:🔢5678/128 scope global tentative dynamic noprefixroute
       valid_lft 7500sec preferred_lft 7200sec
Deleted 602: testX6    inet6 2620:🔢5678/128 scope global dadfailed tentative dynamic noprefixroute
       valid_lft 7500sec preferred_lft 7200sec

Since the address gets removed from the platform cache, at the moment
we don't have a way to check the flags of the removal
message. Therefore, we assume that any address that goes away in
tentative state was detected as duplicate.

https://bugzilla.redhat.com/show_bug.cgi?id=2096386
(cherry picked from commit a7eb77260a)
2022-10-11 21:51:27 +02:00
Thomas Haller
0db1c68a36
device: fix hanging port devices when controller goes down while port is not fully attached
This partly reverts 1fe8166fc9 ('device: only deactivate when the master
we've enslaved to goes away').

If the controller fails while the port is not yet fully attached,
before this patch the following happened:

  <info>  [1664299566.1065] device (bond0): state change: ip-config -> failed (reason 'config-failed', sys-iface-state: 'managed')
  ...
  <warn>  [1664299566.1073] device (bond0): Activation: failed for connection 'bond0'
  <trace> [1664299566.1073] device[6b76ac7314eb0b53] (bond0): master: release one slave a9f10ea824bb1725/eth1 (not enslaved) (configure)
  <debug> [1664299566.1073] device[a9f10ea824bb1725] (eth1): unmanaged: flags set to [!sleeping,!by-type,!platform-init,!user-explicit,!user-settings,!user-conf=0x0/0x179/managed], forget [is-slave=0x800], reason removed)
  ...
  <info>  [1664299566.1080] device (eth1): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')

Note that now eth1 has no controller, but it lingers in "ip-config" state indefinitely.

If we look at a case where the port is already attached we see:

  <info>  [1664299540.9661] device (bond0): state change: secondaries -> failed (reason 'config-failed', sys-iface-state: 'managed')
  ...
  <warn>  [1664299540.9667] device (bond0): Activation: failed for connection 'bond0'
  <trace> [1664299540.9667] device[6b76ac7314eb0b53] (bond0): master: release one slave a9f10ea824bb1725/eth1 (enslaved) (configure)
  <debug> [1664299540.9667] platform: (eth1) link: releasing 10 from master 'bond0' (80)
  ...
  <info>  [1664299540.9740] device (bond0): detached bond port eth1
  ...
  <debug> [1664299540.9749] device[a9f10ea824bb1725] (eth1): Activation: connection 'eth1' master failed
  ...
  <warn>  [1664299540.9749] device (eth1): queue-state[secondaries, reason:none, id:520]: replace previously queued state change
  ...
  <debug> [1664299540.9750] device[a9f10ea824bb1725] (eth1): queue-state[deactivating, reason:dependency-failed, id:533]: queue state change
  <debug> [1664299540.9751] device[a9f10ea824bb1725] (eth1): unmanaged: flags set to [!sleeping,!by-type,!platform-init,!user-explicit,!user-settings,!user-conf=0x0/0x179/managed], forget [is-slave=0x800], reason removed)
  ...
  <debug> [1664299541.0201] device[a9f10ea824bb1725] (eth1): enslaved to unknown device 0 (??)
  ...
  <debug> [1664299541.0227] device[a9f10ea824bb1725] (eth1): queue-state[deactivating, reason:dependency-failed, id:533]: change state
  <info>  [1664299541.0228] device (eth1): state change: ip-check -> deactivating (reason 'dependency-failed', sys-iface-state: 'managed')

Fix that by not ignoring the nm_device_slave_notify_release() call. Now we get:

  <info>  [1664391684.9757] device (bond0): state change: ip-config -> failed (reason 'config-failed', sys-iface-state: 'managed')
  ...
  <debug> [1664391684.9759] active-connection[69c2b12d61f5b171]: set state deactivated (was activating)
  <debug> [1664391684.9760] active-connection[142bb8240f6a696d]: check-master-ready: already signalled (state activating, master 0x56116f1480a0 is in state deactivated)
  ...
  <debug> [1664391684.9762] manager: ActivatingConnection now (none)
  ...
  <warn>  [1664391684.9763] device (bond0): Activation: failed for connection 'bond0'
  <trace> [1664391684.9763] device[142828814dec6e26] (bond0): master: release one slave 720791275fe8a68c/eth1 (not enslaved) (configure)
  <debug> [1664391684.9763] device[720791275fe8a68c] (eth1): Activation: connection 'eth1' master failed
  ...
  <debug> [1664391684.9764] device[720791275fe8a68c] (eth1): queue-state[deactivating, reason:dependency-failed, id:3047]: queue state change
  <debug> [1664391684.9765] device[720791275fe8a68c] (eth1): unmanaged: flags set to [!sleeping,!by-type,!platform-init,!user-explicit,!user-settings,!user-conf=0x0/0x179/managed], forget [is-slave=0x800], reason removed)
  ...
  <debug> [1664391684.9797] device[720791275fe8a68c] (eth1): queue-state[deactivating, reason:dependency-failed, id:3047]: change state
  <info>  [1664391684.9797] device (eth1): state change: config -> deactivating (reason 'dependency-failed', sys-iface-state: 'managed')

Commit 1fe8166fc9 ('device: only deactivate when the master we've
enslaved to goes away') added the "return", but it seems to also add it
in cases where we need to handle this. Restrict the return to cases if
we do "no-config".

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

Fixes: 1fe8166fc9 ('device: only deactivate when the master we've enslaved to goes away')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1406
(cherry picked from commit 2be9c693d9)
2022-10-11 18:10:35 +02:00
Thomas Haller
56a503c879
firewall: introduce helper function for add/flush/delete nft table command
(cherry picked from commit e796a67d6c)
2022-09-29 15:15:40 +02:00
Thomas Haller
d7bc25b3bd
firewall: fail from nm_firewall_nft_call() on non-zero exit code
(cherry picked from commit 02feefb1df)
2022-09-29 15:15:40 +02:00
Thomas Haller
6af0233a21
device: allow resetting the devip state via nm_device_devip_set_state()
There is no reason to disallow resetting the state.

(cherry picked from commit 607a9544cb)
2022-09-29 15:15:39 +02:00
Thomas Haller
f4126a12cd
glib-aux: add NM_UTILS_ERROR_COMMAND_FAILED error code
(cherry picked from commit a5f125f8cb)
2022-09-29 15:15:39 +02:00
Thomas Haller
431c219ad1
glib-aux: add nm_utils_get_process_exit_status_desc_buf() helper
(cherry picked from commit 95e6ebec66)
2022-09-29 15:15:39 +02:00
Thomas Haller
46e3c23d85
bond: use _nm_setting_bond_opt_value_as_intbool() in _platform_lnk_bond_init_from_setting()
Previously, we used _nm_utils_ascii_str_to_bool(). That can accept any
kind of input (like "true"), so one might think that this is better to
use on user-input. However, NMSettingBond already validates the these
options are integers (either "0" or "1"). So a value like "true"
could never be here.

Use _nm_setting_bond_opt_value_as_intbool() because that asserts that
the option if of the expected type (integer).

(cherry picked from commit b1a72d0f21)
2022-09-29 14:14:42 +02:00
Thomas Haller
bb0fb83694
bond: make _platform_lnk_bond_init_from_setting() more readable via a macro
Use macros to make the code shorter and easier to read.

(cherry picked from commit b7c56c3ae1)
2022-09-29 14:14:42 +02:00
Thomas Haller
1ae5af9898
bond: add _nm_setting_bond_opt_value_as_intbool() helper
Bond option values are just strings, however, some of them get
validated to be numbers, etc.

We also have effectively boolean values, like "use-carrier". Internally,
this is not validates as a boolean (_nm_utils_ascii_str_to_bool()) but
instead is an integer of either "0" or "1".

Add a helper function_nm_setting_bond_opt_value_as_intbool() to access
and parse such values.

(cherry picked from commit 489a1b8f1e)
2022-09-29 14:14:41 +02:00
Thomas Haller
45382be34d
bond: assert integer range in _nm_setting_bond_opt_value_as_u{8,16,32}()
The bond setting does some minimal validation of the options.
At least for those number typed values, it validates that the
string can be interpreted as a number and is within a certain range.

Add nm_assert() checks to our opt_value_u$SIZE() functions, that the
requested option is validated to be in a range which is sufficiently
narrow to be converted to the requested type. If that were not the case,
we would need some special handling (or question whether the option should
be retrieved as this type).

(cherry picked from commit a19458e11d)
2022-09-29 14:14:41 +02:00
Thomas Haller
8139b27584
firewall: move logging stdin argument to nft call
(cherry picked from commit b74e2cbfaa)
2022-09-29 13:51:58 +02:00
Thomas Haller
07c519c37f
firewall: expose nm_firewall_nft_call() in header file
(cherry picked from commit cfeecbedff)
2022-09-29 13:51:57 +02:00