Commit graph

24054 commits

Author SHA1 Message Date
Thomas Haller
12afddbbca
device: fix casting pointer to enum for sriov_reset_on_deactivate_cb()
Avoids a compiler warning:

    ../src/devices/nm-device.c:16079:26: error: cast to smaller integer type 'NMDeviceStateReason' from 'gpointer' (aka 'void *') [-Werror,-Wvoid-pointer-to-enum-cast]
            deactivate_ready (self, (NMDeviceStateReason) reason);
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fixes: 121c58f0c4 ('core: set number of SR-IOV VFs asynchronously')
(cherry picked from commit 918ebd600a)
(cherry picked from commit 32641b9fca)
(cherry picked from commit c24888be51)
(cherry picked from commit 3d27459460)
2020-09-08 14:58:00 +02:00
Thomas Haller
c3aa7285e3
device: fix leak in sriov_deactivate_cb()
On master this code was refactored and thereby the leak was
fixed. Instead of backporting that, do an original patch for
nm-1-24 to fix only the leak.

Fixes: 121c58f0c4 ('core: set number of SR-IOV VFs asynchronously')
(cherry picked from commit a28d4a305a)
(cherry picked from commit 2e0cb189d3)
2020-09-08 14:58:00 +02:00
Thomas Haller
284e3dd4fa
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)
2020-09-08 14:58:00 +02:00
Thomas Haller
2e9d7c84d6
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)
2020-09-08 14:58:00 +02:00
Thomas Haller
db7070c59d
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)
2020-09-08 14:58:00 +02:00
Thomas Haller
5838f82707
shared: add nm_utils_buf_utf8safe_escape_cp() helper
(cherry picked from commit 393bc8c8f6)
(cherry picked from commit 10b0260d19)
(cherry picked from commit ff8ba801f3)
2020-09-08 14:58:00 +02:00
Thomas Haller
106528e829
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)
2020-09-08 14:58:00 +02:00
Beniamino Galvani
0d0c324367
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)
2020-09-08 14:58:00 +02:00
Beniamino Galvani
3293ad0fbc
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)
2020-09-08 14:58:00 +02:00
Thomas Haller
2f419e84c8
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)
2020-09-08 14:57:59 +02:00
Thomas Haller
dec168b525
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)
2020-09-08 14:57:59 +02:00
Thomas Haller
4245319eaf
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)
2020-09-08 14:57:59 +02:00
Beniamino Galvani
3c6b14fa0d
n-dhcp4: fix BPF filter endianness issue
The BPF filter takes the byte containing IP Flags and performs a
bitwise AND with "ntohs(IP_MF | IP_OFFMASK)".

On little-endian architectures the IP_MF flag (0x20) is ANDed with
0xFF3F and so the presence of the flag is correctly detected ignoring
other flags as IP_DF (0x40) or IP_RF (0x80).

On big-endian, "ntohs(IP_MF | IP_OFFMASK)" is 0x3FFF and so the filter
wrongly checks the presence of *any* flags. Therefore, a packet with
the DF flag set is dropped.

Instead, take the two bytes containing flags and offset:

    0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |Version|  IHL  |Type of Service|          Total Length         |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |         Identification        |Flags|      Fragment Offset    |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

and verify that IP_MF and the offset are zero.

Fixes: e43b1791a3 ('Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4'')

https://bugzilla.redhat.com/show_bug.cgi?id=1861488
https://github.com/nettools/n-dhcp4/pull/19
(cherry picked from commit 03d38e83e558802a82cb0e4847cb1f1ef75ccd16)
(cherry picked from commit 0024cef238)
(cherry picked from commit 80835f8f89)
(cherry picked from commit 4588e2e817)
(cherry picked from commit 7208f594f6)
2020-09-08 14:57:59 +02:00
Beniamino Galvani
2be3cb89d6
settings: fix assertion when updating default wired connection
The connection is expected to have the NM_GENERATED flag, since it has
a default wired device.

Fixes: d35d3c468a ('settings: rework tracking settings connections and settings plugins')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/471
(cherry picked from commit 4aefad5673)
(cherry picked from commit 3951396de7)
(cherry picked from commit ac89b8f6b7)
(cherry picked from commit c92a857538)
2020-09-08 14:57:59 +02:00
Antonio Cardace
a8846619aa
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)
2020-09-08 14:57:59 +02:00
Thomas Haller
cc73cc2ecc
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)
2020-09-08 14:57:59 +02:00
Thomas Haller
63c976e002
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)
2020-09-08 14:57:59 +02:00
Thomas Haller
323e8eadf3
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)
2020-09-08 14:57:59 +02:00
Beniamino Galvani
091b11801a
dhcp: nettools: fix parsing of classless routes option
Fixes: 6adade6f21 ('dhcp: add nettools dhcp4 client')
(cherry picked from commit dd3114deb0)
(cherry picked from commit bee319bf94)
2020-09-08 14:57:58 +02:00
Alexey Kodanev
e27bfeb19b
nm-manager: fix selinux label for dhclient lease file from initramfs
When moving a lease file from initramfs directory to NetworkManager
run directory, SELinux label for that file retains tmpfs_t type.

Fix it by using sendfile() instead of rename(). That way, the
lease file will have the default type: NetworkManager_var_run_t.
Since we take ownership of the lease file, also drop it from the
old location.

* Before the patch:
ls -Z /var/run/NetworkManager/dhclient-*.lease
system_u:object_r:tmpfs_t:s0 dhclient-13162c00-abfb-4e28-bbfb-170187ddd044-ens3.lease

* After:
ls -Z /var/run/NetworkManager/dhclient-*.lease
system_u:object_r:NetworkManager_var_run_t:s0 dhclient-f47d1908-67ae-49c6-bd5e-19a690d85526-ens3.lease

Fixes: f2fe6c03ee ('manager: don't treat the initramfs-configured DHCP connections as generated')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/353
(cherry picked from commit ce1f9e6eb9)
(cherry picked from commit abeaf6ffc3)
2020-09-08 14:57:58 +02:00
Thomas Haller
98c4bdec39
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)
2020-09-08 14:57:58 +02:00
Thomas Haller
1c0b400fa7
libnm: fix GObject properties of "NMDeviceModem"
Fixes: f18b09b3f6 ('libnm/modem: add device id getter')
Fixes: 0b3dd18c2b ('libnm/modem: add network id getter')
Fixes: 8e270de05e ('libnm/modem: add APN getter')
(cherry picked from commit 389c2ebe8a)
2020-09-08 14:57:58 +02:00
Thomas Haller
d35055ceee
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)
2020-09-08 14:57:58 +02:00
Thomas Haller
27301fe268
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)
2020-09-08 14:57:58 +02:00
Thomas Haller
23d9f55c10
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)
2020-09-08 14:57:58 +02:00
Thomas Haller
df6f73c274
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)
2020-09-08 14:57:58 +02:00
Thomas Haller
a7b4bc1d28
ndisc/tests: merge branch 'th/ndisc-test-assertion-fixes'
(cherry picked from commit 1411f0135e)

(cherry picked from commit 2b28b9b276)
2020-09-08 14:52:35 +02:00
Thomas Haller
b00b4dadfb
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)
2020-09-08 14:52:35 +02:00
Thomas Haller
781849c029
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)
2020-09-08 14:52:35 +02:00
Thomas Haller
348e3addc8
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)
2020-09-08 14:52:35 +02:00
Thomas Haller
95beb170ea
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)
2020-09-08 14:52:35 +02:00
Beniamino Galvani
87e79d214e
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)
2020-09-04 16:38:15 +02:00
Thomas Haller
1b9da18693
tests: suppress valgrind warning about unsupported syscall for "test-config"
(cherry picked from commit d507563a80)
(cherry picked from commit 4036bc48e4)
(cherry picked from commit 9ff160d155)
2020-08-17 19:06:33 +02:00
Beniamino Galvani
3d349eb5fe
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)
2020-08-17 17:49:21 +02:00
Beniamino Galvani
6beaa83d32
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)
2020-08-17 17:49:21 +02:00
Beniamino Galvani
91d2b0fd5a
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)
2020-08-17 17:49:21 +02:00
Beniamino Galvani
1a08885080
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)
2020-08-17 17:49:21 +02:00
Beniamino Galvani
f8f2326715
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)
2020-08-17 17:47:31 +02:00
Beniamino Galvani
70c642325f
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)
2020-08-17 17:47:30 +02:00
Beniamino Galvani
61c44dad91
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)
2020-08-17 17:47:30 +02:00
Beniamino Galvani
b0be1285cc
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)
2020-08-17 17:46:54 +02:00
Beniamino Galvani
692689ead8
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)
2020-08-17 17:46:20 +02:00
Beniamino Galvani
166ad887f9
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)
2020-08-17 17:44:36 +02:00
Beniamino Galvani
e62afcf0bd
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)
2020-08-17 17:41:08 +02:00
Beniamino Galvani
99ef891db6
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)
2020-08-17 17:41:07 +02:00
Beniamino Galvani
b81370f70b
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)
2020-08-17 17:41:07 +02:00
Beniamino Galvani
990f46505d
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)
2020-08-17 17:41:07 +02:00
Beniamino Galvani
505aab90e0
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)
2020-08-17 17:39:47 +02:00
Beniamino Galvani
34a9247a64
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)
2020-08-17 17:39:47 +02:00
Beniamino Galvani
628706fab5
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)
2020-08-17 17:39:47 +02:00