[ovs-dev] [PATCH 1/2] bridge: Honor 'mtu_request' when port is added.

Daniele Di Proietto diproiettod at vmware.com
Tue Aug 30 18:41:14 UTC 2016


'mtu_request' was honored only when the port was reconfigured, not when
the port was added.

This commit fixes the problem and improves a testcase to detect the bug.

Found by inspection.

Fixes: 56abcf497b56("vswitchd: Introduce 'mtu_request' column in
Interface.")
Signed-off-by: Daniele Di Proietto <diproiettod at vmware.com>
---
 tests/ofproto-dpif.at |  5 +++++
 vswitchd/bridge.c     | 29 +++++++++++++++++++++--------
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at
index 3638063..d7705da 100644
--- a/tests/ofproto-dpif.at
+++ b/tests/ofproto-dpif.at
@@ -8887,5 +8887,10 @@ AT_CHECK([ovs-vsctl del-port br0 p1])
 # When 'p1' is deleted, the internal port should return to the default MTU
 AT_CHECK([ovs-vsctl --timeout=10 wait-until Interface br0 mtu=1500])
 
+# New port with 'mtu_request' in the same transaction.
+AT_CHECK([ovs-vsctl add-port br0 p2 -- set int p2 type=dummy mtu_request=1600])
+AT_CHECK([ovs-vsctl --timeout=10 wait-until Interface p2 mtu=1600])
+AT_CHECK([ovs-vsctl --timeout=10 wait-until Interface br0 mtu=1600])
+
 OVS_VSWITCHD_STOP
 AT_CLEANUP
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 720e615..a7a12ec 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -721,6 +721,24 @@ add_ofp_port(ofp_port_t port, ofp_port_t *ports, size_t *n, size_t *allocated)
     return ports;
 }
 
+/* Configures the MTU of 'netdev' based on the "mtu_request" column
+ * in 'iface_cfg'.  'br_type' must be the datapath_type of the bridge
+ * which contains 'netdev'. */
+static int
+iface_set_netdev_mtu(const struct ovsrec_interface *iface_cfg,
+                     const char *br_type, struct netdev *netdev)
+{
+    if (iface_cfg->n_mtu_request == 1
+        && strcmp(netdev_get_type(netdev),
+                  ofproto_port_open_type(br_type, "internal"))) {
+        /* Try to set the MTU to the requested value.  This is not done
+         * for internal interfaces, since their MTU is decided by the
+         * ofproto module, based on other ports in the bridge. */
+        return netdev_set_mtu(netdev, *iface_cfg->mtu_request);
+    }
+    return 0;
+}
+
 static void
 bridge_delete_or_reconfigure_ports(struct bridge *br)
 {
@@ -775,14 +793,7 @@ bridge_delete_or_reconfigure_ports(struct bridge *br)
             goto delete;
         }
 
-        if (iface->cfg->n_mtu_request == 1
-            && strcmp(iface->type,
-                      ofproto_port_open_type(br->type, "internal"))) {
-            /* Try to set the MTU to the requested value.  This is not done
-             * for internal interfaces, since their MTU is decided by the
-             * ofproto module, based on other ports in the bridge. */
-            netdev_set_mtu(iface->netdev, *iface->cfg->mtu_request);
-        }
+        iface_set_netdev_mtu(iface->cfg, br->type, iface->netdev);
 
         /* If the requested OpenFlow port for 'iface' changed, and it's not
          * already the correct port, then we might want to temporarily delete
@@ -1725,6 +1736,8 @@ iface_do_create(const struct bridge *br,
         goto error;
     }
 
+    iface_set_netdev_mtu(iface_cfg, br->type, netdev);
+
     *ofp_portp = iface_pick_ofport(iface_cfg);
     error = ofproto_port_add(br->ofproto, netdev, ofp_portp);
     if (error) {
-- 
2.9.3




More information about the dev mailing list