Set up MTU docker interface

Kuryr should load neutron network mtu and set it on interface.
UT will fixed in a seperate patch

Related kuryr-libnetwork patch:
https://review.openstack.org/#/c/355714/

Change-Id: I89f1228e3596c7bd0b98312f5187cffe95d333e7
Partial-bug: #1613528
This commit is contained in:
Liping Mao 2016-08-16 12:07:58 +08:00
parent b75dddbdfc
commit 5ec8cedbdd
1 changed files with 9 additions and 1 deletions

View File

@ -34,6 +34,7 @@ SUBNET_ID_KEY = 'subnet_id'
UNBINDING_SUBCOMMAND = 'unbind'
VIF_TYPE_KEY = 'binding:vif_type'
VIF_DETAILS_KEY = 'binding:vif_details'
DEFAULT_NETWORK_MTU = 1500
_IPDB_CACHE = None
_IPROUTE_CACHE = None
@ -97,7 +98,8 @@ def cleanup_veth(ifname):
return None
def port_bind(endpoint_id, neutron_port, neutron_subnets):
def port_bind(endpoint_id, neutron_port, neutron_subnets,
neutron_network=None):
"""Binds the Neutron port to the network interface on the host.
:param endpoint_id: the ID of the endpoint as string
@ -105,6 +107,7 @@ def port_bind(endpoint_id, neutron_port, neutron_subnets):
python-neutronclient
:param neutron_subnets: a list of all subnets under network to which this
endpoint is trying to join
:param neutron_network: network which this endpoint is trying to join
:returns: the tuple of the names of the veth pair and the tuple of stdout
and stderr returned by processutils.execute invoked with the
executable script for binding
@ -116,6 +119,10 @@ def port_bind(endpoint_id, neutron_port, neutron_subnets):
port_id = neutron_port['id']
ifname, peer_name = utils.get_veth_pair_names(port_id)
subnets_dict = {subnet['id']: subnet for subnet in neutron_subnets}
if neutron_network is None:
mtu = DEFAULT_NETWORK_MTU
else:
mtu = neutron_network.get('mtu', DEFAULT_NETWORK_MTU)
try:
with ip.create(ifname=ifname, kind=KIND_VETH,
@ -132,6 +139,7 @@ def port_bind(endpoint_id, neutron_port, neutron_subnets):
subnet = subnets_dict[subnet_id]
cidr = netaddr.IPNetwork(subnet['cidr'])
peer_veth.add_ip(fixed_ip[IP_ADDRESS_KEY], cidr.prefixlen)
peer_veth.set_mtu(mtu)
peer_veth.address = neutron_port[MAC_ADDRESS_KEY].lower()
if not _is_up(peer_veth):
peer_veth.up()