p4pktgen:
Automated Test Case
Generation for P4 Programs
Ajay Kharat (20191030011G)
BITS-Pilani
Motivation
- Traditional network devices - fixed set of capabilities
- Rise of programmable network devices in recent years
- Offers great flexibility / capability than traditional network devices
- Flexibility introduces new bugs:
- Hardware
- Toolchains
- Programs
- These bugs were previously covered by traditional network devices due to
fixed set of capabilities
- Use test cases to check whether program is behaving as intended on the
device
2
Problem Statement
- Programmable network devices and programmable languages (P4)
- Offers more flexibility / capability
- Uniform support across different devices
- Introduces new layers and components that can fail
- Subtle differences between toolchains
- Different interpretation of the language specification
- Need for new tools
- Keeps benefits of programmable hardware
- Keep/improve on the reliability of traditional approaches
- p4pktgen tool for automatic generation of test cases for P4 programs for
validation
3
Approach
and
Solution
4
Symbolic Execution using SMT Solvers
Analysis technique that translates program into logical formulas to
examine its behaviour on all inputs
Reasoning done by satisfiability modulo theory (SMT) solvers:
Input: Constraints
Example: (x < y) ^ (y < x - 1)
Output : A variable assignment that makes the formula true or
unsatisfiable.
5
Parser Translator
6
Evaluation of the solution
1. Effective generation of test cases for large P4 programs
For smaller programs, able to generate test cases for all paths in under 3
minutes.
7
2. Generate test cases to reveal bugs in P4 toolchain
- Issues with p4c JSON backend (4 issues confirmed, current status: fixed)
- Incorrect JSON for select statement with multiple key fields
- Incorrect JSON when bit-wise negating a bitvector and casting it to a wider bitvector
- Incorrect JSON for select statements that use masks for ternary matching
- Incorrect JSON specifying maximum length of headers with variable-length fields
- Danger of bugs in P4 compilers are real
- Test cases can help reveal them
Evaluation of the solution
8
Related Work
- Foster et al - verification of P4 programs
Translate P4 programs to a small imperative language and then verify that user-
annotated properties hold using an SMT solver.
- Kheradmand et al - formalization of P4 programs in K framework.
Their focus is on P414 whereas Author’s approach is version-agnostic used and a
direct formalization in SMT. Test case generation is one of their side goals.
- Zeng et al - automatically generating test packets for testing and debugging
networks.
Uses header space framework to model packet processing
requires implementation of protocol and vendor-specific translations into their model
and assuming a fixed table configuration.
Author’s focuses on a single switch and generate table configurations automatically.
9
Future Work
- Support for more P4 features (checksums, action profiles etc)
- Branch coverage to find set of paths that covers all branches
- User-supplied constraints / assertions
- Test different P4 implementations
- Modeling egress pipeline
10

p4pktgen: Automated Test Case Generation for P4 Programs

  • 1.
    p4pktgen: Automated Test Case Generationfor P4 Programs Ajay Kharat (20191030011G) BITS-Pilani
  • 2.
    Motivation - Traditional networkdevices - fixed set of capabilities - Rise of programmable network devices in recent years - Offers great flexibility / capability than traditional network devices - Flexibility introduces new bugs: - Hardware - Toolchains - Programs - These bugs were previously covered by traditional network devices due to fixed set of capabilities - Use test cases to check whether program is behaving as intended on the device 2
  • 3.
    Problem Statement - Programmablenetwork devices and programmable languages (P4) - Offers more flexibility / capability - Uniform support across different devices - Introduces new layers and components that can fail - Subtle differences between toolchains - Different interpretation of the language specification - Need for new tools - Keeps benefits of programmable hardware - Keep/improve on the reliability of traditional approaches - p4pktgen tool for automatic generation of test cases for P4 programs for validation 3
  • 4.
  • 5.
    Symbolic Execution usingSMT Solvers Analysis technique that translates program into logical formulas to examine its behaviour on all inputs Reasoning done by satisfiability modulo theory (SMT) solvers: Input: Constraints Example: (x < y) ^ (y < x - 1) Output : A variable assignment that makes the formula true or unsatisfiable. 5
  • 6.
  • 7.
    Evaluation of thesolution 1. Effective generation of test cases for large P4 programs For smaller programs, able to generate test cases for all paths in under 3 minutes. 7
  • 8.
    2. Generate testcases to reveal bugs in P4 toolchain - Issues with p4c JSON backend (4 issues confirmed, current status: fixed) - Incorrect JSON for select statement with multiple key fields - Incorrect JSON when bit-wise negating a bitvector and casting it to a wider bitvector - Incorrect JSON for select statements that use masks for ternary matching - Incorrect JSON specifying maximum length of headers with variable-length fields - Danger of bugs in P4 compilers are real - Test cases can help reveal them Evaluation of the solution 8
  • 9.
    Related Work - Fosteret al - verification of P4 programs Translate P4 programs to a small imperative language and then verify that user- annotated properties hold using an SMT solver. - Kheradmand et al - formalization of P4 programs in K framework. Their focus is on P414 whereas Author’s approach is version-agnostic used and a direct formalization in SMT. Test case generation is one of their side goals. - Zeng et al - automatically generating test packets for testing and debugging networks. Uses header space framework to model packet processing requires implementation of protocol and vendor-specific translations into their model and assuming a fixed table configuration. Author’s focuses on a single switch and generate table configurations automatically. 9
  • 10.
    Future Work - Supportfor more P4 features (checksums, action profiles etc) - Branch coverage to find set of paths that covers all branches - User-supplied constraints / assertions - Test different P4 implementations - Modeling egress pipeline 10

Editor's Notes

  • #3 Before, traditional network devices with a fixed set of capabilities Now, rise of programmable network devices in recent years Offers great flexibility/capability than traditional network devices However introducing flexibility creates new bugs: Hardware Toolchains Programs These bugs were previously covered by traditional network devices due to fixed set of capabilities Use test cases to check whether program is behaving as intended on the device
  • #10 Foster et al - verification of P4 programs Translate P4 programs to a small imperative language and then verify that user-annotated properties hold using an SMT solver. Like p4pktgen, their approach requires a formalization of P4, but their focus is on verifying the P4 programs themselves,which is desirable but complementary to our work.  Kheradmand et al - formalization of P4 programs in K framework. Their focus is on P414 whereas our approach is version-agnostic used and a direct formalization in SMT. Test case generation is one of their side goals. Zeng et al - automatically generating test packets for testing and debugging networks. Their approach uses the header space framework to model packet processing, requiring the implementation of protocol and vendor-specific translations into their model and assuming a fixed table configuration. We focus on a single switch and generate table configurations automatically.