您好,登錄后才能下訂單哦!
現(xiàn)在neutron支持創(chuàng)建不同的網(wǎng)絡(luò)指定不同的mtu,這個應(yīng)用場景主要是vlan和vxlan混用的情況下。
具體配置
1、neutron.conf network_device_mtu=1450 # 生效的設(shè)備:neutron 網(wǎng)絡(luò)節(jié)點上的 qdhcp 和 qrouter network namespace 的 qr,qg 和 ns 接口以及對應(yīng)的 veth tap 設(shè)備 /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(self.conf.network_device_mtu)
2、ml2_conf.ini path_mtu = 9000 segment_mtu = 1500
flat網(wǎng)絡(luò)類型如何獲取MTU: /usr/lib/python2.7/site-packages/neutron/plugins/ml2/drivers/type_flat.py class FlatTypeDriver(helpers.BaseTypeDriver): # 父類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) # 如果定義了flat provider的physet_mtus,取physical_network_mtus和segment_mtu的最小值 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.py class 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網(wǎng)絡(luò)類型如何獲取MTU: class VlanTypeDriver(helpers.SegmentTypeDriver): # 父類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的獲取mtu方式和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.py class 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 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網(wǎng)絡(luò)類型如何獲取MTU: class VxlanTypeDriver(type_tunnel.EndpointTunnelTypeDriver): # 父類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} 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開銷,自動減去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 overhead GENEVE_ENCAP_MIN_OVERHEAD = 50 GRE_ENCAP_OVERHEAD = 42 VXLAN_ENCAP_OVERHEAD = 50 # vxlan開銷 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: 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
gre網(wǎng)絡(luò)類型如何獲取MTU: class GreTypeDriver(type_tunnel.EndpointTunnelTypeDriver): # 父類也是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): 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開銷,自動減去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 overhead GENEVE_ENCAP_MIN_OVERHEAD = 50 GRE_ENCAP_OVERHEAD = 42 # gre開銷,為什么是42,還不清楚 VXLAN_ENCAP_OVERHEAD = 50 # vxlan開銷 L版發(fā)現(xiàn)neutron多了種網(wǎng)絡(luò)類型geneve,Geneve簡介,暫時還不知道怎么玩的 http://blog.csdn.net/yeasy/article/details/39928153
3、neutron.conf advertise_mtu = true 以前的做法: [root@controller2 ~(keystone_admin)]# cat /etc/neutron/dnsmasq-neutron.conf # 對所有network都生效 dhcp-option-force=26,1450 # 現(xiàn)在可以把這個去掉 log-facility=/var/log/neutron/neutron-dnsmasq.log /usr/lib/python2.7/site-packages/neutron/agent/linux/dhcp.py class 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) # 看這里 # 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)
參考鏈接
http://www.cnblogs.com/sammyliu/p/5079898.html
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。