Commit graph

23269 commits

Author SHA1 Message Date
Thomas Haller
42621dfdca
settings: fix registering AgentManager.RegisterWithCapabilities() twice
Fixes: 297d4985ab
(cherry picked from commit 1634fff1ad)
(cherry picked from commit 8b017dc2fb)
2020-09-09 08:40:45 +02:00
Thomas Haller
d8664e81e0
acd: fix memleak in acd_event()
Only happens with debug logging enabled. So, not a large problem.

Found by Coverity.

Fixes: d9a4b59c18 ('acd: adapt NM code and build options')
(cherry picked from commit 0300c1823a)
(cherry picked from commit faf12086c1)
2020-09-09 08:40:44 +02:00
Lubomir Rintel
230eaa861b
bluetooth: don't set the ifindex after the device has been activated
The Bluetooth DUN device's NMModem would signal the reset of ifindex to zero
when it's disconnected and the NMDeviceBt would accordingly update the
bluetooth device's ip ifindex. This is not okay since commit ab4578302d
('device: refactor nm_device_set_ip_ifindex() and set_ip_iface()') which,
although claiming to be a refactoring, made such use of
nm_device_set_ip_ifindex() illegal. Resetting the ifindex is anyway not
necessary, since it's taken care of _cleanup_generic_post().

Let's leave the ifindex alone once the device is activated, in a manner
analogous to what NMDeviceModem.

Fixes: ab4578302d ('device: refactor nm_device_set_ip_ifindex() and set_ip_iface()')
Fixes: 78ca2a70c7 ('device: don't set invalid ip-iface'):
(cherry picked from commit a5ca504b5b)
(cherry picked from commit fb874e6cda)
2020-09-09 08:40:44 +02:00
Beniamino Galvani
325da5a92c
supplicant: allow PMF with SAE
PMF can be used with SAE, allow it. Actually, it is required according
to WPA3 specifications but there are implementations that don't
require it (hostapd can be configured in a such way); so let's not
make it mandatory for WPA3.

Fixes: 6640fb4b36 ('supplicant: add support for SAE key management')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/257
(cherry picked from commit e36c297fd8)
(cherry picked from commit 299fbc0888)
2020-09-09 08:40:44 +02:00
Beniamino Galvani
058232ceee
core: signal parent-active only when the parent AC is activated
The parent-active signal is used by the manager to determine when the
parent active-connection is ready and a connection that depend on it
can proceed.

The AC state could transition from ACTIVATING directly to
DEACTIVATING; in such case we should not emit the signal but instead
just stop watching the parent AC.

Fixes: 6e382ea91d ('active-connection: add parent active connection tracking')
https://bugzilla.redhat.com/show_bug.cgi?id=1778073
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/510
(cherry picked from commit 02ea74c920)
(cherry picked from commit 30be025e59)
(cherry picked from commit 678c6b6a6a)
(cherry picked from commit 197b4e7b15)
2020-09-09 08:40:44 +02:00
Beniamino Galvani
728881f51b
manager: change autoconnect-slaves logic for already active slaves
Autoconnect-slaves currently forces an activation of all slaves, even
if there is already an active connection for them. This is bad because
at boot slaves first try to autoconnect, then the autoconnect-slaves
of the master kicks in and disconnects/reactivates them.

The only reason why the forceful reactivation was added was to fix
[1]; in that scenario, a slave connection is already active as
non-slave; then it is updated to be a slave; later, the master with
autoconnect-slaves is manually activated. NetworkManager should detect
that the slave connection must now be activated by autoconnect-slaves.

Add a specific check for such situation, instead of always
reactivating all slaves.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1845018

Fixes: 4985ca5ada ('manager: allow autoconnect-slaves to reconnect the same connection')
(cherry picked from commit 024e983c8e)
(cherry picked from commit d07d515dd7)
(cherry picked from commit 4df63b205e)
(cherry picked from commit a2e3f70e83)
2020-09-09 08:40:44 +02:00
Thomas Haller
386b6ebd12
ifcfg-rh: fix accepting onlink flag also for IPv6 routes
In the past, kernel (and NetworkManager) did not support the onlink
flags for IPv6 routes. That is no longer the case.

Fixes: f5e8bbc8e0 ('libnm,core: enable "onlink" flags also for IPv6 routes')
(cherry picked from commit e7816a2508)
(cherry picked from commit 98c4bdec39)
2020-09-09 08:40:44 +02:00
Thomas Haller
c13cef1b58
libnm: fix memleak in nm_device_wifi_request_scan_options_async() for floating options argument
Fixes: 7691fe5753 ('libnm: add new functions allowing passing options to RequestScan() D-Bus call')
(cherry picked from commit 187003882e)
2020-09-09 08:40:44 +02:00
Thomas Haller
07ccbdd828
libnm/device: fix memleak options variant in nm_device_wifi_request_scan_options*()
A function that accepts a floating variant must consume it.

Fixes: 7691fe5753 ('libnm: add new functions allowing passing options to RequestScan() D-Bus call')
(cherry picked from commit 40911fb99b)
(cherry picked from commit 27301fe268)
2020-09-09 08:40:44 +02:00
Thomas Haller
4c704043c6
libnm/device: fix memleak in nm_device_wifi_request_scan_options*()
Fixes: 7691fe5753 ('libnm: add new functions allowing passing options to RequestScan() D-Bus call')
(cherry picked from commit 92285cfd3e)
(cherry picked from commit d35055ceee)
2020-09-09 08:40:44 +02:00
Thomas Haller
59cdb25144
libnm/tests: fix test for nm_client_add_and_activate_connection_async()
nm_client_add_and_activate_connection_async() must be completed by
nm_client_add_and_activate_connection_finish().

Fixes: be8060f42f ('libnm: add an object-creation-failed test')
(cherry picked from commit 256ba8c4cd)
(cherry picked from commit 23d9f55c10)
2020-09-09 08:16:10 +02:00
Thomas Haller
544dfcd22f
libnm: belatedly add GObject property "NMDeviceOvs{Bridge,Port}:slaves"
Backport: don't actually add the API. The patch does nothing, it merely
contains a reference to the cherry-picked commit to satisfy
find-backports scripts. I don't think we should belatedly add this API
in old stable releases.

Fixes: 5f30a2b525 ('libnm: add accessors for ovs port/bridge slaves')

(cherry picked from commit f1bd85634a)
(cherry picked from commit df6f73c274)
2020-09-09 08:15:51 +02:00
Thomas Haller
92b7c3698a
rdisc: avoid static variable in receive_ra()
It's unnecessary and makes the function unnecessarily not thread safe.
Of course, also ndp_msg_opt_route_prefix() uses static variables, so
it's still not thread safe.

Fixes: c3a4656a68 ('rdisc: libndp implementation')
(cherry picked from commit fbb65de32e)
(cherry picked from commit a1a3cce6ef)
(cherry picked from commit 2f419e84c8)
2020-09-09 08:15:21 +02:00
Thomas Haller
f58849e2ae
rdisc: fix parsing ndp_msg_opt_dnssl_lifetime() from IPv6 RA
Fixes: c3a4656a68 ('rdisc: libndp implementation')
(cherry picked from commit d1181533b8)
(cherry picked from commit b28eee1c4b)
(cherry picked from commit dec168b525)
2020-09-09 08:15:21 +02:00
Thomas Haller
cab1713fcd
tui: fix signature for nmt_newt_form_keypress_callback() callback
Fixes: 3bda3fb60c ('nmtui: initial import of nmtui')
(cherry picked from commit 38323216f5)
(cherry picked from commit 5ab7794266)
(cherry picked from commit 4245319eaf)
2020-09-09 08:15:20 +02:00
Antonio Cardace
2d3094d468
nm-setting-bond: fix '[up|down]delay', 'miimon' validation
Just looking at the hashtable entry of 'updelay' and 'downdelay' options
is wrong, we have to inspect their values to check if they're
actually enabled or not.

Otherwise bond connections with valid settings will fail
when created:

$ nmcli c add type bond ifname bond99 bond.options miimon=0,updelay=0,mode=0
Error: Failed to add 'bond-bond99' connection: bond.options: 'updelay' option requires 'miimon' option to be set

Also add unit tests.

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

Fixes: d595f7843e ('libnm: add libnm/libnm-core (part 1)')
(cherry picked from commit 50da785be1)
(cherry picked from commit 2644b0c753)
(cherry picked from commit a8846619aa)
2020-09-09 08:15:20 +02:00
Thomas Haller
53c81fa5a8
ifcfg: fix writer when changing OVS slave to clear previous settings
We need to reset the OVS_PORT and OVS_PORT_UUID variables.
Otherwise, clearing the slave type doesn't work.

On master this is solved differently, by automatically clearing all
variables that are not explicitly set.

Reproducer:

    nmcli con del t-eth1
    nmcli con add type ethernet autoconnect no ifname eth1 master port0 con-name t-eth1 slave-type ovs-port
    echo "
    remove ovs-interface
    remove connection.master
    remove connection.slave-type
    print
    save
    quit
    " | nmcli c edit t-eth1
    nmcli con show t-eth1 | grep 'ovs\|slave-type'

Fixes: 1440fe6a88 ('ifcfg: don't forget master of ovs interfaces')

https://bugzilla.redhat.com/show_bug.cgi?id=1804167
(cherry picked from commit 0c8046574e)
(cherry picked from commit cc73cc2ecc)
2020-09-09 08:15:20 +02:00
Thomas Haller
a19aacae23
ifcfg-rh: fix potential crash with variadic argument make_ip6_setting()
It is undefined behavior and can lead to crashes or memory corruption.
In practice, this only had an issue on Big Endian systems.

Fixes: fdbf4ae5e6 ('ifcfg-rh: add IPV4_DHCP_TIMEOUT key for ipv4.dhcp-timeout property')
(cherry picked from commit 9b82d29f5f)
(cherry picked from commit fe6c3f0867)
(cherry picked from commit 63c976e002)
2020-09-09 08:15:20 +02:00
Thomas Haller
8837bc7fe5
introspection: belatedly add Wi-Fi P2P peer "Name" property to D-Bus introspection file
Fixes: 00e64d1332 ('core/devices: Add P2P Wifi device and peer tracking')
(cherry picked from commit 109a6fd557)
(cherry picked from commit 0c6ebcb6ed)
(cherry picked from commit 323e8eadf3)
2020-09-09 08:15:20 +02:00
Antonio Cardace
8d37bb0d3a
initrd: fix memory leak
Signed-off-by: Antonio Cardace <acardace@redhat.com>
Fixes: 9f9609555d ('initrd: add configuration generator')
(cherry picked from commit d5c05d07c7)
(cherry picked from commit bba54613eb)
(cherry picked from commit 67bb9896b3)
(cherry picked from commit 5913e4cee9)
(cherry picked from commit 9ed8b871bb)
2020-09-09 08:15:20 +02:00
Thomas Haller
dc94723ad8
lldp: fix lldp_neighbor_equal() to compare variants
Fixes: 8200078ec5 ('lldp: support IEEE 802.3 TLVs')
(cherry picked from commit 9b7c5ca12d)
(cherry picked from commit 4b84eeba57)
(cherry picked from commit 739417ab85)
(cherry picked from commit 284e3dd4fa)
2020-09-09 08:15:20 +02:00
Thomas Haller
ecfc48eca5
lldp: fix lldp_neighbor_equal() to compare lists of variants
Fixes: 6c52d946fc ('lldp: add support for management address TLV')
(cherry picked from commit 7c0d73d94a)
(cherry picked from commit 0426681ab4)
(cherry picked from commit 321f9b51c3)
(cherry picked from commit 2e9d7c84d6)
2020-09-09 08:15:20 +02:00
Thomas Haller
2dd77af678
lldp: backslash escape untrusted chassis-id,port-id strings
This is a serious issue, because this is not guaranteed to be UTF-8
data.

Fixes: 07a9364d9c ('device: export list of LLDP neighbors through D-Bus')
(cherry picked from commit 8cd9b87c91)
(cherry picked from commit 94f8e9fbdc)
(cherry picked from commit 90b1df4754)
(cherry picked from commit db7070c59d)
2020-09-09 08:15:20 +02:00
Thomas Haller
463519766d
libnm: fix leak in nm_utils_is_json_object()
Fixes: 32f78ae6c3 ('libnm: expose nm_utils_is_json_object() utility function')
(cherry picked from commit 1cf11ccbca)
(cherry picked from commit 49ec86092b)
(cherry picked from commit 7db30ad811)
(cherry picked from commit fef7d8467c)
(cherry picked from commit 106528e829)
2020-09-09 08:15:20 +02:00
Beniamino Galvani
455371c258
ifcfg-rh: fix memory leak reading tc filters
Fixes: 902bbfdb18 ('ifcfg-rh: add tc support')
(cherry picked from commit 88e8f2829e)
(cherry picked from commit b1e00a5805)
(cherry picked from commit 7a3f78d7eb)
(cherry picked from commit f59af10216)
(cherry picked from commit 0d0c324367)
2020-09-09 08:15:20 +02:00
Beniamino Galvani
91c0a3eb34
ifcfg-rh: check return value of fdopen()
Reported by coverity:

>>> CID 210222: Null pointer dereferences (NULL_RETURNS)
>>> Dereferencing a pointer that might be "NULL" "f" when calling
    "fseek".

Fixes: ac5206aa9c ('2007-11-21')
(cherry picked from commit 581aa981c2)
(cherry picked from commit bb40de0ca0)
(cherry picked from commit cde95a3c75)
(cherry picked from commit 3293ad0fbc)
2020-09-09 08:15:19 +02:00
Thomas Haller
5be0113b09
shared: add nm_utils_buf_utf8safe_escape_cp() helper
(cherry picked from commit 393bc8c8f6)
(cherry picked from commit 10b0260d19)
(cherry picked from commit ff8ba801f3)
(cherry picked from commit 5838f82707)
2020-09-09 08:15:19 +02:00
Thomas Haller
df9c6d129a
ndisc/tests: merge branch 'th/ndisc-test-assertion-fixes'
(cherry picked from commit 1411f0135e)

(cherry picked from commit 2b28b9b276)

(cherry picked from commit a7b4bc1d28)
2020-09-08 14:53:11 +02:00
Thomas Haller
cd819a7349
ndisc/tests: relax assertion in "test-ndisc-fake.c"
Still assertion failures:

  ERROR:../src/ndisc/tests/test-ndisc-fake.c:375:test_preference_changed_cb: assertion failed (_a->timestamp >= _ts): (9 >= 10)

(cherry picked from commit a5133e708e)
(cherry picked from commit 75e8f4c36f)
(cherry picked from commit 80dbc0f17b)
(cherry picked from commit e6f235d971)
(cherry picked from commit b00b4dadfb)
2020-09-08 14:53:10 +02:00
Thomas Haller
86c6fbbf50
ndisc/tests: fix assertion in "test-ndisc-fake.c"
First I wanted to fix

  test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:373:test_preference_changed_cb: assertion failed (_a->timestamp == (data->timestamp1 + 3)): (9 == 10)

but that leads to a different failure:

  test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:375:test_preference_changed_cb: assertion failed (_a->lifetime == (9)): (10 == 9)

Instead, the start and end times must match exact (in their duration),
we only allow them to be shifted by up to one second.

Fixes: 8209095ee1 ('ndisc/tests: relax the assertion in "test-ndisc-fake.c"')
(cherry picked from commit b2f03544a7)
(cherry picked from commit 838777a891)
(cherry picked from commit 1470212f4c)
(cherry picked from commit 6f2731b6cb)
(cherry picked from commit 781849c029)
2020-09-08 14:53:10 +02:00
Thomas Haller
23b8857b9b
ndisc/tests: relax the assertion in "test-ndisc-fake.c"
test:ERROR:../src/ndisc/tests/test-ndisc-fake.c:373:test_preference_changed_cb: assertion failed (_a->timestamp == (data->timestamp1 + 3)): (9 == 10)

(cherry picked from commit 8209095ee1)
(cherry picked from commit 75177f6967)
(cherry picked from commit c32f993486)
(cherry picked from commit 712194ac8c)
(cherry picked from commit 348e3addc8)
2020-09-08 14:53:10 +02:00
Thomas Haller
1bf2184087
ndisc/tests: make assertion checks a macro and not a function in test-ndisc-fake
By having it a function, the assertion failure does not show the line
number of the origin. Make them a macro, so that we see where exactly it
failed.

(cherry picked from commit 3b896cc642)
(cherry picked from commit b1a7eda71d)
(cherry picked from commit 8316943338)
(cherry picked from commit 017bfbf4d7)
(cherry picked from commit 95beb170ea)
2020-09-08 14:53:10 +02:00
Beniamino Galvani
3b51a05187
libnm-core: interpret ovs-patch.peer as an interface name
The 'peer' property of ovs-patch is inserted into the 'options' column
of the ovsdb 'Interface' table. The ovs-vswitchd.conf.db man page says
about it:

  options : peer: optional string
    The name of the Interface for the other side of the patch. The
    named Interface’s own peer option must specify this Interface’s
    name. That is, the two patch interfaces must have reversed name
    and peer values.

Therefore, it is wrong to validate the peer property as an IP address
and document it as such.

Backport: note that on nm-1-22, we have nm_utils_ifname_valid() function
for validating OVS interface names. We don't have that here, so we
re-implement the name validation differently.

Fixes: d4a7fe4679 ('libnm-core: add ovs-patch setting')
(cherry picked from commit beb1dba8c1)
(cherry picked from commit 5598c039e4)
(cherry picked from commit 9b82c62f33)
(cherry picked from commit 87e79d214e)
2020-09-04 16:56:59 +02:00
Beniamino Galvani
5071909e7c
ovs: merge branch 'bg/ovs-mac-pt2'
https://bugzilla.redhat.com/show_bug.cgi?id=1852106
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/557
(cherry picked from commit 15492e6c50)

(cherry picked from commit f819a7cabf)

(cherry picked from commit 8dc357dc11)

(cherry picked from commit a9b3730bf2)

(cherry picked from commit 3d349eb5fe)
2020-08-17 20:11:30 +02:00
Beniamino Galvani
baf91970b3
device: don't reset the MAC without ifindex
nm_device_cleanup() can be called when the device no longer has an
ifindex. In such case, don't try to reset the MAC address as that
would lead to an assertion failure.

(cherry picked from commit 77b6ce7d04)
(cherry picked from commit 791a888cad)
(cherry picked from commit e1f76e7044)
(cherry picked from commit 5f22c06c53)
(cherry picked from commit 6beaa83d32)
2020-08-17 20:11:30 +02:00
Beniamino Galvani
037ff28708
ovs: also set cloned MAC address via netlink
We already set the MAC of OVS interfaces in the ovsdb. Unfortunately,
vswitchd doesn't create the interface with the given MAC from the
beginning, but first creates it with a random MAC and then changes it.

This causes a race condition: as soon as NM sees the new link, it
starts IP configuration on it and (possibly later) vswitchd will
change the MAC.

To avoid this, also set the desired MAC via netlink before starting IP
configuration.

https://bugzilla.redhat.com/show_bug.cgi?id=1852106
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/483
(cherry picked from commit 47ec3d14d4)
(cherry picked from commit 60d10b146d)
(cherry picked from commit 0139995590)
(cherry picked from commit 69c5c5e767)
(cherry picked from commit 91d2b0fd5a)
2020-08-17 20:11:29 +02:00
Beniamino Galvani
9493f1f151
ovs: set MAC address on the bridge for local interfaces
When a user creates a ovs-interface with the same name of the parent
ovs-bridge, openvswitch considers the interface as the "local
interface" [1] and assigns the MAC address of the bridge to the
interface [2].

This is confusing for users, as the cloned MAC property is ignored in
some cases, depending on the ovs-interface name.

Instead, detect when the interface is local and set the MAC from the
ovs-interface connection in the bridge table.

[1] https://github.com/openvswitch/ovs/blob/v2.13.0/vswitchd/vswitch.xml#L2546
[2] https://github.com/openvswitch/ovs/blob/v2.13.0/vswitchd/bridge.c#L4744

(cherry picked from commit 5d4c8521a3)
(cherry picked from commit 7548c29a89)
(cherry picked from commit 127294babc)
(cherry picked from commit f54c5400c8)
(cherry picked from commit 1a08885080)
2020-08-17 20:11:29 +02:00
Beniamino Galvani
aa150c7bfb
merge: branch 'bg/sleep-unmanaged-rh1855563'
https://bugzilla.redhat.com/show_bug.cgi?id=1855563
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/580

(cherry picked from commit 116c49fceb)

(cherry picked from commit 90cb61f8fd)

(cherry picked from commit 2dae6833ad)

(cherry picked from commit 3c960a9f2b)

(cherry picked from commit f8f2326715)
2020-08-17 20:11:15 +02:00
Beniamino Galvani
8d87f752db
policy: block connection from autoconnect in case of failed dependency
A connection that fails due to dependency-failed is not able to
reconnect until the master connection activates again; when this
happens, the master clears the blocked reason for all its slaves in
activate_slave_connections() and tries to reconnect them. For this to
work, the slave should be marked as blocked when it fails with
dependency-failed.

(cherry picked from commit 725fed01cf)
(cherry picked from commit e1755048e3)
(cherry picked from commit ecb134ac34)
(cherry picked from commit bb4781cc58)
(cherry picked from commit 70c642325f)
2020-08-17 20:11:15 +02:00
Beniamino Galvani
b3ec3fa5ab
manager: fix race condition when resuming from sleep
If the device state change (to disconnected or unmanaged) triggered by
a sleep event happens after the wake, the devices becomes wrongly
unmanaged and it's necessary to manually manage it again, or restart
NM.

During the wake event we should disconnect the device_sleep_cb()
callback for all devices because we don't want to react to state
changes anymore; in particular we don't need to detect when the device
becomes disconnected to unmanage it.

(cherry picked from commit fe2d93980b)
(cherry picked from commit 971897195a)
(cherry picked from commit 7913275b02)
(cherry picked from commit 6d0e8a2acf)
(cherry picked from commit 61c44dad91)
2020-08-17 20:11:15 +02:00
Beniamino Galvani
03b9634519
device: restart DHCP only for devices that are active or activating
do_sleep_wake() tries to restart DHCP for all devices, even ones that
are disconnecting. When a device is disconnecting, it still has a DHCP
client instance but we shouldn't restart it because it makes no sense;
and especially, the device could be already removed.

https://bugzilla.redhat.com/show_bug.cgi?id=1852612
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/561
(cherry picked from commit 2c50438987)
(cherry picked from commit 5321490180)
(cherry picked from commit ef755588ad)
(cherry picked from commit da54b35af3)
(cherry picked from commit b0be1285cc)
2020-08-17 20:11:02 +02:00
Beniamino Galvani
4c8edaedc7
ovs: ignore failures of patch interfaces
When there are two patch ports connected, each of them must reference
the other; however they can't be created in a single transaction
because they are part of different bridges (so, different
connections). Therefore, the first patch that gets activated will
always fail with "No usable peer $x exists in 'system' datapath" until
the second patch exists.

In theory we could also match the error message, however this doesn't
seem very robust as the message may slightly change in the future.

(cherry picked from commit ffeac35f04)
(cherry picked from commit 75cbf21738)
(cherry picked from commit 399aad15bf)
(cherry picked from commit 692689ead8)
2020-08-17 20:11:02 +02:00
Beniamino Galvani
b2d5976950
ovsdb: retry calls in case of communication error with server
When the server is restarted the write to unix socket fails with
EPIPE. In such case, don't fail all the calls in queue; instead, after
a sync of the ovsdb state (through a monitor call), start processing
the queue again, including the call that previously failed.

Add a retry counter to avoid that calls are stuck in the queue forever
in a hypothetical scenario in which the write always fails.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/459
(cherry picked from commit db37e530e8)
(cherry picked from commit 54254bf6fe)
(cherry picked from commit 166ad887f9)
2020-08-17 20:11:02 +02:00
Beniamino Galvani
fee0dfc764
ovs: merge branch 'bg/ovs-interface-mtu-rh1808124'
https://bugzilla.redhat.com/show_bug.cgi?id=1807726
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/433
(cherry picked from commit 2da77547ba)

(cherry picked from commit f0b7cb60dd)

(cherry picked from commit e62afcf0bd)
2020-08-17 20:10:40 +02:00
Beniamino Galvani
04264be151
ovs: set the MTU in ovsdb when changing platform MTU of ovs-interface
If we change the the MTU of an ovs interface only through netlink, the
change could be overridden by ovs-vswitchd at any time when other
interfaces change. Set the MTU also in the ovsdb to prevent such
changes.

Note that if the MTU comes from the connection, we already set the
ovsdb MTU at creation time and so this other update becomes
useless. But it is needed when changing the MTU at runtime (reapply)
or when the MTU comes from a different source (e.g. DHCP).

(cherry picked from commit c2a9712945)
(cherry picked from commit e27a59c69e)
(cherry picked from commit 99ef891db6)
2020-08-17 20:10:40 +02:00
Beniamino Galvani
59787018c9
ovs: set MTU from connection when creating an internal interface
The ovs-vswitchd.conf.db(5) man page says about the the mtu_request
column in the Interface table:

  "Requested MTU (Maximum Transmission Unit) for the interface. A
   client can fill this column to change the MTU of an
   interface [...] If this is not set and if the interface has
   internal type, Open vSwitch will change the MTU to match the
   minimum of the other interfaces in the bridge."

Therefore, if the connection specifies a MTU, set it early when adding
the interface to the ovsdb so that it will not be changed to the
minimum of other interfaces.

(cherry picked from commit ad12f26312)
(cherry picked from commit 7311d5e294)
(cherry picked from commit b81370f70b)
2020-08-17 20:10:40 +02:00
Beniamino Galvani
021141481e
ovs/ovsdb: support changing the MTU of an ovs interface
Introduce a nm_ovsdb_set_interface_mtu() function to update the MTU of
an ovs interface in the ovsdb.

(cherry picked from commit a4c2c1a843)
(cherry picked from commit c1be15a66e)
(cherry picked from commit 990f46505d)
2020-08-17 20:10:39 +02:00
Beniamino Galvani
a85c231b0c
ovs: merge branch 'bg/ovs-deactivate-async-pt2'
https://bugzilla.redhat.com/show_bug.cgi?id=1787989
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/412
(cherry picked from commit e24fd88494)

(cherry picked from commit 53b878818c)

(cherry picked from commit 505aab90e0)
2020-08-17 20:10:28 +02:00
Beniamino Galvani
b22a20880e
ovs: discard link updates when deactivating
When the ovs interface gets deactivated, it is released from the
master port and we call nm_device_update_from_platform_link (dev,
NULL) to ignore any later event for the interface. This is important
especially because it sets a zero ifindex on the interface and so,
later when the link disappears, we don't unmanage the device but
directly remove it.

However, since ovs commands are queued, the link could appear during
the deactivation and we need to ignore such events. Add a new device
method can_update_from_platform_link() for such purpose.

(cherry picked from commit e9fc1dea43)
(cherry picked from commit c4eb0c6852)
(cherry picked from commit 34a9247a64)
2020-08-17 20:10:27 +02:00
Beniamino Galvani
296d4e3926
ovs: rework asynchronous deactivation of ovs interfaces
Tracking the deletion of link by ifindex is difficult because the
ifindex of the device is updated through delayed (idle) calls in
NMDevice and so there is the possibility that at a certain time the
device ifindex is not in sync with platform state. It seems simpler to
watch instead the interface name. The ugly thing is that the interface
name can be changed externally, but if users do that on an activating
device they are looking for trouble.

Also change the deactivate code to deal with the scenario where we
already created the interface in the ovsdb but the link didn't show up
yet. To ensure a proper cleanup we must wait that the link appears and
then goes away; however the link may never appear if vswitchd sees
only the last state in ovsdb, and so we must use a ugly timeout to
avoid waiting forever.

https://bugzilla.redhat.com/show_bug.cgi?id=1787989
(cherry picked from commit 9c49f8a879)
(cherry picked from commit 2e5e409bf2)
(cherry picked from commit 628706fab5)
2020-08-17 20:10:27 +02:00