Skip to content

Commit

Permalink
Use mtu setting from table instead of flag
Browse files Browse the repository at this point in the history
Adds mtu to argument lists of key methods and configuration of vlan
interface. Also adds deprecation notice to the "help" info for the file
based network_device_mtu configuration property.

Partially-implements blueprint better-support-for-multiple-networks

Change-Id: Ia401eb95ce8c81d104e59b0348e3474655b9a992
  • Loading branch information
vishvananda committed Jul 2, 2014
1 parent aae8408 commit 4467013
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
25 changes: 16 additions & 9 deletions nova/network/linux_net.py
Expand Up @@ -1269,12 +1269,14 @@ def _ip_bridge_cmd(action, params, device):
return cmd


def _set_device_mtu(dev):
def _set_device_mtu(dev, mtu=None):
"""Set the device MTU."""

if CONF.network_device_mtu:
if not mtu:
mtu = CONF.network_device_mtu
if mtu:
utils.execute('ip', 'link', 'set', dev, 'mtu',
CONF.network_device_mtu, run_as_root=True,
mtu, run_as_root=True,
check_exit_code=[0, 2, 254])


Expand Down Expand Up @@ -1418,7 +1420,8 @@ def plug(self, network, mac_address, gateway=True):
network['bridge'],
iface,
network,
mac_address)
mac_address,
network.get('mtu'))
iface = 'vlan%s' % vlan
else:
iface = CONF.flat_interface or network['bridge_interface']
Expand Down Expand Up @@ -1455,10 +1458,12 @@ def get_dev(self, network):

@staticmethod
def ensure_vlan_bridge(vlan_num, bridge, bridge_interface,
net_attrs=None, mac_address=None):
net_attrs=None, mac_address=None,
mtu=None):
"""Create a vlan and bridge unless they already exist."""
interface = LinuxBridgeInterfaceDriver.ensure_vlan(vlan_num,
bridge_interface, mac_address)
bridge_interface, mac_address,
mtu)
LinuxBridgeInterfaceDriver.ensure_bridge(bridge, interface, net_attrs)
return interface

Expand All @@ -1470,7 +1475,7 @@ def remove_vlan_bridge(vlan_num, bridge):

@staticmethod
@utils.synchronized('lock_vlan', external=True)
def ensure_vlan(vlan_num, bridge_interface, mac_address=None):
def ensure_vlan(vlan_num, bridge_interface, mac_address=None, mtu=None):
"""Create a vlan unless it already exists."""
interface = 'vlan%s' % vlan_num
if not device_exists(interface):
Expand All @@ -1487,7 +1492,9 @@ def ensure_vlan(vlan_num, bridge_interface, mac_address=None):
check_exit_code=[0, 2, 254])
_execute('ip', 'link', 'set', interface, 'up', run_as_root=True,
check_exit_code=[0, 2, 254])
_set_device_mtu(interface)
# NOTE(vish): set mtu every time to ensure that changes to mtu get
# propogated
_set_device_mtu(interface, mtu)
return interface

@staticmethod
Expand Down Expand Up @@ -1698,7 +1705,7 @@ def plug(self, network, mac_address, gateway=True):
'external-ids:attached-mac=%s' % mac_address])
_execute('ip', 'link', 'set', dev, 'address', mac_address,
run_as_root=True)
_set_device_mtu(dev)
_set_device_mtu(dev, network.get('mtu'))
_execute('ip', 'link', 'set', dev, 'up', run_as_root=True)
if not gateway:
# If we weren't instructed to act as a gateway then add the
Expand Down
3 changes: 2 additions & 1 deletion nova/objects/network.py
Expand Up @@ -31,7 +31,8 @@
'for DHCP will be added on each nova-network node which '
'is only visible to the vms on the same host.'),
cfg.IntOpt('network_device_mtu',
help='MTU setting for network interface'),
help='DEPRECATED: THIS VALUE SHOULD BE SET WHEN CREATING THE '
'NETWORK. MTU setting for network interface.'),
]

CONF = cfg.CONF
Expand Down
2 changes: 1 addition & 1 deletion nova/tests/network/test_linux_net.py
Expand Up @@ -520,7 +520,7 @@ def test_vlan_override(self):
info = {}

@staticmethod
def test_ensure(vlan, bridge, interface, network, mac_address):
def test_ensure(vlan, bridge, interface, network, mac_address, mtu):
info['passed_interface'] = interface

self.stubs.Set(linux_net.LinuxBridgeInterfaceDriver,
Expand Down

0 comments on commit 4467013

Please sign in to comment.