bridge: assume wired settings are there

We can now assert instead of checking.

Also, let's move the whole get-the-mtu part down closer to where it is
actually used.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1208
This commit is contained in:
Lubomir Rintel 2022-05-05 10:29:31 +02:00
parent 41291ef773
commit b0240418b3

View file

@ -1090,10 +1090,6 @@ create_and_realize(NMDevice *device,
s_bridge = nm_connection_get_setting_bridge(connection);
nm_assert(s_bridge);
s_wired = nm_connection_get_setting_wired(connection);
if (s_wired)
mtu = nm_setting_wired_get_mtu(s_wired);
hwaddr = nm_setting_bridge_get_mac_address(s_bridge);
if (!hwaddr
&& nm_device_hw_addr_get_cloned(device, connection, FALSE, &hwaddr_cloned, NULL, NULL)) {
@ -1118,6 +1114,11 @@ create_and_realize(NMDevice *device,
_platform_lnk_bridge_init_from_setting(s_bridge, &props);
s_wired = nm_connection_get_setting_wired(connection);
nm_assert(s_wired);
mtu = nm_setting_wired_get_mtu(s_wired);
/* If mtu != 0, we set the MTU of the new bridge at creation time. However, kernel will still
* automatically adjust the MTU of the bridge based on the minimum of the slave's MTU.
* We don't want this automatism as the user asked for a fixed MTU.