Programming the Forwarding Plane
Nick ¡McKeown ¡
Stanford ¡University ¡ ¡
OCP: Wedge switch (open-source design) Switch chip! 3 - - PowerPoint PPT Presentation
Programming the Forwarding Plane Nick McKeown Stanford University Programming the Forwarding Plane Why is there a blackbox in my whitebox? Nick McKeown Stanford University OCP: Wedge
Stanford ¡University ¡ ¡
Stanford ¡University ¡ ¡
3 ¡
Switch ¡chip! ¡
Driver ¡
0.1 1 10 100 1000 10000 100000 1990 1995 2000 2005 2010 2015 2020 Switch Chip CPU
9 ¡
(per ¡chip) ¡
0.1 1 10 100 1000 10000 100000 1990 1995 2000 2005 2010 2015 2020 Switch Chip CPU
10 ¡
(per ¡chip) ¡
12 ¡
Whitebox ¡CPU ¡
Blackbox ¡switch ¡
GPU ¡
Compiler ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡
ApplicaSons ¡ DSP ¡
Compiler ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡
ApplicaSons ¡
My ¡codec ¡ My ¡renderer ¡
16 ¡
21 ¡
¡Programmable ¡ Parser ¡
Memory ¡
ALU ¡
22 ¡
¡Programmable ¡ Parser ¡
Memory ¡
ALU ¡
Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡ Serial ¡ I/O ¡
Parser ¡
¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡
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**
†Barefoot Networks *Intel ‡Stanford University **Princeton University ¶Google §Microsoft ResearchABSTRACT
P4 is a high-level language for programming protocol-inde- pendent packet processors. P4 works in conjunction with SDN control protocols like OpenFlow. In its current form, OpenFlow explicitly specifies protocol headers on which it
years, increasing the complexity of the specification while still not providing the flexibility to add new headers. In this paper we propose P4 as a strawman proposal for how Open- Flow should evolve in the future. We have three goals: (1) Reconfigurability in the field: Programmers should be able to change the way switches process packets once they are
be tied to any specific network protocols. (3) Target inde- pendence: Programmers should be able to describe packet- processing functionality independently of the specifics of the underlying hardware. As an example, we describe how to use P4 to configure a switch to add a new hierarchical label.
1. INTRODUCTION
Software-Defined Networking (SDN) gives operators pro- grammatic control over their networks. In SDN, the con- trol plane is physically separate from the forwarding plane, and one control plane controls multiple forwarding devices. While forwarding devices could be programmed in many ways, having a common, open, vendor-agnostic interface (like OpenFlow) enables a control plane to control forward- ing devices from different hardware and software vendors.
Version Date Header Fields OF 1.0 Dec 2009 12 fields (Ethernet, TCP/IPv4) OF 1.1 Feb 2011 15 fields (MPLS, inter-table metadata) OF 1.2 Dec 2011 36 fields (ARP, ICMP, IPv6, etc.) OF 1.3 Jun 2012 40 fields OF 1.4 Oct 2013 41 fields
Table 1: Fields recognized by the OpenFlow standard The OpenFlow interface started simple, with the abstrac- tion of a single table of rules that could match packets on a dozen header fields (e.g., MAC addresses, IP addresses, pro- tocol, TCP/UDP port numbers, etc.). Over the past five years, the specification has grown increasingly m plicated (see Table 1), with many more multiple stages of rule tables, to allow switches to expose more of their capabilities to the controller. The proliferation of new header fields shows no signs of
creasingly want to apply new forms of packet encapsula- tion (e.g., NVGRE, VXLAN, and STT), for which they re- sort to deploying software switches that are easier to extend with new functionality. Rather than repeatedly extending the OpenFlow specification, we argue that future switches should support flexible mechanisms for parsing packets and matching header fields, allowing controller applications to leverage these capabilities through a common, open inter- face (i.e., a new “OpenFlow 2.0” API). Such a general, ex- tensible approach would be simpler, more elegant, and more future-proof than today’s OpenFlow 1.x standard. Figure 1: P4 is a language to configure switches. Recent chip designs demonstrate that such flexibility can be achieved in custom ASICs at terabit speeds [1, 2, 3]. Pro- gramming this new generation of switch chips is far from easy. Each chip has its own low-level interface, akin to microcode programming. In this paper, we sketch the de- sign of a higher-level language for Programming Proto independent Packet Processors (P4). Figu relationship between P4—used t it how packets are to as Open
ACM Sigcomm Computer Communications Review July 2014
George ¡ Varghese ¡ Amin ¡ ¡ Vahdat ¡ Jen ¡ Rexford ¡ Dan ¡ Daly ¡ Pat ¡ Bosshart ¡ Glen ¡ Gibb ¡ MarSn ¡ Izzard ¡ Dave ¡ Walker ¡ Cole ¡ Schlesinger ¡ Dan ¡ Talayco ¡ Nick ¡ McKeown ¡
¡Programmable ¡ Parser ¡
Logical ¡Data-‑plane ¡View ¡ (your ¡P4 ¡program) ¡ Switch ¡Pipeline ¡
Queues ¡
Programmable ¡ Parser ¡ Fixed ¡AcSon ¡ Match ¡Table ¡ Match ¡Table ¡ Match ¡Table ¡ Match ¡Table ¡ L2 ¡ IPv4 ¡ IPv6 ¡ ACL ¡ AcSon ¡ALUs ¡ AcSon ¡ALUs ¡ AcSon ¡ALUs ¡ AcSon ¡ALUs ¡ CLK ¡
Match ¡Table ¡ AcSon ¡ALUs ¡
Queues ¡
Match ¡Table ¡ Match ¡Table ¡ Match ¡Table ¡ L2 ¡Table ¡ IPv4 ¡Table ¡ IPv6 ¡Table ¡ ACL ¡Table ¡ AcSon ¡ALUs ¡ AcSon ¡ALUs ¡ AcSon ¡ALUs ¡ L2 ¡ IPv4 ¡ IPv6 ¡ ACL ¡ Logical ¡Data-‑plane ¡View ¡ ¡ (your ¡P4 ¡program) ¡ Switch ¡Pipeline ¡ L2 ¡ IPv6 ¡ ACL ¡ IPv4 ¡ L2 ¡AcSon ¡Macro ¡ v4 ¡AcSon ¡Macro ¡ v6 ¡AcSon ¡Macro ¡ ¡ ACL ¡AcSon ¡Macro ¡
33 ¡
Programmable ¡ Parser ¡ CLK ¡
Logical ¡Data-‑plane ¡View ¡ (your ¡P4 ¡program) ¡ Switch ¡Pipeline ¡
Queues ¡
L2 ¡Table ¡ IPv4 ¡Table ¡ ACL ¡Table ¡ IPv6 ¡Table ¡
MyEncap ¡
L2 ¡ IPv4 ¡ IPv6 ¡ ACL ¡ MyEncap ¡ L2 ¡AcSon ¡Macro ¡ v4 ¡AcSon ¡Macro ¡ ACL ¡AcSon ¡Macro ¡ AcSon ¡ MyEncap ¡ v6 ¡AcSon ¡Macro ¡ IPv4 ¡ AcSon ¡ IPv4 ¡ AcSon ¡
34 ¡
IPv6 ¡ AcSon ¡ IPv6 ¡ Programmable ¡ Parser ¡ CLK ¡
35 ¡
L2 ¡ IPv4 ¡ ACL ¡
MyEncap ¡
MyEncap ¡ IPv6 ¡
header_type ethernet_t { fields { dstAddr : 48; srcAddr : 48; etherType : 16; } } parser parse_ethernet { extract(ethernet); return select(latest.etherType) { 0x8100 : parse_vlan; 0x800 : parse_ipv4; 0x86DD : parse_ipv6; } }
TCP ¡ IPv4 ¡ IPv6 ¡ MyEncap ¡ Eth ¡
header_type my_encap_t { fields { foo : 12; bar : 8; baz : 4; qux : 4; next_protocol : 4; } }
36 ¡
L2 ¡ IPv4 ¡ ACL ¡
MyEncap ¡
MyEncap ¡ IPv6 ¡
table ipv4_lpm { reads { ipv4.dstAddr : lpm; } actions { set_next_hop; drop; } } action set_next_hop(nhop_ipv4_addr, port) { modify_field(metadata.nhop_ipv4_addr, nhop_ipv4_addr); modify_field(standard_metadata.egress_port, port); add_to_field(ipv4.ttl, -1); } control ingress { apply(l2); apply(my_encap); if (valid(ipv4) { apply(ipv4_lpm); } else { apply(ipv6_lpm); } apply(acl); }
Programmable ¡Parser ¡ Match ¡Table ¡ Match ¡Table ¡ Match ¡Table ¡ Match ¡Table ¡ AcSon ¡Macro ¡ AcSon ¡Macro ¡ AcSon ¡Macro ¡ AcSon ¡Macro ¡
Control ¡Flow ¡ Switch ¡Pipeline ¡
Queues ¡
L2 ¡Table ¡ IPv4 ¡Table ¡ IPv6 ¡Table ¡ ACL ¡ Table ¡
AcSon ¡ v4 ¡AcSon ¡Macro ¡ v6 ¡AcSon ¡Macro ¡ AcSon ¡
38 ¡
Control ¡Flow ¡Graph ¡
L2 ¡
v4 ¡ v6 ¡ ACL ¡
Table ¡Dependency ¡Graph ¡
39 ¡
Switch ¡Pipeline ¡
Queues ¡
Programmable ¡Parser ¡ L2 ¡Table ¡ IPv4 ¡Table ¡ IPv6 ¡Table ¡ Table ¡Dependency ¡Graph ¡ Control ¡Flow ¡Graph ¡
AcSon ¡ v4 ¡AcSon ¡Macro ¡ v6 ¡AcSon ¡Macro ¡
40 ¡
ACL ¡ Table ¡ AcSon ¡
41 ¡
IPv6-‑Mcast ¡ EG-‑ACL1 ¡ EG-‑Phy-‑ Meta ¡ IG-‑Agg-‑Inu ¡ IG-‑Dmac ¡ IPv4-‑Mcast ¡ IPv4-‑ Nexthop ¡ IPv6-‑ Nexthop ¡ IG-‑Props ¡ IG-‑Router-‑ Mac ¡ Ipv4-‑Ecmp ¡ IG-‑Smac ¡ Ipv4-‑Ucast-‑ LPM ¡ Ipv4-‑Ucast-‑ Host ¡ Ipv6-‑Ucast-‑ Host ¡ Ipv6-‑Ucast-‑ LPM ¡ Ipv6-‑Ecmp ¡ IG_ACL2 ¡ IG_Bcast_St
Ipv4_Urpf ¡ Ipv6_Urpf ¡ IG_ACL1 ¡ EG_Props ¡ IG_Phy_Meta ¡
Exact ¡ TCAM ¡
P4 ¡code, ¡switch ¡models ¡and ¡compilers ¡available ¡at: ¡hjp://github.com/p4lang ¡ ¡
Systems ¡ Targets ¡ Academia ¡ Operators ¡ Original ¡P4 ¡paper ¡authors ¡from ¡Barefoot, ¡Google, ¡Intel, ¡MicrosoF, ¡Princeton ¡University, ¡and ¡Stanford ¡University ¡ ¡
46 ¡
VLAN Ingress Processing
Match: ingress_port vlan.vid Action: add_vlan no_op
MAC Learning
Match: eth.src Action: learn no_op
Switching
Match: eth.dst vlan.vid Action: forward bcast
Routing
Match: ip.dst Action: nexthop drop
Routable
Match: eth.src eth.dst vlan.vid Action: no_op
ACL
Match: ip.src,ip.dst ip.prtcl, port.src,port.dst Action: no_op drop
VLAN Egress Processing
Match: egress_port vlan.vid Action: remove_vlan no_op
route
Code ¡mastery ¡no ¡longer ¡needed ¡
NIC ¡ NIC ¡
P4 ¡Compiler ¡
P4 ¡ code ¡ P4 ¡ code ¡ P4 ¡ code ¡ P4 ¡ code ¡ P4 ¡ code ¡ P4 ¡ code ¡ P4 ¡ code ¡
AutomaScally ¡parSSon ¡ ¡ and ¡generate ¡code ¡
Declared ¡network ¡forwarding ¡behavior ¡
51 ¡