Neutron-Automaticnetworkmtu-创新互联
现在neutron支持创建不同的网络指定不同的mtu,这个应用场景主要是vlan和vxlan混用的情况下。
创新互联服务项目包括钟山网站建设、钟山网站制作、钟山网页制作以及钟山网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,钟山网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到钟山省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!具体配置
1、neutron.conf network_device_mtu=1450 # 生效的设备:neutron 网络节点上的 qdhcp 和 qrouter network namespace 的 qr,qg 和 ns 接口以及对应的 veth tap 设备 /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网络类型如何获取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网络类型如何获取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网络类型如何获取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网络类型如何获取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版发现neutron多了种网络类型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 # 现在可以把这个去掉 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
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
标题名称:Neutron-Automaticnetworkmtu-创新互联
本文网址:http://scjbc.cn/article/cesioe.html