aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTakeru Hayasaka <hayatake396@gmail.com>2023-01-17 04:45:58 +0900
committerNeale Ranns <neale@graphiant.com>2023-03-31 06:04:42 +0000
commitb23c6f4f29b53afa6be2735b30b08fcb115f20cc (patch)
tree59cca6452dca4b17fbce112ca8f4e5b3004565b7 /test
parent55686e1c59f8bcf399f5ff58b3ca1030a415009c (diff)
ip: support flow-hash gtpv1teid
support with GTPv1 TEID added to the flow hash. This can able to ECMP to PGW and parallelization. Type: feature Change-Id: I6f758579027caf6123831ef2db7afe17e424a6eb Signed-off-by: Takeru Hayasaka <hayatake396@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/test_ip4.py46
1 files changed, 45 insertions, 1 deletions
diff --git a/test/test_ip4.py b/test/test_ip4.py
index 736d8f7bc4c..e6597d24210 100644
--- a/test/test_ip4.py
+++ b/test/test_ip4.py
@@ -6,6 +6,7 @@ import unittest
import scapy.compat
from scapy.contrib.mpls import MPLS
+from scapy.contrib.gtp import GTP_U_Header
from scapy.layers.inet import IP, UDP, TCP, ICMP, icmptypes, icmpcodes
from scapy.layers.inet6 import IPv6
from scapy.layers.l2 import Ether, Dot1Q, ARP
@@ -1210,6 +1211,7 @@ class TestIPLoadBalance(VppTestCase):
"""IP Load-Balancing"""
fhc = VppEnum.vl_api_ip_flow_hash_config_t
+ fhcv2 = VppEnum.vl_api_ip_flow_hash_config_v2_t
af = VppEnum.vl_api_address_family_t
#
@@ -1217,16 +1219,20 @@ class TestIPLoadBalance(VppTestCase):
#
port_ip_pkts = []
port_mpls_pkts = []
+ port_gtp_pkts = []
#
# An array of packets that differ only in the source address
#
src_ip_pkts = []
src_mpls_pkts = []
+ src_gtp_pkts = []
for ii in range(NUM_PKTS):
+ internal_src_ip_hdr = IP(dst="10.0.0.1", src="20.0.0.1")
+
port_ip_hdr = (
- IP(dst="10.0.0.1", src="20.0.0.1")
+ internal_src_ip_hdr
/ UDP(sport=1234, dport=1234 + ii)
/ Raw(b"\xa5" * 100)
)
@@ -1240,6 +1246,15 @@ class TestIPLoadBalance(VppTestCase):
/ port_ip_hdr
)
)
+ port_gtp_pkts.append(
+ (
+ Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
+ / internal_src_ip_hdr
+ / UDP(sport=2152, dport=2152, chksum=0)
+ / GTP_U_Header(gtp_type="g_pdu", teid=200)
+ / Raw(b"\xa5" * 100)
+ )
+ )
src_ip_hdr = (
IP(dst="10.0.0.1", src="20.0.0.%d" % ii)
@@ -1256,6 +1271,15 @@ class TestIPLoadBalance(VppTestCase):
/ src_ip_hdr
)
)
+ src_gtp_pkts.append(
+ (
+ Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac)
+ / IP(dst="10.0.0.1", src="20.0.0.1")
+ / UDP(sport=2152, dport=2152, chksum=0)
+ / GTP_U_Header(gtp_type="g_pdu", teid=ii)
+ / Raw(b"\xa5" * 100)
+ )
+ )
route_10_0_0_1 = VppIpRoute(
self,
@@ -1331,6 +1355,26 @@ class TestIPLoadBalance(VppTestCase):
self.send_and_expect_only(self.pg0, port_ip_pkts, self.pg2)
#
+ # this case gtp v1 teid key LB
+ #
+ self.vapi.set_ip_flow_hash_v3(
+ af=af.ADDRESS_IP4,
+ table_id=0,
+ flow_hash_config=(
+ fhcv2.IP_API_V2_FLOW_HASH_SRC_IP
+ | fhcv2.IP_API_V2_FLOW_HASH_PROTO
+ | fhcv2.IP_API_V2_FLOW_HASH_GTPV1_TEID
+ ),
+ )
+ self.logger.info(self.vapi.cli("show ip fib"))
+
+ self.send_and_expect_load_balancing(
+ self.pg0, src_gtp_pkts, [self.pg1, self.pg2]
+ )
+
+ self.send_and_expect_only(self.pg0, port_gtp_pkts, self.pg2)
+
+ #
# change the flow hash config back to defaults
#
self.vapi.set_ip_flow_hash(vrf_id=0, src=1, dst=1, proto=1, sport=1, dport=1)