1 Design Decisions In Open vSwitch
2 ================================
4 This document describes design decisions that went into implementing
5 Open vSwitch. While we believe these to be reasonable decisions, it is
6 impossible to predict how Open vSwitch will be used in all environments.
7 Understanding assumptions made by Open vSwitch is critical to a
8 successful deployment. The end of this document contains contact
9 information that can be used to let us know how we can make Open vSwitch
10 more generally useful.
15 Over time, Open vSwitch has added many knobs that control whether a
16 given controller receives OpenFlow asynchronous messages. This
17 section describes how all of these features interact.
19 First, a service controller never receives any asynchronous messages
20 unless it changes its miss_send_len from the service controller
21 default of zero in one of the following ways:
23 - Sending an OFPT_SET_CONFIG message with nonzero miss_send_len.
25 - Sending any NXT_SET_ASYNC_CONFIG message: as a side effect, this
26 message changes the miss_send_len to
27 OFP_DEFAULT_MISS_SEND_LEN (128) for service controllers.
29 Second, OFPT_FLOW_REMOVED and NXT_FLOW_REMOVED messages are generated
30 only if the flow that was removed had the OFPFF_SEND_FLOW_REM flag
33 Third, OFPT_PACKET_IN and NXT_PACKET_IN messages are sent only to
34 OpenFlow controller connections that have the correct connection ID
35 (see "struct nx_controller_id" and "struct nx_action_controller"):
37 - For packet-in messages generated by a NXAST_CONTROLLER action,
38 the controller ID specified in the action.
40 - For other packet-in messages, controller ID zero. (This is the
41 default ID when an OpenFlow controller does not configure one.)
43 Finally, Open vSwitch consults a per-connection table indexed by the
44 message type, reason code, and current role. The following table
45 shows how this table is initialized by default when an OpenFlow
46 connection is made. An entry labeled "yes" means that the message is
47 sent, an entry labeled "---" means that the message is suppressed.
51 message and reason code other slave
52 ---------------------------------------- ------- -----
53 OFPT_PACKET_IN / NXT_PACKET_IN
56 OFPR_INVALID_TTL --- ---
57 OFPR_ACTION_SET (OF1.4+) yes ---
58 OFPR_GROUP (OF1.4+) yes ---
60 OFPT_FLOW_REMOVED / NXT_FLOW_REMOVED
61 OFPRR_IDLE_TIMEOUT yes ---
62 OFPRR_HARD_TIMEOUT yes ---
71 The NXT_SET_ASYNC_CONFIG message directly sets all of the values in
72 this table for the current connection. The
73 OFPC_INVALID_TTL_TO_CONTROLLER bit in the OFPT_SET_CONFIG message
74 controls the setting for OFPR_INVALID_TTL for the "master" role.
80 The OpenFlow 1.0 specification requires the output port of the OFPAT_ENQUEUE
81 action to "refer to a valid physical port (i.e. < OFPP_MAX) or OFPP_IN_PORT".
82 Although OFPP_LOCAL is not less than OFPP_MAX, it is an 'internal' port which
83 can have QoS applied to it in Linux. Since we allow the OFPAT_ENQUEUE to apply
84 to 'internal' ports whose port numbers are less than OFPP_MAX, we interpret
85 OFPP_LOCAL as a physical port and support OFPAT_ENQUEUE on it as well.
91 The OpenFlow specification for the behavior of OFPT_FLOW_MOD is
92 confusing. The following tables summarize the Open vSwitch
93 implementation of its behavior in the following categories:
95 - "match on priority": Whether the flow_mod acts only on flows
96 whose priority matches that included in the flow_mod message.
98 - "match on out_port": Whether the flow_mod acts only on flows
99 that output to the out_port included in the flow_mod message (if
100 out_port is not OFPP_NONE). OpenFlow 1.1 and later have a
101 similar feature (not listed separately here) for out_group.
103 - "match on flow_cookie": Whether the flow_mod acts only on flows
104 whose flow_cookie matches an optional controller-specified value
107 - "updates flow_cookie": Whether the flow_mod changes the
108 flow_cookie of the flow or flows that it matches to the
109 flow_cookie included in the flow_mod message.
111 - "updates OFPFF_ flags": Whether the flow_mod changes the
112 OFPFF_SEND_FLOW_REM flag of the flow or flows that it matches to
113 the setting included in the flags of the flow_mod message.
115 - "honors OFPFF_CHECK_OVERLAP": Whether the OFPFF_CHECK_OVERLAP
116 flag in the flow_mod is significant.
118 - "updates idle_timeout" and "updates hard_timeout": Whether the
119 idle_timeout and hard_timeout in the flow_mod, respectively,
120 have an effect on the flow or flows matched by the flow_mod.
122 - "updates idle timer": Whether the flow_mod resets the per-flow
123 timer that measures how long a flow has been idle.
125 - "updates hard timer": Whether the flow_mod resets the per-flow
126 timer that measures how long it has been since a flow was
129 - "zeros counters": Whether the flow_mod resets per-flow packet
130 and byte counters to zero.
132 - "may add a new flow": Whether the flow_mod may add a new flow to
133 the flow table. (Obviously this is always true for "add"
134 commands but in some OpenFlow versions "modify" and
135 "modify-strict" can also add new flows.)
137 - "sends flow_removed message": Whether the flow_mod generates a
138 flow_removed message for the flow or flows that it affects.
140 An entry labeled "yes" means that the flow mod type does have the
141 indicated behavior, "---" means that it does not, an empty cell means
142 that the property is not applicable, and other values are explained
150 ADD MODIFY STRICT DELETE STRICT
151 === ====== ====== ====== ======
152 match on priority yes --- yes --- yes
153 match on out_port --- --- --- yes yes
154 match on flow_cookie --- --- --- --- ---
155 match on table_id --- --- --- --- ---
156 controller chooses table_id --- --- ---
157 updates flow_cookie yes yes yes
158 updates OFPFF_SEND_FLOW_REM yes + +
159 honors OFPFF_CHECK_OVERLAP yes + +
160 updates idle_timeout yes + +
161 updates hard_timeout yes + +
162 resets idle timer yes + +
163 resets hard timer yes yes yes
164 zeros counters yes + +
165 may add a new flow yes yes yes
166 sends flow_removed message --- --- --- % %
168 (+) "modify" and "modify-strict" only take these actions when they
169 create a new flow, not when they update an existing flow.
171 (%) "delete" and "delete_strict" generates a flow_removed message if
172 the deleted flow or flows have the OFPFF_SEND_FLOW_REM flag set.
173 (Each controller can separately control whether it wants to
174 receive the generated messages.)
180 OpenFlow 1.1 makes these changes:
182 - The controller now must specify the table_id of the flow match
183 searched and into which a flow may be inserted. Behavior for a
184 table_id of 255 is undefined.
186 - A flow_mod, except an "add", can now match on the flow_cookie.
188 - When a flow_mod matches on the flow_cookie, "modify" and
189 "modify-strict" never insert a new flow.
193 ADD MODIFY STRICT DELETE STRICT
194 === ====== ====== ====== ======
195 match on priority yes --- yes --- yes
196 match on out_port --- --- --- yes yes
197 match on flow_cookie --- yes yes yes yes
198 match on table_id yes yes yes yes yes
199 controller chooses table_id yes yes yes
200 updates flow_cookie yes --- ---
201 updates OFPFF_SEND_FLOW_REM yes + +
202 honors OFPFF_CHECK_OVERLAP yes + +
203 updates idle_timeout yes + +
204 updates hard_timeout yes + +
205 resets idle timer yes + +
206 resets hard timer yes yes yes
207 zeros counters yes + +
208 may add a new flow yes # #
209 sends flow_removed message --- --- --- % %
211 (+) "modify" and "modify-strict" only take these actions when they
212 create a new flow, not when they update an existing flow.
214 (%) "delete" and "delete_strict" generates a flow_removed message if
215 the deleted flow or flows have the OFPFF_SEND_FLOW_REM flag set.
216 (Each controller can separately control whether it wants to
217 receive the generated messages.)
219 (#) "modify" and "modify-strict" only add a new flow if the flow_mod
220 does not match on any bits of the flow cookie
226 OpenFlow 1.2 makes these changes:
228 - Only "add" commands ever add flows, "modify" and "modify-strict"
231 - A new flag OFPFF_RESET_COUNTS now controls whether "modify" and
232 "modify-strict" reset counters, whereas previously they never
233 reset counters (except when they inserted a new flow).
237 ADD MODIFY STRICT DELETE STRICT
238 === ====== ====== ====== ======
239 match on priority yes --- yes --- yes
240 match on out_port --- --- --- yes yes
241 match on flow_cookie --- yes yes yes yes
242 match on table_id yes yes yes yes yes
243 controller chooses table_id yes yes yes
244 updates flow_cookie yes --- ---
245 updates OFPFF_SEND_FLOW_REM yes --- ---
246 honors OFPFF_CHECK_OVERLAP yes --- ---
247 updates idle_timeout yes --- ---
248 updates hard_timeout yes --- ---
249 resets idle timer yes --- ---
250 resets hard timer yes yes yes
251 zeros counters yes & &
252 may add a new flow yes --- ---
253 sends flow_removed message --- --- --- % %
255 (%) "delete" and "delete_strict" generates a flow_removed message if
256 the deleted flow or flows have the OFPFF_SEND_FLOW_REM flag set.
257 (Each controller can separately control whether it wants to
258 receive the generated messages.)
260 (&) "modify" and "modify-strict" reset counters if the
261 OFPFF_RESET_COUNTS flag is specified.
267 OpenFlow 1.3 makes these changes:
269 - Behavior for a table_id of 255 is now defined, for "delete" and
270 "delete-strict" commands, as meaning to delete from all tables.
271 A table_id of 255 is now explicitly invalid for other commands.
273 - New flags OFPFF_NO_PKT_COUNTS and OFPFF_NO_BYT_COUNTS for "add"
276 The table for 1.3 is the same as the one shown above for 1.2.
282 OpenFlow 1.4 makes these changes:
284 - Adds the "importance" field to flow_mods, but it does not
285 explicitly specify which kinds of flow_mods set the importance.
286 For consistency, Open vSwitch uses the same rule for importance
287 as for idle_timeout and hard_timeout, that is, only an "ADD"
288 flow_mod sets the importance. (This issue has been filed with
291 - Eviction Mechanism to automatically delete entries of lower
292 importance to make space for newer entries.
298 Open vSwitch makes all flow table modifications atomically, i.e., any
299 datapath packet only sees flow table configurations either before or
300 after any change made by any flow_mod. For example, if a controller
301 removes all flows with a single OpenFlow "flow_mod", no packet sees an
302 intermediate version of the OpenFlow pipeline where only some of the
303 flows have been deleted.
305 It should be noted that Open vSwitch caches datapath flows, and that
306 the cached flows are NOT flushed immediately when a flow table
307 changes. Instead, the datapath flows are revalidated against the new
308 flow table as soon as possible, and usually within one second of the
309 modification. This design amortizes the cost of datapath cache
310 flushing across multiple flow table changes, and has a significant
311 performance effect during simultaneous heavy flow table churn and high
312 traffic load. This means that different cached datapath flows may
313 have been computed based on a different flow table configurations, but
314 each of the datapath flows is guaranteed to have been computed over a
315 coherent view of the flow tables, as described above.
317 With OpenFlow 1.4 bundles this atomicity can be extended across an
318 arbitrary set of flow_mods. Bundles are supported for flow_mod and
319 port_mod messages only. For flow_mods, both 'atomic' and 'ordered'
320 bundle flags are trivially supported, as all bundled messages are
321 executed in the order they were added and all flow table modifications
322 are now atomic to the datapath. Port mods may not appear in atomic
323 bundles, as port status modifications are not atomic.
325 To support bundles, ovs-ofctl has a '--bundle' option that makes the
326 flow mod commands ('add-flow', 'add-flows', 'mod-flows', 'del-flows',
327 and 'replace-flows') use an OpenFlow 1.4 bundle to operate the
328 modifications as a single atomic transaction. If any of the flow mods
329 in a transaction fail, none of them are executed. All flow mods in a
330 bundle appear to datapath lookups simultaneously.
332 Furthermore, ovs-ofctl 'add-flow' and 'add-flows' commands now accept
333 arbitrary flow mods as an input by allowing the flow specification to
334 start with an explicit 'add', 'modify', 'modify_strict', 'delete', or
335 'delete_strict' keyword. A missing keyword is treated as 'add', so
336 this is fully backwards compatible. With the new '--bundle' option
337 all the flow mods are executed as a single atomic transaction using an
338 OpenFlow 1.4 bundle. Without the '--bundle' option the flow mods are
339 executed in order up to the first failing flow_mod, and in case of an
340 error the earlier successful flow_mods are not rolled back.
346 The OpenFlow 1.1 specification for OFPT_PACKET_IN is confusing. The
347 definition in OF1.1 openflow.h is[*]:
350 /* Packet received on port (datapath -> controller). */
351 struct ofp_packet_in {
352 struct ofp_header header;
353 uint32_t buffer_id; /* ID assigned by datapath. */
354 uint32_t in_port; /* Port on which frame was received. */
355 uint32_t in_phy_port; /* Physical Port on which frame was received. */
356 uint16_t total_len; /* Full length of frame. */
357 uint8_t reason; /* Reason packet is being sent (one of OFPR_*) */
358 uint8_t table_id; /* ID of the table that was looked up */
359 uint8_t data[0]; /* Ethernet frame, halfway through 32-bit word,
360 so the IP header is 32-bit aligned. The
361 amount of data is inferred from the length
362 field in the header. Because of padding,
363 offsetof(struct ofp_packet_in, data) ==
364 sizeof(struct ofp_packet_in) - 2. */
366 OFP_ASSERT(sizeof(struct ofp_packet_in) == 24);
369 The confusing part is the comment on the data[] member. This comment
370 is a leftover from OF1.0 openflow.h, in which the comment was correct:
371 sizeof(struct ofp_packet_in) is 20 in OF1.0 and offsetof(struct
372 ofp_packet_in, data) is 18. When OF1.1 was written, the structure
373 members were changed but the comment was carelessly not updated, and
374 the comment became wrong: sizeof(struct ofp_packet_in) and
375 offsetof(struct ofp_packet_in, data) are both 24 in OF1.1.
377 That leaves the question of how to implement ofp_packet_in in OF1.1.
378 The OpenFlow reference implementation for OF1.1 does not include any
379 padding, that is, the first byte of the encapsulated frame immediately
380 follows the 'table_id' member without a gap. Open vSwitch therefore
381 implements it the same way for compatibility.
383 For an earlier discussion, please see the thread archived at:
384 https://mailman.stanford.edu/pipermail/openflow-discuss/2011-August/002604.html
386 [*] The quoted definition is directly from OF1.1. Definitions used
387 inside OVS omit the 8-byte ofp_header members, so the sizes in
388 this discussion are 8 bytes larger than those declared in OVS
395 The 802.1Q VLAN header causes more trouble than any other 4 bytes in
396 networking. More specifically, three versions of OpenFlow and Open
397 vSwitch have among them four different ways to match the contents and
398 presence of the VLAN header. The following table describes how each
401 Match NXM OF1.0 OF1.1 OF1.2
402 ----- --------- ----------- ----------- ------------
403 [1] 0000/0000 ????/1,??/? ????/1,??/? 0000/0000,--
404 [2] 0000/ffff ffff/0,??/? ffff/0,??/? 0000/ffff,--
405 [3] 1xxx/1fff 0xxx/0,??/1 0xxx/0,??/1 1xxx/ffff,--
406 [4] z000/f000 ????/1,0y/0 fffe/0,0y/0 1000/1000,0y
407 [5] zxxx/ffff 0xxx/0,0y/0 0xxx/0,0y/0 1xxx/ffff,0y
408 [6] 0000/0fff <none> <none> <none>
409 [7] 0000/f000 <none> <none> <none>
410 [8] 0000/efff <none> <none> <none>
411 [9] 1001/1001 <none> <none> 1001/1001,--
412 [10] 3000/3000 <none> <none> <none>
414 Each column is interpreted as follows.
416 - Match: See the list below.
418 - NXM: xxxx/yyyy means NXM_OF_VLAN_TCI_W with value xxxx and mask
419 yyyy. A mask of 0000 is equivalent to omitting
420 NXM_OF_VLAN_TCI(_W), a mask of ffff is equivalent to
423 - OF1.0 and OF1.1: wwww/x,yy/z means dl_vlan wwww, OFPFW_DL_VLAN
424 x, dl_vlan_pcp yy, and OFPFW_DL_VLAN_PCP z. ? means that the
425 given nibble is ignored (and conventionally 0 for wwww or yy,
426 conventionally 1 for x or z). <none> means that the given match
429 - OF1.2: xxxx/yyyy,zz means OXM_OF_VLAN_VID_W with value xxxx and
430 mask yyyy, and OXM_OF_VLAN_PCP (which is not maskable) with
431 value zz. A mask of 0000 is equivalent to omitting
432 OXM_OF_VLAN_VID(_W), a mask of ffff is equivalent to
433 OXM_OF_VLAN_VID. -- means that OXM_OF_VLAN_PCP is omitted.
434 <none> means that the given match is not supported.
438 [1] Matches any packet, that is, one without an 802.1Q header or with
439 an 802.1Q header with any TCI value.
441 [2] Matches only packets without an 802.1Q header.
443 NXM: Any match with (vlan_tci == 0) and (vlan_tci_mask & 0x1000)
444 != 0 is equivalent to the one listed in the table.
446 OF1.0: The spec doesn't define behavior if dl_vlan is set to
447 0xffff and OFPFW_DL_VLAN_PCP is not set.
449 OF1.1: The spec says explicitly to ignore dl_vlan_pcp when
450 dl_vlan is set to 0xffff.
452 OF1.2: The spec doesn't say what should happen if (vlan_vid == 0)
453 and (vlan_vid_mask & 0x1000) != 0 but (vlan_vid_mask != 0x1000),
454 but it would be straightforward to also interpret as [2].
456 [3] Matches only packets that have an 802.1Q header with VID xxx (and
459 [4] Matches only packets that have an 802.1Q header with PCP y (and
462 NXM: z is ((y << 1) | 1).
464 OF1.0: The spec isn't very clear, but OVS implements it this way.
466 OF1.2: Presumably other masks such that (vlan_vid_mask & 0x1fff)
467 == 0x1000 would also work, but the spec doesn't define their
470 [5] Matches only packets that have an 802.1Q header with VID xxx and
473 NXM: z is ((y << 1) | 1).
475 OF1.2: Presumably other masks such that (vlan_vid_mask & 0x1fff)
476 == 0x1fff would also work.
478 [6] Matches packets with no 802.1Q header or with an 802.1Q header
479 with a VID of 0. Only possible with NXM.
481 [7] Matches packets with no 802.1Q header or with an 802.1Q header
482 with a PCP of 0. Only possible with NXM.
484 [8] Matches packets with no 802.1Q header or with an 802.1Q header
485 with both VID and PCP of 0. Only possible with NXM.
487 [9] Matches only packets that have an 802.1Q header with an
488 odd-numbered VID (and any PCP). Only possible with NXM and
489 OF1.2. (This is just an example; one can match on any desired
492 [10] Matches only packets that have an 802.1Q header with an
493 odd-numbered PCP (and any VID). Only possible with NXM. (This
494 is just an example; one can match on any desired VID bit
499 - OF1.2: The top three bits of OXM_OF_VLAN_VID are fixed to zero,
500 so bits 13, 14, and 15 in the masks listed in the table may be
501 set to arbitrary values, as long as the corresponding value bits
502 are also zero. The suggested ffff mask for [2], [3], and [5]
503 allows a shorter OXM representation (the mask is omitted) than
504 the minimal 1fff mask.
510 OpenFlow 1.0 and later versions have the concept of a "flow cookie",
511 which is a 64-bit integer value attached to each flow. The treatment
512 of the flow cookie has varied greatly across OpenFlow versions,
517 - OFPFC_ADD set the cookie in the flow that it added.
519 - OFPFC_MODIFY and OFPFC_MODIFY_STRICT updated the cookie for
520 the flow or flows that it modified.
522 - OFPST_FLOW messages included the flow cookie.
524 - OFPT_FLOW_REMOVED messages reported the cookie of the flow
527 OpenFlow 1.1 made the following changes:
529 - Flow mod operations OFPFC_MODIFY, OFPFC_MODIFY_STRICT,
530 OFPFC_DELETE, and OFPFC_DELETE_STRICT, plus flow stats
531 requests and aggregate stats requests, gained the ability to
532 match on flow cookies with an arbitrary mask.
534 - OFPFC_MODIFY and OFPFC_MODIFY_STRICT were changed to add a
535 new flow, in the case of no match, only if the flow table
536 modification operation did not match on the cookie field.
537 (In OpenFlow 1.0, modify operations always added a new flow
538 when there was no match.)
540 - OFPFC_MODIFY and OFPFC_MODIFY_STRICT no longer updated flow
543 OpenFlow 1.2 made the following changes:
545 - OFPC_MODIFY and OFPFC_MODIFY_STRICT were changed to never
546 add a new flow, regardless of whether the flow cookie was
549 Open vSwitch support for OpenFlow 1.0 implements the OpenFlow 1.0
550 behavior with the following extensions:
552 - An NXM extension field NXM_NX_COOKIE(_W) allows the NXM
553 versions of OFPFC_MODIFY, OFPFC_MODIFY_STRICT, OFPFC_DELETE,
554 and OFPFC_DELETE_STRICT flow_mods, plus flow stats requests
555 and aggregate stats requests, to match on flow cookies with
556 arbitrary masks. This is much like the equivalent OpenFlow
559 - Like OpenFlow 1.1, OFPC_MODIFY and OFPFC_MODIFY_STRICT add a
560 new flow if there is no match and the mask is zero (or not
563 - The "cookie" field in OFPT_FLOW_MOD and NXT_FLOW_MOD messages
564 is used as the cookie value for OFPFC_ADD commands, as
565 described in OpenFlow 1.0. For OFPFC_MODIFY and
566 OFPFC_MODIFY_STRICT commands, the "cookie" field is used as a
567 new cookie for flows that match unless it is UINT64_MAX, in
568 which case the flow's cookie is not updated.
570 - NXT_PACKET_IN (the Nicira extended version of
571 OFPT_PACKET_IN) reports the cookie of the rule that
572 generated the packet, or all-1-bits if no rule generated the
573 packet. (Older versions of OVS used all-0-bits instead of
576 The following table shows the handling of different protocols when
577 receiving OFPFC_MODIFY and OFPFC_MODIFY_STRICT messages. A mask of 0
578 indicates either an explicit mask of zero or an implicit one by not
579 specifying the NXM_NX_COOKIE(_W) field.
582 Match Update Add on miss Add on miss
583 cookie cookie mask!=0 mask==0
584 ====== ====== =========== ===========
585 OpenFlow 1.0 no yes <always add on miss>
586 OpenFlow 1.1 yes no no yes
587 OpenFlow 1.2 yes no no no
590 * Updates the flow's cookie unless the "cookie" field is UINT64_MAX.
593 Multiple Table Support
594 ======================
596 OpenFlow 1.0 has only rudimentary support for multiple flow tables.
597 Notably, OpenFlow 1.0 does not allow the controller to specify the
598 flow table to which a flow is to be added. Open vSwitch adds an
599 extension for this purpose, which is enabled on a per-OpenFlow
600 connection basis using the NXT_FLOW_MOD_TABLE_ID message. When the
601 extension is enabled, the upper 8 bits of the 'command' member in an
602 OFPT_FLOW_MOD or NXT_FLOW_MOD message designates the table to which a
605 The Open vSwitch software switch implementation offers 255 flow
606 tables. On packet ingress, only the first flow table (table 0) is
607 searched, and the contents of the remaining tables are not considered
608 in any way. Tables other than table 0 only come into play when an
609 NXAST_RESUBMIT_TABLE action specifies another table to search.
611 Tables 128 and above are reserved for use by the switch itself.
612 Controllers should use only tables 0 through 127.
615 OFPTC_* Table Configuration
616 ===========================
618 This section covers the history of the OFPTC_* table configuration
619 bits across OpenFlow versions.
621 OpenFlow 1.0 flow tables had fixed configurations.
623 OpenFlow 1.1 enabled controllers to configure behavior upon flow table
624 miss and added the OFPTC_MISS_* constants for that purpose. OFPTC_*
625 did not control anything else but it was nevertheless conceptualized
626 as a set of bit-fields instead of an enum. OF1.1 added the
627 OFPT_TABLE_MOD message to set OFPTC_MISS_* for a flow table and added
628 the 'config' field to the OFPST_TABLE reply to report the current
631 OpenFlow 1.2 did not change anything in this regard.
633 OpenFlow 1.3 switched to another means to changing flow table miss
634 behavior and deprecated OFPTC_MISS_* without adding any more OFPTC_*
635 constants. This meant that OFPT_TABLE_MOD now had no purpose at all,
636 but OF1.3 kept it around "for backward compatibility with older and
637 newer versions of the specification." At the same time, OF1.3
638 introduced a new message OFPMP_TABLE_FEATURES that included a field
639 'config' documented as reporting the OFPTC_* values set with
640 OFPT_TABLE_MOD; of course this served no real purpose because no
641 OFPTC_* values are defined. OF1.3 did remove the OFPTC_* field from
642 OFPMP_TABLE (previously named OFPST_TABLE).
644 OpenFlow 1.4 defined two new OFPTC_* constants, OFPTC_EVICTION and
645 OFPTC_VACANCY_EVENTS, using bits that did not overlap with
646 OFPTC_MISS_* even though those bits had not been defined since OF1.2.
647 OFPT_TABLE_MOD still controlled these settings. The field for OFPTC_*
648 values in OFPMP_TABLE_FEATURES was renamed from 'config' to
649 'capabilities' and documented as reporting the flags that are
650 supported in a OFPT_TABLE_MOD message. The OFPMP_TABLE_DESC message
651 newly added in OF1.4 reported the OFPTC_* setting.
653 OpenFlow 1.5 did not change anything in this regard.
655 The following table summarizes. The columns say:
657 - OpenFlow version(s).
659 - The OFPTC_* flags defined in those versions.
661 - Whether OFPT_TABLE_MOD can modify OFPTC_* flags.
663 - Whether OFPST_TABLE/OFPMP_TABLE reports the OFPTC_* flags.
665 - What OFPMP_TABLE_FEATURES reports (if it exists): either the
666 current configuration or the switch's capabilities.
668 - Whether OFPMP_TABLE_DESC reports the current configuration.
670 OpenFlow OFPTC_* flags TABLE_MOD stats? TABLE_FEATURES TABLE_DESC
671 --------- ----------------------- --------- ------ -------------- ----------
672 OF1.0 none no[*][+] no[*] nothing[*][+] no[*][+]
673 OF1.1/1.2 MISS_* yes yes nothing[+] no[+]
674 OF1.3 none yes[*] no[*] config[*] no[*][+]
675 OF1.4/1.5 EVICTION/VACANCY_EVENTS yes no capabilities yes
677 [*] Nothing to report/change anyway.
685 Open vSwitch supports stateless handling of IPv6 packets. Flows can be
686 written to support matching TCP, UDP, and ICMPv6 headers within an IPv6
687 packet. Deeper matching of some Neighbor Discovery messages is also
690 IPv6 was not designed to interact well with middle-boxes. This,
691 combined with Open vSwitch's stateless nature, have affected the
692 processing of IPv6 traffic, which is detailed below.
697 The base IPv6 header is incredibly simple with the intention of only
698 containing information relevant for routing packets between two
699 endpoints. IPv6 relies heavily on the use of extension headers to
700 provide any other functionality. Unfortunately, the extension headers
701 were designed in such a way that it is impossible to move to the next
702 header (including the layer-4 payload) unless the current header is
705 Open vSwitch will process the following extension headers and continue
708 * Fragment (see the next section)
709 * AH (Authentication Header)
712 * Destination Options
714 When a header is encountered that is not in that list, it is considered
715 "terminal". A terminal header's IPv6 protocol value is stored in
716 "nw_proto" for matching purposes. If a terminal header is TCP, UDP, or
717 ICMPv6, the packet will be further processed in an attempt to extract
723 IPv6 requires that every link in the internet have an MTU of 1280 octets
724 or greater (RFC 2460). As such, a terminal header (as described above in
725 "Extension Headers") in the first fragment should generally be
726 reachable. In this case, the terminal header's IPv6 protocol type is
727 stored in the "nw_proto" field for matching purposes. If a terminal
728 header cannot be found in the first fragment (one with a fragment offset
729 of zero), the "nw_proto" field is set to 0. Subsequent fragments (those
730 with a non-zero fragment offset) have the "nw_proto" field set to the
731 IPv6 protocol type for fragments (44).
736 An IPv6 jumbogram (RFC 2675) is a packet containing a payload longer
737 than 65,535 octets. A jumbogram is only relevant in subnets with a link
738 MTU greater than 65,575 octets, and are not required to be supported on
739 nodes that do not connect to link with such large MTUs. Currently, Open
740 vSwitch doesn't process jumbograms.
749 An OpenFlow switch must establish and maintain a TCP network
750 connection to its controller. There are two basic ways to categorize
751 the network that this connection traverses: either it is completely
752 separate from the one that the switch is otherwise controlling, or its
753 path may overlap the network that the switch controls. We call the
754 former case "out-of-band control", the latter case "in-band control".
756 Out-of-band control has the following benefits:
758 - Simplicity: Out-of-band control slightly simplifies the switch
761 - Reliability: Excessive switch traffic volume cannot interfere
762 with control traffic.
764 - Integrity: Machines not on the control network cannot
765 impersonate a switch or a controller.
767 - Confidentiality: Machines not on the control network cannot
768 snoop on control traffic.
770 In-band control, on the other hand, has the following advantages:
772 - No dedicated port: There is no need to dedicate a physical
773 switch port to control, which is important on switches that have
774 few ports (e.g. wireless routers, low-end embedded platforms).
776 - No dedicated network: There is no need to build and maintain a
777 separate control network. This is important in many
778 environments because it reduces proliferation of switches and
781 Open vSwitch supports both out-of-band and in-band control. This
782 section describes the principles behind in-band control. See the
783 description of the Controller table in ovs-vswitchd.conf.db(5) to
784 configure OVS for in-band control.
789 The fundamental principle of in-band control is that an OpenFlow
790 switch must recognize and switch control traffic without involving the
791 OpenFlow controller. All the details of implementing in-band control
792 are special cases of this principle.
794 The rationale for this principle is simple. If the switch does not
795 handle in-band control traffic itself, then it will be caught in a
796 contradiction: it must contact the controller, but it cannot, because
797 only the controller can set up the flows that are needed to contact
800 The following points describe important special cases of this
803 - In-band control must be implemented regardless of whether the
806 It is tempting to implement the in-band control rules only when
807 the switch is not connected to the controller, using the
808 reasoning that the controller should have complete control once
809 it has established a connection with the switch.
811 This does not work in practice. Consider the case where the
812 switch is connected to the controller. Occasionally it can
813 happen that the controller forgets or otherwise needs to obtain
814 the MAC address of the switch. To do so, the controller sends a
815 broadcast ARP request. A switch that implements the in-band
816 control rules only when it is disconnected will then send an
817 OFPT_PACKET_IN message up to the controller. The controller will
818 be unable to respond, because it does not know the MAC address of
819 the switch. This is a deadlock situation that can only be
820 resolved by the switch noticing that its connection to the
821 controller has hung and reconnecting.
823 - In-band control must override flows set up by the controller.
825 It is reasonable to assume that flows set up by the OpenFlow
826 controller should take precedence over in-band control, on the
827 basis that the controller should be in charge of the switch.
829 Again, this does not work in practice. Reasonable controller
830 implementations may set up a "last resort" fallback rule that
831 wildcards every field and, e.g., sends it up to the controller or
832 discards it. If a controller does that, then it will isolate
833 itself from the switch.
835 - The switch must recognize all control traffic.
837 The fundamental principle of in-band control states, in part,
838 that a switch must recognize control traffic without involving
839 the OpenFlow controller. More specifically, the switch must
840 recognize *all* control traffic. "False negatives", that is,
841 packets that constitute control traffic but that the switch does
842 not recognize as control traffic, lead to control traffic storms.
844 Consider an OpenFlow switch that only recognizes control packets
845 sent to or from that switch. Now suppose that two switches of
846 this type, named A and B, are connected to ports on an Ethernet
847 hub (not a switch) and that an OpenFlow controller is connected
848 to a third hub port. In this setup, control traffic sent by
849 switch A will be seen by switch B, which will send it to the
850 controller as part of an OFPT_PACKET_IN message. Switch A will
851 then see the OFPT_PACKET_IN message's packet, re-encapsulate it
852 in another OFPT_PACKET_IN, and send it to the controller. Switch
853 B will then see that OFPT_PACKET_IN, and so on in an infinite
856 Incidentally, the consequences of "false positives", where
857 packets that are not control traffic are nevertheless recognized
858 as control traffic, are much less severe. The controller will
859 not be able to control their behavior, but the network will
860 remain in working order. False positives do constitute a
863 - The switch should use echo-requests to detect disconnection.
865 TCP will notice that a connection has hung, but this can take a
866 considerable amount of time. For example, with default settings
867 the Linux kernel TCP implementation will retransmit for between
868 13 and 30 minutes, depending on the connection's retransmission
869 timeout, according to kernel documentation. This is far too long
870 for a switch to be disconnected, so an OpenFlow switch should
871 implement its own connection timeout. OpenFlow OFPT_ECHO_REQUEST
872 messages are the best way to do this, since they test the
873 OpenFlow connection itself.
878 This section describes how Open vSwitch implements in-band control.
879 Correctly implementing in-band control has proven difficult due to its
880 many subtleties, and has thus gone through many iterations. Please
881 read through and understand the reasoning behind the chosen rules
882 before making modifications.
884 Open vSwitch implements in-band control as "hidden" flows, that is,
885 flows that are not visible through OpenFlow, and at a higher priority
886 than wildcarded flows can be set up through OpenFlow. This is done so
887 that the OpenFlow controller cannot interfere with them and possibly
888 break connectivity with its switches. It is possible to see all
889 flows, including in-band ones, with the ovs-appctl "bridge/dump-flows"
892 The Open vSwitch implementation of in-band control can hide traffic to
893 arbitrary "remotes", where each remote is one TCP port on one IP address.
894 Currently the remotes are automatically configured as the in-band OpenFlow
895 controllers plus the OVSDB managers, if any. (The latter is a requirement
896 because OVSDB managers are responsible for configuring OpenFlow controllers,
897 so if the manager cannot be reached then OpenFlow cannot be reconfigured.)
899 The following rules (with the OFPP_NORMAL action) are set up on any bridge
900 that has any remotes:
902 (a) DHCP requests sent from the local port.
903 (b) ARP replies to the local port's MAC address.
904 (c) ARP requests from the local port's MAC address.
906 In-band also sets up the following rules for each unique next-hop MAC
907 address for the remotes' IPs (the "next hop" is either the remote
908 itself, if it is on a local subnet, or the gateway to reach the remote):
910 (d) ARP replies to the next hop's MAC address.
911 (e) ARP requests from the next hop's MAC address.
913 In-band also sets up the following rules for each unique remote IP address:
915 (f) ARP replies containing the remote's IP address as a target.
916 (g) ARP requests containing the remote's IP address as a source.
918 In-band also sets up the following rules for each unique remote (IP,port)
921 (h) TCP traffic to the remote's IP and port.
922 (i) TCP traffic from the remote's IP and port.
924 The goal of these rules is to be as narrow as possible to allow a
925 switch to join a network and be able to communicate with the
926 remotes. As mentioned earlier, these rules have higher priority
927 than the controller's rules, so if they are too broad, they may
928 prevent the controller from implementing its policy. As such,
929 in-band actively monitors some aspects of flow and packet processing
930 so that the rules can be made more precise.
932 In-band control monitors attempts to add flows into the datapath that
933 could interfere with its duties. The datapath only allows exact
934 match entries, so in-band control is able to be very precise about
935 the flows it prevents. Flows that miss in the datapath are sent to
936 userspace to be processed, so preventing these flows from being
937 cached in the "fast path" does not affect correctness. The only type
938 of flow that is currently prevented is one that would prevent DHCP
939 replies from being seen by the local port. For example, a rule that
940 forwarded all DHCP traffic to the controller would not be allowed,
941 but one that forwarded to all ports (including the local port) would.
943 As mentioned earlier, packets that miss in the datapath are sent to
944 the userspace for processing. The userspace has its own flow table,
945 the "classifier", so in-band checks whether any special processing
946 is needed before the classifier is consulted. If a packet is a DHCP
947 response to a request from the local port, the packet is forwarded to
948 the local port, regardless of the flow table. Note that this requires
949 L7 processing of DHCP replies to determine whether the 'chaddr' field
950 matches the MAC address of the local port.
952 It is interesting to note that for an L3-based in-band control
953 mechanism, the majority of rules are devoted to ARP traffic. At first
954 glance, some of these rules appear redundant. However, each serves an
955 important role. First, in order to determine the MAC address of the
956 remote side (controller or gateway) for other ARP rules, we must allow
957 ARP traffic for our local port with rules (b) and (c). If we are
958 between a switch and its connection to the remote, we have to
959 allow the other switch's ARP traffic to through. This is done with
960 rules (d) and (e), since we do not know the addresses of the other
961 switches a priori, but do know the remote's or gateway's. Finally,
962 if the remote is running in a local guest VM that is not reached
963 through the local port, the switch that is connected to the VM must
964 allow ARP traffic based on the remote's IP address, since it will
965 not know the MAC address of the local port that is sending the traffic
966 or the MAC address of the remote in the guest VM.
968 With a few notable exceptions below, in-band should work in most
969 network setups. The following are considered "supported" in the
970 current implementation:
972 - Locally Connected. The switch and remote are on the same
973 subnet. This uses rules (a), (b), (c), (h), and (i).
975 - Reached through Gateway. The switch and remote are on
976 different subnets and must go through a gateway. This uses
977 rules (a), (b), (c), (h), and (i).
979 - Between Switch and Remote. This switch is between another
980 switch and the remote, and we want to allow the other
981 switch's traffic through. This uses rules (d), (e), (h), and
982 (i). It uses (b) and (c) indirectly in order to know the MAC
983 address for rules (d) and (e). Note that DHCP for the other
984 switch will not work unless an OpenFlow controller explicitly lets this
985 switch pass the traffic.
987 - Between Switch and Gateway. This switch is between another
988 switch and the gateway, and we want to allow the other switch's
989 traffic through. This uses the same rules and logic as the
990 "Between Switch and Remote" configuration described earlier.
992 - Remote on Local VM. The remote is a guest VM on the
993 system running in-band control. This uses rules (a), (b), (c),
996 - Remote on Local VM with Different Networks. The remote
997 is a guest VM on the system running in-band control, but the
998 local port is not used to connect to the remote. For
999 example, an IP address is configured on eth0 of the switch. The
1000 remote's VM is connected through eth1 of the switch, but an
1001 IP address has not been configured for that port on the switch.
1002 As such, the switch will use eth0 to connect to the remote,
1003 and eth1's rules about the local port will not work. In the
1004 example, the switch attached to eth0 would use rules (a), (b),
1005 (c), (h), and (i) on eth0. The switch attached to eth1 would use
1006 rules (f), (g), (h), and (i).
1008 The following are explicitly *not* supported by in-band control:
1010 - Specify Remote by Name. Currently, the remote must be
1011 identified by IP address. A naive approach would be to permit
1012 all DNS traffic. Unfortunately, this would prevent the
1013 controller from defining any policy over DNS. Since switches
1014 that are located behind us need to connect to the remote,
1015 in-band cannot simply add a rule that allows DNS traffic from
1016 the local port. The "correct" way to support this is to parse
1017 DNS requests to allow all traffic related to a request for the
1018 remote's name through. Due to the potential security
1019 problems and amount of processing, we decided to hold off for
1022 - Differing Remotes for Switches. All switches must know
1023 the L3 addresses for all the remotes that other switches
1024 may use, since rules need to be set up to allow traffic related
1025 to those remotes through. See rules (f), (g), (h), and (i).
1027 - Differing Routes for Switches. In order for the switch to
1028 allow other switches to connect to a remote through a
1029 gateway, it allows the gateway's traffic through with rules (d)
1030 and (e). If the routes to the remote differ for the two
1031 switches, we will not know the MAC address of the alternate
1038 It seems likely that many controllers, at least at startup, use the
1039 OpenFlow "flow statistics" request to obtain existing flows, then
1040 compare the flows' actions against the actions that they expect to
1041 find. Before version 1.8.0, Open vSwitch always returned exact,
1042 byte-for-byte copies of the actions that had been added to the flow
1043 table. The current version of Open vSwitch does not always do this in
1044 some exceptional cases. This section lists the exceptions that
1045 controller authors must keep in mind if they compare actual actions
1046 against desired actions in a bytewise fashion:
1048 - Open vSwitch zeros padding bytes in action structures,
1049 regardless of their values when the flows were added.
1051 - Open vSwitch "normalizes" the instructions in OpenFlow 1.1
1052 (and later) in the following way:
1054 * OVS sorts the instructions into the following order:
1055 Apply-Actions, Clear-Actions, Write-Actions,
1056 Write-Metadata, Goto-Table.
1058 * OVS drops Apply-Actions instructions that have empty
1061 * OVS drops Write-Actions instructions that have empty
1064 Please report other discrepancies, if you notice any, so that we can
1065 fix or document them.
1071 Suggestions to improve Open vSwitch are welcome at discuss@openvswitch.org.