ovn-trace(8) | Open vSwitch Manual | ovn-trace(8) |
ovn-trace - Open Virtual Network logical network tracing utility
ovn-trace [options] datapath microflow
ovn-trace [options] --detach
This utility simulates packet forwarding within an OVN logical network. It can be used to run through ``what-if’’ scenarios: if a packet originates at a logical port, what will happen to it and where will it ultimately end up? Users already familiar with the Open vSwitch ofproto/trace command described in ovs-vswitch(8) will find ovn-trace to be a similar tool for logical networks.
ovn-trace works by reading the Logical_Flow and other tables from the OVN southbound database (see ovn-sb(5)). It simulates a packet’s path through logical networks by repeatedly looking it up in the logical flow table, following the entire tree of possibilities.
ovn-trace simulates only the OVN logical network. It does not simulate the physical elements on which the logical network is layered. This means that, for example, it is unimportant how VMs are distributed among hypervisors, or whether their hypervisors are functioning and reachable, so ovn-trace will yield the same results regardless. There is one important exception: ovn-northd, the daemon that generates the logical flows that ovn-trace simulates, treats logical ports differently based on whether they are up or down. Thus, if you see surprising results, ensure that the ports involved in a simulation are up.
The simplest way to use ovn-trace is to provide datapath and microflow arguments on the command line. In this case, it simulates the behavior of a single packet and exits. For an alternate usage model, see Daemon Mode below.
The datapath argument specifies the name of a logical datapath. Acceptable names are the name from the northbound Logical_Switch or Logical_Router table, the UUID of a record from one of those tables, or the UUID of a record from the southbound Datapath_Binding table.
The microflow argument describes the packet whose forwarding is to be simulated, in the syntax of an OVN logical expression, as described in ovn-sb(5), to express constraints. The parser understands prerequisites; for example, if the expression refers to ip4.src, there is no need to explicitly state ip4 or eth.type == 0x800.
For reasonable L2 behavior, the microflow should include at least inport and eth.dst, plus eth.src if port security is enabled. For example:
inport == "lp11" && eth.src == 00:01:02:03:04:05 && eth.dst == ff:ff:ff:ff:ff:ff
For reasonable L3 behavior, microflow should also include ip4.src and ip4.dst (or ip6.src and ip6.dst) and ip.ttl. For example:
inport == "lp111" && eth.src == f0:00:00:00:01:11 && eth.dst == 00:00:00:00:ff:11
&& ip4.src == 192.168.11.1 && ip4.dst == 192.168.22.2 && ip.ttl == 64
Here’s an ARP microflow example:
inport == "lp123"
&& eth.dst == ff:ff:ff:ff:ff:ff && eth.src == f0:00:00:00:01:11
&& arp.op == 1 && arp.sha == f0:00:00:00:01:11 && arp.spa == 192.168.1.11
&& arp.tha == ff:ff:ff:ff:ff:ff && arp.tpa == 192.168.2.22
ovn-trace will reject erroneous microflow expressions, which beyond syntax errors fall into two categories. First, they can be ambiguous. For example, tcp.src == 80 is ambiguous because it does not state IPv4 or IPv6 as the Ethernet type. ip4 && tcp.src > 1024 is also ambiguous because it does not constrain bits of tcp.src to particular values. Second, they can be contradictory, e.g. ip4 && ip6.
ovn-trace supports the three different forms of output, each described in a separate section below. Regardless of the selected output format, ovn-trace starts the output with a line that shows the microflow being traced in OpenFlow syntax.
The detailed form of output is also the default form. This form groups output into sections headed up by the ingress or egress pipeline being traversed. Each pipeline lists each table that was visited (by number and name), the ovn-northd source file and line number of the code that added the flow, the match expression and priority of the logical flow that was matched, and the actions that were executed.
The execution of OVN logical actions naturally forms a ``control stack’’ that resembles that of a program in conventional programming languages such as C or Java. Because the next action that calls into another logical flow table for a lookup is a recursive construct, OVN ``programs’’ in practice tend to form deep control stacks that, displayed in the obvious way using additional indentation for each level, quickly use up the horizontal space on all but the widest displays. To make detailed output more readable, without loss of generality, ovn-trace omits indentation for ``tail recursion,’’ that is, when next is the last action in a logical flow, it does not indent details of the next table lookup more deeply. Output still uses indentation when it is needed for clarity.
OVN ``programs’’ traces also tend to encounter long strings of logical flows with match expression 1 (which matches every packet) and the single action next;. These are uninteresting and merely clutter output, so ovn-trace omits them entirely even from detailed output.
The following excerpt from detailed ovn-trace output shows a section for a packet traversing the ingress pipeline of logical datapath ls1 with ingress logical port lp111. The packet matches a logical flow in table 0 (aka ls_in_port_sec_l2) with priority 50 and executes next(1); to pass to table 1. Tables 1 through 11 are trivial and omitted. In table 12 (aka ls_in_l2_lkup), the packet matches a flow with priority 50 based on its Ethernet destination address and the flow’s actions output the packet to the lrp11-attachement logical port.
ingress(dp="ls1", inport="lp111")
---------------------------------
0. ls_in_port_sec_l2: inport == "lp111", priority 50
next(1);
12. ls_in_l2_lkup: eth.dst == 00:00:00:00:ff:11, priority 50
outport = "lrp11-attachment";
output;
Summary output includes the logical pipelines visited by a packet and the logical actions executed on it. Compared to the detailed output, however, it removes details of tables and logical flows traversed by a packet. It uses a format closer to that of a programming language and does not attempt to avoid indentation. The summary output equivalent to the above detailed output fragment is:
ingress(dp="ls1", inport="lp111") {
outport = "lrp11-attachment";
output;
...
};
Minimal output includes only actions that modify packet data (not including OVN registers or metadata such as outport) and output actions that actually deliver a packet to a logical port (excluding patch ports). The operands of actions that modify packet data are displayed reduced to constants, e.g. ip4.dst = reg0; might be show as ip4.dst = 192.168.0.1; if that was the value actually loaded. This yields output even simpler than the summary format. (Users familiar with Open vSwitch may recognize this as similar in spirit to the datapath actions listed at the bottom of ofproto/trace output.)
The minimal output format reflects the externally seen behavior of the logical networks more than it does the implementation. This makes this output format the most suitable for use in regression tests, because it is least likely to change when logical flow tables are rearranged without semantic change.
Some OVN logical actions use or update state that is not available in the southbound database. ovn-trace handles these actions as described below:
If ovn-trace is invoked with the --detach option (see Daemon Options, below), it runs in the background as a daemon and accepts commands from ovs-appctl (or another JSON-RPC client) indefinitely. The currently supported commands are described below.
PKI configuration is required to use SSL for the connection to the database (and the switch, if --ovs is specified).
ovn-trace | Open vSwitch 2.10.7 |