summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsongyanchao <[email protected]>2023-10-20 02:48:07 +0000
committersongyanchao <[email protected]>2023-10-20 02:48:07 +0000
commitbee81db36e1d2d37215a87e75ea34f58e2d1f796 (patch)
tree30b0609a6654cde5200e7b59b91e31d344364c2c /test
parent389699671f7d8e12241b4a7a37f2afd4ed28145e (diff)
🎈 perf(DPISDN-21): Optimize pkt_classifier_engine data structures
Optimize pkt_classifier_engine data structures
Diffstat (limited to 'test')
-rw-r--r--test/classifier_test.py187
1 files changed, 185 insertions, 2 deletions
diff --git a/test/classifier_test.py b/test/classifier_test.py
index 56a2bdb..5b54455 100644
--- a/test/classifier_test.py
+++ b/test/classifier_test.py
@@ -227,7 +227,7 @@ vwire_id=0
@group("classifier_base_test")
-class TestForBase(BaseTest):
+class BaseForLinearSearch(BaseTest):
def setUp(self):
self.dataplane = ptf.dataplane_instance
@@ -334,6 +334,128 @@ class TestForBase(BaseTest):
finally:
mrzcpd.stop()
+
+@group("classifier_base_test")
+class TestForTreeSearch(BaseTest):
+ def setUp(self):
+ self.dataplane = ptf.dataplane_instance
+
+ def __init__(self):
+ BaseTest.__init__(self)
+
+ def runTest(self):
+ try:
+ # Init & Start mrzcpd
+ global base_conf
+ for i in range(8,128):
+ base_conf += "[classifier_rule:" + str(i) + "]\n"
+ base_conf += "rule_id=" + str(i+1) + "\n"
+ base_conf += "dst_ip_addr_v4=172.19.2." + str(i) + "\n"
+ base_conf += "dst_ip_mask_v4=32\n"
+ base_conf += "action=nf_steering\n"
+ base_conf += "priority=1\n"
+ base_conf += "category=0\n"
+ base_conf += "sid=1000\n"
+ base_conf += "vwire_id=0\n\n"
+
+ print(base_conf)
+ mrzcpd = Mrzcpd(base_conf)
+ mrzcpd.start()
+
+ """
+ +---------------------------+ +--------------------------------+ +--------------+
+ | PTF | | MRZCPD | | PTF |
+ +---------------------------+ +--------------------------------+ +--------------+
+ | Ipv4 DstIP=172.17.2.100 | ---> | RuleID=1, DstIP=172.17.2.100 | ---> | veth0-ptf0 |
+ +---------------------------+ +--------------------------------+ +--------------+
+ | Ipv4 DstIP=172.17.2.101 | ---> | RuleID=2, DstIP=172.17.2.101 | ---> | veth1-ptf0 |
+ +---------------------------+ +--------------------------------+ +--------------+
+ """
+
+ # Check classifier rule id 1 - 2, check ipv4 dst ip rule.
+ for i in range(0, 2):
+ # Create packet for classifier rule
+ verify_pkt = send_pkt = simple_tcp_packet(
+ ip_src="172.17.1.100", ip_dst="172.17.2." + str(100 + i))
+ send_packet(self, 5, send_pkt)
+ verify_packets(self, verify_pkt, [i])
+
+ """
+ +---------------------------+ +--------------------------------+ +--------------+
+ | PTF | | MRZCPD | | PTF |
+ +---------------------------+ +--------------------------------+ +--------------+
+ | Ipv4 SrcIP=172.17.2.102 | ---> | RuleID=3, SrcIP=172.17.2.102 | ---> | veth2-ptf2 |
+ +---------------------------+ +--------------------------------+ +--------------+
+ | Ipv4 SrcIP=172.17.2.103 | ---> | RuleID=4, SrcIP=172.17.2.103 | ---> | veth3-ptf3 |
+ +---------------------------+ +--------------------------------+ +--------------+
+ """
+
+ # Check classifier rule id 3 - 4, check ipv4 src ip rule.
+ for i in range(2, 4):
+ # Create packet for classifier rule
+ verify_pkt = send_pkt = simple_tcp_packet(
+ ip_src="172.17.2." + str(100 + i), ip_dst="172.17.1.100")
+
+ send_packet(self, 5, send_pkt)
+ verify_packets(self, verify_pkt, [i])
+
+ """
+ +---------------------------+ +--------------------------------+ +--------------+
+ | PTF | | MRZCPD | | PTF |
+ +---------------------------+ +--------------------------------+ +--------------+
+ | Ipv6 DstIP= 2222::4 | ---> | RuleID=5, DstIP= 2222::4 | ---> | veth0-ptf0 |
+ +---------------------------+ +--------------------------------+ +--------------+
+ | Ipv6 DstIP= 2222::5 | ---> | RuleID=6, DstIP= 2222::5 | ---> | veth1-ptf1 |
+ +---------------------------+ +--------------------------------+ +--------------+
+ """
+
+ # Check classifier rule id 5 - 6, check ipv6 dst ip rule.
+ for i in range(4, 6):
+ # Create packet for classifier rule
+ verify_pkt = send_pkt = simple_tcpv6_packet(
+ ipv6_src="1111::8888", ipv6_dst="2222::" + str(i))
+
+ send_packet(self, 5, send_pkt)
+ verify_packets(self, verify_pkt, [i % 4])
+
+ """
+ +---------------------------+ +--------------------------------+ +--------------+
+ | PTF | | MRZCPD | | PTF |
+ +---------------------------+ +--------------------------------+ +--------------+
+ | Ipv6 SrcIP= 2222::6 | ---> | RuleID=7, SrcIP= 2222::6 | ---> | veth2-ptf2 |
+ +---------------------------+ +--------------------------------+ +--------------+
+ | Ipv6 SrcIP= 2222::7 | ---> | RuleID=8, SrcIP= 2222::7 | ---> | veth3-ptf3 |
+ +---------------------------+ +--------------------------------+ +--------------+
+ """
+ # Check classifier rule id 7 - 8, check ipv6 src ip rule.
+ for i in range(6, 8):
+ # Create packet for classifier rule
+ verify_pkt = send_pkt = simple_tcpv6_packet(
+ ipv6_src="2222::" + str(i), ipv6_dst="1111::8888")
+
+ send_packet(self, 5, send_pkt)
+ verify_packets(self, verify_pkt, [i % 4])
+
+ """
+ +---------------------------+ +---------+-----------------+---------+ +--------------+
+ | PTF | | Vwire | Classifier | Vwire | | PTF |
+ +---------------------------+ +---------+-----------------+---------+ +--------------+
+ | SrcIP=172.17.3.100 | | veth5 | No Match Rule | veth5 | ---> | veth5-ptf5 |
+ | DstIP=172.17.1.100 | ---> | veth4 | To Vwire | veth4 | | |
+ +---------------------------+ +---------+-----------------+---------+ +--------------+
+
+ """
+
+ # Check miss packet
+ verify_pkt = send_pkt = simple_tcp_packet(
+ ip_src="172.17.3.100", ip_dst="172.17.1.100")
+
+ send_packet(self, 4, send_pkt)
+ verify_packets(self, verify_pkt, [5])
+
+ finally:
+ mrzcpd.stop()
+
category_conf = """Current not support priority"""
full_field_match_conf = """
@@ -491,7 +613,56 @@ action=nf_steering
@ group("full_field_match_test")
-class TestForFullFieldMatch(BaseTest):
+class FullFieldMatchTestForLinear(BaseTest):
+ def setUp(self):
+ self.dataplane = ptf.dataplane_instance
+
+ def __init__(self):
+ BaseTest.__init__(self)
+
+ def runTest(self):
+ try:
+ # Init & Start mrzcpd
+ mrzcpd = Mrzcpd(full_field_match_conf)
+ mrzcpd.start()
+
+ # Check IPv4 for miss
+ send_pkt = simple_tcp_packet(
+ ip_src="172.17.1.100", ip_dst="172.17.2.100", tcp_sport=1000, tcp_dport=1000)
+ verify_pkt = simple_tcp_packet(
+ ip_src="172.17.1.100", ip_dst="172.17.2.100", tcp_sport=1000, tcp_dport=1000)
+ send_packet(self, 3, send_pkt)
+ verify_packets(self, verify_pkt, [2])
+
+ # Check IPv4 for match
+ send_pkt = simple_tcp_packet(
+ ip_src="172.17.1.100", ip_dst="172.17.2.100", tcp_sport=1000, tcp_dport=80)
+ verify_pkt = simple_tcp_packet(
+ ip_src="172.17.1.100", ip_dst="172.17.2.100", tcp_sport=1000, tcp_dport=80)
+ send_packet(self, 3, send_pkt)
+ verify_packets(self, verify_pkt, [0])
+
+ # Check IPv6 for miss
+ send_pkt = simple_udpv6_packet(
+ ipv6_src="1111::8888", ipv6_dst="2222::9999", udp_sport=1000, udp_dport=1000)
+ verify_pkt = simple_udpv6_packet(
+ ipv6_src="1111::8888", ipv6_dst="2222::9999", udp_sport=1000, udp_dport=1000)
+ send_packet(self, 2, send_pkt)
+ verify_packets(self, verify_pkt, [3])
+
+ # Check IPv6 for match
+ send_pkt = simple_udpv6_packet(
+ ipv6_src="1111::8888", ipv6_dst="2222::9999", udp_sport=1000, udp_dport=80)
+ verify_pkt = simple_udpv6_packet(
+ ipv6_src="1111::8888", ipv6_dst="2222::9999", udp_sport=1000, udp_dport=80)
+ send_packet(self, 2, send_pkt)
+ verify_packets(self, verify_pkt, [1])
+
+ finally:
+ mrzcpd.stop()
+
+@ group("full_field_match_test")
+class FullFieldMatchTestForTreeSearch(BaseTest):
def setUp(self):
self.dataplane = ptf.dataplane_instance
@@ -501,6 +672,17 @@ class TestForFullFieldMatch(BaseTest):
def runTest(self):
try:
# Init & Start mrzcpd
+ global base_conf
+ for i in range(8,128):
+ base_conf += "[classifier_rule:" + str(i) + "]\n"
+ base_conf += "rule_id=" + str(i+1) + "\n"
+ base_conf += "dst_ip_addr_v4=172.19.2." + str(i) + "\n"
+ base_conf += "dst_ip_mask_v4=32\n"
+ base_conf += "action=nf_steering\n"
+ base_conf += "priority=1\n"
+ base_conf += "category=0\n"
+ base_conf += "sid=1000\n"
+ base_conf += "vwire_id=0\n\n"
mrzcpd = Mrzcpd(full_field_match_conf)
mrzcpd.start()
@@ -538,3 +720,4 @@ class TestForFullFieldMatch(BaseTest):
finally:
mrzcpd.stop()
+