From patchwork Thu Jun 29 08:22:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhongbaisong X-Patchwork-Id: 782107 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wyt3d0lLlz9s2G for ; Thu, 29 Jun 2017 18:23:56 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0E136258; Thu, 29 Jun 2017 08:23:53 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 13C9B9C for ; Thu, 29 Jun 2017 08:23:52 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C3DAC125 for ; Thu, 29 Jun 2017 08:23:50 +0000 (UTC) Received: from 172.30.72.57 (EHLO DGGEML403-HUB.china.huawei.com) ([172.30.72.57]) by dggrg03-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AQH41691; Thu, 29 Jun 2017 16:23:19 +0800 (CST) Received: from localhost (10.177.238.156) by DGGEML403-HUB.china.huawei.com (10.3.17.33) with Microsoft SMTP Server id 14.3.301.0; Thu, 29 Jun 2017 16:23:09 +0800 From: zhongbaisong To: Date: Thu, 29 Jun 2017 16:22:58 +0800 Message-ID: <1498724578-1692-1-git-send-email-zhongbaisong@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.177.238.156] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.5954B912.003C, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: cf5fcb29662b39f3e2eaca06cfa3f3e8 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] bridge: Add support to set mtu by ovs-vsctl command X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This commit add the support to set mtu with ovs-vsctl command like: ovs-vsctl set interface port mtu=2000 Signed-off-by: zhongbaisong 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)