Programmable forwarding models
A match selects an action
A programmable forwarding pipeline reads selected packet fields and metadata, chooses an action, and may update metadata for later stages. In this lesson use a single fictional IPv4 table: a rule matches an ingress port, destination prefix and protocol/port if specified. The highest numeric priority among matching entries wins. Distinct priorities avoid ties. A miss drops. This is a deliberately simplified OpenFlow-like model, not OpenFlow syntax, a stateful firewall, or a full IP forwarding implementation.
Evaluate overlapping rules
Read the table below. A packet arriving at port 1 with destination 192.0.2.20 and TCP destination port 443 matches the broad deny and the specific allow, but priority 200 wins and selects output 2. A TCP packet to port 80 for that same address matches only the deny. A packet to 192.0.2.30 also matches the deny. Port 4 has no rule and drops. For the reverse direction, a separate rule permits packets entering port 2 toward 198.51.100.10; this is intentionally a broad return rule, not connection tracking. A production policy would restrict it further using appropriate identity and state.
Priority | ingress | destination | proto | dport | action200 | 1 | 192.0.2.20/32 | TCP | 443 | output 2100 | 1 | 192.0.2.0/24 | any | any | drop150 | 2 | 198.51.100.10/32| any | any | output 1Miss: dropPriority is not longest prefix alone
If the broad deny is accidentally assigned priority 250, the TLS service packet now drops even though its allow rule has a more specific /32. Prefix length does not override the explicit priority in this model. Correct the intended ordering, then test both permitted and denied packets. A rule count or an API success response alone cannot establish that policy is correct. The table assumes decoded IPv4 fields, no fragments, no source validation, no TTL or checksum processing, and no Layer 2 resolution. Output selection is not proof of end-to-end delivery.
P4 and eBPF/XDP solve different problems
P4 is a language for defining packet-processing behavior, including parsers and match-action control. The target architecture determines available resources and actions; a compiler maps a program to that target. Changing table entries is different from changing the pipeline program. Linux eBPF provides verified programs for several hooks; XDP is an early ingress packet-processing hook with actions such as pass, drop and redirect. AF_XDP can deliver redirected frames to user space. Neither P4 nor XDP is itself an SDN controller, and verifier acceptance does not prove that a network policy meets business intent. Consult systems programming and cloud/container networking lessons for implementation prerequisites.
Practice with a paper table
Change the deny priority to 250, predict the permitted-service packet result, then restore 100. Try a UDP packet to port 443 and a TCP packet entering port 4. Explain which matching fields matter and which behavior the model cannot demonstrate. No switch configuration, program attachment or packet transmission is needed.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Programmable forwarding models Quiz
Reason about SDN architecture, match-action rules and controller failure.
In the toy table, ingress 1 TCP to 192.0.2.20:443 selects what?
What happens if the broad deny priority becomes 250?
What happens to UDP destination port 443 entering port 1 toward 192.0.2.20?
What can a P4 program define?
What does eBPF verifier acceptance establish?