SlideShare a Scribd company logo
1 of 24
Compiling P4 to XDP
Mihai Budiu, VMware Research
William Tu, VMware NSBU
{mbudiu,tuc}@vmware.com
February 27, 2017
IOVisor summit
XDP
https://www.iovisor.org/technology/xdp
P4
P4: Programming Protocol-Independent Packet Processors
Pat Bosshart, Dan Daly, Glen Gibb, Martin Izzard, Nick McKeown, Jennifer Rexford, Cole Schlesinger, Dan
Talayco, Amin Vahdat, George Varghese, David Walker ACM SIGCOMM Computer Communications
Review (CCR). Volume 44, Issue #3 (July 2014)
Initially designed for programmable switches. P416 can support many kinds of packet processing devices.
http://P4.org
P4.org Consortium
Carriers, cloud operators, chip,
networking, systems, universities,
start-ups
P416
• C-like, strongly typed
• Arbitrary length bitstrings
• Match-action tables
• Parser = state machine
• No loops, no pointers, no memory allocation
• Support for external, target-specific accelerators
(e.g., checksum units, multicast, learning, etc.)
P416-> C -> EBPF
• p4c-xdp: back-end for the P416 reference compiler
• Generate stylized C
– No loops, all data on stack
– EBPF tables for control/data-plane communication
– Filtering, forwarding, encapsulation
– Currently use Linux TC subsystem for forwarding
• https://github.com/williamtu/p4c-xdp
P416 generic data plane model
Data plane
P4 P4 P4
Programmable
blocks
Fixed function
The XDP switching model
Parser
Match+
Action
Deparser
XDP Data Plane
packetin
packetout
EBPF tables
Control-plane API Drop/tx/pass
Output port
Input port
headers
headers
xdp_model.p4
enum xdp_action {
XDP_ABORTED, // some fatal error occurred during processing;
XDP_DROP, // packet should be dropped
XDP_PASS, // packet should be passed to the Linux kernel
XDP_TX // packet resent out on the same interface
}
struct xdp_input {
bit<32> input_port;
}
struct xdp_output {
xdp_action output_action;
bit<32> output_port; // output port for packet
}
parser xdp_parse<H>(packet_in packet, out H headers);
control xdp_switch<H>(inout H hdrs, in xdp_input i, out xdp_output o);
control xdp_deparse<H>(in H headers, packet_out packet);
package xdp<H>(xdp_parse<H> p, xdp_switch<H> s, xdp_deparse<H> d);
Flow
app.p4
Clang +
LLVM
Data Plane XDP driver
Verifier
app.h
BPF system call
Hardware
Kernel space
User space
app.c
p4c-xdp
control-plane.c
Control-plane API
app.o
exe Match-Action
tables
Simple Example
• Parse Ethernet and IPv4 header
• Lookup a table using Ethernet’s destination as key
• Based on Ethernet’s destination address, execute one action:
• Drop the packet (XDP_DROP)
• Pass the packet to network stack (XDP_PASS)
Parser
Match+
Action
Deparser
Drop
Network stack
packet
P4 Protocol Header Definition
header Ethernet {
bit<48> source;
bit<48> destination;
bit<16> protocol;
}
header IPv4{
bit<4> version;
bit<4> ihl;
bit<8> diffserv;
…
}
struct Headers {
Ethernet ethernet;
IPv4 ipv4;
}
C struct + valid bit
C struct
struct Ethernet{
u8 source[6];
u8 destination[6];
u16 protocol;
u8 ebpf_valid;
}
…
xdp.h
P4c-xdp
P4 Protocol Parser
parser Parser(packet_in packet,
out Headers hd) {
state start {
packet.extract(hd.ethernet);
transition select(hd.ethernet.protocl) {
16w0x800: parse_ipv4;
default: accept;
}
}
state parse_ipv4 {
packet.extract(hd.ipv4);
transition accept;
}
}
Code Block
Switch-case
Code Block
BPF Direct Pkt Access
BPF Direct Pkt Access
goto
Table Match and Action
control Ingress (inout Headers hdr,
in xdp_input xin, out xdp_output xout)
{
action Drop_action() {
xout.output_action = xdp_action.XDP_DROP; }
action Fallback_action() {
xout.output_action = xdp_action.XDP_PASS; }
table mactable {
key = {hdr.ethernet.destination : exact; }
actions = {
Fallback_action;
Drop_action;
}
implementation = hash_table(64);
BPF HashMap
Key size of 6 byte
Value with enum type + parameter
Two action types
Deparser: Update the Packet
control Deparser(in Headers hdrs,
packet_out packet) {
apply {
packet.emit(hdrs.ethernet);
packet.emit(hdrs.vlan_tag);
packet.emit(hdrs.ipv4);
}
}
• Parser saves results at ‘hdrs’
• Users can push/pop headers by emitting more or
skipping emit
• Ex: vlan push/pop by add/remove packet.emit(hdrs.vlan_tag);
• Need to adjust skb->data by adding xdp_adjust_head helper
Example: VLAN Push
VLANETH payloadIPv4
skb->data
ETH payloadIPv4
skb->data
The payload remains in the
same memory
xdp_adjust_head() helper for extra 4 bytes
Setup and Installation
• Source code at Github
• git clone https://github.com/williamtu/p4c-xdp/
• Vagrant box / docker image available
• Dependencies:
• P4 2016: https://github.com/p4lang/p4c
• Linux >= 4.10.0-rc7: http://www.kernel.org/
• iproute2 >= 4.8.0: https://www.kernel.org/pub/linux/utils/net/iproute2/
• clang+LLVM >=3.7.1: http://llvm.org/releases
• P4C-XDP binary
• #./p4c-xdp --target xdp -o <output_xdp.c> <input.p4>
Experiences with BPF Verifier
• Typical packet access check: data + [off] <= data_end
• where [off] can be either immediate or
• coming from a tracked register that contains an immediate
• Two patches related to direct packet access
• bpf: enable verifier to better track const alu ops, commit 3fadc8011583
• bpf: enable verifier to add 0 to packet ptr, commit 63dfef75ed753
R1=pkt(id=0,off=0,r=22) R2=pkt_end R3=imm144,min_value=144,max_value=144
30: (bf) r5 = r3
31: (07) r5 += 23
32: (77) r5 >>= 3
33: (bf) r6 = r1 // r6 == pkt
34: (0f) r6 += r5 // pkt += r5
Pending Issues
• BPF 512 Byte maximum stack size [#22]
• Not necessarily due to the size of local variables
• LLVM allocates too many things into 8 byte registers
• LLVM spills registers onto the stack
• Possible workarounds:
• Bump up the maximum stack size in kernel
• Enable more efficient use of stack in LLVM
• Registers having const_imm spills without tracking state [#34]
• BPF only has 10 registers, LLVM spills the register to stack when necessary
• BPF verifier keeps the register states and restore after BPF_LOAD
• Current version does not support spill const_imm
Demo Testbed
• Linux kernel net-next 4.10.0-rc7
• Due to two BPF verifier fixes
• Plus our own 2 patches to increase BPF stack size to 4096
• i40e XDP driver
• V4 patch: http://patchwork.ozlabs.org/patch/706701/
• Demo source code at, see demo*
• https://github.com/williamtu/p4c-xdp/tree/master/tests/
16-core Intel Xeon
E5 2650 2.4GHz
32GB memory
Intel i40e driver
Intel X710 10GbE
Dual port i40e
21
Sender 138
Intel X710 10GbE
i40e driver with XDP patch
Linux kernel
4.10.0-rc7
IP: 2.2.2.9
Run P4-XDP Receiver 139
Demo1: Swap Ethernet (xdp11.p4)
• Swap Ethernet source and destination
• Send to the receiving interface (return XDP_TX)
https://github.com/williamtu/p4c-xdp/blob/master/tests/xdp11.p4 https://youtu.be/On7hEJ6bPVU
Sender
Receiver
Swap Eth
XDP_TX
Demo2: ping4/6 and stats (xdp12.p4)
• Parse IPv4/IPv6 ICMP ping
• Drop ipv6 ping, and return XDP_DROP
• Demonstrate control plane
• Update ipv4 statistics, and return XDP_PASS
https://youtu.be/vlp1MzWVOc8
https://github.com/williamtu/p4c-xdp/blob/master/tests/xdp12.p4
Demo3: Encapsulation (xdp16.p4)
• Define a customized header
• Insert the header in front of Ethernet (or any where you want)
ETH payloadIPv4
header myhdr_t
{
bit<32> id;
bit<32> timestamp;
}
control Ingress(…) {
action TS_action()
{
hd.myhdr.ts = BPF_KTIME_GET_NS(); // BPF helper
hd.myhdr.id = 0xfefefefe;
xoutdrop = false; //XDP_PASS
}
my hdr ETH payloadIPv4
Emit at deparser
https://youtu.be/TibGxCXPNVc
https://github.com/williamtu/p4c-xdp/blob/master/tests/xdp16.p4
Future Wok
• Forward / broadcast /clone
• Currently rely on TC (bpf_skb_clone_redirect)
• XDP_FORWARD support in driver/kernel?
• Recirculation
• Add recirculation support in XDP driver
• Return xdp_recirculate and tail call.
• Use cases
Thank You
Questions?

More Related Content

What's hot

Accelerating Networked Applications with Flexible Packet Processing
Accelerating Networked Applications with Flexible Packet ProcessingAccelerating Networked Applications with Flexible Packet Processing
Accelerating Networked Applications with Flexible Packet ProcessingOpen-NFP
 
Protecting the Privacy of the Network – Using P4 to Prototype and Extend Netw...
Protecting the Privacy of the Network – Using P4 to Prototype and Extend Netw...Protecting the Privacy of the Network – Using P4 to Prototype and Extend Netw...
Protecting the Privacy of the Network – Using P4 to Prototype and Extend Netw...Open-NFP
 
Measuring a 25 and 40Gb/s Data Plane
Measuring a 25 and 40Gb/s Data PlaneMeasuring a 25 and 40Gb/s Data Plane
Measuring a 25 and 40Gb/s Data PlaneOpen-NFP
 
20170925 onos and p4
20170925 onos and p420170925 onos and p4
20170925 onos and p4Yi Tseng
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Andriy Berestovskyy
 
CETH for XDP [Linux Meetup Santa Clara | July 2016]
CETH for XDP [Linux Meetup Santa Clara | July 2016] CETH for XDP [Linux Meetup Santa Clara | July 2016]
CETH for XDP [Linux Meetup Santa Clara | July 2016] IO Visor Project
 
Network Measurement with P4 and C on Netronome Agilio
Network Measurement with P4 and C on Netronome AgilioNetwork Measurement with P4 and C on Netronome Agilio
Network Measurement with P4 and C on Netronome AgilioOpen-NFP
 
Kernel Recipes 2013 - Nftables, what motivations and what solutions
Kernel Recipes 2013 - Nftables, what motivations and what solutionsKernel Recipes 2013 - Nftables, what motivations and what solutions
Kernel Recipes 2013 - Nftables, what motivations and what solutionsAnne Nicolas
 
Linux Native, HTTP Aware Network Security
Linux Native, HTTP Aware Network SecurityLinux Native, HTTP Aware Network Security
Linux Native, HTTP Aware Network SecurityThomas Graf
 
LinuxCon 2015 Stateful NAT with OVS
LinuxCon 2015 Stateful NAT with OVSLinuxCon 2015 Stateful NAT with OVS
LinuxCon 2015 Stateful NAT with OVSThomas Graf
 
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDPDockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDPThomas Graf
 
Comprehensive XDP Off‌load-handling the Edge Cases
Comprehensive XDP Off‌load-handling the Edge CasesComprehensive XDP Off‌load-handling the Edge Cases
Comprehensive XDP Off‌load-handling the Edge CasesNetronome
 
Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...
Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...
Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...Anne Nicolas
 
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
The Next Generation Firewall for Red Hat Enterprise Linux 7 RCThe Next Generation Firewall for Red Hat Enterprise Linux 7 RC
The Next Generation Firewall for Red Hat Enterprise Linux 7 RCThomas Graf
 
BKK16-400B ODPI - Standardizing Hadoop
BKK16-400B ODPI - Standardizing HadoopBKK16-400B ODPI - Standardizing Hadoop
BKK16-400B ODPI - Standardizing HadoopLinaro
 
Programming Protocol-Independent Packet Processors
Programming Protocol-Independent Packet ProcessorsProgramming Protocol-Independent Packet Processors
Programming Protocol-Independent Packet ProcessorsOpen Networking Summits
 
Cilium - BPF & XDP for containers
 Cilium - BPF & XDP for containers Cilium - BPF & XDP for containers
Cilium - BPF & XDP for containersDocker, Inc.
 

What's hot (20)

Accelerating Networked Applications with Flexible Packet Processing
Accelerating Networked Applications with Flexible Packet ProcessingAccelerating Networked Applications with Flexible Packet Processing
Accelerating Networked Applications with Flexible Packet Processing
 
Protecting the Privacy of the Network – Using P4 to Prototype and Extend Netw...
Protecting the Privacy of the Network – Using P4 to Prototype and Extend Netw...Protecting the Privacy of the Network – Using P4 to Prototype and Extend Netw...
Protecting the Privacy of the Network – Using P4 to Prototype and Extend Netw...
 
Measuring a 25 and 40Gb/s Data Plane
Measuring a 25 and 40Gb/s Data PlaneMeasuring a 25 and 40Gb/s Data Plane
Measuring a 25 and 40Gb/s Data Plane
 
20170925 onos and p4
20170925 onos and p420170925 onos and p4
20170925 onos and p4
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
 
Ebpf ovsconf-2016
Ebpf ovsconf-2016Ebpf ovsconf-2016
Ebpf ovsconf-2016
 
CETH for XDP [Linux Meetup Santa Clara | July 2016]
CETH for XDP [Linux Meetup Santa Clara | July 2016] CETH for XDP [Linux Meetup Santa Clara | July 2016]
CETH for XDP [Linux Meetup Santa Clara | July 2016]
 
Network Measurement with P4 and C on Netronome Agilio
Network Measurement with P4 and C on Netronome AgilioNetwork Measurement with P4 and C on Netronome Agilio
Network Measurement with P4 and C on Netronome Agilio
 
Kernel Recipes 2013 - Nftables, what motivations and what solutions
Kernel Recipes 2013 - Nftables, what motivations and what solutionsKernel Recipes 2013 - Nftables, what motivations and what solutions
Kernel Recipes 2013 - Nftables, what motivations and what solutions
 
Linux Native, HTTP Aware Network Security
Linux Native, HTTP Aware Network SecurityLinux Native, HTTP Aware Network Security
Linux Native, HTTP Aware Network Security
 
LinuxCon 2015 Stateful NAT with OVS
LinuxCon 2015 Stateful NAT with OVSLinuxCon 2015 Stateful NAT with OVS
LinuxCon 2015 Stateful NAT with OVS
 
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDPDockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
DockerCon 2017 - Cilium - Network and Application Security with BPF and XDP
 
Comprehensive XDP Off‌load-handling the Edge Cases
Comprehensive XDP Off‌load-handling the Edge CasesComprehensive XDP Off‌load-handling the Edge Cases
Comprehensive XDP Off‌load-handling the Edge Cases
 
Lustre Best Practices
Lustre Best Practices Lustre Best Practices
Lustre Best Practices
 
Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...
Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...
Kernel Recipes 2018 - XDP: a new fast and programmable network layer - Jesper...
 
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
The Next Generation Firewall for Red Hat Enterprise Linux 7 RCThe Next Generation Firewall for Red Hat Enterprise Linux 7 RC
The Next Generation Firewall for Red Hat Enterprise Linux 7 RC
 
BKK16-400B ODPI - Standardizing Hadoop
BKK16-400B ODPI - Standardizing HadoopBKK16-400B ODPI - Standardizing Hadoop
BKK16-400B ODPI - Standardizing Hadoop
 
DPDK In Depth
DPDK In DepthDPDK In Depth
DPDK In Depth
 
Programming Protocol-Independent Packet Processors
Programming Protocol-Independent Packet ProcessorsProgramming Protocol-Independent Packet Processors
Programming Protocol-Independent Packet Processors
 
Cilium - BPF & XDP for containers
 Cilium - BPF & XDP for containers Cilium - BPF & XDP for containers
Cilium - BPF & XDP for containers
 

Viewers also liked

նյութերի տեղափոխումն օրգանիզմում
նյութերի տեղափոխումն օրգանիզմումնյութերի տեղափոխումն օրգանիզմում
նյութերի տեղափոխումն օրգանիզմումManul06
 
Oncology Nursing Society 2013 Teach back poster presentation
Oncology Nursing Society 2013 Teach back poster presentationOncology Nursing Society 2013 Teach back poster presentation
Oncology Nursing Society 2013 Teach back poster presentationMelissa Jo Powell
 
Vasu Contracts Pvt Ltd company profile
Vasu Contracts Pvt Ltd  company profileVasu Contracts Pvt Ltd  company profile
Vasu Contracts Pvt Ltd company profileSatish Verma
 
Mathematics teaching that make sense
Mathematics teaching that make senseMathematics teaching that make sense
Mathematics teaching that make senseAmiruddin Amiruddin
 
Instructional design for distance education
Instructional design for distance educationInstructional design for distance education
Instructional design for distance educationElboni Todd
 
Bulletin 2007-12
Bulletin 2007-12Bulletin 2007-12
Bulletin 2007-12Rob Wilson
 
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)William Liang
 

Viewers also liked (14)

նյութերի տեղափոխումն օրգանիզմում
նյութերի տեղափոխումն օրգանիզմումնյութերի տեղափոխումն օրգանիզմում
նյութերի տեղափոխումն օրգանիզմում
 
Oncology Nursing Society 2013 Teach back poster presentation
Oncology Nursing Society 2013 Teach back poster presentationOncology Nursing Society 2013 Teach back poster presentation
Oncology Nursing Society 2013 Teach back poster presentation
 
Presentation shoes xxi century 2
Presentation shoes xxi century 2Presentation shoes xxi century 2
Presentation shoes xxi century 2
 
Comercio (1)
Comercio (1)Comercio (1)
Comercio (1)
 
Proyecto titulacion
Proyecto titulacionProyecto titulacion
Proyecto titulacion
 
Vasu Contracts Pvt Ltd company profile
Vasu Contracts Pvt Ltd  company profileVasu Contracts Pvt Ltd  company profile
Vasu Contracts Pvt Ltd company profile
 
Mathematics teaching that make sense
Mathematics teaching that make senseMathematics teaching that make sense
Mathematics teaching that make sense
 
Instructional design for distance education
Instructional design for distance educationInstructional design for distance education
Instructional design for distance education
 
Benchmarking kel3
Benchmarking   kel3Benchmarking   kel3
Benchmarking kel3
 
Bulletin 2007-12
Bulletin 2007-12Bulletin 2007-12
Bulletin 2007-12
 
08
0808
08
 
Masters Dissertation Posters 2014
Masters Dissertation Posters 2014 Masters Dissertation Posters 2014
Masters Dissertation Posters 2014
 
La contaminacion
La contaminacion La contaminacion
La contaminacion
 
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
An introduction to the linux kernel and device drivers (NTU CSIE 2016.03)
 

Similar to Compiling P4 to XDP, IOVISOR Summit 2017

Install FD.IO VPP On Intel(r) Architecture & Test with Trex*
Install FD.IO VPP On Intel(r) Architecture & Test with Trex*Install FD.IO VPP On Intel(r) Architecture & Test with Trex*
Install FD.IO VPP On Intel(r) Architecture & Test with Trex*Michelle Holley
 
Rina p4 rina workshop
Rina p4   rina workshopRina p4   rina workshop
Rina p4 rina workshopEduard Grasa
 
OSN days 2019 - Open Networking and Programmable Switch
OSN days 2019 - Open Networking and Programmable SwitchOSN days 2019 - Open Networking and Programmable Switch
OSN days 2019 - Open Networking and Programmable SwitchChun Ming Ou
 
Introduction to eBPF and XDP
Introduction to eBPF and XDPIntroduction to eBPF and XDP
Introduction to eBPF and XDPlcplcp1
 
BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!Linaro
 
DevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructure
DevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructureDevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructure
DevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructureAngelo Failla
 
DPDK Summit 2015 - Intel - Keith Wiles
DPDK Summit 2015 - Intel - Keith WilesDPDK Summit 2015 - Intel - Keith Wiles
DPDK Summit 2015 - Intel - Keith WilesJim St. Leger
 
Linux sever building
Linux sever buildingLinux sever building
Linux sever buildingEdmond Yu
 
Dataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and toolsDataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and toolsStefano Salsano
 
Analise NetFlow in Real Time
Analise NetFlow in Real TimeAnalise NetFlow in Real Time
Analise NetFlow in Real TimePiotr Perzyna
 
P4_tutorial.pdf
P4_tutorial.pdfP4_tutorial.pdf
P4_tutorial.pdfPramodhN3
 
Make Your Containers Faster: Linux Container Performance Tools
Make Your Containers Faster: Linux Container Performance ToolsMake Your Containers Faster: Linux Container Performance Tools
Make Your Containers Faster: Linux Container Performance ToolsKernel TLV
 
Software Network Data Plane - Satisfying the need for speed - FD.io - VPP and...
Software Network Data Plane - Satisfying the need for speed - FD.io - VPP and...Software Network Data Plane - Satisfying the need for speed - FD.io - VPP and...
Software Network Data Plane - Satisfying the need for speed - FD.io - VPP and...Haidee McMahon
 
Summit 16: How to Compose a New OPNFV Solution Stack?
Summit 16: How to Compose a New OPNFV Solution Stack?Summit 16: How to Compose a New OPNFV Solution Stack?
Summit 16: How to Compose a New OPNFV Solution Stack?OPNFV
 
D. Fast, Simple User-Space Network Functions with Snabb (RIPE 77)
D. Fast, Simple User-Space Network Functions with Snabb (RIPE 77)D. Fast, Simple User-Space Network Functions with Snabb (RIPE 77)
D. Fast, Simple User-Space Network Functions with Snabb (RIPE 77)Igalia
 
Tech Days 2015: AdaCore Roadmap
Tech Days 2015: AdaCore RoadmapTech Days 2015: AdaCore Roadmap
Tech Days 2015: AdaCore RoadmapAdaCore
 
Debugging Python with gdb
Debugging Python with gdbDebugging Python with gdb
Debugging Python with gdbRoman Podoliaka
 
[OpenStack Days Korea 2016] Track1 - All flash CEPH 구성 및 최적화
[OpenStack Days Korea 2016] Track1 - All flash CEPH 구성 및 최적화[OpenStack Days Korea 2016] Track1 - All flash CEPH 구성 및 최적화
[OpenStack Days Korea 2016] Track1 - All flash CEPH 구성 및 최적화OpenStack Korea Community
 

Similar to Compiling P4 to XDP, IOVISOR Summit 2017 (20)

eBPF Basics
eBPF BasicseBPF Basics
eBPF Basics
 
FD.io - The Universal Dataplane
FD.io - The Universal DataplaneFD.io - The Universal Dataplane
FD.io - The Universal Dataplane
 
Install FD.IO VPP On Intel(r) Architecture & Test with Trex*
Install FD.IO VPP On Intel(r) Architecture & Test with Trex*Install FD.IO VPP On Intel(r) Architecture & Test with Trex*
Install FD.IO VPP On Intel(r) Architecture & Test with Trex*
 
Rina p4 rina workshop
Rina p4   rina workshopRina p4   rina workshop
Rina p4 rina workshop
 
OSN days 2019 - Open Networking and Programmable Switch
OSN days 2019 - Open Networking and Programmable SwitchOSN days 2019 - Open Networking and Programmable Switch
OSN days 2019 - Open Networking and Programmable Switch
 
Introduction to eBPF and XDP
Introduction to eBPF and XDPIntroduction to eBPF and XDP
Introduction to eBPF and XDP
 
BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!
 
DevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructure
DevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructureDevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructure
DevopsItalia2015 - DHCP at Facebook - Evolution of an infrastructure
 
DPDK Summit 2015 - Intel - Keith Wiles
DPDK Summit 2015 - Intel - Keith WilesDPDK Summit 2015 - Intel - Keith Wiles
DPDK Summit 2015 - Intel - Keith Wiles
 
Linux sever building
Linux sever buildingLinux sever building
Linux sever building
 
Dataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and toolsDataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and tools
 
Analise NetFlow in Real Time
Analise NetFlow in Real TimeAnalise NetFlow in Real Time
Analise NetFlow in Real Time
 
P4_tutorial.pdf
P4_tutorial.pdfP4_tutorial.pdf
P4_tutorial.pdf
 
Make Your Containers Faster: Linux Container Performance Tools
Make Your Containers Faster: Linux Container Performance ToolsMake Your Containers Faster: Linux Container Performance Tools
Make Your Containers Faster: Linux Container Performance Tools
 
Software Network Data Plane - Satisfying the need for speed - FD.io - VPP and...
Software Network Data Plane - Satisfying the need for speed - FD.io - VPP and...Software Network Data Plane - Satisfying the need for speed - FD.io - VPP and...
Software Network Data Plane - Satisfying the need for speed - FD.io - VPP and...
 
Summit 16: How to Compose a New OPNFV Solution Stack?
Summit 16: How to Compose a New OPNFV Solution Stack?Summit 16: How to Compose a New OPNFV Solution Stack?
Summit 16: How to Compose a New OPNFV Solution Stack?
 
D. Fast, Simple User-Space Network Functions with Snabb (RIPE 77)
D. Fast, Simple User-Space Network Functions with Snabb (RIPE 77)D. Fast, Simple User-Space Network Functions with Snabb (RIPE 77)
D. Fast, Simple User-Space Network Functions with Snabb (RIPE 77)
 
Tech Days 2015: AdaCore Roadmap
Tech Days 2015: AdaCore RoadmapTech Days 2015: AdaCore Roadmap
Tech Days 2015: AdaCore Roadmap
 
Debugging Python with gdb
Debugging Python with gdbDebugging Python with gdb
Debugging Python with gdb
 
[OpenStack Days Korea 2016] Track1 - All flash CEPH 구성 및 최적화
[OpenStack Days Korea 2016] Track1 - All flash CEPH 구성 및 최적화[OpenStack Days Korea 2016] Track1 - All flash CEPH 구성 및 최적화
[OpenStack Days Korea 2016] Track1 - All flash CEPH 구성 및 최적화
 

Recently uploaded

WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 

Recently uploaded (20)

WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 

Compiling P4 to XDP, IOVISOR Summit 2017

  • 1. Compiling P4 to XDP Mihai Budiu, VMware Research William Tu, VMware NSBU {mbudiu,tuc}@vmware.com February 27, 2017 IOVisor summit
  • 3. P4 P4: Programming Protocol-Independent Packet Processors Pat Bosshart, Dan Daly, Glen Gibb, Martin Izzard, Nick McKeown, Jennifer Rexford, Cole Schlesinger, Dan Talayco, Amin Vahdat, George Varghese, David Walker ACM SIGCOMM Computer Communications Review (CCR). Volume 44, Issue #3 (July 2014) Initially designed for programmable switches. P416 can support many kinds of packet processing devices. http://P4.org
  • 4. P4.org Consortium Carriers, cloud operators, chip, networking, systems, universities, start-ups
  • 5. P416 • C-like, strongly typed • Arbitrary length bitstrings • Match-action tables • Parser = state machine • No loops, no pointers, no memory allocation • Support for external, target-specific accelerators (e.g., checksum units, multicast, learning, etc.)
  • 6. P416-> C -> EBPF • p4c-xdp: back-end for the P416 reference compiler • Generate stylized C – No loops, all data on stack – EBPF tables for control/data-plane communication – Filtering, forwarding, encapsulation – Currently use Linux TC subsystem for forwarding • https://github.com/williamtu/p4c-xdp
  • 7. P416 generic data plane model Data plane P4 P4 P4 Programmable blocks Fixed function
  • 8. The XDP switching model Parser Match+ Action Deparser XDP Data Plane packetin packetout EBPF tables Control-plane API Drop/tx/pass Output port Input port headers headers
  • 9. xdp_model.p4 enum xdp_action { XDP_ABORTED, // some fatal error occurred during processing; XDP_DROP, // packet should be dropped XDP_PASS, // packet should be passed to the Linux kernel XDP_TX // packet resent out on the same interface } struct xdp_input { bit<32> input_port; } struct xdp_output { xdp_action output_action; bit<32> output_port; // output port for packet } parser xdp_parse<H>(packet_in packet, out H headers); control xdp_switch<H>(inout H hdrs, in xdp_input i, out xdp_output o); control xdp_deparse<H>(in H headers, packet_out packet); package xdp<H>(xdp_parse<H> p, xdp_switch<H> s, xdp_deparse<H> d);
  • 10. Flow app.p4 Clang + LLVM Data Plane XDP driver Verifier app.h BPF system call Hardware Kernel space User space app.c p4c-xdp control-plane.c Control-plane API app.o exe Match-Action tables
  • 11. Simple Example • Parse Ethernet and IPv4 header • Lookup a table using Ethernet’s destination as key • Based on Ethernet’s destination address, execute one action: • Drop the packet (XDP_DROP) • Pass the packet to network stack (XDP_PASS) Parser Match+ Action Deparser Drop Network stack packet
  • 12. P4 Protocol Header Definition header Ethernet { bit<48> source; bit<48> destination; bit<16> protocol; } header IPv4{ bit<4> version; bit<4> ihl; bit<8> diffserv; … } struct Headers { Ethernet ethernet; IPv4 ipv4; } C struct + valid bit C struct struct Ethernet{ u8 source[6]; u8 destination[6]; u16 protocol; u8 ebpf_valid; } … xdp.h P4c-xdp
  • 13. P4 Protocol Parser parser Parser(packet_in packet, out Headers hd) { state start { packet.extract(hd.ethernet); transition select(hd.ethernet.protocl) { 16w0x800: parse_ipv4; default: accept; } } state parse_ipv4 { packet.extract(hd.ipv4); transition accept; } } Code Block Switch-case Code Block BPF Direct Pkt Access BPF Direct Pkt Access goto
  • 14. Table Match and Action control Ingress (inout Headers hdr, in xdp_input xin, out xdp_output xout) { action Drop_action() { xout.output_action = xdp_action.XDP_DROP; } action Fallback_action() { xout.output_action = xdp_action.XDP_PASS; } table mactable { key = {hdr.ethernet.destination : exact; } actions = { Fallback_action; Drop_action; } implementation = hash_table(64); BPF HashMap Key size of 6 byte Value with enum type + parameter Two action types
  • 15. Deparser: Update the Packet control Deparser(in Headers hdrs, packet_out packet) { apply { packet.emit(hdrs.ethernet); packet.emit(hdrs.vlan_tag); packet.emit(hdrs.ipv4); } } • Parser saves results at ‘hdrs’ • Users can push/pop headers by emitting more or skipping emit • Ex: vlan push/pop by add/remove packet.emit(hdrs.vlan_tag); • Need to adjust skb->data by adding xdp_adjust_head helper Example: VLAN Push VLANETH payloadIPv4 skb->data ETH payloadIPv4 skb->data The payload remains in the same memory xdp_adjust_head() helper for extra 4 bytes
  • 16. Setup and Installation • Source code at Github • git clone https://github.com/williamtu/p4c-xdp/ • Vagrant box / docker image available • Dependencies: • P4 2016: https://github.com/p4lang/p4c • Linux >= 4.10.0-rc7: http://www.kernel.org/ • iproute2 >= 4.8.0: https://www.kernel.org/pub/linux/utils/net/iproute2/ • clang+LLVM >=3.7.1: http://llvm.org/releases • P4C-XDP binary • #./p4c-xdp --target xdp -o <output_xdp.c> <input.p4>
  • 17. Experiences with BPF Verifier • Typical packet access check: data + [off] <= data_end • where [off] can be either immediate or • coming from a tracked register that contains an immediate • Two patches related to direct packet access • bpf: enable verifier to better track const alu ops, commit 3fadc8011583 • bpf: enable verifier to add 0 to packet ptr, commit 63dfef75ed753 R1=pkt(id=0,off=0,r=22) R2=pkt_end R3=imm144,min_value=144,max_value=144 30: (bf) r5 = r3 31: (07) r5 += 23 32: (77) r5 >>= 3 33: (bf) r6 = r1 // r6 == pkt 34: (0f) r6 += r5 // pkt += r5
  • 18. Pending Issues • BPF 512 Byte maximum stack size [#22] • Not necessarily due to the size of local variables • LLVM allocates too many things into 8 byte registers • LLVM spills registers onto the stack • Possible workarounds: • Bump up the maximum stack size in kernel • Enable more efficient use of stack in LLVM • Registers having const_imm spills without tracking state [#34] • BPF only has 10 registers, LLVM spills the register to stack when necessary • BPF verifier keeps the register states and restore after BPF_LOAD • Current version does not support spill const_imm
  • 19. Demo Testbed • Linux kernel net-next 4.10.0-rc7 • Due to two BPF verifier fixes • Plus our own 2 patches to increase BPF stack size to 4096 • i40e XDP driver • V4 patch: http://patchwork.ozlabs.org/patch/706701/ • Demo source code at, see demo* • https://github.com/williamtu/p4c-xdp/tree/master/tests/ 16-core Intel Xeon E5 2650 2.4GHz 32GB memory Intel i40e driver Intel X710 10GbE Dual port i40e 21 Sender 138 Intel X710 10GbE i40e driver with XDP patch Linux kernel 4.10.0-rc7 IP: 2.2.2.9 Run P4-XDP Receiver 139
  • 20. Demo1: Swap Ethernet (xdp11.p4) • Swap Ethernet source and destination • Send to the receiving interface (return XDP_TX) https://github.com/williamtu/p4c-xdp/blob/master/tests/xdp11.p4 https://youtu.be/On7hEJ6bPVU Sender Receiver Swap Eth XDP_TX
  • 21. Demo2: ping4/6 and stats (xdp12.p4) • Parse IPv4/IPv6 ICMP ping • Drop ipv6 ping, and return XDP_DROP • Demonstrate control plane • Update ipv4 statistics, and return XDP_PASS https://youtu.be/vlp1MzWVOc8 https://github.com/williamtu/p4c-xdp/blob/master/tests/xdp12.p4
  • 22. Demo3: Encapsulation (xdp16.p4) • Define a customized header • Insert the header in front of Ethernet (or any where you want) ETH payloadIPv4 header myhdr_t { bit<32> id; bit<32> timestamp; } control Ingress(…) { action TS_action() { hd.myhdr.ts = BPF_KTIME_GET_NS(); // BPF helper hd.myhdr.id = 0xfefefefe; xoutdrop = false; //XDP_PASS } my hdr ETH payloadIPv4 Emit at deparser https://youtu.be/TibGxCXPNVc https://github.com/williamtu/p4c-xdp/blob/master/tests/xdp16.p4
  • 23. Future Wok • Forward / broadcast /clone • Currently rely on TC (bpf_skb_clone_redirect) • XDP_FORWARD support in driver/kernel? • Recirculation • Add recirculation support in XDP driver • Return xdp_recirculate and tail call. • Use cases

Editor's Notes

  1. llvm, where it allocates too many things into wide registers and then it spills them onto the stack although they could be spilled into the original stack locations of the local variables. E.g. There are two locations for ethtype on the stack: One in our headers, and one in the spill location, the later being 64 bits. It would almost be better if there was no register allocation at all, and the data would just be manipulated directly on the stack.
  2. # ip link set dev enp66s0f0 xdp obj xdp11.o verb # ./xdp10
  3. action TS_action() { hd.myhdr.ts = BPF_KTIME_GET_NS(); hd.myhdr.id = 0xfefefefe; xoutdrop = false; }