We can configure user-defined flex hashing to load-balance MPLS traffic based on TCP or UDP source and destination port information. User-defined flex hashing, which supports protocol versions IPv4 and IPv6, enables you to set byte offsets in packet headers to influence hashing computation. We specify two offsets, each 2 bytes in length, from the first 128 bytes of a packet. You can configure the selected bytes to be directly used for hashing or to be used only when the data pattern in these bytes matches specific values (conditional match). To provide load balancing in spine layers, configure flex hashing and encapsulate the traffic in VXLAN, thus enabling entropy at UDP source ports. At de-encapsulation, configure the no-inner-payload statement to load-balance based on the outer UDP header.
To configure user-defined flex hashing:
set forwarding-options enhanced-hash-key flex-hashing name ethtype mpls num-labels num_labels hash-offset offset1 base-offset1 offset1-value offset1_value offset1-mask offset1_mask offset2 base-offset2 offset2-value offset2_value offset2-mask offset2_mask
To configure a conditional match (repeat the following command with values for offsets and match data 2-4):
set forwarding-options enhanced-hash-key conditional-match name offset1 base-offset1 offset1-value offset1_value offset1-mask offset1_mask matchdata1 matchdata1 matchdata1-mask matchdata1-mask
To enable load balancing on VXLAN transit traffic based on the outer UDP header:
set forwarding-options enhanced-hash-key vxlan no-inner-payload
To troubleshoot, use the show forwarding-options enhanced-hash-key command.
Limitations:
- Use a maximum of two MPLS labels.
- Use only even values for offset1 and offset2.
- If you are using conditional matches, configure the conditions before you attach them to the flex-hashing entry.
- An aggregated Ethernet (ae) or LAG interface is not supported as an input interface. You can configure input interfaces on LAGs by configuring the same user-defined flex-hashing data and the same conditional-match data on all member interfaces of a LAG interface.
- Apply a similar set of commands to the various member interfaces. For example, if the members of a particular LAG are xe-0/0/2, xe-0/0/3, and xe-0/0/4, configure three slightly different flex-hashing rules on those individual member interfaces?the rules are identical except that they have different names for the incoming traffic:
- set forwarding-options enhanced-hash-key flex-hashing FLEX_L2_V6_TCP_4 ethtype mpls interface xe-0/0/2
set forwarding-options enhanced-hash-key flex-hashing FLEX_L2_V6_TCP_4 ethtype mpls num-labels 2
set forwarding-options enhanced-hash-key flex-hashing FLEX_L2_V6_TCP_4 ethtype mpls conditional-match COND_L2_V6_TCP_4
set forwarding-options enhanced-hash-key flex-hashing FLEX_L2_V6_TCP_4 ethtype mpls hash-offset offset1 base-offset1 start-of-L3-OuterHeader
set forwarding-options enhanced-hash-key flex-hashing FLEX_L2_V6_TCP_4 ethtype mpls hash-offset offset1 offset2 offset2-mask ffff
[...configuration commands truncated...] - set forwarding-options enhanced-hash-key flex-hashing FLEX_L2_V6_TCP_5 ethtype mpls interface xe-0/0/3
[...configuration commands truncated...] - set forwarding-options enhanced-hash-key flex-hashing FLEX_L2_V6_TCP_6 ethtype mpls interface xe-0/0/4
[...configuration commands truncated...] - Use unique flex-data profile names and unique conditional-data profile names for each member interface?for example, in the following conditional-data profile names, the port number is unique in each instance:
- ...enhanced-hash-key conditional-match COND_L1_V6_UDP_SRC_PORT_1...
- ...enhanced-hash-key conditional-match COND_L1_V6_UDP_SRC_PORT_2...