2.15. template_classifier module

class template_classifier.TestClassifier(methodName='runTest')

Bases: framework.VppTestCase

static build_ip6_mask(nh='', src_ip='', dst_ip='', src_port='', dst_port='')

Build IPv6 ACL mask data with hexstring format.

Parameters
  • nh (str) – next header 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_ip6_match(nh=0, src_ip='', dst_ip='', src_port=0, dst_port=0)

Build IPv6 ACL match data with hexstring format.

Parameters
  • nh (int) – next header number with valid option “x”

  • src_ip (str) – source ip6 address with format of “xxx:xxxx::xxxx”

  • dst_ip (str) – destination ip6 address with format of “xxx:xxxx::xxxx”

  • src_port (int) – source port number “x”

  • dst_port (int) – destination port number “x”

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=0, src_ip='', dst_ip='', src_port=0, dst_port=0)

Build IP ACL match data with hexstring format.

Parameters
  • proto (int) – protocol number with valid option “x”

  • 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 (int) – source port number “x”

  • dst_port (int) – destination port number “x”

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(table_index, match, pbr_option=0, vrfid=0, is_add=1)

Create Classify Session

Parameters
  • table_index (int) – table index to identify classify table.

  • match (str) – matched value for interested traffic.

  • pbr_option (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)

Create Classify Table

Parameters
  • key (str) – key for classify table (ex, ACL name).

  • mask (str) – mask value for interested traffic.

  • data_offset (int) –

create_stream(src_if, dst_if, packet_sizes, proto_l=scapy.layers.inet.UDP)

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.

  • proto_l (Scapy) – Required IP protocol. Default protocol is UDP.

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)

output_acl_set_interface(intf, table_index, is_add=1)

Configure Output ACL interface

Parameters
  • intf (VppInterface) – Interface to apply Output 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/6 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.

classmethod setUpClass()

Perform standard class setup (defined by class method setUpClass in class VppTestCase) before running the test case, set test case related variables and configure VPP.

tearDown()

Run standard test teardown and acl related log.

verify_capture(dst_if, capture, proto_l=scapy.layers.inet.UDP)

Verify captured input packet stream for defined interface.

Parameters
  • dst_if (VppInterface) – Interface to verify captured packet stream.

  • capture (list) – Captured packet stream.

  • proto_l (Scapy) – Required IP protocol. Default protocol is UDP.

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.