Skip to content

Commit

Permalink
bridge: Honor 'mtu_request' when port is added.
Browse files Browse the repository at this point in the history
'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: 56abcf4("vswitchd: Introduce 'mtu_request' column in
Interface.")
Signed-off-by: Daniele Di Proietto <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
ddiproietto committed Aug 31, 2016
1 parent 6776244 commit 7c12e20
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
5 changes: 5 additions & 0 deletions tests/ofproto-dpif.at
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 21 additions & 8 deletions vswitchd/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7c12e20

Please sign in to comment.