Runtime Verification of P4 Switches with Reinforcement Learning - - PowerPoint PPT Presentation

runtime verification of p4 switches with reinforcement
SMART_READER_LITE
LIVE PREVIEW

Runtime Verification of P4 Switches with Reinforcement Learning - - PowerPoint PPT Presentation

Runtime Verification of P4 Switches with Reinforcement Learning Apoorv Shukla (TU Berlin) with Kevin Nico Hudemann (TU Berlin), Artur Hecker (Huawei), Stefan Schmid (Vienna Uni.) Apoorv Shukla| NetAI19 P4 [1] : Data plane Programming Language


slide-1
SLIDE 1

Apoorv Shukla| NetAI’19

Runtime Verification of P4 Switches with Reinforcement Learning

Apoorv Shukla (TU Berlin)

with Kevin Nico Hudemann (TU Berlin), Artur Hecker (Huawei), Stefan Schmid (Vienna Uni.)

slide-2
SLIDE 2

Apoorv Shukla| NetAI’19

P4[1]: Data plane Programming Language

  • Domain-specific high-level language for data plane programming
  • Support for user-defined custom protocols, target independence,

etc.

[1] P. Bosshart, D. Daly, G. Gibby, M. Izzardy, N. McKeown, J. Rexford, C. Schlesinger, D. Talaycoy, A. Vahdat, G. Varghese, D. Walker. P4: Programming Protocol-Independent Packet Processors. SIGCOMM’ 14.

2

slide-3
SLIDE 3

Apoorv Shukla| NetAI’19

P4 Pipeline: Complex

3

PSA Architecture with programmable (yellow) and non- programmable blocks (grey)

Ingress Match- Action

Packet Replication Engine (PRE)

Packet

Egress Parser Egress Match- Action Egress Deparser Ingress Deparser Buffer Queuing Engine (BQE) Ingress Parser

slide-4
SLIDE 4

Apoorv Shukla| NetAI’19

P4: Multiple versions and platforms

  • Versions: P414 & P416
  • Platforms: bmv2, Tofino, eBPF, XDP
  • Platform-specific implementations

Interplay between programmable and non-programmable blocks gets complex!

4

slide-5
SLIDE 5

Apoorv Shukla| NetAI’19

Bugs happen

  • Bugs related to memory safety: buffer overflow, invalid memory

accesses (detectable by static analysis)

  • Runtime bugs related to checksum, ECMP/hash-calculation,

platform-dependent, etc.

5

slide-6
SLIDE 6

Apoorv Shukla| NetAI’19

Runtime bug detection is hard

  • P4 is half a program; forwarding rules populated at runtime
  • Static Analysis prone to false positives: insufficient
  • Switch does not throw any runtime exceptions: hard to catch

6

This talk: P4 Runtime bug Detection!

slide-7
SLIDE 7

Apoorv Shukla| NetAI’19

Example: Platform-Independent Bug

  • L3 switch parser of P4 language tutorials does not validate IPv4

ihl

  • Packets with IP options are forwarded with wrong checksum

7

slide-8
SLIDE 8

Apoorv Shukla| NetAI’19

Motivating Example: Platform-Dependent Bug

  • Conflicting forwarding decisions can lead to unexpected behavior
  • Dependent on implementation of packet replication engine (PRE)

8

More bug examples in the paper!

slide-9
SLIDE 9

Apoorv Shukla| NetAI’19

Problem Statement

Is it possible to automatically detect runtime bugs in P4 switches?

9

slide-10
SLIDE 10

Apoorv Shukla| NetAI’19

Goal

  • Design a system which automatically detects runtime bugs
  • Detects both: platform-dependent and –independent bugs
  • Is non-intrusive: no changes to the P4 program or switch

10

slide-11
SLIDE 11

Apoorv Shukla| NetAI’19

Approach in a nutshell

  • Use fuzzing, and guide it through reinforcement learning agent
  • Generate +ve rewards if an anomaly is detected in the feedback
  • Feedback also guides the agent further

11

slide-12
SLIDE 12

Apoorv Shukla| NetAI’19

P4RL

  • P4RL Agent – Guides Fuzzing
  • p4q – Query Language for expressivity, reducing input search

space At Agent Environment Rt St Rt+1 St+1

12

Credit: https://www.kdnuggets.com/2018/03/5-things-reinforcement-learning.html

slide-13
SLIDE 13

Apoorv Shukla| NetAI’19

P4RL Reinforcement Learning

  • States: Sequence of bytes forming the packet header
  • Actions: Add/modify/delete bytes at position X
  • Rewards:

1, if the packet triggered a bug 0, otherwise

13

slide-14
SLIDE 14

Apoorv Shukla| NetAI’19

Reducing Input Search Space for Fuzzing

  • Pre-generated dictionary created using control plane

configuration, compiled P4 program and p4q queries

  • Compiled P4 program in JSON format aids in knowing accepted

header layouts

  • Check boundary values first for header fields by queries

14

slide-15
SLIDE 15

Apoorv Shukla| NetAI’19

Query Language: p4q

  • Goal: Specify expected P4 switch behavior
  • If-then-else conditional statements
  • Common boolean expressions & relational operators

(ing.hdr.ipv4 & ing.hdr.ipv4.version !=4, egr.egress_port == False, )

15

slide-16
SLIDE 16

Apoorv Shukla| NetAI’19

P4RL Agent-guided Fuzzing

16

slide-17
SLIDE 17

Apoorv Shukla| NetAI’19

P4RL DDQN

  • Combination of double Q-learning and deep Q networks with a

simple form of prioritized experience replay

  • Select next action based upon the result of feeding current

environment state to neural network

  • Two separate neural networks for action selection and evaluation

17

slide-18
SLIDE 18

Apoorv Shukla| NetAI’19

P4RL Workflow

P4 Network

  • 1. Get control plane config

P4 Switch

P4Runtime

Control Plane User written queries Agent Reward System P4RL

  • 2. Select

fuzz action

  • 4. Get

Reward

  • 3. Send packets &

monitor behaviour

18

slide-19
SLIDE 19

Apoorv Shukla| NetAI’19

Evaluation Strategy

  • Target: Publicly available L3 (basic.p4) switch

(simple_switch_grpc) implementation

  • Baseline: Simple Agent relying on random action selection
  • Metrics:
  • Mean Cumulative Reward (MCR) over 10 runs
  • Bug Detection Time

19

slide-20
SLIDE 20

Apoorv Shukla| NetAI’19

Bugs found by P4RL in publicly available programs

PI – Platform-independent PD – Platform-dependent

20

slide-21
SLIDE 21

Apoorv Shukla| NetAI’19

Learning Performance: P4RL Agent vs. Baseline

21

➔ P4RL generates ~3× rewards

slide-22
SLIDE 22

Apoorv Shukla| NetAI’19

Detection Time Speedup: P4RL Agent vs. Baseline

➔ P4RL up to 4.42× faster

22

slide-23
SLIDE 23

Apoorv Shukla| NetAI’19

Limitations: Undecidability

23

<Input> No P4RL engine Yes

Credit: https://www.coopertoons.com/education/haltingproblem/haltingproblem.html

slide-24
SLIDE 24

Apoorv Shukla| NetAI’19

Conclusion

  • P4RL’s machine learning-guided fuzzing enables detection of

complex runtime bugs (non-intrusively)

  • Identifies platform-dependent and -independent bugs
  • Ensure correctness in P4 deployments

24

slide-25
SLIDE 25

Apoorv Shukla| NetAI’19

Summary

25

1 . G e t c

  • n

t r

  • l

p l a n e c

  • n

f i g P4 Switch P4Runtime Control Plane User written queries Agent Reward System

P4RL

  • 2. Select

fuzz action

  • 4. Get

Reward

  • 3. Send packets &

monitor behavior

P4 Network

Contact: apoorv@inet.tu-berlin.de Code: gitlab.inet.tu-berlin.de/apoorv/P4ML