ovn-northd.8: Update documentation.
[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 sends IP packets to
250       the connection tracker before advancing to ingress table
251       <code>ACLs</code>.
252     </p>
253
254     <h3>Ingress table 4: <code>from-lport</code> ACLs</h3>
255
256     <p>
257       Logical flows in this table closely reproduce those in the
258       <code>ACL</code> table in the <code>OVN_Northbound</code> database
259       for the <code>from-lport</code> direction.  <code>allow</code>
260       ACLs translate into logical flows with the <code>next;</code>
261       action, <code>allow-related</code> ACLs translate into logical
262       flows with the <code>ct_commit; next;</code> actions, other ACLs
263       translate to <code>drop;</code>.  The <code>priority</code> values
264       from the <code>ACL</code> table have a limited range and have 1000
265       added to them to leave room for OVN default flows at both higher
266       and lower priorities.
267     </p>
268
269     <p>
270       This table also contains a priority 0 flow with action
271       <code>next;</code>, so that ACLs allow packets by default.  If the
272       logical datapath has a statetful ACL, the following flows will
273       also be added:
274     </p>
275
276     <ul>
277       <li>
278         A priority-1 flow to commit IP traffic to the connection
279         tracker.  This is needed for the default allow policy because,
280         while the initiater's direction may not have any stateful rules,
281         the server's may and then its return traffic would not be known
282         and marked as invalid.
283       </li>
284
285       <li>
286         A priority-65535 flow that allows any traffic that has been
287         committed to the connection tracker (i.e., established flows).
288       </li>
289
290       <li>
291         A priority-65535 flow that allows any traffic that is considered
292         related to a committed flow in the connection tracker (e.g., an
293         ICMP Port Unreachable from a non-listening UDP port).
294       </li>
295
296       <li>
297         A priority-65535 flow that drops all traffic marked by the
298         connection tracker as invalid.
299       </li>
300     </ul>
301
302     <h3>Ingress Table 5: ARP responder</h3>
303
304     <p>
305       This table implements ARP responder for known IPs.  It contains these
306       logical flows:
307     </p>
308
309     <ul>
310       <li>
311         Priority-100 flows to skip ARP responder if inport is of type
312         <code>localnet</code>, and advances directly to the next table.
313       </li>
314
315       <li>
316         <p>
317           Priority-50 flows that matches ARP requests to each known IP address
318           <var>A</var> of logical port <var>P</var>, and respond with ARP
319           replies directly with corresponding Ethernet address <var>E</var>:
320         </p>
321
322         <pre>
323 eth.dst = eth.src;
324 eth.src = <var>E</var>;
325 arp.op = 2; /* ARP reply. */
326 arp.tha = arp.sha;
327 arp.sha = <var>E</var>;
328 arp.tpa = arp.spa;
329 arp.spa = <var>A</var>;
330 outport = <var>P</var>;
331 inport = ""; /* Allow sending out inport. */
332 output;
333         </pre>
334
335         <p>
336           These flows are omitted for logical ports (other than router ports)
337           that are down.
338         </p>
339       </li>
340
341       <li>
342         One priority-0 fallback flow that matches all packets and advances to
343         the next table.
344       </li>
345     </ul>
346
347     <h3>Ingress Table 6: Destination Lookup</h3>
348
349     <p>
350       This table implements switching behavior.  It contains these logical
351       flows:
352     </p>
353
354     <ul>
355       <li>
356         A priority-100 flow that outputs all packets with an Ethernet broadcast
357         or multicast <code>eth.dst</code> to the <code>MC_FLOOD</code>
358         multicast group, which <code>ovn-northd</code> populates with all
359         enabled logical ports.
360       </li>
361
362       <li>
363         One priority-50 flow that matches each known Ethernet address against
364         <code>eth.dst</code> and outputs the packet to the single associated
365         output port.
366       </li>
367
368       <li>
369         One priority-0 fallback flow that matches all packets and outputs them
370         to the <code>MC_UNKNOWN</code> multicast group, which
371         <code>ovn-northd</code> populates with all enabled logical ports that
372         accept unknown destination packets.  As a small optimization, if no
373         logical ports accept unknown destination packets,
374         <code>ovn-northd</code> omits this multicast group and logical flow.
375       </li>
376     </ul>
377
378     <h3>Egress Table 0: <code>to-lport</code> Pre-ACLs</h3>
379
380     <p>
381       This is similar to ingress table <code>Pre-ACLs</code> except for
382      <code>to-lport</code> traffic.
383     </p>
384
385     <h3>Egress Table 1: <code>to-lport</code> ACLs</h3>
386
387     <p>
388       This is similar to ingress table <code>ACLs</code> except for
389       <code>to-lport</code> ACLs.
390     </p>
391
392     <h3>Egress Table 2: Egress Port Security - IP</h3>
393
394     <p>
395       This is similar to the port security logic in table
396       <code>Ingress Port Security - IP</code> except that <code>outport</code>,
397       <code>eth.dst</code>, <code>ip4.dst</code> and <code>ip6.dst</code>
398       are checked instead of <code>inport</code>, <code>eth.src</code>,
399       <code>ip4.src</code> and <code>ip6.src</code>
400     </p>
401
402     <h3>Egress Table 3: Egress Port Security - L2</h3>
403
404     <p>
405       This is similar to the ingress port security logic in ingress table
406       <code>Admission Control and Ingress Port Security - L2</code>,
407       but with important differences.  Most obviously, <code>outport</code> and
408       <code>eth.dst</code> are checked instead of <code>inport</code> and
409       <code>eth.src</code>.  Second, packets directed to broadcast or multicast
410       <code>eth.dst</code> are always accepted instead of being subject to the
411       port security rules; this is implemented through a priority-100 flow that
412       matches on <code>eth.mcast</code> with action <code>output;</code>.
413       Finally, to ensure that even broadcast and multicast packets are not
414       delivered to disabled logical ports, a priority-150 flow for each
415       disabled logical <code>outport</code> overrides the priority-100 flow
416       with a <code>drop;</code> action.
417     </p>
418
419     <h2>Logical Router Datapaths</h2>
420
421     <p>
422       Logical router datapaths will only exist for <ref table="Logical_Router"
423       db="OVN_Northbound"/> rows in the <ref db="OVN_Northbound"/> database
424       that do not have <ref column="enabled" table="Logical_Router"
425       db="OVN_Northbound"/> set to <code>false</code>
426     </p>
427
428     <h3>Ingress Table 0: L2 Admission Control</h3>
429
430     <p>
431       This table drops packets that the router shouldn't see at all based on
432       their Ethernet headers.  It contains the following flows:
433     </p>
434
435     <ul>
436       <li>
437         Priority-100 flows to drop packets with VLAN tags or multicast Ethernet
438         source addresses.
439       </li>
440
441       <li>
442         For each enabled router port <var>P</var> with Ethernet address
443         <var>E</var>, a priority-50 flow that matches <code>inport ==
444         <var>P</var> &amp;&amp; (eth.mcast || eth.dst ==
445         <var>E</var></code>), with action <code>next;</code>.
446       </li>
447     </ul>
448
449     <p>
450       Other packets are implicitly dropped.
451     </p>
452
453     <h3>Ingress Table 1: IP Input</h3>
454
455     <p>
456       This table is the core of the logical router datapath functionality.  It
457       contains the following flows to implement very basic IP host
458       functionality.
459     </p>
460
461     <ul>
462       <li>
463         <p>
464           L3 admission control: A priority-100 flow drops packets that match
465           any of the following:
466         </p>
467
468         <ul>
469           <li>
470             <code>ip4.src[28..31] == 0xe</code> (multicast source)
471           </li>
472           <li>
473             <code>ip4.src == 255.255.255.255</code> (broadcast source)
474           </li>
475           <li>
476             <code>ip4.src == 127.0.0.0/8 || ip4.dst == 127.0.0.0/8</code>
477             (localhost source or destination)
478           </li>
479           <li>
480             <code>ip4.src == 0.0.0.0/8 || ip4.dst == 0.0.0.0/8</code> (zero
481             network source or destination)
482           </li>
483           <li>
484             <code>ip4.src</code> is any IP address owned by the router.
485           </li>
486           <li>
487             <code>ip4.src</code> is the broadcast address of any IP network
488             known to the router.
489           </li>
490         </ul>
491       </li>
492
493       <li>
494         <p>
495           ICMP echo reply.  These flows reply to ICMP echo requests received
496           for the router's IP address.  Let <var>A</var> be an IP address
497           owned by a router port.  Then, for each <var>A</var>, a priority-90
498           flow matches on <code>ip4.dst == <var>A</var></code> and <code>
499           icmp4.type == 8 &amp;&amp; icmp4.code == 0</code> (ICMP echo
500           request).  The port of the router that receives the echo request
501           does not matter. Also, the ip.ttl of the echo request packet is not
502           checked, so it complies with RFC 1812, section 4.2.2.9. These flows
503           use the following actions where <var>S</var> is the router's IP
504           address:
505         </p>
506
507         <pre>
508 ip4.dst = ip4.src;
509 ip4.src = <var>S</var>;
510 ip.ttl = 255;
511 icmp4.type = 0;
512 inport = ""; /* Allow sending out inport. */
513 next;
514         </pre>
515       </li>
516
517       <li>
518         <p>
519           Reply to ARP requests.
520         </p>
521
522         <p>
523           These flows reply to ARP requests for the router's own IP address.
524           For each router port <var>P</var> that owns IP address <var>A</var>
525           and Ethernet address <var>E</var>, a priority-90 flow matches
526           <code>inport == <var>P</var> &amp;&amp; arp.op == 1 &amp;&amp;
527           arp.tpa == <var>A</var></code> (ARP request) with the following
528           actions:
529         </p>
530
531         <pre>
532 eth.dst = eth.src;
533 eth.src = <var>E</var>;
534 arp.op = 2; /* ARP reply. */
535 arp.tha = arp.sha;
536 arp.sha = <var>E</var>;
537 arp.tpa = arp.spa;
538 arp.spa = <var>A</var>;
539 outport = <var>P</var>;
540 inport = ""; /* Allow sending out inport. */
541 output;
542         </pre>
543       </li>
544
545       <li>
546         <p>
547           These flows reply to ARP requests for the virtual IP addresses
548           configured in the router for DNAT. For a configured DNAT IP address
549           <var>A</var>, for each router port <var>P</var> with Ethernet
550           address <var>E</var>, a priority-90 flow matches
551           <code>inport == <var>P</var> &amp;&amp; arp.op == 1 &amp;&amp;
552           arp.tpa == <var>A</var></code> (ARP request)
553           with the following actions:
554         </p>
555
556         <pre>
557 eth.dst = eth.src;
558 eth.src = <var>E</var>;
559 arp.op = 2; /* ARP reply. */
560 arp.tha = arp.sha;
561 arp.sha = <var>E</var>;
562 arp.tpa = arp.spa;
563 arp.spa = <var>A</var>;
564 outport = <var>P</var>;
565 inport = ""; /* Allow sending out inport. */
566 output;
567         </pre>
568       </li>
569
570       <li>
571         ARP reply handling.  These flows use ARP replies to populate the
572         logical router's ARP table.  A priority-90 flow with match <code>arp.op
573         == 2</code> has actions <code>put_arp(inport, arp.spa,
574         arp.sha);</code>.
575       </li>
576
577       <li>
578         <p>
579           UDP port unreachable.  Priority-80 flows generate ICMP port
580           unreachable messages in reply to UDP datagrams directed to the
581           router's IP address.  The logical router doesn't accept any UDP
582           traffic so it always generates such a reply.
583         </p>
584
585         <p>
586           These flows should not match IP fragments with nonzero offset.
587         </p>
588
589         <p>
590           Details TBD.  Not yet implemented.
591         </p>
592       </li>
593
594       <li>
595         <p>
596           TCP reset.  Priority-80 flows generate TCP reset messages in reply to
597           TCP datagrams directed to the router's IP address.  The logical
598           router doesn't accept any TCP traffic so it always generates such a
599           reply.
600         </p>
601
602         <p>
603           These flows should not match IP fragments with nonzero offset.
604         </p>
605
606         <p>
607           Details TBD.  Not yet implemented.
608         </p>
609       </li>
610
611       <li>
612         <p>
613           Protocol unreachable.  Priority-70 flows generate ICMP protocol
614           unreachable messages in reply to packets directed to the router's IP
615           address on IP protocols other than UDP, TCP, and ICMP.
616         </p>
617
618         <p>
619           These flows should not match IP fragments with nonzero offset.
620         </p>
621
622         <p>
623           Details TBD.  Not yet implemented.
624         </p>
625       </li>
626
627       <li>
628         Drop other IP traffic to this router.  These flows drop any other
629         traffic destined to an IP address of this router that is not already
630         handled by one of the flows above, which amounts to ICMP (other than
631         echo requests) and fragments with nonzero offsets.  For each IP address
632         <var>A</var> owned by the router, a priority-60 flow matches
633         <code>ip4.dst == <var>A</var></code> and drops the traffic.  An
634         exception is made and the above flow is not added if the router
635         port's own IP address is used to SNAT packets passing through that
636         router.
637       </li>
638     </ul>
639
640     <p>
641       The flows above handle all of the traffic that might be directed to the
642       router itself.  The following flows (with lower priorities) handle the
643       remaining traffic, potentially for forwarding:
644     </p>
645
646     <ul>
647       <li>
648         Drop Ethernet local broadcast.  A priority-50 flow with match
649         <code>eth.bcast</code> drops traffic destined to the local Ethernet
650         broadcast address.  By definition this traffic should not be forwarded.
651       </li>
652
653       <li>
654         Drop IP multicast.  A priority-50 flow with match
655         <code>ip4.mcast</code> drops IP multicast traffic.
656       </li>
657
658       <li>
659         <p>
660           ICMP time exceeded.  For each router port <var>P</var>, whose IP
661           address is <var>A</var>, a priority-40 flow with match <code>inport
662           == <var>P</var> &amp;&amp; ip.ttl == {0, 1} &amp;&amp;
663           !ip.later_frag</code> matches packets whose TTL has expired, with the
664           following actions to send an ICMP time exceeded reply:
665         </p>
666
667         <pre>
668 icmp4 {
669     icmp4.type = 11; /* Time exceeded. */
670     icmp4.code = 0;  /* TTL exceeded in transit. */
671     ip4.dst = ip4.src;
672     ip4.src = <var>A</var>;
673     ip.ttl = 255;
674     next;
675 };
676         </pre>
677
678         <p>
679           Not yet implemented.
680         </p>
681       </li>
682
683       <li>
684         TTL discard.  A priority-30 flow with match <code>ip.ttl == {0,
685         1}</code> and actions <code>drop;</code> drops other packets whose TTL
686         has expired, that should not receive a ICMP error reply (i.e. fragments
687         with nonzero offset).
688       </li>
689
690       <li>
691         Next table.  A priority-0 flows match all packets that aren't already
692         handled and uses actions <code>next;</code> to feed them to the ingress
693         table for routing.
694       </li>
695     </ul>
696
697     <h3>Ingress Table 2: UNSNAT</h3>
698
699     <p>
700       This is for already established connections' reverse traffic.
701       i.e., SNAT has already been done in egress pipeline and now the
702       packet has entered the ingress pipeline as part of a reply.  It is
703       unSNATted here.
704     </p>
705
706     <ul>
707       <li>
708         <p>
709           For each configuration in the OVN Northbound database, that asks
710           to change the source IP address of a packet from <var>A</var> to
711           <var>B</var>, a priority-100 flow matches <code>ip &amp;&amp;
712           ip4.dst == <var>B</var></code> with an action
713           <code>ct_snat; next;</code>.
714         </p>
715
716         <p>
717           A priority-0 logical flow with match <code>1</code> has actions
718           <code>next;</code>.
719         </p>
720       </li>
721     </ul>
722
723     <h3>Ingress Table 3: DNAT</h3>
724
725     <p>
726       Packets enter the pipeline with destination IP address that needs to
727       be DNATted from a virtual IP address to a real IP address.  Packets
728       in the reverse direction needs to be unDNATed.
729     </p>
730     <ul>
731       <li>
732         <p>
733           For each configuration in the OVN Northbound database, that asks
734           to change the destination IP address of a packet from <var>A</var> to
735           <var>B</var>, a priority-100 flow matches <code>ip &amp;&amp;
736           ip4.dst == <var>A</var></code> with an action <code>inport = "";
737           ct_dnat(<var>B</var>);</code>.
738         </p>
739
740         <p>
741           For all IP packets of a Gateway router, a priority-50 flow with an
742           action <code>inport = ""; ct_dnat;</code>.
743         </p>
744
745         <p>
746           A priority-0 logical flow with match <code>1</code> has actions
747           <code>next;</code>.
748         </p>
749       </li>
750     </ul>
751
752     <h3>Ingress Table 4: IP Routing</h3>
753
754     <p>
755       A packet that arrives at this table is an IP packet that should be routed
756       to the address in <code>ip4.dst</code>.  This table implements IP
757       routing, setting <code>reg0</code> to the next-hop IP address (leaving
758       <code>ip4.dst</code>, the packet's final destination, unchanged) and
759       advances to the next table for ARP resolution.  It also sets
760       <code>reg1</code> to the IP address owned by the selected router port
761       (which is used later in table 6 as the IP source address for an ARP
762       request, if needed).
763     </p>
764
765     <p>
766       This table contains the following logical flows:
767     </p>
768
769     <ul>
770       <li>
771         <p>
772           Routing table.  For each route to IPv4 network <var>N</var> with
773           netmask <var>M</var>, on router port <var>P</var> with IP address
774           <var>A</var> and Ethernet
775           address <var>E</var>, a logical flow with match <code>ip4.dst ==
776           <var>N</var>/<var>M</var></code>, whose priority is the number of
777           1-bits in <var>M</var>, has the following actions:
778         </p>
779
780         <pre>
781 ip.ttl--;
782 reg0 = <var>G</var>;
783 reg1 = <var>A</var>;
784 eth.src = <var>E</var>;
785 outport = <var>P</var>;
786 next;
787         </pre>
788
789         <p>
790           (Ingress table 1 already verified that <code>ip.ttl--;</code> will
791           not yield a TTL exceeded error.)
792         </p>
793
794         <p>
795           If the route has a gateway, <var>G</var> is the gateway IP address.
796           Instead, if the route is from a configured static route, <var>G</var>
797           is the next hop IP address.  Else it is <code>ip4.dst</code>.
798         </p>
799       </li>
800
801       <li>
802         <p>
803           Destination unreachable.  For each router port <var>P</var>, which
804           owns IP address <var>A</var>, a priority-0 logical flow with match
805           <code>in_port == <var>P</var> &amp;&amp; !ip.later_frag &amp;&amp;
806           !icmp</code> has the following actions:
807         </p>
808
809         <pre>
810 icmp4 {
811     icmp4.type = 3; /* Destination unreachable. */
812     icmp4.code = 0; /* Network unreachable. */
813     ip4.dst = ip4.src;
814     ip4.src = <var>A</var>;
815     ip.ttl = 255;
816     next(2);
817 };
818         </pre>
819
820         <p>
821           (The <code>!icmp</code> check prevents recursion if the destination
822           unreachable message itself cannot be routed.)
823         </p>
824
825         <p>
826           These flows are omitted if the logical router has a default route,
827           that is, a route with netmask 0.0.0.0.
828         </p>
829       </li>
830     </ul>
831
832     <h3>Ingress Table 5: ARP Resolution</h3>
833
834     <p>
835       Any packet that reaches this table is an IP packet whose next-hop IP
836       address is in <code>reg0</code>.  (<code>ip4.dst</code> is the final
837       destination.)  This table resolves the IP address in <code>reg0</code>
838       into an output port in <code>outport</code> and an Ethernet address in
839       <code>eth.dst</code>, using the following flows:
840     </p>
841
842     <ul>
843       <li>
844         <p>
845           Static MAC bindings.  MAC bindings can be known statically based on
846           data in the <code>OVN_Northbound</code> database.  For router ports
847           connected to logical switches, MAC bindings can be known statically
848           from the <code>addresses</code> column in the
849           <code>Logical_Switch_Port</code> table.  For router ports
850           connected to other logical routers, MAC bindings can be known
851           statically from the <code>mac</code> and <code>network</code>
852           column in the <code>Logical_Router_Port</code> table.
853         </p>
854
855         <p>
856           For each IP address <var>A</var> whose host is known to have Ethernet
857           address <var>E</var> on router port <var>P</var>, a priority-100 flow
858           with match <code>outport === <var>P</var> &amp;&amp; reg0 ==
859           <var>A</var></code> has actions <code>eth.dst = <var>E</var>;
860           next;</code>.
861         </p>
862
863         <p>
864           For each logical router port with an IP address <var>A</var> and
865           a mac address of <var>E</var> that is reachable via a different
866           logical router port <var>P</var>, a priority-100 flow with
867           match <code>outport === <var>P</var> &amp;&amp; reg0 ==
868           <var>A</var></code> has actions <code>eth.dst = <var>E</var>;
869           next;</code>.
870         </p>
871       </li>
872
873       <li>
874         <p>
875           Dynamic MAC bindings.  This flows resolves MAC-to-IP bindings that
876           have become known dynamically through ARP.  (The next table will
877           issue an ARP request for cases where the binding is not yet known.)
878         </p>
879
880         <p>
881           A priority-0 logical flow with match <code>1</code> has actions
882           <code>get_arp(outport, reg0); next;</code>.
883         </p>
884       </li>
885     </ul>
886
887     <h3>Ingress Table 6: ARP Request</h3>
888
889     <p>
890       In the common case where the Ethernet destination has been resolved, this
891       table outputs the packet.  Otherwise, it composes and sends an ARP
892       request.  It holds the following flows:
893     </p>
894
895     <ul>
896       <li>
897         <p>
898           Unknown MAC address.  A priority-100 flow with match <code>eth.dst ==
899           00:00:00:00:00:00</code> has the following actions:
900         </p>
901
902         <pre>
903 arp {
904     eth.dst = ff:ff:ff:ff:ff:ff;
905     arp.spa = reg1;
906     arp.op = 1;  /* ARP request. */
907     output;
908 };
909         </pre>
910
911         <p>
912           (Ingress table 4 initialized <code>reg1</code> with the IP address
913           owned by <code>outport</code>.)
914         </p>
915
916         <p>
917           The IP packet that triggers the ARP request is dropped.
918         </p>
919       </li>
920
921       <li>
922         Known MAC address.  A priority-0 flow with match <code>1</code> has
923         actions <code>output;</code>.
924       </li>
925     </ul>
926
927     <h3>Egress Table 0: SNAT</h3>
928
929     <p>
930       Packets that are configured to be SNATed get their source IP address
931       changed based on the configuration in the OVN Northbound database.
932     </p>
933     <ul>
934       <li>
935         <p>
936           For each configuration in the OVN Northbound database, that asks
937           to change the source IP address of a packet from an IP address of
938           <var>A</var> or to change the source IP address of a packet that
939           belongs to network <var>A</var> to <var>B</var>, a flow matches
940           <code>ip &amp;&amp; ip4.src == <var>A</var></code> with an action
941           <code>ct_snat(<var>B</var>);</code>.  The priority of the flow
942           is calculated based on the mask of <var>A</var>, with matches
943           having larger masks getting higher priorities.
944         </p>
945         <p>
946           A priority-0 logical flow with match <code>1</code> has actions
947           <code>next;</code>.
948         </p>
949       </li>
950     </ul>
951
952     <h3>Egress Table 1: Delivery</h3>
953
954     <p>
955       Packets that reach this table are ready for delivery.  It contains
956       priority-100 logical flows that match packets on each enabled logical
957       router port, with action <code>output;</code>.
958     </p>
959
960 </manpage>