Neutron now supports the creation of different networks to specify different MTU, the scenario is primarily VLAN and Vxlan mixed.
Specific configuration
1. neutron.confnetwork_device_mtu=1450 # Devices in force: the namespace and NS interfaces of QDHCP and Qrouter network QR,QG and the corresponding Veth T on neutron networking nodes AP Device/usr/lib/python2.7/site-packages/neutron/agent/linux/interface.py If Self.conf.network_device_mtu:ns_dev . LINK.SET_MTU (SELF.CONF.NETWORK_DEVICE_MTU) if SELF.CONF.OVS_USE_VETH:ROOT_DEV.LINK.SET_MTU (sel F.CONF.NETWORK_DEVICE_MTU)
2, ML2_CONF.INIPATH_MTU = 9000SEGMENT_MTU = 1500
Flat how network types get mtu: /usr/lib/python2.7/site-packages/neutron/plugins/ml2/drivers/type_flat.pyclass Flattypedriver (helpers. Basetypedriver): # Parent class basetypedriver "" "Manage state for flat networks with ML2. The FlatTypeDriver implements the ' flat ' network_type. flat network segments provide connectivity between VMs and other devices Using any connected ieee 802.1d conformant physical_network, without the use of VLAN tags, tunneling, or Other segmentation mechanisms. therefore at most one flat network segment can exist on each available physical_network. "" " def __init__ (self): Super (Flattypedriver, self). __init__ () self._parse_ Networks (CFG. CONF.ml2_type_flat.flat_networks) # if flat is defined Provider Physet_mtus, take physical_network_mtus and segment_mtu the minimum value def get_mtu (self, physical_network): seg_mtu = super ( flattypedriver, self). GET_MTU () mtu = [] if seg_mtu > 0: mtu.append (SEG_MTU) if physical_network in self.physnet_mtus: mtu.append (int (self).Physnet_mtus[physical_network]) return min (MTU) if mtu else 0 /usr/lib/python2.7/site-packages/ Neutron/plugins/ml2/drivers/helpers.pyclass basetypedriver (API. Typedriver): "" "Basetypedriver for functions common to segment and flat. "" " def __init__ (self): try: self.physnet_mtus = utils.parse_ Mappings ( cfg. conf.ml2.physical_network_mtus ) except Exception: self.physnet_mtuS = []    DEF GET_MTU (Self, physical_network=none): return cfg. CONF.ml2.segment_mtu
VLAN network type How to obtain Mtu: class vlantypedriver (helpers. Segmenttypedriver): # Parent class segmenttypedriver "" "Manage state for VLAN networks with ML2. The VlanTypeDriver implements the ' VLAN ' network_type. vlan network segments provide connectivity between VMs and other devices Using any connected ieee 802.1q conformant physical_network segmented into virtual networks via IEEE 802.1Q Headers. up to 4094 vlan network segments can exist on each available physical_network. "" " def __init__ (self): super (Vlantypedriver, self). __init__ (vlanallocation) self._parse_network _vlan_ranges () # vlan gets the same MTU as flat  DEF GET_MTU (self, physical_network):         SEG_MTU = super (vlantypedriver, self). GET_MTU () mtu = [] if seg_mtu > 0: mtu.append (SEG_MTU) if physical_network in self.physnet_mtus: mtu.append (int (self.physnet_mtus[physical_network)) return min (MTU) if mtu else 0 /usr/lIb/python2.7/site-packages/neutron/plugins/ml2/drivers/helpers.pyclass basetypedriver (API. Typedriver): "" "Basetypedriver for functions common to segment and flat. "" " def __init__ (self): try: self.physnet_mtus = utils.parse_ Mappings ( cfg. conf.ml2.physical_network_mtus ) except Exception: self.physnet_mtus = [] def get_mtu (Self, physical_network=none): return cfg. conf.ml2.segment_mtu &Nbsp; class segmenttypedriver (basetypedriver): "" " segmenttypedriver for segment allocation. provide methods helping to perform segment allocation fully or partially specified. "" " def __init__ (Self, model): super (segmenttypedriver, self). __init__ () self.model = model Self.primary_keys = set (Dict (model.__table__.columns)) self.primary_keys.remove ("allocated")
Vxlan How the network type gets Mtu:class vxlantypedriver (Type_tunnel. Endpointtunneltypedriver): # Parent class endpointtunneltypedriver def __init__ (self): super (vxlantypedriver, self). __init__ ( vxlanallocation, vxlanendpoints) def get_type (self): return p_ Const. Type_vxlan def initialize (self): Try: self._initialize (CFG. CONF.ml2_type_vxlan.vni_ranges) except n_exc. Networktunnelrangeerror: log.exception ( _le ("failed to parse vni_ranges. " "service terminated!")) raise systemexit () def get_endpoints ( Self): "" "Get every vxlan endpoints from database. "" " vxlan_endpoints = self._get_endpoints () return [{' IP_Address ': vxlan_endpoint.ip_address, ' Udp_port ': vxlan_endpoint.udp_port, ' host ':  VXLAN_ENDPOINT.HOST} &NBsp; for vxlan_ Endpoint in vxlan_endpoints] def add_endpoint (Self, ip, host, udp_port=p_const. Vxlan_udp_port): return self._add_endpoint (Ip, host, udp_port=udp_port) def get_mtu (self, physical_network=none): mtu = super (vxlantypedriver, self). GET_MTU () return mtu - p_const. Vxlan_encap_overhead if mtu else 0 # mtu - vxlan cost, auto minus VXLAN overhead from neutron.plugins.common import constants as p_const/usr/lib/python2.7/site-packages/neutron/plugins/common/constants.py# network type mtu overheadgenEve_encap_min_overhead = 50gre_encap_overhead = 42vxlan_encap_overhead = 50 # vxlan overhead Class endpointtunneltypedriver (tunneltypedriver): Class TunnelTypeDriver ( Helpers. Segmenttypedriver): "" "define stable abstract interface for ml2 type drivers. tunnel type networks rely on Tunnel endpoints. this class defines abstract methods to manage these endpoints. "" " def get_mtu ( Self, physical_network=none): seg_mtu = super ( tunneltypedriver, self). GET_MTU () mtu = [] if seg_mtu > 0: &nbSp; mtu.append (SEG_MTU) if cfg. conf.ml2.path_mtu > 0: Mtu.append (CFG. CONF.ML2.PATH_MTU) return min (MTU) if mtu Else 0
How the GRE network type gets Mtu:class gretypedriver (Type_tunnel. Endpointtunneltypedriver): # Parent class is also endpointtunneltypedriver Def __init__ (self): super (gretypedriver, self). __init __ ( greallocation, greendpoints) def get_type (self): return p_ Const. Type_gre def initialize (self): try: self._initialize (CFG. CONF.ml2_type_gre.tunnel_id_ranges) except n_exc. Networktunnelrangeerror: log.exception ( _le ("failed to parse tunnel_id_ranges. " "service terminated!")) raise systemexit () def get_endpoints (self): "" "Get every gre endpoints from database. "" " gre_endpoints = self._get_endpoints () return [{' IP_Address ': gre_endpoint.ip_address, ' host ': gre_ endpoint.host} For gre_endpoint in gre_endpoints] def add_endpoint (Self, ip, host):  &NBsp; return self._add_endpoint (ip, host) DEF GET_MTU (self, physical_network=none): mtu = super (gretypedriver, self). GET_MTU (physical_network) return mtu - p_const. Gre_encap_overhead if mtu else 0 # mtu - gre Overhead , Auto minus gre overhead from neutron.plugins.common import constants as p_const/usr/lib/python2.7/site-packages/neutron/plugins/common/constants.py # network type mtu overheadgeneve_encap_min_overhead = 50gre_encap_overhead = 42 # gre overhead, why is 42, not yet clear vxlan_encap_overhead = 50 # vxlan overhead L version found neutron more kinds of network type Geneve,geneve introduction, temporarily do not know how to play http://blog.csdn.net/yeasy/article/details/39928153
3, Neutron.confadvertise_mtu = true Previous practice: [[Email protected] ~ (Keystone_admin)]# cat /etc/neutron/dnsmasq-neutron.conf # is effective for all network dhcp-option-force=26,1450 # now we can get rid of this log-facility=/var/log/neutron/neutron-dnsmasq.log/usr/lib/python2.7/site-packages/. NEUTRON/AGENT/LINUX/DHCP.PYCLASS DNSMASQ (dhcplocalprocess): # the ports that need to be opened when security policies are active # on the Neutron port used for DHCP. These are provided as a convenience # for users of this class. if cfg. conf.advertise_mtu: mtu = Self.network.mtu # do not advertise unknown mtu if mtu > 0: cmd.append ('--dhcp-option-force= option:mtu,%d ' % mtu) # see here # cap the limit because creating lots of subnets can inflate # this possible lease cap. cmd.append ('--dhcp-lease-max=%d ' % min (possible_leases, Self.conf.dnsmasq_lease_max)) cmd.append ('--conf-file=%s ' % self.conf.dnsmasq_confiG_file) if self.conf.dnsmasq_dns_servers: cmd.extend ( '--server=%s ' % server for server in Self.conf.dnsmasq_dns_servers)
Reference links
Http://www.cnblogs.com/sammyliu/p/5079898.html
This article is from the "The-way-to-cloud" blog, make sure to keep this source http://iceyao.blog.51cto.com/9426658/1784871
Neutron-automatic Network MTU