]> git.proxmox.com Git - mirror_ovs.git/blame - DESIGN.md
Add support for OpenFlow 1.4+ "importance" values.
[mirror_ovs.git] / DESIGN.md
CommitLineData
542cc9bb
TG
1Design Decisions In Open vSwitch
2================================
d31f1109
JP
3
4This document describes design decisions that went into implementing
5Open vSwitch. While we believe these to be reasonable decisions, it is
6impossible to predict how Open vSwitch will be used in all environments.
7Understanding assumptions made by Open vSwitch is critical to a
8successful deployment. The end of this document contains contact
9information that can be used to let us know how we can make Open vSwitch
10more generally useful.
11
80d5aefd
BP
12Asynchronous Messages
13=====================
14
15Over time, Open vSwitch has added many knobs that control whether a
16given controller receives OpenFlow asynchronous messages. This
17section describes how all of these features interact.
18
19First, a service controller never receives any asynchronous messages
4550b647
MM
20unless it changes its miss_send_len from the service controller
21default of zero in one of the following ways:
22
542cc9bb 23 - Sending an OFPT_SET_CONFIG message with nonzero miss_send_len.
4550b647 24
542cc9bb
TG
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.
80d5aefd
BP
28
29Second, OFPT_FLOW_REMOVED and NXT_FLOW_REMOVED messages are generated
30only if the flow that was removed had the OFPFF_SEND_FLOW_REM flag
31set.
32
a7349929
BP
33Third, OFPT_PACKET_IN and NXT_PACKET_IN messages are sent only to
34OpenFlow controller connections that have the correct connection ID
35(see "struct nx_controller_id" and "struct nx_action_controller"):
36
542cc9bb
TG
37 - For packet-in messages generated by a NXAST_CONTROLLER action,
38 the controller ID specified in the action.
a7349929 39
542cc9bb
TG
40 - For other packet-in messages, controller ID zero. (This is the
41 default ID when an OpenFlow controller does not configure one.)
a7349929 42
80d5aefd
BP
43Finally, Open vSwitch consults a per-connection table indexed by the
44message type, reason code, and current role. The following table
45shows how this table is initialized by default when an OpenFlow
46connection is made. An entry labeled "yes" means that the message is
47sent, an entry labeled "---" means that the message is suppressed.
48
542cc9bb 49```
80d5aefd
BP
50 master/
51 message and reason code other slave
52 ---------------------------------------- ------- -----
53 OFPT_PACKET_IN / NXT_PACKET_IN
54 OFPR_NO_MATCH yes ---
55 OFPR_ACTION yes ---
56 OFPR_INVALID_TTL --- ---
57
58 OFPT_FLOW_REMOVED / NXT_FLOW_REMOVED
59 OFPRR_IDLE_TIMEOUT yes ---
60 OFPRR_HARD_TIMEOUT yes ---
61 OFPRR_DELETE yes ---
62
63 OFPT_PORT_STATUS
64 OFPPR_ADD yes yes
65 OFPPR_DELETE yes yes
66 OFPPR_MODIFY yes yes
542cc9bb 67```
80d5aefd
BP
68
69The NXT_SET_ASYNC_CONFIG message directly sets all of the values in
70this table for the current connection. The
71OFPC_INVALID_TTL_TO_CONTROLLER bit in the OFPT_SET_CONFIG message
72controls the setting for OFPR_INVALID_TTL for the "master" role.
73
74
75OFPAT_ENQUEUE
76=============
82172632
EJ
77
78The OpenFlow 1.0 specification requires the output port of the OFPAT_ENQUEUE
79action to "refer to a valid physical port (i.e. < OFPP_MAX) or OFPP_IN_PORT".
80Although OFPP_LOCAL is not less than OFPP_MAX, it is an 'internal' port which
81can have QoS applied to it in Linux. Since we allow the OFPAT_ENQUEUE to apply
82to 'internal' ports whose port numbers are less than OFPP_MAX, we interpret
83OFPP_LOCAL as a physical port and support OFPAT_ENQUEUE on it as well.
84
d31f1109 85
12442ec5
BP
86OFPT_FLOW_MOD
87=============
88
3432cb4e
BP
89The OpenFlow specification for the behavior of OFPT_FLOW_MOD is
90confusing. The following tables summarize the Open vSwitch
12442ec5
BP
91implementation of its behavior in the following categories:
92
542cc9bb
TG
93 - "match on priority": Whether the flow_mod acts only on flows
94 whose priority matches that included in the flow_mod message.
12442ec5 95
542cc9bb
TG
96 - "match on out_port": Whether the flow_mod acts only on flows
97 that output to the out_port included in the flow_mod message (if
98 out_port is not OFPP_NONE). OpenFlow 1.1 and later have a
99 similar feature (not listed separately here) for out_group.
3432cb4e 100
542cc9bb
TG
101 - "match on flow_cookie": Whether the flow_mod acts only on flows
102 whose flow_cookie matches an optional controller-specified value
103 and mask.
12442ec5 104
542cc9bb
TG
105 - "updates flow_cookie": Whether the flow_mod changes the
106 flow_cookie of the flow or flows that it matches to the
107 flow_cookie included in the flow_mod message.
12442ec5 108
542cc9bb
TG
109 - "updates OFPFF_ flags": Whether the flow_mod changes the
110 OFPFF_SEND_FLOW_REM flag of the flow or flows that it matches to
111 the setting included in the flags of the flow_mod message.
12442ec5 112
542cc9bb
TG
113 - "honors OFPFF_CHECK_OVERLAP": Whether the OFPFF_CHECK_OVERLAP
114 flag in the flow_mod is significant.
12442ec5 115
542cc9bb
TG
116 - "updates idle_timeout" and "updates hard_timeout": Whether the
117 idle_timeout and hard_timeout in the flow_mod, respectively,
118 have an effect on the flow or flows matched by the flow_mod.
12442ec5 119
542cc9bb
TG
120 - "updates idle timer": Whether the flow_mod resets the per-flow
121 timer that measures how long a flow has been idle.
12442ec5 122
542cc9bb
TG
123 - "updates hard timer": Whether the flow_mod resets the per-flow
124 timer that measures how long it has been since a flow was
125 modified.
12442ec5 126
542cc9bb
TG
127 - "zeros counters": Whether the flow_mod resets per-flow packet
128 and byte counters to zero.
12442ec5 129
542cc9bb
TG
130 - "may add a new flow": Whether the flow_mod may add a new flow to
131 the flow table. (Obviously this is always true for "add"
132 commands but in some OpenFlow versions "modify" and
133 "modify-strict" can also add new flows.)
3432cb4e 134
542cc9bb
TG
135 - "sends flow_removed message": Whether the flow_mod generates a
136 flow_removed message for the flow or flows that it affects.
12442ec5
BP
137
138An entry labeled "yes" means that the flow mod type does have the
139indicated behavior, "---" means that it does not, an empty cell means
140that the property is not applicable, and other values are explained
141below the table.
142
3432cb4e
BP
143OpenFlow 1.0
144------------
145
542cc9bb 146```
12442ec5
BP
147 MODIFY DELETE
148 ADD MODIFY STRICT DELETE STRICT
149 === ====== ====== ====== ======
3432cb4e 150match on priority yes --- yes --- yes
906087ee 151match on out_port --- --- --- yes yes
3432cb4e
BP
152match on flow_cookie --- --- --- --- ---
153match on table_id --- --- --- --- ---
154controller chooses table_id --- --- ---
12442ec5
BP
155updates flow_cookie yes yes yes
156updates OFPFF_SEND_FLOW_REM yes + +
157honors OFPFF_CHECK_OVERLAP yes + +
158updates idle_timeout yes + +
159updates hard_timeout yes + +
160resets idle timer yes + +
161resets hard timer yes yes yes
162zeros counters yes + +
3432cb4e
BP
163may add a new flow yes yes yes
164sends flow_removed message --- --- --- % %
165
166(+) "modify" and "modify-strict" only take these actions when they
167 create a new flow, not when they update an existing flow.
168
169(%) "delete" and "delete_strict" generates a flow_removed message if
170 the deleted flow or flows have the OFPFF_SEND_FLOW_REM flag set.
171 (Each controller can separately control whether it wants to
172 receive the generated messages.)
542cc9bb 173```
3432cb4e
BP
174
175OpenFlow 1.1
176------------
177
178OpenFlow 1.1 makes these changes:
179
542cc9bb
TG
180 - The controller now must specify the table_id of the flow match
181 searched and into which a flow may be inserted. Behavior for a
182 table_id of 255 is undefined.
3432cb4e 183
542cc9bb 184 - A flow_mod, except an "add", can now match on the flow_cookie.
3432cb4e 185
542cc9bb
TG
186 - When a flow_mod matches on the flow_cookie, "modify" and
187 "modify-strict" never insert a new flow.
3432cb4e 188
542cc9bb 189```
3432cb4e
BP
190 MODIFY DELETE
191 ADD MODIFY STRICT DELETE STRICT
192 === ====== ====== ====== ======
193match on priority yes --- yes --- yes
194match on out_port --- --- --- yes yes
195match on flow_cookie --- yes yes yes yes
196match on table_id yes yes yes yes yes
197controller chooses table_id yes yes yes
198updates flow_cookie yes --- ---
199updates OFPFF_SEND_FLOW_REM yes + +
200honors OFPFF_CHECK_OVERLAP yes + +
201updates idle_timeout yes + +
202updates hard_timeout yes + +
203resets idle timer yes + +
204resets hard timer yes yes yes
205zeros counters yes + +
206may add a new flow yes # #
12442ec5
BP
207sends flow_removed message --- --- --- % %
208
209(+) "modify" and "modify-strict" only take these actions when they
210 create a new flow, not when they update an existing flow.
211
212(%) "delete" and "delete_strict" generates a flow_removed message if
213 the deleted flow or flows have the OFPFF_SEND_FLOW_REM flag set.
214 (Each controller can separately control whether it wants to
215 receive the generated messages.)
216
3432cb4e
BP
217(#) "modify" and "modify-strict" only add a new flow if the flow_mod
218 does not match on any bits of the flow cookie
542cc9bb 219```
3432cb4e
BP
220
221OpenFlow 1.2
222------------
223
224OpenFlow 1.2 makes these changes:
225
542cc9bb
TG
226 - Only "add" commands ever add flows, "modify" and "modify-strict"
227 never do.
3432cb4e 228
542cc9bb
TG
229 - A new flag OFPFF_RESET_COUNTS now controls whether "modify" and
230 "modify-strict" reset counters, whereas previously they never
231 reset counters (except when they inserted a new flow).
3432cb4e 232
542cc9bb 233```
3432cb4e
BP
234 MODIFY DELETE
235 ADD MODIFY STRICT DELETE STRICT
236 === ====== ====== ====== ======
237match on priority yes --- yes --- yes
238match on out_port --- --- --- yes yes
239match on flow_cookie --- yes yes yes yes
240match on table_id yes yes yes yes yes
241controller chooses table_id yes yes yes
242updates flow_cookie yes --- ---
243updates OFPFF_SEND_FLOW_REM yes --- ---
244honors OFPFF_CHECK_OVERLAP yes --- ---
245updates idle_timeout yes --- ---
246updates hard_timeout yes --- ---
247resets idle timer yes --- ---
248resets hard timer yes yes yes
249zeros counters yes & &
250may add a new flow yes --- ---
251sends flow_removed message --- --- --- % %
252
253(%) "delete" and "delete_strict" generates a flow_removed message if
254 the deleted flow or flows have the OFPFF_SEND_FLOW_REM flag set.
255 (Each controller can separately control whether it wants to
256 receive the generated messages.)
257
258(&) "modify" and "modify-strict" reset counters if the
259 OFPFF_RESET_COUNTS flag is specified.
542cc9bb 260```
3432cb4e
BP
261
262OpenFlow 1.3
263------------
264
265OpenFlow 1.3 makes these changes:
266
542cc9bb
TG
267 - Behavior for a table_id of 255 is now defined, for "delete" and
268 "delete-strict" commands, as meaning to delete from all tables.
269 A table_id of 255 is now explicitly invalid for other commands.
3432cb4e 270
542cc9bb
TG
271 - New flags OFPFF_NO_PKT_COUNTS and OFPFF_NO_BYT_COUNTS for "add"
272 operations.
3432cb4e
BP
273
274The table for 1.3 is the same as the one shown above for 1.2.
275
12442ec5 276
c37c0382
AC
277OpenFlow 1.4
278------------
279
ca26eb44
RB
280OpenFlow 1.4 adds the "importance" field to flow_mods, but it does not
281explicitly specify which kinds of flow_mods set the importance.For
282consistency, Open vSwitch uses the same rule for importance as for
283idle_timeout and hard_timeout, that is, only an "ADD" flow_mod sets
284the importance. (This issue has been filed with the ONF as EXT-496.)
c37c0382 285
4d197ebb
BP
286OFPT_PACKET_IN
287==============
288
289The OpenFlow 1.1 specification for OFPT_PACKET_IN is confusing. The
290definition in OF1.1 openflow.h is[*]:
291
542cc9bb 292```
4d197ebb
BP
293 /* Packet received on port (datapath -> controller). */
294 struct ofp_packet_in {
295 struct ofp_header header;
296 uint32_t buffer_id; /* ID assigned by datapath. */
297 uint32_t in_port; /* Port on which frame was received. */
298 uint32_t in_phy_port; /* Physical Port on which frame was received. */
299 uint16_t total_len; /* Full length of frame. */
300 uint8_t reason; /* Reason packet is being sent (one of OFPR_*) */
301 uint8_t table_id; /* ID of the table that was looked up */
302 uint8_t data[0]; /* Ethernet frame, halfway through 32-bit word,
303 so the IP header is 32-bit aligned. The
304 amount of data is inferred from the length
305 field in the header. Because of padding,
306 offsetof(struct ofp_packet_in, data) ==
307 sizeof(struct ofp_packet_in) - 2. */
308 };
309 OFP_ASSERT(sizeof(struct ofp_packet_in) == 24);
542cc9bb 310```
4d197ebb
BP
311
312The confusing part is the comment on the data[] member. This comment
313is a leftover from OF1.0 openflow.h, in which the comment was correct:
314sizeof(struct ofp_packet_in) is 20 in OF1.0 and offsetof(struct
315ofp_packet_in, data) is 18. When OF1.1 was written, the structure
316members were changed but the comment was carelessly not updated, and
317the comment became wrong: sizeof(struct ofp_packet_in) and
318offsetof(struct ofp_packet_in, data) are both 24 in OF1.1.
319
320That leaves the question of how to implement ofp_packet_in in OF1.1.
321The OpenFlow reference implementation for OF1.1 does not include any
322padding, that is, the first byte of the encapsulated frame immediately
323follows the 'table_id' member without a gap. Open vSwitch therefore
324implements it the same way for compatibility.
325
326For an earlier discussion, please see the thread archived at:
327https://mailman.stanford.edu/pipermail/openflow-discuss/2011-August/002604.html
328
329[*] The quoted definition is directly from OF1.1. Definitions used
330 inside OVS omit the 8-byte ofp_header members, so the sizes in
331 this discussion are 8 bytes larger than those declared in OVS
332 header files.
333
334
df778240
BP
335VLAN Matching
336=============
337
338The 802.1Q VLAN header causes more trouble than any other 4 bytes in
339networking. More specifically, three versions of OpenFlow and Open
340vSwitch have among them four different ways to match the contents and
341presence of the VLAN header. The following table describes how each
342version works.
343
344 Match NXM OF1.0 OF1.1 OF1.2
345 ----- --------- ----------- ----------- ------------
346 [1] 0000/0000 ????/1,??/? ????/1,??/? 0000/0000,--
347 [2] 0000/ffff ffff/0,??/? ffff/0,??/? 0000/ffff,--
348 [3] 1xxx/1fff 0xxx/0,??/1 0xxx/0,??/1 1xxx/ffff,--
349 [4] z000/f000 ????/1,0y/0 fffe/0,0y/0 1000/1000,0y
350 [5] zxxx/ffff 0xxx/0,0y/0 0xxx/0,0y/0 1xxx/ffff,0y
351 [6] 0000/0fff <none> <none> <none>
352 [7] 0000/f000 <none> <none> <none>
353 [8] 0000/efff <none> <none> <none>
354 [9] 1001/1001 <none> <none> 1001/1001,--
355 [10] 3000/3000 <none> <none> <none>
356
357Each column is interpreted as follows.
358
542cc9bb 359 - Match: See the list below.
df778240 360
542cc9bb
TG
361 - NXM: xxxx/yyyy means NXM_OF_VLAN_TCI_W with value xxxx and mask
362 yyyy. A mask of 0000 is equivalent to omitting
363 NXM_OF_VLAN_TCI(_W), a mask of ffff is equivalent to
364 NXM_OF_VLAN_TCI.
df778240 365
542cc9bb
TG
366 - OF1.0 and OF1.1: wwww/x,yy/z means dl_vlan wwww, OFPFW_DL_VLAN
367 x, dl_vlan_pcp yy, and OFPFW_DL_VLAN_PCP z. ? means that the
368 given nibble is ignored (and conventionally 0 for wwww or yy,
369 conventionally 1 for x or z). <none> means that the given match
370 is not supported.
df778240 371
542cc9bb
TG
372 - OF1.2: xxxx/yyyy,zz means OXM_OF_VLAN_VID_W with value xxxx and
373 mask yyyy, and OXM_OF_VLAN_PCP (which is not maskable) with
374 value zz. A mask of 0000 is equivalent to omitting
375 OXM_OF_VLAN_VID(_W), a mask of ffff is equivalent to
376 OXM_OF_VLAN_VID. -- means that OXM_OF_VLAN_PCP is omitted.
377 <none> means that the given match is not supported.
df778240
BP
378
379The matches are:
380
381 [1] Matches any packet, that is, one without an 802.1Q header or with
382 an 802.1Q header with any TCI value.
383
384 [2] Matches only packets without an 802.1Q header.
385
386 NXM: Any match with (vlan_tci == 0) and (vlan_tci_mask & 0x1000)
387 != 0 is equivalent to the one listed in the table.
388
389 OF1.0: The spec doesn't define behavior if dl_vlan is set to
390 0xffff and OFPFW_DL_VLAN_PCP is not set.
391
392 OF1.1: The spec says explicitly to ignore dl_vlan_pcp when
393 dl_vlan is set to 0xffff.
394
395 OF1.2: The spec doesn't say what should happen if (vlan_vid == 0)
396 and (vlan_vid_mask & 0x1000) != 0 but (vlan_vid_mask != 0x1000),
397 but it would be straightforward to also interpret as [2].
398
399 [3] Matches only packets that have an 802.1Q header with VID xxx (and
400 any PCP).
401
402 [4] Matches only packets that have an 802.1Q header with PCP y (and
403 any VID).
404
405 NXM: z is ((y << 1) | 1).
406
407 OF1.0: The spec isn't very clear, but OVS implements it this way.
408
409 OF1.2: Presumably other masks such that (vlan_vid_mask & 0x1fff)
410 == 0x1000 would also work, but the spec doesn't define their
411 behavior.
412
413 [5] Matches only packets that have an 802.1Q header with VID xxx and
414 PCP y.
415
416 NXM: z is ((y << 1) | 1).
417
418 OF1.2: Presumably other masks such that (vlan_vid_mask & 0x1fff)
419 == 0x1fff would also work.
420
421 [6] Matches packets with no 802.1Q header or with an 802.1Q header
422 with a VID of 0. Only possible with NXM.
423
424 [7] Matches packets with no 802.1Q header or with an 802.1Q header
425 with a PCP of 0. Only possible with NXM.
426
427 [8] Matches packets with no 802.1Q header or with an 802.1Q header
428 with both VID and PCP of 0. Only possible with NXM.
429
430 [9] Matches only packets that have an 802.1Q header with an
431 odd-numbered VID (and any PCP). Only possible with NXM and
432 OF1.2. (This is just an example; one can match on any desired
433 VID bit pattern.)
434
435[10] Matches only packets that have an 802.1Q header with an
436 odd-numbered PCP (and any VID). Only possible with NXM. (This
437 is just an example; one can match on any desired VID bit
438 pattern.)
439
440Additional notes:
441
542cc9bb
TG
442 - OF1.2: The top three bits of OXM_OF_VLAN_VID are fixed to zero,
443 so bits 13, 14, and 15 in the masks listed in the table may be
444 set to arbitrary values, as long as the corresponding value bits
445 are also zero. The suggested ffff mask for [2], [3], and [5]
446 allows a shorter OXM representation (the mask is omitted) than
447 the minimal 1fff mask.
df778240
BP
448
449
f66b87de
BP
450Flow Cookies
451============
452
453OpenFlow 1.0 and later versions have the concept of a "flow cookie",
454which is a 64-bit integer value attached to each flow. The treatment
455of the flow cookie has varied greatly across OpenFlow versions,
456however.
457
458In OpenFlow 1.0:
459
542cc9bb 460 - OFPFC_ADD set the cookie in the flow that it added.
f66b87de 461
542cc9bb
TG
462 - OFPFC_MODIFY and OFPFC_MODIFY_STRICT updated the cookie for
463 the flow or flows that it modified.
f66b87de 464
542cc9bb 465 - OFPST_FLOW messages included the flow cookie.
f66b87de 466
542cc9bb
TG
467 - OFPT_FLOW_REMOVED messages reported the cookie of the flow
468 that was removed.
f66b87de
BP
469
470OpenFlow 1.1 made the following changes:
471
542cc9bb
TG
472 - Flow mod operations OFPFC_MODIFY, OFPFC_MODIFY_STRICT,
473 OFPFC_DELETE, and OFPFC_DELETE_STRICT, plus flow stats
474 requests and aggregate stats requests, gained the ability to
475 match on flow cookies with an arbitrary mask.
f66b87de 476
542cc9bb
TG
477 - OFPFC_MODIFY and OFPFC_MODIFY_STRICT were changed to add a
478 new flow, in the case of no match, only if the flow table
479 modification operation did not match on the cookie field.
480 (In OpenFlow 1.0, modify operations always added a new flow
481 when there was no match.)
f66b87de 482
542cc9bb
TG
483 - OFPFC_MODIFY and OFPFC_MODIFY_STRICT no longer updated flow
484 cookies.
f66b87de
BP
485
486OpenFlow 1.2 made the following changes:
487
542cc9bb
TG
488 - OFPC_MODIFY and OFPFC_MODIFY_STRICT were changed to never
489 add a new flow, regardless of whether the flow cookie was
490 used for matching.
f66b87de
BP
491
492Open vSwitch support for OpenFlow 1.0 implements the OpenFlow 1.0
493behavior with the following extensions:
494
542cc9bb
TG
495 - An NXM extension field NXM_NX_COOKIE(_W) allows the NXM
496 versions of OFPFC_MODIFY, OFPFC_MODIFY_STRICT, OFPFC_DELETE,
497 and OFPFC_DELETE_STRICT flow_mods, plus flow stats requests
498 and aggregate stats requests, to match on flow cookies with
499 arbitrary masks. This is much like the equivalent OpenFlow
500 1.1 feature.
501
502 - Like OpenFlow 1.1, OFPC_MODIFY and OFPFC_MODIFY_STRICT add a
503 new flow if there is no match and the mask is zero (or not
504 given).
505
506 - The "cookie" field in OFPT_FLOW_MOD and NXT_FLOW_MOD messages
507 is used as the cookie value for OFPFC_ADD commands, as
508 described in OpenFlow 1.0. For OFPFC_MODIFY and
509 OFPFC_MODIFY_STRICT commands, the "cookie" field is used as a
510 new cookie for flows that match unless it is UINT64_MAX, in
511 which case the flow's cookie is not updated.
512
513 - NXT_PACKET_IN (the Nicira extended version of
514 OFPT_PACKET_IN) reports the cookie of the rule that
515 generated the packet, or all-1-bits if no rule generated the
516 packet. (Older versions of OVS used all-0-bits instead of
517 all-1-bits.)
f66b87de 518
623e1caf
JP
519The following table shows the handling of different protocols when
520receiving OFPFC_MODIFY and OFPFC_MODIFY_STRICT messages. A mask of 0
521indicates either an explicit mask of zero or an implicit one by not
522specifying the NXM_NX_COOKIE(_W) field.
523
542cc9bb 524```
623e1caf
JP
525 Match Update Add on miss Add on miss
526 cookie cookie mask!=0 mask==0
527 ====== ====== =========== ===========
528OpenFlow 1.0 no yes <always add on miss>
529OpenFlow 1.1 yes no no yes
530OpenFlow 1.2 yes no no no
531NXM yes yes* no yes
532
533* Updates the flow's cookie unless the "cookie" field is UINT64_MAX.
542cc9bb 534```
f66b87de 535
66abb12b
BP
536Multiple Table Support
537======================
538
539OpenFlow 1.0 has only rudimentary support for multiple flow tables.
540Notably, OpenFlow 1.0 does not allow the controller to specify the
541flow table to which a flow is to be added. Open vSwitch adds an
542extension for this purpose, which is enabled on a per-OpenFlow
543connection basis using the NXT_FLOW_MOD_TABLE_ID message. When the
544extension is enabled, the upper 8 bits of the 'command' member in an
545OFPT_FLOW_MOD or NXT_FLOW_MOD message designates the table to which a
546flow is to be added.
547
548The Open vSwitch software switch implementation offers 255 flow
549tables. On packet ingress, only the first flow table (table 0) is
550searched, and the contents of the remaining tables are not considered
551in any way. Tables other than table 0 only come into play when an
552NXAST_RESUBMIT_TABLE action specifies another table to search.
553
554Tables 128 and above are reserved for use by the switch itself.
555Controllers should use only tables 0 through 127.
556
557
d31f1109
JP
558IPv6
559====
560
561Open vSwitch supports stateless handling of IPv6 packets. Flows can be
562written to support matching TCP, UDP, and ICMPv6 headers within an IPv6
685a51a5
JP
563packet. Deeper matching of some Neighbor Discovery messages is also
564supported.
d31f1109
JP
565
566IPv6 was not designed to interact well with middle-boxes. This,
567combined with Open vSwitch's stateless nature, have affected the
568processing of IPv6 traffic, which is detailed below.
569
570Extension Headers
571-----------------
572
573The base IPv6 header is incredibly simple with the intention of only
574containing information relevant for routing packets between two
575endpoints. IPv6 relies heavily on the use of extension headers to
576provide any other functionality. Unfortunately, the extension headers
577were designed in such a way that it is impossible to move to the next
578header (including the layer-4 payload) unless the current header is
579understood.
580
581Open vSwitch will process the following extension headers and continue
582to the next header:
583
542cc9bb
TG
584 * Fragment (see the next section)
585 * AH (Authentication Header)
586 * Hop-by-Hop Options
587 * Routing
588 * Destination Options
d31f1109
JP
589
590When a header is encountered that is not in that list, it is considered
591"terminal". A terminal header's IPv6 protocol value is stored in
592"nw_proto" for matching purposes. If a terminal header is TCP, UDP, or
593ICMPv6, the packet will be further processed in an attempt to extract
594layer-4 information.
595
596Fragments
597---------
598
599IPv6 requires that every link in the internet have an MTU of 1280 octets
600or greater (RFC 2460). As such, a terminal header (as described above in
601"Extension Headers") in the first fragment should generally be
602reachable. In this case, the terminal header's IPv6 protocol type is
603stored in the "nw_proto" field for matching purposes. If a terminal
604header cannot be found in the first fragment (one with a fragment offset
605of zero), the "nw_proto" field is set to 0. Subsequent fragments (those
606with a non-zero fragment offset) have the "nw_proto" field set to the
607IPv6 protocol type for fragments (44).
608
609Jumbograms
610----------
611
612An IPv6 jumbogram (RFC 2675) is a packet containing a payload longer
613than 65,535 octets. A jumbogram is only relevant in subnets with a link
614MTU greater than 65,575 octets, and are not required to be supported on
615nodes that do not connect to link with such large MTUs. Currently, Open
616vSwitch doesn't process jumbograms.
617
618
946350dc
BP
619In-Band Control
620===============
621
56e9c3b9
BP
622Motivation
623----------
624
625An OpenFlow switch must establish and maintain a TCP network
626connection to its controller. There are two basic ways to categorize
627the network that this connection traverses: either it is completely
628separate from the one that the switch is otherwise controlling, or its
629path may overlap the network that the switch controls. We call the
630former case "out-of-band control", the latter case "in-band control".
631
632Out-of-band control has the following benefits:
633
542cc9bb
TG
634 - Simplicity: Out-of-band control slightly simplifies the switch
635 implementation.
56e9c3b9 636
542cc9bb
TG
637 - Reliability: Excessive switch traffic volume cannot interfere
638 with control traffic.
56e9c3b9 639
542cc9bb
TG
640 - Integrity: Machines not on the control network cannot
641 impersonate a switch or a controller.
56e9c3b9 642
542cc9bb
TG
643 - Confidentiality: Machines not on the control network cannot
644 snoop on control traffic.
56e9c3b9
BP
645
646In-band control, on the other hand, has the following advantages:
647
542cc9bb
TG
648 - No dedicated port: There is no need to dedicate a physical
649 switch port to control, which is important on switches that have
650 few ports (e.g. wireless routers, low-end embedded platforms).
56e9c3b9 651
542cc9bb
TG
652 - No dedicated network: There is no need to build and maintain a
653 separate control network. This is important in many
654 environments because it reduces proliferation of switches and
655 wiring.
56e9c3b9
BP
656
657Open vSwitch supports both out-of-band and in-band control. This
658section describes the principles behind in-band control. See the
659description of the Controller table in ovs-vswitchd.conf.db(5) to
660configure OVS for in-band control.
661
662Principles
663----------
664
665The fundamental principle of in-band control is that an OpenFlow
666switch must recognize and switch control traffic without involving the
667OpenFlow controller. All the details of implementing in-band control
668are special cases of this principle.
669
670The rationale for this principle is simple. If the switch does not
671handle in-band control traffic itself, then it will be caught in a
672contradiction: it must contact the controller, but it cannot, because
673only the controller can set up the flows that are needed to contact
674the controller.
675
676The following points describe important special cases of this
677principle.
678
542cc9bb
TG
679 - In-band control must be implemented regardless of whether the
680 switch is connected.
681
682 It is tempting to implement the in-band control rules only when
683 the switch is not connected to the controller, using the
684 reasoning that the controller should have complete control once
685 it has established a connection with the switch.
686
687 This does not work in practice. Consider the case where the
688 switch is connected to the controller. Occasionally it can
689 happen that the controller forgets or otherwise needs to obtain
690 the MAC address of the switch. To do so, the controller sends a
691 broadcast ARP request. A switch that implements the in-band
692 control rules only when it is disconnected will then send an
693 OFPT_PACKET_IN message up to the controller. The controller will
694 be unable to respond, because it does not know the MAC address of
695 the switch. This is a deadlock situation that can only be
696 resolved by the switch noticing that its connection to the
697 controller has hung and reconnecting.
698
699 - In-band control must override flows set up by the controller.
700
701 It is reasonable to assume that flows set up by the OpenFlow
702 controller should take precedence over in-band control, on the
703 basis that the controller should be in charge of the switch.
704
705 Again, this does not work in practice. Reasonable controller
706 implementations may set up a "last resort" fallback rule that
707 wildcards every field and, e.g., sends it up to the controller or
708 discards it. If a controller does that, then it will isolate
709 itself from the switch.
710
711 - The switch must recognize all control traffic.
712
713 The fundamental principle of in-band control states, in part,
714 that a switch must recognize control traffic without involving
715 the OpenFlow controller. More specifically, the switch must
716 recognize *all* control traffic. "False negatives", that is,
717 packets that constitute control traffic but that the switch does
718 not recognize as control traffic, lead to control traffic storms.
719
720 Consider an OpenFlow switch that only recognizes control packets
721 sent to or from that switch. Now suppose that two switches of
722 this type, named A and B, are connected to ports on an Ethernet
723 hub (not a switch) and that an OpenFlow controller is connected
724 to a third hub port. In this setup, control traffic sent by
725 switch A will be seen by switch B, which will send it to the
726 controller as part of an OFPT_PACKET_IN message. Switch A will
727 then see the OFPT_PACKET_IN message's packet, re-encapsulate it
728 in another OFPT_PACKET_IN, and send it to the controller. Switch
729 B will then see that OFPT_PACKET_IN, and so on in an infinite
730 loop.
731
732 Incidentally, the consequences of "false positives", where
733 packets that are not control traffic are nevertheless recognized
734 as control traffic, are much less severe. The controller will
735 not be able to control their behavior, but the network will
736 remain in working order. False positives do constitute a
737 security problem.
738
739 - The switch should use echo-requests to detect disconnection.
740
741 TCP will notice that a connection has hung, but this can take a
742 considerable amount of time. For example, with default settings
743 the Linux kernel TCP implementation will retransmit for between
744 13 and 30 minutes, depending on the connection's retransmission
745 timeout, according to kernel documentation. This is far too long
746 for a switch to be disconnected, so an OpenFlow switch should
747 implement its own connection timeout. OpenFlow OFPT_ECHO_REQUEST
748 messages are the best way to do this, since they test the
749 OpenFlow connection itself.
56e9c3b9
BP
750
751Implementation
752--------------
753
754This section describes how Open vSwitch implements in-band control.
755Correctly implementing in-band control has proven difficult due to its
756many subtleties, and has thus gone through many iterations. Please
757read through and understand the reasoning behind the chosen rules
758before making modifications.
759
760Open vSwitch implements in-band control as "hidden" flows, that is,
761flows that are not visible through OpenFlow, and at a higher priority
762than wildcarded flows can be set up through OpenFlow. This is done so
763that the OpenFlow controller cannot interfere with them and possibly
764break connectivity with its switches. It is possible to see all
765flows, including in-band ones, with the ovs-appctl "bridge/dump-flows"
766command.
946350dc
BP
767
768The Open vSwitch implementation of in-band control can hide traffic to
769arbitrary "remotes", where each remote is one TCP port on one IP address.
770Currently the remotes are automatically configured as the in-band OpenFlow
771controllers plus the OVSDB managers, if any. (The latter is a requirement
772because OVSDB managers are responsible for configuring OpenFlow controllers,
773so if the manager cannot be reached then OpenFlow cannot be reconfigured.)
774
775The following rules (with the OFPP_NORMAL action) are set up on any bridge
776that has any remotes:
777
778 (a) DHCP requests sent from the local port.
779 (b) ARP replies to the local port's MAC address.
780 (c) ARP requests from the local port's MAC address.
781
782In-band also sets up the following rules for each unique next-hop MAC
783address for the remotes' IPs (the "next hop" is either the remote
784itself, if it is on a local subnet, or the gateway to reach the remote):
785
786 (d) ARP replies to the next hop's MAC address.
787 (e) ARP requests from the next hop's MAC address.
788
789In-band also sets up the following rules for each unique remote IP address:
790
791 (f) ARP replies containing the remote's IP address as a target.
792 (g) ARP requests containing the remote's IP address as a source.
793
794In-band also sets up the following rules for each unique remote (IP,port)
795pair:
796
797 (h) TCP traffic to the remote's IP and port.
798 (i) TCP traffic from the remote's IP and port.
799
800The goal of these rules is to be as narrow as possible to allow a
801switch to join a network and be able to communicate with the
802remotes. As mentioned earlier, these rules have higher priority
803than the controller's rules, so if they are too broad, they may
804prevent the controller from implementing its policy. As such,
805in-band actively monitors some aspects of flow and packet processing
806so that the rules can be made more precise.
807
808In-band control monitors attempts to add flows into the datapath that
809could interfere with its duties. The datapath only allows exact
810match entries, so in-band control is able to be very precise about
811the flows it prevents. Flows that miss in the datapath are sent to
812userspace to be processed, so preventing these flows from being
813cached in the "fast path" does not affect correctness. The only type
814of flow that is currently prevented is one that would prevent DHCP
815replies from being seen by the local port. For example, a rule that
816forwarded all DHCP traffic to the controller would not be allowed,
817but one that forwarded to all ports (including the local port) would.
818
819As mentioned earlier, packets that miss in the datapath are sent to
820the userspace for processing. The userspace has its own flow table,
821the "classifier", so in-band checks whether any special processing
822is needed before the classifier is consulted. If a packet is a DHCP
823response to a request from the local port, the packet is forwarded to
824the local port, regardless of the flow table. Note that this requires
825L7 processing of DHCP replies to determine whether the 'chaddr' field
826matches the MAC address of the local port.
827
828It is interesting to note that for an L3-based in-band control
829mechanism, the majority of rules are devoted to ARP traffic. At first
830glance, some of these rules appear redundant. However, each serves an
831important role. First, in order to determine the MAC address of the
832remote side (controller or gateway) for other ARP rules, we must allow
833ARP traffic for our local port with rules (b) and (c). If we are
834between a switch and its connection to the remote, we have to
835allow the other switch's ARP traffic to through. This is done with
836rules (d) and (e), since we do not know the addresses of the other
837switches a priori, but do know the remote's or gateway's. Finally,
838if the remote is running in a local guest VM that is not reached
839through the local port, the switch that is connected to the VM must
840allow ARP traffic based on the remote's IP address, since it will
841not know the MAC address of the local port that is sending the traffic
842or the MAC address of the remote in the guest VM.
843
844With a few notable exceptions below, in-band should work in most
845network setups. The following are considered "supported' in the
846current implementation:
847
542cc9bb
TG
848 - Locally Connected. The switch and remote are on the same
849 subnet. This uses rules (a), (b), (c), (h), and (i).
850
851 - Reached through Gateway. The switch and remote are on
852 different subnets and must go through a gateway. This uses
853 rules (a), (b), (c), (h), and (i).
854
855 - Between Switch and Remote. This switch is between another
856 switch and the remote, and we want to allow the other
857 switch's traffic through. This uses rules (d), (e), (h), and
858 (i). It uses (b) and (c) indirectly in order to know the MAC
859 address for rules (d) and (e). Note that DHCP for the other
860 switch will not work unless an OpenFlow controller explicitly lets this
861 switch pass the traffic.
862
863 - Between Switch and Gateway. This switch is between another
864 switch and the gateway, and we want to allow the other switch's
865 traffic through. This uses the same rules and logic as the
866 "Between Switch and Remote" configuration described earlier.
867
868 - Remote on Local VM. The remote is a guest VM on the
869 system running in-band control. This uses rules (a), (b), (c),
870 (h), and (i).
871
872 - Remote on Local VM with Different Networks. The remote
873 is a guest VM on the system running in-band control, but the
874 local port is not used to connect to the remote. For
875 example, an IP address is configured on eth0 of the switch. The
876 remote's VM is connected through eth1 of the switch, but an
877 IP address has not been configured for that port on the switch.
878 As such, the switch will use eth0 to connect to the remote,
879 and eth1's rules about the local port will not work. In the
880 example, the switch attached to eth0 would use rules (a), (b),
881 (c), (h), and (i) on eth0. The switch attached to eth1 would use
882 rules (f), (g), (h), and (i).
946350dc
BP
883
884The following are explicitly *not* supported by in-band control:
885
542cc9bb
TG
886 - Specify Remote by Name. Currently, the remote must be
887 identified by IP address. A naive approach would be to permit
888 all DNS traffic. Unfortunately, this would prevent the
889 controller from defining any policy over DNS. Since switches
890 that are located behind us need to connect to the remote,
891 in-band cannot simply add a rule that allows DNS traffic from
892 the local port. The "correct" way to support this is to parse
893 DNS requests to allow all traffic related to a request for the
894 remote's name through. Due to the potential security
895 problems and amount of processing, we decided to hold off for
896 the time-being.
897
898 - Differing Remotes for Switches. All switches must know
899 the L3 addresses for all the remotes that other switches
900 may use, since rules need to be set up to allow traffic related
901 to those remotes through. See rules (f), (g), (h), and (i).
902
903 - Differing Routes for Switches. In order for the switch to
904 allow other switches to connect to a remote through a
905 gateway, it allows the gateway's traffic through with rules (d)
906 and (e). If the routes to the remote differ for the two
907 switches, we will not know the MAC address of the alternate
908 gateway.
946350dc
BP
909
910
f25d0cf3
BP
911Action Reproduction
912===================
913
914It seems likely that many controllers, at least at startup, use the
915OpenFlow "flow statistics" request to obtain existing flows, then
916compare the flows' actions against the actions that they expect to
917find. Before version 1.8.0, Open vSwitch always returned exact,
918byte-for-byte copies of the actions that had been added to the flow
919table. The current version of Open vSwitch does not always do this in
920some exceptional cases. This section lists the exceptions that
921controller authors must keep in mind if they compare actual actions
922against desired actions in a bytewise fashion:
923
542cc9bb
TG
924 - Open vSwitch zeros padding bytes in action structures,
925 regardless of their values when the flows were added.
f25d0cf3 926
542cc9bb
TG
927 - Open vSwitch "normalizes" the instructions in OpenFlow 1.1
928 (and later) in the following way:
d01c980f 929
542cc9bb
TG
930 * OVS sorts the instructions into the following order:
931 Apply-Actions, Clear-Actions, Write-Actions,
932 Write-Metadata, Goto-Table.
d01c980f 933
542cc9bb
TG
934 * OVS drops Apply-Actions instructions that have empty
935 action lists.
d01c980f 936
542cc9bb
TG
937 * OVS drops Write-Actions instructions that have empty
938 action sets.
d01c980f 939
f25d0cf3
BP
940Please report other discrepancies, if you notice any, so that we can
941fix or document them.
942
943
d31f1109
JP
944Suggestions
945===========
946
947Suggestions to improve Open vSwitch are welcome at discuss@openvswitch.org.