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