178a1a9ee6cc360f24826226d86b650da54126f1
[cascardo/ovs.git] / ovn / northd / ovn-northd.8.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <manpage program="ovn-northd" section="8" title="ovn-northd">
3     <h1>Name</h1>
4     <p>ovn-northd -- Open Virtual Network central control daemon</p>
5
6     <h1>Synopsis</h1>
7     <p><code>ovn-northd</code> [<var>options</var>]</p>
8
9     <h1>Description</h1>
10     <p>
11       <code>ovn-northd</code> is a centralized daemon responsible for
12       translating the high-level OVN configuration into logical
13       configuration consumable by daemons such as
14       <code>ovn-controller</code>.  It translates the logical network
15       configuration in terms of conventional network concepts, taken
16       from the OVN Northbound Database (see <code>ovn-nb</code>(5)),
17       into logical datapath flows in the OVN Southbound Database (see
18       <code>ovn-sb</code>(5)) below it.
19     </p>
20
21     <h1>Configuration</h1>
22     <p>
23       <code>ovn-northd</code> requires a connection to the Northbound
24       and Southbound databases.  The defaults are <code>ovnnb_db.sock</code>
25       and <code>ovnsb_db.sock</code> respectively
26       in the local Open vSwitch's "run" directory.  This may be
27       overridden with the following commands:
28     </p>
29     <ul>
30       <li>
31         <p>
32           <code>--ovnnb-db=<var>database</var></code>
33         </p>
34         <p>
35           The database containing the OVN Northbound Database.
36         </p>
37       </li>
38       <li>
39         <p>
40           <code>--ovnsb-db=<var>database</var></code>
41         </p>
42         <p>
43           The database containing the OVN Southbound Database.
44         </p>
45       </li>
46     </ul>
47     <p>
48       The <var>database</var> argument must take one of the following forms:
49     </p>
50     <ul>
51       <li>
52         <p>
53           <code>ssl:<var>ip</var>:<var>port</var></code>
54         </p>
55         <p>
56           The specified SSL <var>port</var> on the host at the given
57           <var>ip</var>, which must be expressed as an IP address (not a DNS
58           name) in IPv4 or IPv6 address format.  If <var>ip</var> is an IPv6
59           address, then wrap <var>ip</var> with square brackets, e.g.:
60           <code>ssl:[::1]:6640</code>.  The <code>--private-key</code>,
61           <code>--certificate</code>, and <code>--ca-cert</code> options are
62           mandatory when this form is used.
63         </p>
64       </li>
65       <li>
66         <p>
67           <code>tcp:<var>ip</var>:<var>port</var></code>
68         </p>
69         <p>
70           Connect to the given TCP <var>port</var> on <var>ip</var>, where
71           <var>ip</var> can be IPv4 or IPv6 address. If <var>ip</var> is an
72           IPv6 address, then wrap <var>ip</var> with square brackets, e.g.:
73           <code>tcp:[::1]:6640</code>.
74         </p>
75       </li>
76       <li>
77         <p>
78           <code>unix:<var>file</var></code>
79         </p>
80         <p>
81           On POSIX, connect to the Unix domain server socket named
82           <var>file</var>.
83         </p>
84         <p>
85           On Windows, connect to a localhost TCP port whose value is written
86           in <var>file</var>.
87         </p>
88       </li>
89     </ul>
90
91     <h1>Runtime Management Commands</h1>
92     <p>
93       <code>ovs-appctl</code> can send commands to a running
94       <code>ovn-northd</code> process.  The currently supported commands
95       are described below.
96       <dl>
97       <dt><code>exit</code></dt>
98       <dd>
99         Causes <code>ovn-northd</code> to gracefully terminate.
100       </dd>
101       </dl>
102     </p>
103
104     <h1>Logical Flow Table Structure</h1>
105
106     <p>
107       One of the main purposes of <code>ovn-northd</code> is to populate the
108       <code>Logical_Flow</code> table in the <code>OVN_Southbound</code>
109       database.  This section describes how <code>ovn-northd</code> does this
110       for switch and router logical datapaths.
111     </p>
112
113     <h2>Logical Switch Datapaths</h2>
114
115     <h3>Ingress Table 0: Admission Control and Ingress Port Security - L2</h3>
116
117     <p>
118       Ingress table 0 contains these logical flows:
119     </p>
120
121     <ul>
122       <li>
123         Priority 100 flows to drop packets with VLAN tags or multicast Ethernet
124         source addresses.
125       </li>
126
127       <li>
128         Priority 50 flows that implement ingress port security for each enabled
129         logical port.  For logical ports on which port security is enabled,
130         these match the <code>inport</code> and the valid <code>eth.src</code>
131         address(es) and advance only those packets to the next flow table.  For
132         logical ports on which port security is not enabled, these advance all
133         packets that match the <code>inport</code>.
134       </li>
135     </ul>
136
137     <p>
138       There are no flows for disabled logical ports because the default-drop
139       behavior of logical flow tables causes packets that ingress from them to
140       be dropped.
141     </p>
142
143     <h3>Ingress Table 1: Ingress Port Security - IP</h3>
144
145     <p>
146       Ingress table 1 contains these logical flows:
147     </p>
148
149     <ul>
150       <li>
151         <p>
152           For each element in the port security set having one or more IPv4 or
153           IPv6 addresses (or both),
154         </p>
155
156         <ul>
157           <li>
158             Priority 90 flow to allow IPv4 traffic if it has IPv4 addresses
159             which match the <code>inport</code>, valid <code>eth.src</code>
160             and valid <code>ip4.src</code> address(es).
161           </li>
162
163           <li>
164             Priority 90 flow to allow IPv4 DHCP discovery traffic if it has a
165             valid <code>eth.src</code>. This is necessary since DHCP discovery
166             messages are sent from the unspecified IPv4 address (0.0.0.0) since
167             the IPv4 address has not yet been assigned.
168           </li>
169
170           <li>
171             Priority 90 flow to allow IPv6 traffic if it has IPv6 addresses
172             which match the <code>inport</code>, valid <code>eth.src</code> and
173             valid <code>ip6.src</code> address(es).
174           </li>
175
176           <li>
177             Priority 90 flow to allow IPv6 DAD (Duplicate Address Detection)
178             traffic if it has a valid <code>eth.src</code>. This is is
179             necessary since DAD include requires joining an multicast group and
180             sending neighbor solicitations for the newly assigned address. Since
181             no address is yet assigned, these are sent from the unspecified
182             IPv6 address (::).
183           </li>
184
185           <li>
186             Priority 80 flow to drop IP (both IPv4 and IPv6) traffic which
187             match the <code>inport</code> and valid <code>eth.src</code>.
188           </li>
189         </ul>
190       </li>
191
192       <li>
193         One priority-0 fallback flow that matches all packets and advances to
194         the next table.
195       </li>
196     </ul>
197
198     <h3>Ingress Table 2: Ingress Port Security - Neighbor discovery</h3>
199
200     <p>
201       Ingress table 2 contains these logical flows:
202     </p>
203
204     <ul>
205       <li>
206         <p>
207           For each element in the port security set,
208         </p>
209
210         <ul>
211           <li>
212             Priority 90 flow to allow ARP traffic which match the
213             <code>inport</code> and valid <code>eth.src</code> and
214             <code>arp.sha</code>. If the element has one or more
215             IPv4 addresses, then it also matches the valid
216             <code>arp.spa</code>.
217           </li>
218
219           <li>
220             Priority 90 flow to allow IPv6 Neighbor Solicitation and
221             Advertisement traffic which match the <code>inport</code>,
222             valid <code>eth.src</code> and
223             <code>nd.sll</code>/<code>nd.tll</code>.
224             If the element has one or more IPv6 addresses, then it also
225             matches the valid <code>nd.target</code> address(es) for Neighbor
226             Advertisement traffic.
227           </li>
228
229           <li>
230             Priority 80 flow to drop ARP and IPv6 Neighbor Solicitation and
231             Advertisement traffic which match the <code>inport</code> and
232             valid <code>eth.src</code>.
233           </li>
234         </ul>
235       </li>
236
237       <li>
238         One priority-0 fallback flow that matches all packets and advances to
239         the next table.
240       </li>
241     </ul>
242
243     <h3>Ingress Table 3: <code>from-lport</code> Pre-ACLs</h3>
244
245     <p>
246       This table prepares flows for possible stateful ACL processing in
247       ingress table <code>ACLs</code>.  It contains a priority-0 flow that
248       simply moves traffic to the next table.  If stateful ACLs are used in the
249       logical datapath, a priority-100 flow is added that sets a hint
250       (with <code>reg0[0] = 1; next;</code>) for table
251       <code>Pre-stateful</code> to send IP packets to the connection tracker
252       before eventually advancing to ingress table <code>ACLs</code>.
253     </p>
254
255     <h3>Ingress Table 4: Pre-LB</h3>
256
257     <p>
258       This table prepares flows for possible stateful load balancing processing
259       in ingress table <code>LB</code> and <code>Stateful</code>.  It contains
260       a priority-0 flow that simply moves traffic to the next table.  If load
261       balancing rules with virtual IP addresses (and ports) are configured in
262       <code>OVN_Northbound</code> database for a logical datapath, a
263       priority-100 flow is added for each configured virtual IP address
264       <var>VIP</var> with a match <code>ip &amp;&amp; ip4.dst == <var>VIP</var>
265       </code> that sets an action <code>reg0[0] = 1; next;</code> to act as a
266       hint for table <code>Pre-stateful</code> to send IP packets to the
267       connection tracker for packet de-fragmentation before eventually
268       advancing to ingress table <code>LB</code>.
269     </p>
270
271     <h3>Ingress Table 5: Pre-stateful</h3>
272
273     <p>
274       This table prepares flows for all possible stateful processing
275       in next tables.  It contains a priority-0 flow that simply moves
276       traffic to the next table.  A priority-100 flow sends the packets to
277       connection tracker based on a hint provided by the previous tables
278       (with a match for <code>reg0[0] == 1</code>) by using the
279       <code>ct_next;</code> action.
280     </p>
281
282     <h3>Ingress table 6: <code>from-lport</code> ACLs</h3>
283
284     <p>
285       Logical flows in this table closely reproduce those in the
286       <code>ACL</code> table in the <code>OVN_Northbound</code> database
287       for the <code>from-lport</code> direction.  <code>allow</code>
288       ACLs translate into logical flows with the <code>next;</code>
289       action, <code>allow-related</code> ACLs translate into logical
290       flows with the <code>reg0[1] = 1; next;</code> actions (which acts
291       as a hint for the next tables to commit the connection to conntrack),
292       other ACLs translate to <code>drop;</code>.  The <code>priority</code>
293       values from the <code>ACL</code> table have a limited range and have 1000
294       added to them to leave room for OVN default flows at both higher
295       and lower priorities.
296     </p>
297
298     <p>
299       This table also contains a priority 0 flow with action
300       <code>next;</code>, so that ACLs allow packets by default.  If the
301       logical datapath has a statetful ACL, the following flows will
302       also be added:
303     </p>
304
305     <ul>
306       <li>
307         A priority-1 flow that sets the hint to commit IP traffic to the
308         connection tracker (with action <code>reg0[1] = 1; next;</code>).  This
309         is needed for the default allow policy because, while the initiator's
310         direction may not have any stateful rules, the server's may and then
311         its return traffic would not be known and marked as invalid.
312       </li>
313
314       <li>
315         A priority-65535 flow that allows any traffic that has been
316         committed to the connection tracker (i.e., established flows).
317       </li>
318
319       <li>
320         A priority-65535 flow that allows any traffic that is considered
321         related to a committed flow in the connection tracker (e.g., an
322         ICMP Port Unreachable from a non-listening UDP port).
323       </li>
324
325       <li>
326         A priority-65535 flow that drops all traffic marked by the
327         connection tracker as invalid.
328       </li>
329     </ul>
330
331     <h3>Ingress Table 7: LB</h3>
332
333     <p>
334       It contains a priority-0 flow that simply moves traffic to the next
335       table.  For established connections a priority 100 flow matches on
336       <code>ct.est &amp;&amp; !ct.rel &amp;&amp; !ct.new &amp;&amp;
337       !ct.inv</code> and sets an action <code>reg0[2] = 1; next;</code> to act
338       as a hint for table <code>Stateful</code> to send packets through
339       connection tracker to NAT the packets.  (The packet will automatically
340       get DNATed to the same IP address as the first packet in that
341       connection.)
342     </p>
343
344     <h3>Ingress Table 8: Stateful</h3>
345
346     <ul>
347       <li>
348         For all the configured load balancing rules in
349         <code>OVN_Northbound</code> database that includes a L4 port
350         <var>PORT</var> of protocol <var>P</var> and IPv4 address
351         <var>VIP</var>, a priority-120 flow that matches on
352         <code>ct.new &amp;&amp; ip &amp;&amp; ip4.dst == <var>VIP
353         </var>&amp;&amp; <var>P</var> &amp;&amp; <var>P</var>.dst == <var>PORT
354         </var></code> with an action of <code>ct_lb(<var>args</var>)</code>,
355         where <var>args</var> contains comma separated IPv4 addresses (and
356         optional port numbers) to load balance to.
357       </li>
358       <li>
359         For all the configured load balancing rules in
360         <code>OVN_Northbound</code> database that includes just an IP address
361         <var>VIP</var> to match on, a priority-110 flow that matches on
362         <code>ct.new &amp;&amp; ip &amp;&amp; ip4.dst == <var>VIP</var></code>
363         with an action of <code>ct_lb(<var>args</var>)</code>, where
364         <var>args</var> contains comma separated IPv4 addresses.
365       </li>
366       <li>
367         A priority-100 flow commits packets to connection tracker using
368         <code>ct_commit; next;</code> action based on a hint provided by
369         the previous tables (with a match for <code>reg0[1] == 1</code>).
370       </li>
371       <li>
372         A priority-100 flow sends the packets to connection tracker using
373         <code>ct_lb;</code> as the action based on a hint provided by the
374         previous tables (with a match for <code>reg0[2] == 1</code>).
375       </li>
376       <li>
377         A priority-0 flow that simply moves traffic to the next table.
378       </li>
379     </ul>
380
381     <h3>Ingress Table 9: ARP responder</h3>
382
383     <p>
384       This table implements ARP responder for known IPs.  It contains these
385       logical flows:
386     </p>
387
388     <ul>
389       <li>
390         Priority-100 flows to skip ARP responder if inport is of type
391         <code>localnet</code>, and advances directly to the next table.
392       </li>
393
394       <li>
395         <p>
396           Priority-50 flows that matches ARP requests to each known IP address
397           <var>A</var> of logical port <var>P</var>, and respond with ARP
398           replies directly with corresponding Ethernet address <var>E</var>:
399         </p>
400
401         <pre>
402 eth.dst = eth.src;
403 eth.src = <var>E</var>;
404 arp.op = 2; /* ARP reply. */
405 arp.tha = arp.sha;
406 arp.sha = <var>E</var>;
407 arp.tpa = arp.spa;
408 arp.spa = <var>A</var>;
409 outport = <var>P</var>;
410 inport = ""; /* Allow sending out inport. */
411 output;
412         </pre>
413
414         <p>
415           These flows are omitted for logical ports (other than router ports)
416           that are down.
417         </p>
418       </li>
419
420       <li>
421         One priority-0 fallback flow that matches all packets and advances to
422         the next table.
423       </li>
424     </ul>
425
426     <h3>Ingress Table 10: Destination Lookup</h3>
427
428     <p>
429       This table implements switching behavior.  It contains these logical
430       flows:
431     </p>
432
433     <ul>
434       <li>
435         A priority-100 flow that outputs all packets with an Ethernet broadcast
436         or multicast <code>eth.dst</code> to the <code>MC_FLOOD</code>
437         multicast group, which <code>ovn-northd</code> populates with all
438         enabled logical ports.
439       </li>
440
441       <li>
442         One priority-50 flow that matches each known Ethernet address against
443         <code>eth.dst</code> and outputs the packet to the single associated
444         output port.
445       </li>
446
447       <li>
448         One priority-0 fallback flow that matches all packets and outputs them
449         to the <code>MC_UNKNOWN</code> multicast group, which
450         <code>ovn-northd</code> populates with all enabled logical ports that
451         accept unknown destination packets.  As a small optimization, if no
452         logical ports accept unknown destination packets,
453         <code>ovn-northd</code> omits this multicast group and logical flow.
454       </li>
455     </ul>
456
457     <h3>Egress Table 0: Pre-LB</h3>
458
459     <p>
460       This table is similar to ingress table <code>Pre-LB</code>.  It
461       contains a priority-0 flow that simply moves traffic to the next table.
462       If any load balancing rules exist for the datapath, a priority-100 flow
463       is added with a match of <code>ip</code> and action of <code>reg0[0] = 1;
464        next;</code> to act as a hint for table <code>Pre-stateful</code> to
465       send IP packets to the connection tracker for packet de-fragmentation.
466     </p>
467
468     <h3>Egress Table 1: <code>to-lport</code> Pre-ACLs</h3>
469
470     <p>
471       This is similar to ingress table <code>Pre-ACLs</code> except for
472      <code>to-lport</code> traffic.
473     </p>
474
475     <h3>Egress Table 2: Pre-stateful</h3>
476
477     <p>
478       This is similar to ingress table <code>Pre-stateful</code>.
479     </p>
480
481     <h3>Egress Table 3: LB</h3>
482     <p>
483       This is similar to ingress table <code>LB</code>.
484     </p>
485
486     <h3>Egress Table 4: <code>to-lport</code> ACLs</h3>
487
488     <p>
489       This is similar to ingress table <code>ACLs</code> except for
490       <code>to-lport</code> ACLs.
491     </p>
492
493     <h3>Egress Table 5: Stateful</h3>
494
495     <p>
496       This is similar to ingress table <code>Stateful</code> except that
497       there are no rules added for load balancing new connections.
498     </p>
499
500     <h3>Egress Table 6: Egress Port Security - IP</h3>
501
502     <p>
503       This is similar to the port security logic in table
504       <code>Ingress Port Security - IP</code> except that <code>outport</code>,
505       <code>eth.dst</code>, <code>ip4.dst</code> and <code>ip6.dst</code>
506       are checked instead of <code>inport</code>, <code>eth.src</code>,
507       <code>ip4.src</code> and <code>ip6.src</code>
508     </p>
509
510     <h3>Egress Table 7: Egress Port Security - L2</h3>
511
512     <p>
513       This is similar to the ingress port security logic in ingress table
514       <code>Admission Control and Ingress Port Security - L2</code>,
515       but with important differences.  Most obviously, <code>outport</code> and
516       <code>eth.dst</code> are checked instead of <code>inport</code> and
517       <code>eth.src</code>.  Second, packets directed to broadcast or multicast
518       <code>eth.dst</code> are always accepted instead of being subject to the
519       port security rules; this is implemented through a priority-100 flow that
520       matches on <code>eth.mcast</code> with action <code>output;</code>.
521       Finally, to ensure that even broadcast and multicast packets are not
522       delivered to disabled logical ports, a priority-150 flow for each
523       disabled logical <code>outport</code> overrides the priority-100 flow
524       with a <code>drop;</code> action.
525     </p>
526
527     <h2>Logical Router Datapaths</h2>
528
529     <p>
530       Logical router datapaths will only exist for <ref table="Logical_Router"
531       db="OVN_Northbound"/> rows in the <ref db="OVN_Northbound"/> database
532       that do not have <ref column="enabled" table="Logical_Router"
533       db="OVN_Northbound"/> set to <code>false</code>
534     </p>
535
536     <h3>Ingress Table 0: L2 Admission Control</h3>
537
538     <p>
539       This table drops packets that the router shouldn't see at all based on
540       their Ethernet headers.  It contains the following flows:
541     </p>
542
543     <ul>
544       <li>
545         Priority-100 flows to drop packets with VLAN tags or multicast Ethernet
546         source addresses.
547       </li>
548
549       <li>
550         For each enabled router port <var>P</var> with Ethernet address
551         <var>E</var>, a priority-50 flow that matches <code>inport ==
552         <var>P</var> &amp;&amp; (eth.mcast || eth.dst ==
553         <var>E</var></code>), with action <code>next;</code>.
554       </li>
555     </ul>
556
557     <p>
558       Other packets are implicitly dropped.
559     </p>
560
561     <h3>Ingress Table 1: IP Input</h3>
562
563     <p>
564       This table is the core of the logical router datapath functionality.  It
565       contains the following flows to implement very basic IP host
566       functionality.
567     </p>
568
569     <ul>
570       <li>
571         <p>
572           L3 admission control: A priority-100 flow drops packets that match
573           any of the following:
574         </p>
575
576         <ul>
577           <li>
578             <code>ip4.src[28..31] == 0xe</code> (multicast source)
579           </li>
580           <li>
581             <code>ip4.src == 255.255.255.255</code> (broadcast source)
582           </li>
583           <li>
584             <code>ip4.src == 127.0.0.0/8 || ip4.dst == 127.0.0.0/8</code>
585             (localhost source or destination)
586           </li>
587           <li>
588             <code>ip4.src == 0.0.0.0/8 || ip4.dst == 0.0.0.0/8</code> (zero
589             network source or destination)
590           </li>
591           <li>
592             <code>ip4.src</code> is any IP address owned by the router.
593           </li>
594           <li>
595             <code>ip4.src</code> is the broadcast address of any IP network
596             known to the router.
597           </li>
598         </ul>
599       </li>
600
601       <li>
602         <p>
603           ICMP echo reply.  These flows reply to ICMP echo requests received
604           for the router's IP address.  Let <var>A</var> be an IP address
605           owned by a router port.  Then, for each <var>A</var>, a priority-90
606           flow matches on <code>ip4.dst == <var>A</var></code> and <code>
607           icmp4.type == 8 &amp;&amp; icmp4.code == 0</code> (ICMP echo
608           request).  The port of the router that receives the echo request
609           does not matter. Also, the ip.ttl of the echo request packet is not
610           checked, so it complies with RFC 1812, section 4.2.2.9. These flows
611           use the following actions:
612         </p>
613
614         <pre>
615 ip4.dst &lt;-&gt; ip4.src;
616 ip.ttl = 255;
617 icmp4.type = 0;
618 inport = ""; /* Allow sending out inport. */
619 next;
620         </pre>
621       </li>
622
623       <li>
624         <p>
625           Reply to ARP requests.
626         </p>
627
628         <p>
629           These flows reply to ARP requests for the router's own IP address.
630           For each router port <var>P</var> that owns IP address <var>A</var>
631           and Ethernet address <var>E</var>, a priority-90 flow matches
632           <code>inport == <var>P</var> &amp;&amp; arp.op == 1 &amp;&amp;
633           arp.tpa == <var>A</var></code> (ARP request) with the following
634           actions:
635         </p>
636
637         <pre>
638 eth.dst = eth.src;
639 eth.src = <var>E</var>;
640 arp.op = 2; /* ARP reply. */
641 arp.tha = arp.sha;
642 arp.sha = <var>E</var>;
643 arp.tpa = arp.spa;
644 arp.spa = <var>A</var>;
645 outport = <var>P</var>;
646 inport = ""; /* Allow sending out inport. */
647 output;
648         </pre>
649       </li>
650
651       <li>
652         <p>
653           These flows reply to ARP requests for the virtual IP addresses
654           configured in the router for DNAT. For a configured DNAT IP address
655           <var>A</var>, for each router port <var>P</var> with Ethernet
656           address <var>E</var>, a priority-90 flow matches
657           <code>inport == <var>P</var> &amp;&amp; arp.op == 1 &amp;&amp;
658           arp.tpa == <var>A</var></code> (ARP request)
659           with the following actions:
660         </p>
661
662         <pre>
663 eth.dst = eth.src;
664 eth.src = <var>E</var>;
665 arp.op = 2; /* ARP reply. */
666 arp.tha = arp.sha;
667 arp.sha = <var>E</var>;
668 arp.tpa = arp.spa;
669 arp.spa = <var>A</var>;
670 outport = <var>P</var>;
671 inport = ""; /* Allow sending out inport. */
672 output;
673         </pre>
674       </li>
675
676       <li>
677         ARP reply handling.  These flows use ARP replies to populate the
678         logical router's ARP table.  A priority-90 flow with match <code>arp.op
679         == 2</code> has actions <code>put_arp(inport, arp.spa,
680         arp.sha);</code>.
681       </li>
682
683       <li>
684         <p>
685           UDP port unreachable.  Priority-80 flows generate ICMP port
686           unreachable messages in reply to UDP datagrams directed to the
687           router's IP address.  The logical router doesn't accept any UDP
688           traffic so it always generates such a reply.
689         </p>
690
691         <p>
692           These flows should not match IP fragments with nonzero offset.
693         </p>
694
695         <p>
696           Details TBD.  Not yet implemented.
697         </p>
698       </li>
699
700       <li>
701         <p>
702           TCP reset.  Priority-80 flows generate TCP reset messages in reply to
703           TCP datagrams directed to the router's IP address.  The logical
704           router doesn't accept any TCP traffic so it always generates such a
705           reply.
706         </p>
707
708         <p>
709           These flows should not match IP fragments with nonzero offset.
710         </p>
711
712         <p>
713           Details TBD.  Not yet implemented.
714         </p>
715       </li>
716
717       <li>
718         <p>
719           Protocol unreachable.  Priority-70 flows generate ICMP protocol
720           unreachable messages in reply to packets directed to the router's IP
721           address on IP protocols other than UDP, TCP, and ICMP.
722         </p>
723
724         <p>
725           These flows should not match IP fragments with nonzero offset.
726         </p>
727
728         <p>
729           Details TBD.  Not yet implemented.
730         </p>
731       </li>
732
733       <li>
734         Drop other IP traffic to this router.  These flows drop any other
735         traffic destined to an IP address of this router that is not already
736         handled by one of the flows above, which amounts to ICMP (other than
737         echo requests) and fragments with nonzero offsets.  For each IP address
738         <var>A</var> owned by the router, a priority-60 flow matches
739         <code>ip4.dst == <var>A</var></code> and drops the traffic.  An
740         exception is made and the above flow is not added if the router
741         port's own IP address is used to SNAT packets passing through that
742         router.
743       </li>
744     </ul>
745
746     <p>
747       The flows above handle all of the traffic that might be directed to the
748       router itself.  The following flows (with lower priorities) handle the
749       remaining traffic, potentially for forwarding:
750     </p>
751
752     <ul>
753       <li>
754         Drop Ethernet local broadcast.  A priority-50 flow with match
755         <code>eth.bcast</code> drops traffic destined to the local Ethernet
756         broadcast address.  By definition this traffic should not be forwarded.
757       </li>
758
759       <li>
760         Drop IP multicast.  A priority-50 flow with match
761         <code>ip4.mcast</code> drops IP multicast traffic.
762       </li>
763
764       <li>
765         <p>
766           ICMP time exceeded.  For each router port <var>P</var>, whose IP
767           address is <var>A</var>, a priority-40 flow with match <code>inport
768           == <var>P</var> &amp;&amp; ip.ttl == {0, 1} &amp;&amp;
769           !ip.later_frag</code> matches packets whose TTL has expired, with the
770           following actions to send an ICMP time exceeded reply:
771         </p>
772
773         <pre>
774 icmp4 {
775     icmp4.type = 11; /* Time exceeded. */
776     icmp4.code = 0;  /* TTL exceeded in transit. */
777     ip4.dst = ip4.src;
778     ip4.src = <var>A</var>;
779     ip.ttl = 255;
780     next;
781 };
782         </pre>
783
784         <p>
785           Not yet implemented.
786         </p>
787       </li>
788
789       <li>
790         TTL discard.  A priority-30 flow with match <code>ip.ttl == {0,
791         1}</code> and actions <code>drop;</code> drops other packets whose TTL
792         has expired, that should not receive a ICMP error reply (i.e. fragments
793         with nonzero offset).
794       </li>
795
796       <li>
797         Next table.  A priority-0 flows match all packets that aren't already
798         handled and uses actions <code>next;</code> to feed them to the ingress
799         table for routing.
800       </li>
801     </ul>
802
803     <h3>Ingress Table 2: UNSNAT</h3>
804
805     <p>
806       This is for already established connections' reverse traffic.
807       i.e., SNAT has already been done in egress pipeline and now the
808       packet has entered the ingress pipeline as part of a reply.  It is
809       unSNATted here.
810     </p>
811
812     <ul>
813       <li>
814         <p>
815           For each configuration in the OVN Northbound database, that asks
816           to change the source IP address of a packet from <var>A</var> to
817           <var>B</var>, a priority-100 flow matches <code>ip &amp;&amp;
818           ip4.dst == <var>B</var></code> with an action
819           <code>ct_snat; next;</code>.
820         </p>
821
822         <p>
823           A priority-0 logical flow with match <code>1</code> has actions
824           <code>next;</code>.
825         </p>
826       </li>
827     </ul>
828
829     <h3>Ingress Table 3: DNAT</h3>
830
831     <p>
832       Packets enter the pipeline with destination IP address that needs to
833       be DNATted from a virtual IP address to a real IP address.  Packets
834       in the reverse direction needs to be unDNATed.
835     </p>
836     <ul>
837       <li>
838         <p>
839           For each configuration in the OVN Northbound database, that asks
840           to change the destination IP address of a packet from <var>A</var> to
841           <var>B</var>, a priority-100 flow matches <code>ip &amp;&amp;
842           ip4.dst == <var>A</var></code> with an action <code>inport = "";
843           ct_dnat(<var>B</var>);</code>.
844         </p>
845
846         <p>
847           For all IP packets of a Gateway router, a priority-50 flow with an
848           action <code>inport = ""; ct_dnat;</code>.
849         </p>
850
851         <p>
852           A priority-0 logical flow with match <code>1</code> has actions
853           <code>next;</code>.
854         </p>
855       </li>
856     </ul>
857
858     <h3>Ingress Table 4: IP Routing</h3>
859
860     <p>
861       A packet that arrives at this table is an IP packet that should be routed
862       to the address in <code>ip4.dst</code>.  This table implements IP
863       routing, setting <code>reg0</code> to the next-hop IP address (leaving
864       <code>ip4.dst</code>, the packet's final destination, unchanged) and
865       advances to the next table for ARP resolution.  It also sets
866       <code>reg1</code> to the IP address owned by the selected router port
867       (which is used later in table 6 as the IP source address for an ARP
868       request, if needed).
869     </p>
870
871     <p>
872       This table contains the following logical flows:
873     </p>
874
875     <ul>
876       <li>
877         <p>
878           Routing table.  For each route to IPv4 network <var>N</var> with
879           netmask <var>M</var>, on router port <var>P</var> with IP address
880           <var>A</var> and Ethernet
881           address <var>E</var>, a logical flow with match <code>ip4.dst ==
882           <var>N</var>/<var>M</var></code>, whose priority is the number of
883           1-bits in <var>M</var>, has the following actions:
884         </p>
885
886         <pre>
887 ip.ttl--;
888 reg0 = <var>G</var>;
889 reg1 = <var>A</var>;
890 eth.src = <var>E</var>;
891 outport = <var>P</var>;
892 inport = ""; /* Allow sending out inport. */
893 next;
894         </pre>
895
896         <p>
897           (Ingress table 1 already verified that <code>ip.ttl--;</code> will
898           not yield a TTL exceeded error.)
899         </p>
900
901         <p>
902           If the route has a gateway, <var>G</var> is the gateway IP address.
903           Instead, if the route is from a configured static route, <var>G</var>
904           is the next hop IP address.  Else it is <code>ip4.dst</code>.
905         </p>
906       </li>
907
908       <li>
909         <p>
910           Destination unreachable.  For each router port <var>P</var>, which
911           owns IP address <var>A</var>, a priority-0 logical flow with match
912           <code>in_port == <var>P</var> &amp;&amp; !ip.later_frag &amp;&amp;
913           !icmp</code> has the following actions:
914         </p>
915
916         <pre>
917 icmp4 {
918     icmp4.type = 3; /* Destination unreachable. */
919     icmp4.code = 0; /* Network unreachable. */
920     ip4.dst = ip4.src;
921     ip4.src = <var>A</var>;
922     ip.ttl = 255;
923     next(2);
924 };
925         </pre>
926
927         <p>
928           (The <code>!icmp</code> check prevents recursion if the destination
929           unreachable message itself cannot be routed.)
930         </p>
931
932         <p>
933           These flows are omitted if the logical router has a default route,
934           that is, a route with netmask 0.0.0.0.
935         </p>
936       </li>
937     </ul>
938
939     <h3>Ingress Table 5: ARP Resolution</h3>
940
941     <p>
942       Any packet that reaches this table is an IP packet whose next-hop IP
943       address is in <code>reg0</code>.  (<code>ip4.dst</code> is the final
944       destination.)  This table resolves the IP address in <code>reg0</code>
945       into an output port in <code>outport</code> and an Ethernet address in
946       <code>eth.dst</code>, using the following flows:
947     </p>
948
949     <ul>
950       <li>
951         <p>
952           Static MAC bindings.  MAC bindings can be known statically based on
953           data in the <code>OVN_Northbound</code> database.  For router ports
954           connected to logical switches, MAC bindings can be known statically
955           from the <code>addresses</code> column in the
956           <code>Logical_Switch_Port</code> table.  For router ports
957           connected to other logical routers, MAC bindings can be known
958           statically from the <code>mac</code> and <code>networks</code>
959           column in the <code>Logical_Router_Port</code> table.
960         </p>
961
962         <p>
963           For each IP address <var>A</var> whose host is known to have Ethernet
964           address <var>E</var> on router port <var>P</var>, a priority-100 flow
965           with match <code>outport === <var>P</var> &amp;&amp; reg0 ==
966           <var>A</var></code> has actions <code>eth.dst = <var>E</var>;
967           next;</code>.
968         </p>
969
970         <p>
971           For each logical router port with an IP address <var>A</var> and
972           a mac address of <var>E</var> that is reachable via a different
973           logical router port <var>P</var>, a priority-100 flow with
974           match <code>outport === <var>P</var> &amp;&amp; reg0 ==
975           <var>A</var></code> has actions <code>eth.dst = <var>E</var>;
976           next;</code>.
977         </p>
978       </li>
979
980       <li>
981         <p>
982           Dynamic MAC bindings.  This flows resolves MAC-to-IP bindings that
983           have become known dynamically through ARP.  (The next table will
984           issue an ARP request for cases where the binding is not yet known.)
985         </p>
986
987         <p>
988           A priority-0 logical flow with match <code>1</code> has actions
989           <code>get_arp(outport, reg0); next;</code>.
990         </p>
991       </li>
992     </ul>
993
994     <h3>Ingress Table 6: ARP Request</h3>
995
996     <p>
997       In the common case where the Ethernet destination has been resolved, this
998       table outputs the packet.  Otherwise, it composes and sends an ARP
999       request.  It holds the following flows:
1000     </p>
1001
1002     <ul>
1003       <li>
1004         <p>
1005           Unknown MAC address.  A priority-100 flow with match <code>eth.dst ==
1006           00:00:00:00:00:00</code> has the following actions:
1007         </p>
1008
1009         <pre>
1010 arp {
1011     eth.dst = ff:ff:ff:ff:ff:ff;
1012     arp.spa = reg1;
1013     arp.op = 1;  /* ARP request. */
1014     output;
1015 };
1016         </pre>
1017
1018         <p>
1019           (Ingress table 4 initialized <code>reg1</code> with the IP address
1020           owned by <code>outport</code>.)
1021         </p>
1022
1023         <p>
1024           The IP packet that triggers the ARP request is dropped.
1025         </p>
1026       </li>
1027
1028       <li>
1029         Known MAC address.  A priority-0 flow with match <code>1</code> has
1030         actions <code>output;</code>.
1031       </li>
1032     </ul>
1033
1034     <h3>Egress Table 0: SNAT</h3>
1035
1036     <p>
1037       Packets that are configured to be SNATed get their source IP address
1038       changed based on the configuration in the OVN Northbound database.
1039     </p>
1040     <ul>
1041       <li>
1042         <p>
1043           For each configuration in the OVN Northbound database, that asks
1044           to change the source IP address of a packet from an IP address of
1045           <var>A</var> or to change the source IP address of a packet that
1046           belongs to network <var>A</var> to <var>B</var>, a flow matches
1047           <code>ip &amp;&amp; ip4.src == <var>A</var></code> with an action
1048           <code>ct_snat(<var>B</var>);</code>.  The priority of the flow
1049           is calculated based on the mask of <var>A</var>, with matches
1050           having larger masks getting higher priorities.
1051         </p>
1052         <p>
1053           A priority-0 logical flow with match <code>1</code> has actions
1054           <code>next;</code>.
1055         </p>
1056       </li>
1057     </ul>
1058
1059     <h3>Egress Table 1: Delivery</h3>
1060
1061     <p>
1062       Packets that reach this table are ready for delivery.  It contains
1063       priority-100 logical flows that match packets on each enabled logical
1064       router port, with action <code>output;</code>.
1065     </p>
1066
1067 </manpage>