summary refs log tree commit diff
path: root/src/devices/nm-device-bridge.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2020-12-06 21:57:59 +0100
committerMichael Biebl <biebl@debian.org>2020-12-06 21:57:59 +0100
commit65f86e8f56267192d42f2b629fc6b0c99fb9cd0c (patch)
tree180827692f002e5f1dad6a0fa8ca489e6bb6438f /src/devices/nm-device-bridge.c
parentf2ddac4cbc895837ddcc55015fae112f9859cd0a (diff)
New upstream version 1.28.0 upstream/1.28.0
Diffstat (limited to 'src/devices/nm-device-bridge.c')
-rw-r--r--src/devices/nm-device-bridge.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/devices/nm-device-bridge.c b/src/devices/nm-device-bridge.c
index 3c27b349..48dcec1b 100644
--- a/src/devices/nm-device-bridge.c
+++ b/src/devices/nm-device-bridge.c
@@ -1027,6 +1027,7 @@ create_and_realize(NMDevice *             device,
                    const NMPlatformLink **out_plink,
                    GError **              error)
 {
+    NMSettingWired *    s_wired;
     NMSettingBridge *   s_bridge;
     const char *        iface = nm_device_get_iface(device);
     const char *        hwaddr;
@@ -1034,12 +1035,17 @@ create_and_realize(NMDevice *             device,
     guint8              mac_address[NM_UTILS_HWADDR_LEN_MAX];
     NMPlatformLnkBridge props;
     int                 r;
+    guint32             mtu = 0;
 
     nm_assert(iface);
 
     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)) {
@@ -1097,10 +1103,17 @@ create_and_realize(NMDevice *             device,
 
     to_sysfs_group_address_sys(nm_setting_bridge_get_group_address(s_bridge), &props.group_addr);
 
+    /* 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.
+     *
+     * To workaround this behavior of kernel, we will later toggle the MTU twice. See
+     * NMDeviceClass.mtu_force_set. */
     r = nm_platform_link_bridge_add(nm_device_get_platform(device),
                                     iface,
                                     hwaddr ? mac_address : NULL,
                                     hwaddr ? ETH_ALEN : 0,
+                                    mtu,
                                     &props,
                                     out_plink);
     if (r < 0) {
@@ -1152,6 +1165,7 @@ nm_device_bridge_class_init(NMDeviceBridgeClass *klass)
     device_class->link_types                = NM_DEVICE_DEFINE_LINK_TYPES(NM_LINK_TYPE_BRIDGE);
 
     device_class->is_master                   = TRUE;
+    device_class->mtu_force_set               = TRUE;
     device_class->get_generic_capabilities    = get_generic_capabilities;
     device_class->check_connection_compatible = check_connection_compatible;
     device_class->check_connection_available  = check_connection_available;