Commit graph

30935 commits

Author SHA1 Message Date
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
925ea8b24c dns: merge branch 'bg/dns-sort'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1427

(cherry picked from commit e03b8fa447)
2022-10-14 10:46:31 +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
fabefd9bd5 dhcp: merge branch 'bg/dhcp6-dad-pt2'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1363
https://bugzilla.redhat.com/show_bug.cgi?id=2096386

(cherry picked from commit 12e5b944f6)
2022-10-11 21:51:27 +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
afe53b902f
doc: fix bind-activation description for AddAndActivateConnection2 D-Bus API
Fixes: eb883e34a5 ('core: Add option to AddAndActivateConnection2 to bind the lifetime')
(cherry picked from commit 88f5e7518a)
2022-10-05 10:48:25 +02:00
Thomas Haller
ecc671d88f
build: merge branch 'th/build-gettext-update-po'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1405

(cherry picked from commit 5713a533f5)
2022-10-03 17:53:37 +02:00
Thomas Haller
c34d3a7c10
build: don't "update-po" during make dist
Instead, hack gettext's Makefile.

gettext has an issue with parallel make. See [1] and [2].
Reproduce with:

  git reset --hard &&
    git clean -fdx &&
    NOCONFIGURE=yes ./autogen.sh &&
    ./configure --enable-gtk-doc --enable-introspection &&
    make -j distcheck V=1

We worked around this by setting "DIST_DEPENDS_ON_UPDATE_PO = yes",
however that (obviously) results in regenerating source files during
dist. "Source files" in the sense that the po files are commited to git
and get distributed in the release. Doing this is very ugly.

In particular it's ugly, because `make -C po update-po` is not reproducible
and the output depends on the current time (*had one job*).
Otherwise, we could just regenerate the files before doing a release.

This means, running "release.sh" script ends up with a dirty tree
afterwards. Also, the distributed po files are not the ones from the source
tree when we did the release. Also, since "release.sh rc1" does two distributions
(once for the rc1 and once for the next devel snapshot), the commit for the
second distribution will have a large diff for the po files.

This reverts commit 978d8eb699 ('po: make dist depend on update-po')
and hacks around the problem.

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1094#note_1435313
[2] https://lists.gnu.org/archive/html/bug-gettext/2022-06/msg00022.html

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1405
(cherry picked from commit 7ee0da3eaf)
2022-10-03 17:53:36 +02:00
Thomas Haller
b03b01adfb
gitlab: fail if "run-test.sh" with dirty working tree
(cherry picked from commit 991481a568)
2022-10-03 17:53:36 +02:00
Thomas Haller
278d32c7e7
core: merge branch 'th/mlag-bonding-slb' (part 2)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1385

(cherry picked from commit c5beec90a8)
2022-09-29 15:15:41 +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
3548033fad
bond: merge branch 'th/bond-opt-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1380

(cherry picked from commit 8a0aa2c8ac)
2022-09-29 14:14:43 +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
234ec6f263
firewall: merge branch 'th/firewall-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1379

(cherry picked from commit a939324a78)
2022-09-29 13:51:59 +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
Thomas Haller
49ae45f838
firewall-utils: move _append() macro to be used by other places
(cherry picked from commit 0a0c197916)
2022-09-29 13:51:57 +02:00
Thomas Haller
558bcd5aae
firewall/trivial: rename nm_firewall_config_apply() to nm_firewall_config_apply_sync()
Sync/blocking methods are ugly. Their name should highlight this.
Also, we may have an async variant, so we will need the "good" name
for apply() and apply_finish().

(cherry picked from commit dc66fb7d04)
2022-09-29 13:51:56 +02:00
Thomas Haller
bbf3d01e82
firewall: more renaming and splitting _fw_nft_set_shared()
Blocking calls are ugly. Rename those to have a "_sync()" suffix.
Also, split from _fw_nft_set_shared() the part that constructs the
stdin for nft.

(cherry picked from commit 7362ad6266)
2022-09-29 13:51:56 +02:00
Thomas Haller
bfb4452f7d
firewall/trivial: rename nm_firewall_config_new() to nm_firewall_config_new_shared()
(cherry picked from commit 7ad3fb1956)
2022-09-29 13:51:55 +02:00
Thomas Haller
6fa0068c1e
firewall/trivial: rename "shared"/"add" argument in firewall utils to "up"
(cherry picked from commit e185f7966d)
2022-09-29 13:51:55 +02:00
Thomas Haller
aed57e8acc
glib-aux: add nm_strv_contains() helper
(cherry picked from commit ee0f3f6242)
2022-09-29 13:38:32 +02:00
Fernando Fernandez Mancera
65d31a11f8 veth: drop iface peer check during create_and_realize()
When fetching the parent device, if the system is slow, NetworkManager
can hit a race condition where the property is still NULL. In that case,
NetworkManager should create the veth link.

Checking that the peer device exists, it is type NM_DEVICE_TYPE_VETH and
it have a parent device is enough to know that we can skip the link
creation.

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

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

Fixes: 4655b7c308 ('veth: fix veth activation on booting')
(cherry picked from commit 07e0ab48d1)
2022-09-29 10:35:12 +02:00
Thomas Haller
7a3de841b8
glib-aux: fix nm_str_buf_finalize() for cloning buffer
NMStrBuf can also contains NUL characters. We thus cannot use g_strndup(),
which uses strncpy() and truncates at the first NUL.

Fixes: 13d25f9d0b ('glib-aux: add support for starting with stack-allocated buffer in NMStrBuf')
(cherry picked from commit 520411623d)
2022-09-29 10:26:37 +02:00
Fernando Fernandez Mancera
178ff4e42a bond: fix arp_all_target option when arp_interval is disabled
The bond option arp_all_target can be set even if arp_interval is
disabled.

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

Fixes: e064eb9d13 ('bond: use netlink to set bond options')
(cherry picked from commit 3871c670ab)
2022-09-27 13:54:11 +02:00
Beniamino Galvani
30366e5b3a
libnm-core: allow empty slave-type with a NMSettingBondPort
It is allowed to have a connection with empty connection.slave-type
and a NMSettingBondPort; the property will be set automatically during
normalization if a master is set, otherwise the setting will be removed.

With this change, it becomes possible to remove a port from a bond
from nmcli, turning it into a non-slave connection. Before, this used
to fail with:

  $ nmcli connection add type ethernet ifname test con-name test+ connection.master bond0 connection.slave-type bond
  $ nmcli connection modify test+ connection.master '' connection.slave-type ''
  Error: Failed to modify connection 'test+': connection.slave-type: A connection with a 'bond-port' setting must have the slave-type set to 'bond'

https://bugzilla.redhat.com/show_bug.cgi?id=2126262
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1382

Fixes: 9958510f28 ('bond: add support of queue_id of bond port')
(cherry picked from commit 23ce9cff99)
2022-09-27 08:23:41 +02:00
Fernando Fernandez Mancera
d23c6040f8
policy: fix disposal of devices list
When disposing NMPolicy all the devices in the devices hash-table should
be unregistered and removed from the hash-table.

Fixes: 7e3d090acb ('policy: refactor tracking of registered devices')
(cherry picked from commit 5a87683b14)
2022-09-27 08:22:07 +02:00
Thomas Haller
c456bfa7c4
platform: fix tracking similar objects in NMPGlobalTracker
NMPGlobalTracker allows to track objects for independent users/callers.
That is, callers that are not aware whether another caller tracks the
same/similar object. It thus groups all objects by their nmp_object_id_equal()
(as `TrackObjData` struct), while keeping a list of each individually tracked
object (as `TrackData` struct which honors the object and the user-tag parameter).

When the same caller (based on the user-tag) tracks the same object again, then
NMPGlobalTracker will only track it once and combine the objects. That is done by
also having a dictionary for the `TrackData` entries (`self->by_data`).

This latter dictionary lookup wrongly considered nmp_object_id_equal().
Instead, it needs to consider all minor differences of the objects, and
use nmp_object_equal().

For example, for NMPlatformMptcpAddress, only the "address" is part of
the ID. Other fields, like the MPTCP flags are not. Imagine a profile is
active with MPTCP endpoints configured with flags "subflow". During reapply,
the user can only update the MPTCP flags (e.g. to "signal"). When that happens,
the caller (NML3Cfg) would track a new NMPlatformMptcpAddress instance, that only
differs by MPTCP flags. In this case, we need to track the new address for the
differences that it has according to nmp_object_equal(), and not
nmp_object_id_equal().

Due to this bug, reapply might not work correctly. For other supported types (routing
rules and routes) this bug may have been harder to reproduce, because most attributes
of rules/routes are also part of the ID and because it's uncommon to reapply a minor
change to a rule/route.

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

Fixes: b8398b9e79 ('platform: add NMPRulesManager for syncing routing rules')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1375
(cherry picked from commit d8aacba3b2)
2022-09-15 18:19:52 +02:00
Wen Liang
c9fe11f91d Merge branch 'wl/ifcfg' into main
https://bugzilla.redhat.com/show_bug.cgi?id=2122703

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

(cherry picked from commit f225344812)
2022-09-14 10:35:45 -04:00
Thomas Haller
533b30e5a2 ifcfg-rh: rework error handling in parse_infiniband_p_key()
(cherry picked from commit 61d74b0c15)
2022-09-14 10:35:45 -04:00
Wen Liang
fe21880c46 ipoib: skip validating the DEVICE when reading the ifcfg file
For the ipoib connection, it is still considered as valid if the
profile does not set the device name. Also, the ifcfg reader should not
duplicate the checks that `nm_connection_verify()` performs (especially
not wrongly). Therefore, NM should skip validating the DEVICE when
reading the ifcfg file for the ipoib connection.

https://bugzilla.redhat.com/show_bug.cgi?id=2122703
(cherry picked from commit 4c32dd9d25)
2022-09-14 10:35:45 -04:00
Wen Liang
33f2f82a09 infiniband: avoid normalizing the p-key when reading from ifcfg
When writing the p-key setting to the ifcfg file and reading the
setting back, the value has to be consistent. This is not limited to
p-key only, any setting value during the ifcfg write and read also has
to be consistent.

This was probably added in commit cb5606cf1c ('ifcfg-rh:
add support for Infiniband partitions') as this is also what
ifup-ib does ([1]). For NetworkManager profiles however, the
p-key is also valid without the high bit set, so the ifcfg-rh
reader must honor that.

[1] 0c9fb6ca7b/rdma.ifup-ib (L75)

(cherry picked from commit a4fe16a426)
2022-09-14 10:35:45 -04:00
Lubomir Rintel
dc2d2da9db
device: don't ignore external slave removals
We've been outright ignoring master-slave checks if the link ended up
without a master since commit 2e22880894 ('device: don't remove the
device from master if its link has no master').

This was done to deal with OpenVSwitch port-interface relationship,
where the interface's platform link lacked an actual master in platform
(what matters there is the OVSDB entry), but the fix was too wide.

Let's limit the special case to devices whose were not enslaved to
masters that lack a platform link, which pretty much happens for
OpenVSwitch only.

Morale: Write better commit messages of future you is going to be upset
Fixes: 2e22880894 ('device: don't remove the device from master if its link has no master')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1358
(cherry picked from commit a1de6810df)
2022-09-13 12:38:19 +02:00
Thomas Haller
7b487e6951
glib-aux: fix spurious semicolon after NM_STR_BUF_INIT() macros
It's wrong, and it breaks certain uses.

Fixes: 13d25f9d0b ('glib-aux: add support for starting with stack-allocated buffer in NMStrBuf')
(cherry picked from commit c5ec4ebd77)
2022-09-13 12:37:34 +02:00
Thomas Haller
35129566f7
bond: merge branch 'ff/bond_primary'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1362

(cherry picked from commit c92fe1bfa0)
2022-09-13 12:28:45 +02:00
Fernando Fernandez Mancera
1ba916915d bond: fix primary bond option when the link is not present
Bond option netlink support requires primary property to be a ifindex
instead of the interface name. This is a workaround for supporting
specifying a primary that does not exist yet.

```
nmcli con add type bond ifname mybond0 bond.options "mode=active-backup,primary=veth1"
Connection 'bond-mybond0' (38100ef9-11e2-4003-aff9-cb2d152ce34f) successfully added.
nmcli con add type ethernet ifname veth1 master mybond0

cat /sys/class/net/mybond0/bonding/primary
veth1
```

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

Fixes: e064eb9d13 ('bond: use netlink to set bond options')
(cherry picked from commit 4fd90fb6cc)
2022-09-13 11:08:01 +02:00