p4alu: arithmetic logic unit in p4

13
~ p4alu ~ Arithmetic Logic Unit in P4 Kentaro Ebisawa | Ponto Networks, Inc. [email protected] Twitter: @ebiken p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 1

Upload: kentaro-ebisawa

Post on 22-Jan-2018

288 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: p4alu: Arithmetic Logic Unit in P4

~ p4alu ~

Arithmetic Logic Unit in P4

Kentaro Ebisawa | Ponto Networks, Inc.

[email protected]

Twitter: @ebiken

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 1

Page 2: p4alu: Arithmetic Logic Unit in P4

• “p4alu” is an P4 program who would parse UDP packet with payload in "p4alu header format" and apply calculation.

• This program is tested using BMv2 simple_switch P4 target.

• Source Code on GitHub• https://github.com/ebiken/p4sandbox/tree/master/p4alu

• Generic P4 information in Japanese (日本語)• How to Run P4 Behavior Model v2 (JAPANESE)

• https://www.slideshare.net/kentaroebisawa/how-to-run-p4-bmv2

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 2

p4alu

Page 3: p4alu: Arithmetic Logic Unit in P4

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 3

ALU

IntegerOperand

IntegerOperand

IntegerResult

opCode

op1 op2

result

Page 4: p4alu: Arithmetic Logic Unit in P4

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 4

p4alu header format

IntegerOperand

IntegerOperand

IntegerResult

opCode

op1 op2

result

Page 5: p4alu: Arithmetic Logic Unit in P4

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 5

P4 parser

Page 6: p4alu: Arithmetic Logic Unit in P4

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 6

P4 action

Page 7: p4alu: Arithmetic Logic Unit in P4

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 7

P4 table & control

Page 8: p4alu: Arithmetic Logic Unit in P4

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 8

Setup netns based hosts

BMv2 running p4alu

Page 9: p4alu: Arithmetic Logic Unit in P4

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 9

Compile and Run on BMv2

Page 10: p4alu: Arithmetic Logic Unit in P4

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 10

Configure Tables via runtime_CLI

Forward Packetfrom/to port#0 <-> port#1

Apply action based on opCode• opCode: 1 => p4alu_add• opCode: 2 => p4alu_sub

BMv2 Runtime CLI command format

Page 11: p4alu: Arithmetic Logic Unit in P4

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 11

Packet Format (sending from host0)

• opCode: 0x01 => p4alu_add• opCode: 0x02 => p4alu_sub

Page 12: p4alu: Arithmetic Logic Unit in P4

CuiShark by @slankdev | https://github.com/slankdev/cuishark

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 12

packets after going through p4alu

op1 opCodeop2 result

Page 13: p4alu: Arithmetic Logic Unit in P4

CuiShark by @slankdev | https://github.com/slankdev/cuishark

p4alu ... Arithmetic Logic Unit in P4 | Software Router BoF @ IW2017 Japan | 2017/11/29 13

packets after going through p4alu

op1 opCodeop2 result