Message ID | 1498724578-1692-1-git-send-email-zhongbaisong@huawei.com |
---|---|
State | Rejected |
Headers | show |
On Thu, Jun 29, 2017 at 04:22:58PM +0800, zhongbaisong wrote: > This commit add the support to set mtu with ovs-vsctl command like: > ovs-vsctl set interface port mtu=2000 > > Signed-off-by: zhongbaisong <zhongbaisong@huawei.com> Thanks for contributing to Open vSwitch! "checkpatch" says: ERROR: Inappropriate bracing around statement #36 FILE: vswitchd/bridge.c:4456: if (iface->change_seq != netdev_get_change_seq(iface->netdev)) ERROR: Inappropriate bracing around statement #40 FILE: vswitchd/bridge.c:4460: if (n_mtu == 0) But to me this patch does not make conceptual sense. The mtu column reports an interface's MTU, it does not set it, and there is already a column to set MTU. Please read the documentation: MTU: The MTU (maximum transmission unit) is the largest amount of data that can fit into a single Ethernet frame. The standard Ethernet MTU is 1500 bytes. Some physical media and many kinds of virtual interfaces can be configured with higher MTUs. A client may change an interface MTU by filling in mtu_request. Open vSwitch then reports in mtu the currently configured value. mtu: optional integer The currently configured MTU for the interface. This column will be empty for an interface that does not have an MTU as, for example, some kinds of tunnels do not. Open vSwitch sets this column’s value, so other clients should treat it as read-only. mtu_request: optional integer, at least 1 Requested MTU (Maximum Transmission Unit) for the interface. A client can fill this column to change the MTU of an interface. RFC 791 requires every internet module to be able to forward a datagram of 68 octets without further fragmentation. The maximum size of an IP packet is 65535 bytes. If this is not set and if the interface has internal type, Open vSwitch will change the MTU to match the minimum of th
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)
This commit add the support to set mtu with ovs-vsctl command like: ovs-vsctl set interface port mtu=2000 Signed-off-by: zhongbaisong <zhongbaisong@huawei.com>