Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Openstack Jumbo Frame adjustment practice

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Jumbo Frame (jumbo frame)

The IEEE 802.3 Ethernet standard specifies only the frame MTU that supports 1500Byte, with a total frame size of 1518Byte. (increase to 1522Byte when using IEEE 802.1Q VLAN/QoS tags) while jumbo frames tend to use the frame MTU of 9000Byte, which adds up the frame size of 9018/9022Byte.

Jumbo frames are not yet part of the official IEEE 802.3 Ethernet standard. Therefore, different hardware manufacturers may have different degrees of device support.

Using jumbo frames, the increased effective message length improves the efficiency of bandwidth use (see figure below). At the same time, the growth of messages also brings an increase in transmission delay, delay-sensitive data is not suitable for the use of giant frame transmission.

MTU configuration items in neutron

To sum up from the description of the configuration item, global_physnet_mtu and physical_network_mtus jointly define the MTU,path_mtu of underlay physical network and the MTU of overlay network.

* * 3 use cases for adjusting MTU

Single MTU value physical network system * *

In neutron.conf

1. [DEFAULT]

2.global_physnet_mtu = 900,

In ml2.ini

1. [ml2]

2.path_mtu = 9000

This configuration defines an MTU value of 9000 for all underlay networks (flat,vlan) and overlay networks (vxlan,gre).

Multi-MTU value physical network system

In neutron.conf

1. [DEFAULT]

2.global_physnet_mtu = 9000

In ml2.ini

1. [ovs]

2. Bridge_mappings = provider1:eth2,provider2:eth3,provider3:eth4

3. [ml2]

4. Physical_network_mtus = provider2:4000,provider3:1500

5. Path_mtu = 9000

This configuration defines an MTU value of 4000 for underlay network provider2, 1500 for provider2 3, and 9000 for others, such as provider1. The MTU value of overlay network is 9000.

Overlay Network MTU

In neutron.conf

[DEFAULT]

2. Global_physnet_mtu = 9000

In ml2.ini

[ml2]

2. Path_mtu = 4000

This configuration defines that the MTU value of all underlay networks is 9000 and the MTU value of overlay networks is 4000.

Code analysis

MTU processing when creating a network resource

Flat and vlan networks, according to the actual physical network mapping and physical_network_mtus, global_physnet_mtu information, obtain the minimum available MTU value.

1. Def get_deployment_physnet_mtu ():

2. Return cfg.CONF.global_physnet_mtu

3.

4. Class BaseTypeDriver (api.ML2TypeDriver):

5. Def init (self):

6. Try:

7. Self.physnet_mtus = helpers.parse_mappings (

8. Cfg.CONF.ml2.physical_network_mtus, unique_values=False

9.)

10. Except Exception as e:

11. LOG.error ("Failed to parse physical_network_mtus:% s", e)

12. Self.physnet_mtus = []

13.

14. Def get_mtu (self, physical_network=None):

15. Return p_utils.get_deployment_physnet_mtu ()

16.

17. Class FlatTypeDriver (helpers.BaseTypeDriver):

18....

19. Def get_mtu (self, physical_network):

20. Seg_mtu = super (FlatTypeDriver, self) .get_mtu

21. Mtu = []

twenty-two。 If seg_mtu > 0:

23. Mtu.append (seg_mtu)

24. If physical_network in self.physnet_mtus:

25. Mtu.append (int (self.physnet_ mtus [physical _ network]))

twenty-six。 Return min (mtu) if mtu else 0

twenty-seven。

twenty-eight。 Class VlanTypeDriver (helpers.SegmentTypeDriver):

twenty-nine。 ...

thirty。 Def get_mtu (self, physical_network):

thirty-one。 Seg_mtu = super (VlanTypeDriver, self). Get_mtu ()

thirty-two。 Mtu = []

thirty-three。 If seg_mtu > 0:

thirty-four。 Mtu.append (seg_mtu)

thirty-five。 If physical_network in self.physnet_mtus:

thirty-six。 Mtu.append (int (self.physnet_ mtus [physical _ network]))

thirty-seven。 Return min (mtu) if mtu else 0

For Geneve,Gre,Vxlan type network, the minimum available MTU value is selected according to global_physnet_mtu and path_mtu, and the actual available MTU value is obtained by subtracting the header overhead of each type of message.

1. Class _ TunnelTypeDriverBase (helpers.SegmentTypeDriver):

2....

3. Def get_mtu (self, physical_network=None):

4. Seg_mtu = super (_ TunnelTypeDriverBase, self) .get_mtu ()

5. Mtu = []

6. If seg_mtu > 0:

7. Mtu.append (seg_mtu)

8. If cfg.CONF.ml2.path_mtu > 0:

9. Mtu.append (cfg.CONF.ml2.path_mtu)

10. Version = cfg.CONF.ml2.overlay_ip_version

11. Ip_header_length = pauper.IProomHEADERLENGTH [version]

Return min (mtu)-ip_header_length if mtu else 0

13.

Class GeneveTypeDriver (type_tunnel.EndpointTunnelTypeDriver):

15....

Def get_mtu (self, physical_network=None):

Mtu = super (GeneveTypeDriver, self). Get_mtu ()

Return mtu-self.max_encap_size if mtu else 0

19.

Class GreTypeDriver (type_tunnel.EndpointTunnelTypeDriver):

21. ...

Def get_mtu (self, physical_network=None):

23. Mtu = super (GreTypeDriver, self). Get_mtu (physical_network)

24. Return mtu-p_const.GRE_ENCAP_OVERHEAD if mtu else 0

25.

Class VxlanTypeDriver (type_tunnel.EndpointTunnelTypeDriver):

twenty-seven。 ...

Def get_mtu (self, physical_network=None):

Mtu = super (VxlanTypeDriver, self). Get_mtu ()

Return mtu-p_const.VXLAN_ENCAP_OVERHEAD if mtu else 0

When the user actually creates the network resource, if the network MTU value is not explicitly specified, the system-defined maximum available MTU under that network type is used. Explicitly specifying MTU,neutron checks whether the user-defined MTU is less than or equal to the system-defined maximum available MTU for that network type.

1. Def _ get_network_mtu (self, network_db, validate=True):

2. Mtus = []

3....

4. For s in segments:

5. Segment_type = s.get ('network_type')

6. If segment_type is None:

7....

8. Else:

9. Mtu = type_driver.get_mtu (s ['physical_network'])

Some drivers, like 'local', may return None; the assumption

11. # then is that for the segment type, MTU has no meaning or

Unlimited, and so we should then ignore those values.

13. If mtu:

14. Mtus.append (mtu)

15.

Max_mtu = min (mtus) if mtus else p_utils.get_deployment_physnet_mtu ()

Net_mtu = network_db.get ('mtu')

18.

19. If validate:

20. # validate that requested mtu conforms to allocated segments

21. If net_mtu and max_mtu and max_mtu

< net_mtu: msg = _("Requested MTU is too big, maximum is %d") % max_mtu raise exc.InvalidInput(error_message=msg) 24. 25. # if mtu is not set in database, use the maximum possible return net_mtu or max_mtu 虚拟机tap设置MTU 在使用Linux Bridge实现的Neutron网络中,Linux Bridge Agent在侦测到新的device后,会通过ip link set 操作,根据network中的MTU值,设置虚拟机绑定至Linux Bridge的tap设备的MTU值。反观Openvswitch实现的网络中却没有相关的设置。实际在使用过程中需要通过ovs-vsctl set Interface mtu_request=命令人工去设置tap设备的MTU值。

1. Class LinuxBridgeManager (amb.CommonAgentManagerBase):

2. Def plug_interface (self, network_id, network_segment, tap_name

3. Device_owner):

4. Return self.add_tap_interface (network_id, network_segment.network_type

5. Network_segment.physical_network

6. Network_segment.segmentation_id

7. Tap_name, device_owner

8. Network_segment.mtu)

9.

10. Def _ set_tap_mtu (self, tap_device_name, mtu):

Ip_lib.IPDevice (tap_device_name) link.set_mtu (mtu)

Network device tap sets MTU

When dhcp and router-related tap devices are in plug, neutron will run "ip link set mtu" in the namespace where each tap device is located to set the tap device MTU value according to the MTU of the network.

1. Class OVSInterfaceDriver (LinuxInterfaceDriver):

Def plug_new (self, network_id, port_id, device_name, mac_address

3. Bridge=None, namespace=None, prefix=None, mtu=None):

4....

5. # NOTE (ihrachys): the order here is significant: we must set MTU after

6. # the device is moved into a namespace, otherwise OVS bridge does not

7. # allow to set MTU that is higher than the least of all device MTUs on

8. # the bridge

9. If mtu:

10. Self.set_mtu (device_name, mtu, namespace=namespace, prefix=prefix)

11. Else:

12. LOG.warning ("No MTU configured for port% s", port_id)

13....

14.

Def set_mtu (self, device_name, mtu, namespace=None, prefix=None):

16. If self.conf.ovs_use_veth:

Tap_name = self._get_tap_name (device_name, prefix)

Root_dev, ns_dev = _ get_veth (

19. Tap_name, device_name, namespace2=namespace)

20. Root_dev.link.set_mtu (mtu)

Else:

Ns_dev = ip_lib.IPWrapper (namespace=namespace) .device (device_name)

23. Ns_dev.link.set_mtu (mtu)

24.

Class IpLinkCommand (IpDeviceCommandBase):

COMMAND = 'link'

twenty-seven。 ...

twenty-eight。 Def set_mtu (self, mtu_size):

twenty-nine。 Self._as_root ([], ('set', self.name,' mtu', mtu_size))

Inter-bridge veth setting MTU

Since the J version of Openstack, neutron uses ovs patch port instead of linux veth to implement the connection between OVS bridges (for performance improvement). But still retain the way of veth connection. You can enable the veth connection bridge in openvswitch_agent.ini by configuring use_veth_interconnection=true. If this configuration is enabled, the default veth_ MTU value is 9000. When the configuration link MTU is greater than 9000, you need to modify the value of veth_mtu in the openvswitch_agent.ini configuration file to avoid a bottleneck effect.

1. Class OVSNeutronAgent (l2population_rpc.L2populationRpcCallBackTunnelMixin

2. Dvr_rpc.DVRAgentRpcCallbackMixin):

3. Def init (self, bridge_classes, ext_manager, conf=None):

4....

5. Self.use_veth_interconnection = ovs_conf.use_veth_interconnection

6. Self.veth_mtu = agent_conf.veth_mtu

7....

8. Def setup_physical_bridges (self, bridge_mappings):

9. 'Setup the physical network bridges.

10.

11. Creates physical network bridges and links them to the

12. Integration bridge using veths or patch ports.

13.

14.: param bridge_mappings: map physical network names to bridge names.

15.''

16. Self.phys_brs = {}

17. Self.int_ofports = {}

18. Self.phys_ofports = {}

19. Ip_wrapper = ip_lib.IPWrapper ()

20. Ovs = ovs_lib.BaseOVS ()

21. Ovs_bridges = ovs.get_bridges ()

twenty-two。 For physical_network, bridge in bridge_mappings.items ():

23. ...

24. If self.use_veth_interconnection:

25. # enable veth to pass traffic

twenty-six。 Int_veth.link.set_up ()

twenty-seven。 Phys_veth.link.set_up ()

twenty-eight。 If self.veth_mtu:

twenty-nine。 # set up mtu size for veth interfaces

thirty。 Int_veth.link.set_mtu (self.veth_mtu)

thirty-one。 Phys_veth.link.set_mtu (self.veth_mtu)

thirty-two。 Else:

thirty-three。 # associate patch ports to pass traffic

thirty-four。 Self.int_br.set_db_attribute ('Interface', int_if_name

thirty-five。 'options', {' peer': phys_if_name})

thirty-six。 Br.set_db_attribute ('Interface', phys_if_name

thirty-seven。 'options', {' peer': int_if_name})

How to set MTU for virtual machine network card

The configuration of MTU in the internal network card of the virtual machine is to request the IP address through the virtual machine DHCP and request the MTU value by the way. Interface MTU Option is clearly defined in RFC2132 DHCP Option and BOOTP Vendor Extensions. DHCP Option Code 26 defines the MTU value of the network interface with two bytes of MTU data. As shown in the table below.

In DHCP agent, the spawn_process of dnsmasq adjusts its startup parameters according to the MTU value of network. So that the virtual machine can correctly configure the MTU value of its own network card in the process of DHCP.

1. Class Dnsmasq (DhcpLocalProcess):

2. Def _ build_cmdline_callback (self, pid_file):

3. # We ignore local resolv.conf if dns servers are specified

4. # or if local resolution is explicitly disabled.

5....

6. Mtu = getattr (self.network, 'mtu', 0)

7. # Do not advertise unknown mtu

8. If mtu > 0:

9. Cmd.append ('--dhcp-option-force=option:mtu,%d'% mtu)

10....

11. Return cmd

Probe MTU

Detect whether the ICMP value is set correctly by specifying the size of the MTU message content and the non-fragmentation of the IP message. Note that the size here refers to icmp data size. The size does not include ICMP header length (8Byte) and IP header length (20Byte).

Under windows:

1. Ping-f-l

Under linux:

Ping-M do-s

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report