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