def->uuid, NULL, NULL, 0,
virDomainNetGetActualVirtPortProfile(net),
virDomainNetGetActualVlan(net),
+ 0, NULL,
VIR_NETDEV_TAP_CREATE_IFUP | VIR_NETDEV_TAP_CREATE_PERSIST) < 0) {
goto cleanup;
}
if (virNetDevTapCreateInBridgePort(network->def->bridge,
&macTapIfName, &network->def->mac,
NULL, NULL, &tapfd, 1, NULL, NULL,
+ 0, NULL,
VIR_NETDEV_TAP_CREATE_USE_MAC_FOR_BRIDGE |
VIR_NETDEV_TAP_CREATE_IFUP |
VIR_NETDEV_TAP_CREATE_PERSIST) < 0) {
def->uuid, tunpath, tapfd, *tapfdSize,
virDomainNetGetActualVirtPortProfile(net),
virDomainNetGetActualVlan(net),
+ 0, NULL,
tap_create_flags) < 0) {
virDomainAuditNetDevice(def, net, tunpath, false);
goto cleanup;
vm->uuid, net->backend.tap, &tapfd, 1,
virDomainNetGetActualVirtPortProfile(net),
virDomainNetGetActualVlan(net),
+ 0, NULL,
VIR_NETDEV_TAP_CREATE_IFUP |
VIR_NETDEV_TAP_CREATE_PERSIST) < 0) {
if (template_ifname)
* @tapfd: array of file descriptor return value for the new tap device
* @tapfdSize: number of file descriptors in @tapfd
* @virtPortProfile: bridge/port specific configuration
+ * @mtu: requested MTU for port (or 0 for "default")
+ * @actualMTU: MTU actually set for port (after accounting for bridge's MTU)
* @flags: OR of virNetDevTapCreateFlags:
* VIR_NETDEV_TAP_CREATE_IFUP
size_t tapfdSize,
virNetDevVPortProfilePtr virtPortProfile,
virNetDevVlanPtr virtVlan,
+ unsigned int mtu,
+ unsigned int *actualMTU,
unsigned int flags)
{
virMacAddr tapmac;
if (virNetDevSetMAC(*ifname, &tapmac) < 0)
goto error;
- /* We need to set the interface MTU before adding it
- * to the bridge, because the bridge will have its
- * MTU adjusted automatically when we add the new interface.
+ /* If an MTU is specified for the new device, set it before
+ * attaching the device to the bridge, as it may affect the MTU of
+ * the bridge (in particular if it is the first device attached to
+ * the bridge, or if it is smaller than the current MTU of the
+ * bridge). If MTU isn't specified for the new device (i.e. 0),
+ * we need to set the interface MTU to the current MTU of the
+ * bridge (to avoid inadvertantly changing the bridge's MTU).
*/
- if (virNetDevSetMTUFromDevice(*ifname, brname) < 0)
- goto error;
+ if (mtu > 0) {
+ if (virNetDevSetMTU(*ifname, mtu) < 0)
+ goto error;
+ } else {
+ if (virNetDevSetMTUFromDevice(*ifname, brname) < 0)
+ goto error;
+ }
+ if (actualMTU) {
+ int retMTU = virNetDevGetMTU(*ifname);
+
+ if (retMTU < 0)
+ goto error;
+
+ *actualMTU = retMTU;
+ }
+
if (virtPortProfile) {
if (virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_MIDONET) {
size_t tapfdSize,
virNetDevVPortProfilePtr virtPortProfile,
virNetDevVlanPtr virtVlan,
+ unsigned int mtu,
+ unsigned int *actualMTU,
unsigned int flags)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_RETURN_CHECK;
size_t tapfdSize ATTRIBUTE_UNUSED,
virNetDevVPortProfilePtr virtPortProfile ATTRIBUTE_UNUSED,
virNetDevVlanPtr virtVlan ATTRIBUTE_UNUSED,
+ unsigned int mtu ATTRIBUTE_UNUSED,
+ unsigned int *actualMTU ATTRIBUTE_UNUSED,
unsigned int fakeflags ATTRIBUTE_UNUSED)
{
VIR_FREE(*ifname);