How does forwarding mechanism in P4 Switch compare to CEF?

CEF maintains FIB and Adjacency table with specific data structure for faster and efficient route lookup and L2 header swap. Does P4 switch also maintain similar table in the backend? Can P4 match-action table provide similar performance?

P4 the name comes from "Programming Protocol-Independent Packet Processors” [1].

The “Protocol-Independent” part of that name comes from the fact that you can write P4 programs that don’t have a FIB, nor an adjacency table, nor the ability to recognize or handle IPv4 packets.

Now, many P4 programs deployed in production can do those things, yes. P4 match-action tables are used to implement those features, and many other data plane features.

The performance of P4 running a target depends completely upon the target’s capabilities. It could be a BMv2/behavioral-model software switch running on a x86_64 CPU, costing thousands of instructions to process each packet, plus cache misses, etc. that lower performance, or it could be running on a Tofino ASIC or a programmable NIC capable of handling packet sizes averaging around 300 to 500 bytes at full line rate.

[1] P4 (programming language) - Wikipedia

1 Like