This commit add the support to set mtu with ovs-vsctl command like:
        ovs-vsctl set interface port mtu=2000

Signed-off-by: zhongbaisong <[email protected]>

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 8336d70..71f73d6 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -307,6 +307,7 @@ static struct iface *iface_find(const char *name);
 static struct iface *iface_from_ofp_port(const struct bridge *,
                                          ofp_port_t ofp_port);
 static void iface_set_mac(const struct bridge *, const struct port *, struct 
iface *);
+static void iface_set_mtu(struct iface *iface);
 static void iface_set_ofport(const struct ovsrec_interface *, ofp_port_t 
ofport);
 static void iface_clear_db_record(const struct ovsrec_interface *if_cfg, char 
*errp);
 static void iface_configure_qos(struct iface *, const struct ovsrec_qos *);
@@ -688,6 +689,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch 
*ovs_cfg)
                 iface_configure_cfm(iface);
                 iface_configure_qos(iface, port->cfg->qos);
                 iface_set_mac(br, port, iface);
+                iface_set_mtu(iface);
                 ofproto_port_set_bfd(br->ofproto, iface->ofp_port,
                                      &iface->cfg->bfd);
                 ofproto_port_set_lldp(br->ofproto, iface->ofp_port,
@@ -4440,6 +4442,32 @@ iface_set_mac(const struct bridge *br, const struct port 
*port, struct iface *if
     }
 }
 
+/* Set MTU of 'iface', if one is specified in the configuration file. */
+static void
+iface_set_mtu(struct iface *iface)
+{
+    int mtu, n_mtu;
+    int error;
+
+    if (strcmp(iface->type, "internal")) {
+        return;
+    }
+
+    if (iface->change_seq != netdev_get_change_seq(iface->netdev))
+        return ;
+
+    n_mtu = iface->cfg->n_mtu;
+    if (n_mtu == 0)
+        return;
+
+    mtu = iface->cfg->mtu[n_mtu-1];
+    error = netdev_set_mtu(iface->netdev, mtu);
+    if (error && error != EOPNOTSUPP) {
+        VLOG_ERR("interface %s: setting MTU failed (%s)",
+                 iface->name, ovs_strerror(error));
+    }
+}
+
 /* Sets the ofport column of 'if_cfg' to 'ofport'. */
 static void
 iface_set_ofport(const struct ovsrec_interface *if_cfg, ofp_port_t ofport)
-- 
1.9.5.msysgit.1


_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to