2.19. test_classifier module¶
-
class
test_classifier.
TestClassifier
(methodName='runTest')¶ Bases:
framework.VppTestCase
Classifier Test Case
-
static
build_ip_mask
(proto='', src_ip='', dst_ip='', src_port='', dst_port='')¶ Build IP ACL mask data with hexstring format
Parameters: - proto (str) – protocol number <0-ff>
- src_ip (str) – source ip address <0-ffffffff>
- dst_ip (str) – destination ip address <0-ffffffff>
- src_port (str) – source port number <0-ffff>
- dst_port (str) – destination port number <0-ffff>
-
static
build_ip_match
(proto='', src_ip='', dst_ip='', src_port='', dst_port='')¶ Build IP ACL match data with hexstring format
Parameters: - proto (str) – protocol number with valid option “<0-ff>”
- src_ip (str) – source ip address with format of “x.x.x.x”
- dst_ip (str) – destination ip address with format of “x.x.x.x”
- src_port (str) – source port number <0-ffff>
- dst_port (str) – destination port number <0-ffff>
-
static
build_mac_mask
(dst_mac='', src_mac='', ether_type='')¶ Build MAC ACL mask data with hexstring format
Parameters: - dst_mac (str) – source MAC address <0-ffffffffffff>
- src_mac (str) – destination MAC address <0-ffffffffffff>
- ether_type (str) – ethernet type <0-ffff>
-
static
build_mac_match
(dst_mac='', src_mac='', ether_type='')¶ Build MAC ACL match data with hexstring format
Parameters: - dst_mac (str) – source MAC address <x:x:x:x:x:x>
- src_mac (str) – destination MAC address <x:x:x:x:x:x>
- ether_type (str) – ethernet type <0-ffff>
-
config_pbr_fib_entry
(intf, is_add=1)¶ Configure fib entry to route traffic toward PBR VRF table
Parameters: intf (VppInterface) – destination interface to be routed for PBR.
-
create_classify_session
(intf, table_index, match, pbr_option=0, vrfid=0, is_add=1)¶ Create Classify Session
Parameters: - intf (VppInterface) – Interface to apply classify session.
- table_index (int) – table index to identify classify table.
- match (str) – matched value for interested traffic.
- pbr_action (int) – enable/disable PBR feature.
- vrfid (int) – VRF id.
- is_add (int) – option to configure classify session. - create(1) or delete(0)
-
create_classify_table
(key, mask, data_offset=0, is_add=1)¶ Create Classify Table
Parameters: - key (str) – key for classify table (ex, ACL name).
- mask (str) – mask value for interested traffic.
- match_n_vectors (int) –
- is_add (int) – option to configure classify table. - create(1) or delete(0)
-
create_stream
(src_if, dst_if, packet_sizes)¶ Create input packet stream for defined interfaces.
Parameters: - src_if (VppInterface) – Source Interface for packet stream.
- dst_if (VppInterface) – Destination Interface for packet stream.
- packet_sizes (list) – packet size to test.
-
input_acl_set_interface
(intf, table_index, is_add=1)¶ Configure Input ACL interface
Parameters: - intf (VppInterface) – Interface to apply Input ACL feature.
- table_index (int) – table index to identify classify table.
- is_add (int) – option to configure classify session. - enable(1) or disable(0)
-
setUp
()¶ Perform test setup before test case.
- Config:
- create 4 pg interfaces
- untagged pg0/pg1/pg2 interface
- pg0 ——-> pg1 (IP ACL)
- —> pg2 (MAC ACL))
- -> pg3 (PBR)
- setup interfaces:
- put it into UP state
- set IPv4 addresses
- resolve neighbor address using ARP
Variables: - interfaces (list) – pg interfaces.
- pg_if_packet_sizes (list) – packet sizes in test.
- acl_tbl_idx (dict) – ACL table index.
- pbr_vrfid (int) – VRF id for PBR test.
-
tearDown
()¶ Run standard test teardown and acl related log.
-
test_acl_ip
()¶ IP ACL test
- Test scenario for basic IP ACL with source IP
- Create IPv4 stream for pg0 -> pg1 interface.
- Create ACL with source IP address.
- Send and verify received packets on pg1 interface.
-
test_acl_mac
()¶ MAC ACL test
- Test scenario for basic MAC ACL with source MAC
- Create IPv4 stream for pg0 -> pg2 interface.
- Create ACL with source MAC address.
- Send and verify received packets on pg2 interface.
-
test_acl_pbr
()¶ IP PBR test
- Test scenario for PBR with source IP
- Create IPv4 stream for pg0 -> pg3 interface.
- Configure PBR fib entry for packet forwarding.
- Send and verify received packets on pg3 interface.
-
verify_capture
(dst_if, capture)¶ Verify captured input packet stream for defined interface.
Parameters: - dst_if (VppInterface) – Interface to verify captured packet stream.
- capture (list) – Captured packet stream.
-
verify_vrf
(vrf_id)¶ Check if the FIB table / VRF ID is configured.
Parameters: vrf_id (int) – The FIB table / VRF ID to be verified. Returns: 1 if the FIB table / VRF ID is configured, otherwise return 0.
-
static