Section 1.39

Data plane versus control plane

Definition

The data plane and the control plane are two roles in a system that handles traffic or events. The data plane does the routine work on each packet, request or event under the rules in force; a router’s data plane forwards each packet by looking up its destination in a forwarding table. The control plane decides and changes those rules: routes, configuration, policies, keys or programs. The data plane reads the rules on every event and must be fast; the control plane changes them occasionally and holds more authority.

The idea

The names come from network routers. A router may receive millions of packets per second and must choose an output port for each one quickly, so it looks up the destination address in a forwarding table that maps address ranges to ports. Building that table is slow, complex work: the router exchanges messages with its neighbors through a routing protocol such as BGP (Border Gateway Protocol) and computes the best paths. Splitting the two jobs keeps the per-packet work simple and fast. Software-defined networking (SDN) goes further and moves the control plane of many switches into one central controller.

The same split appears in any system whose rules change while it runs. A sensor device runs an event handler on every reading: that is its data plane. Now and then the device receives a new filter rule, key or program and installs it: that is its control plane. One data-plane event affects one reading; one control-plane message changes how every later reading is treated, so control-plane input needs stronger authentication §1.6 and authorization §1.7.

The planes are roles, not separate machines. A large router runs them on different hardware. A microcontroller §6.1 usually runs them on one processor, with one memory, one flash chip and often shared locks. Wherever the two planes share a resource, a data-plane event may have to wait while a control-plane operation holds that resource, even though the design keeps the planes apart.

How it works

An update passes through five stages.

  1. Receive the update, often over the same radio, link or message queue that carries data-plane traffic.

  2. Check it: authenticate the sender, confirm that the sender may change rules, and validate the new rules. A signature check alone can take many milliseconds of processor time on a microcontroller.

  3. Build the new rule set in memory, or write it to flash storage. On many microcontrollers the processor stalls while the flash that holds its program code is erased or written, so every task stops.

  4. Publish: make the new rules the active ones. This moment is the linearization point §8.6 of the update: events that start after it use the new rules.

  5. Reclaim the old rules once no event can still be reading them.

At any stage, a data-plane event waits when it needs a resource that the update holds: processor time, if the update runs at the same or a higher priority or cannot be interrupted; a lock on the rule table; a first-in, first-out §14.14 queue in which a slow update sits ahead of the events; memory, if the old and new rule sets together exceed what is free; or a device such as a radio, bus or flash chip.

The standard repair keeps update work off the data plane’s path. The update runs at a lower priority, so data-plane work preempts it, that is, takes the processor away from it, whenever an event is ready. It builds the new rule set in a private copy that the data plane never reads, without holding any lock that the data plane needs. It publishes with one atomic operation §9.8, a write that no task can observe half done, which replaces the pointer to the active rule set. Each event reads that pointer once, at its start, and uses one rule set throughout, so no event mixes old and new rules. This pattern is immutable publication §9.24; read-copy update §9.20 (RCU) is a widely used form of it.

Interference also runs the other way. A flood of data-plane traffic can keep a low-priority control plane from running and so delay an urgent change, such as withdrawing a stolen key. Routers therefore limit the rate of packets addressed to their own control plane.

Worked example

A hypothetical device runs both planes on one processor. Each data event needs 1 ms of processing and must finish within 5 ms of its arrival. An update needs 35 ms of processing. The update starts at time 0 ms, and data events arrive at 10, 20 and 30 ms.

Design 1: one worker, first come, first served. The update occupies the worker from 0 to 35 ms, and the events then run one after another.

All three miss the 5 ms requirement, although the data-plane code has no bug.

Design 2: a separate, lower-priority update thread that holds a lock. Data-plane work can now preempt the update, but the update holds the lock on the rule table from 0 to 35 ms. The event of 10 ms preempts the update, asks for the lock and waits until 35 ms. The response times are again 26, 17 and 8 ms: the lock, not the processor, is the shared resource.

Design 3: build privately, publish with one pointer write. The update builds the new table without the lock. Each event preempts the update, reads the active-table pointer and finishes 1 ms later, so every response time is 1 ms. The update loses 3×1=33 \times 1 = 3 ms to the events and publishes at 35+3=3835 + 3 = 38 ms. All three events used the old rules, because they started before the publication. With 4 KiB per table, both tables exist until the old one is reclaimed, so the update needs 4+4=84 + 4 = 8 KiB at its peak.

Stated precisely

Two separate claims describe how an update affects the data plane, and each needs its own evidence. Effect claim: let tpt_p be the publication time of an update. Every data-plane event that starts after tpt_p uses the new rule set, every event that started before tpt_p uses the old rule set until it finishes, and no event uses parts of both.

Cost claim: consider one data-plane event on a single processor. Let CC be its own processing time. Let BB be the total time, between its arrival and its completion, during which the event is ready but cannot run because of control-plane work: update code that the event cannot preempt, a lock or device the update holds, or a processor stalled by the update’s flash erase. Let II be the time in the same interval spent on other work that runs ahead of the event, earlier data events included. The event’s response time RR, from arrival to completion, is then R=C+B+I,R = C + B + I, and the data plane meets its deadline DD during updates exactly when C+B+I≤DC + B + I \le D holds for every event. In Design 1, the event of 20 ms has C=1C = 1, B=35−20=15B = 35 - 20 = 15 and I=1I = 1, so R=1+15+1=17R = 1 + 15 + 1 = 17 ms.

The effect claim assumes that each event reads the active-rule pointer once, that one atomic operation writes the pointer, and that the old rule set is neither changed nor freed while an event that read it may still run. A small BB assumes that data-plane work can preempt update work, that the update holds no resource the data plane needs for longer than a measured or analyzed bound, and that memory for both rule sets is reserved before the update starts.

Limits and common mistakes

Separate names, functions, threads or interfaces do not isolate the two planes. Isolation exists only for resources that are actually separate, such as processor time under preemptive priorities, separate locks, reserved memory and separate queues.

Priority does not help against a lock. A high-priority data-plane task that waits for a lock held by a low-priority update waits for the whole hold time, and longer if a medium-priority task preempts the update meanwhile, which is priority inversion §9.16. Priority inheritance §9.17 removes that extra wait but not the hold time.

Measurements taken before or after an update omit BB, which exists only while the update runs. A claim that service continues during updates needs measurement or analysis of the update itself.

The control plane is the larger target. An attacker who can inject one control-plane message changes the treatment of every later event, and an attacker who can trigger updates at will can use their cost for a denial of service §1.28. Control-plane input needs authentication, authorization, protection against replay and a rate limit.

Some texts name a third role, the management plane: the interfaces that operators use to configure and monitor a system. Others count it as part of the control plane.

Questions answered

Can a control-plane update block ordinary data-plane service?

Yes: a control-plane update delays or stops ordinary data-plane service whenever the two planes share a resource and the update holds it. The control plane installs or changes rules, configuration, keys or programs; the data plane handles each ordinary request or event under the current rules. On one processor the shared resources include processor time, a lock on the rule table, a common message queue, memory, and devices such as flash memory §6.6, whose erasure stalls the processor on many microcontrollers. A data-plane event that needs any of them waits until the update releases it, although the data-plane code has no bug. A separate update thread does not help while the event still waits for the same lock.

To bound the delay, run the update at a lower priority so that data-plane work preempts it, build the new rules in a private copy without holding locks the data plane needs, reserve memory for both versions, and switch to the new rules with one atomic pointer write. A claim that service continues during updates must state the data-plane deadline and show that the longest time the update can hold any shared resource, plus the event’s own processing time, fits within it.

Related entries: Schedulability (§9.37), Linearization point (§8.6), Availability (§1.10), Immutable publication (§9.24), Priority inversion (§9.16).