ovn-trace(8)

🌸 ovn-trace(8) β€” OVN Manual 🌸

okay bestie, buckle up, because this is the tool that lets you ask the universe "so like… where does this packet actually GO?" πŸ’«

✨ NAME ✨

ovn-trace β€” Open Virtual Network logical network tracing utility πŸ¦‹


✨ SYNOPSIS ✨

ovn-trace [options] [datapath] microflow

ovn-trace [options] --detach

✨ DESCRIPTION ✨

This utility simulates packet forwarding inside an OVN logical network. It's your little what-if machine: if a packet starts out at a logical port, what happens to it, and where does it end up at the end of the day? πŸ’… If you already know the ofproto/trace command from Open vSwitch (that's in ovs-vswitch(8)), you're gonna feel right at home β€” ovn-trace is basically that same energy but for logical networks. 🫢

Here's how it works, no cap: ovn-trace reads the Logical_Flow table and the other tables out of the OVN southbound database (peep ovn-sb(5)). Then it simulates a packet's whole journey through the logical networks by looking it up in the logical flow table over and over, following the entire tree of possibilities β€” not just one path, the whole tree. 🌳✨

Important vibe check: ovn-trace only simulates the OVN logical network. It does not simulate the physical stuff the logical network is layered on top of. So like, it does not care how your VMs are spread across hypervisors, or whether those hypervisors are even alive and reachable β€” same results every time, periodt. πŸ’€ There is one big exception though: ovn-northd, the daemon that generates the logical flows ovn-trace simulates, treats logical ports differently depending on whether they're up or down. So if the results are giving surprising, go double-check that the ports involved in your simulation are up. πŸ™ˆ

The easiest way to use ovn-trace is to just hand it the microflow (and optionally the datapath) right there on the command line. Do that and it simulates one single packet and dips. If you want a whole other usage model, scroll down to Daemon Mode below. πŸ‘‘

The optional datapath argument is the name of a logical datapath. What counts as an acceptable name, you ask? Any of these:

  • the name from the northbound Logical_Switch or Logical_Router table
  • the UUID of a record from one of those tables
  • the UUID of a record from the southbound Datapath_Binding table

(it's optional because ovn-trace can figure it out from the inport that the microflow matches) 🧚

The microflow argument describes the packet whose forwarding you wanna simulate, written in the syntax of an OVN logical expression as described in ovn-sb(5), so you can express constraints. And good news: the parser understands prerequisites β€” so if your expression mentions ip4.src, you do not have to sit there spelling out ip4 or eth.type == 0x800 too. She already knows. πŸ’–

For reasonable L2 behavior, your microflow should include at least inport and eth.dst, plus eth.src if port security is enabled. Like so:

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

And here's an ARP microflow example, because ARP deserves its own moment πŸŽ€:

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

Now, ovn-trace will reject erroneous microflow expressions, and beyond plain syntax errors they fall into two categories:

  1. They can be ambiguous. Example: tcp.src == 80 is ambiguous because it never says whether the Ethernet type is IPv4 or IPv6. Also ip4 && tcp.src > 1024 is ambiguous because it doesn't constrain the bits of tcp.src to particular values. πŸ€·β€β™€οΈ
  2. They can be contradictory, e.g. ip4 && ip6. Pick a lane, babe. πŸ’€

✨ OUTPUT ✨

ovn-trace supports three different forms of output, and each one gets its own section right below. But no matter which output format you pick, ovn-trace always starts the output with a line showing the microflow being traced, in OpenFlow syntax. Consistent queen. πŸ‘‘

πŸ’– Detailed Output πŸ’–

The detailed form of output is also the default form. It groups the 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
  • the actions that were executed

The execution of OVN logical actions naturally forms a control stack, kinda like the one you'd see in a conventional programming language such as C or Java. And 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. Display those the obvious way, with extra indentation for every level, and you've eaten up all the horizontal space on every display that isn't comically wide. 😭 So to keep detailed output readable, and without loss of generality, ovn-trace skips indentation for tail recursion β€” that is, when next is the last action in a logical flow, it does not indent the details of the next table lookup any deeper. It still uses indentation when it's actually needed for clarity. ✨

OVN "programs" traces also tend to run into long strings of logical flows with the match expression 1 (which matches every single packet) and the single action next;. Those are boring, they're just clutter, so ovn-trace omits them entirely β€” even from detailed output. Not me filtering out the NPC flows πŸ’…

Here's an excerpt from detailed ovn-trace output showing 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 19 (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);
19. ls_in_l2_lkup: eth.dst == 00:00:00:00:ff:11, priority 50
outport = "lrp11-attachment";
output;

πŸ’– Summary Output πŸ’–

Summary output includes the logical pipelines visited by a packet and the logical actions executed on it. Compared to the detailed output though, it removes details of tables and logical flows traversed by a packet. It uses a format that's closer to a programming language, and it does not bother trying to avoid indentation. The summary output equivalent to that detailed output fragment above is:

ingress(dp="ls1", inport="lp111") {
outport = "lrp11-attachment";
output;
...
};

πŸ’– Minimal Output πŸ’–

Minimal output includes only actions that modify packet data (and that does not include OVN registers or metadata such as outport) plus the output actions that actually deliver a packet to a logical port (patch ports excluded). The operands of actions that modify packet data get displayed reduced to constants β€” like, ip4.dst = reg0; might be shown as ip4.dst = 192.168.0.1; if that's the value that was actually loaded. This gives you output even simpler than the summary format. (If you know Open vSwitch, you might 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 reflects the implementation. Which is exactly why this format is the most suitable one for regression tests β€” it's the least likely to change when logical flow tables get rearranged without any semantic change. Chef's kiss for stability. πŸ‘©β€πŸ³πŸ’‹


✨ STATEFUL ACTIONS ✨

Some OVN logical actions use or update state that is not available in the southbound database. ovn-trace handles those actions like this:

  • ct_next β€” By default ovn-trace treats flows as "tracked" and "established." Peep the description of the --ct option for a way to override this behavior. πŸ”₯
  • ct_dnat (without an argument) β€” Forks the pipeline. In one fork, it advances to the next table as if next; were executed, and the packet is not changed, on the assumption that no NAT state was available. In the other fork, the pipeline continues without change after the ct_dnat action. 🍴
  • ct_snat (without an argument) β€” This action distinguishes between gateway routers and distributed routers. A gateway router is defined as a logical datapath that contains an l3gateway port; any other logical datapath is a distributed router. On a gateway router, ct_snat; is treated as a no-op. On a distributed router, it's treated the same way as ct_dnat;. πŸ‘‘
  • ct_dnat(ip), ct_snat(ip) β€” Forks the pipeline. In one fork, it sets ip4.dst (or ip4.src) to ip and ct.dnat (or ct.snat) to 1, then advances to the next table as if next; were executed. In the other fork, the pipeline continues without change after the ct_dnat (or ct_snat) action. 🍴
  • ct_lb_mark;, ct_lb_mark(ip[:port]...); β€” Forks the pipeline. In one fork, it sets ip4.dst (or ip6.dst) to one of the load-balancer addresses and the destination port to its associated port, if any, and sets ct.dnat to 1. With one or more arguments, it gives preference to the address specified on --lb-dst, if any; without arguments, it uses the address and port specified on --lb-dst. In the other fork, the pipeline continues without change after the ct_lb_mark action. 🍴
  • ct_commit, put_arp, put_nd β€” These actions are treated as no-ops. πŸ«₯

✨ DAEMON MODE ✨

If ovn-trace gets invoked with the --detach option (see Daemon Options, below), it runs in the background as a daemon and accepts commands from ovn-appctl (or another JSON-RPC client) forever and ever. ♾️ The currently supported commands are described below.

  • trace [options] [datapath] microflow β€” Traces microflow through datapath and replies with the results of the trace. Accepts the options described under Trace Options below. πŸ”
  • exit β€” Causes ovn-trace to gracefully terminate. bye bestie πŸ‘‹πŸ’–

✨ OPTIONS ✨

okay bestie, this is where the real customization happens πŸ’… every flag you could ever want, fr fr.

Trace Options πŸ¦‹

  • --detailed
  • --summary
  • --minimal

These options control the form and level of detail in ovn-trace output. If more than one of these options is specified, all of the selected forms are output, in the order listed above, each headed by a banner line. If none of these options is given, --detailed is the default. See Output, above, for a description of each kind of output.

  • --all β€” Selects all three forms of output. it's giving "I want everything" energy ✨
  • --ovs[=remote] β€” Makes ovn-trace attempt to obtain and display the OpenFlow flows that correspond to each OVN logical flow. To do so, ovn-trace connects to remote (by default, unix:/br-int.mgmt) over OpenFlow and retrieves the flows. If remote is specified, it must be an active OpenFlow connection method described in ovsdb(7).

To make the best use of the output, it is important to understand the relationship between logical flows and OpenFlow flows. ovn-architecture(7), under Architectural Physical Life Cycle of a Packet, describes this relationship. Keep in mind the following points:

  • ovn-trace currently shows all the OpenFlow flows to which a logical flow corresponds, even though an actual packet ordinarily matches only one of these.
  • Some logical flows can map to the Open vSwitch ``conjunctive match'' extension (see ovs-fields(7)). Currently ovn-trace cannot display the flows with conjunction actions that effectively produce the conj_id match.
  • Some logical flows may not be represented in the OpenFlow tables on a given hypervisor, if they could not be used on that hypervisor.
  • Some OpenFlow flows do not correspond to logical flows, such as OpenFlow flows that map between physical and logical ports. These flows will never show up in a trace.
  • When ovn-trace omits uninteresting logical flows from output, it does not look up the corresponding OpenFlow flows.
  • --ct=flags β€” This option sets the ct_state flags that a ct_next logical action will report. The flags must be a comma- or space-separated list of the following connection tracking flags:
    • trk: Include to indicate connection tracking has taken place. (This bit is set automatically even if not listed in flags.
    • new: Include to indicate a new flow.
    • est: Include to indicate an established flow.
    • rel: Include to indicate a related flow.
    • rpl: Include to indicate a reply flow.
    • inv: Include to indicate a connection entry in a bad state.
    • dnat: Include to indicate a packet whose destination IP address has been changed.
    • snat: Include to indicate a packet whose source IP address has been changed.

The ct_next action is used to implement the OVN distributed firewall. For testing, useful flag combinations include:

  • trk,new: A packet in a flow in either direction through a firewall that has not yet been committed (with ct_commit).
  • trk,est: A packet in an established flow going out through a firewall.
  • trk,rpl: A packet coming in through a firewall in reply to an established flow.
  • trk,inv: An invalid packet in either direction.

A packet might pass through the connection tracker twice in one trip through OVN: once following egress from a VM as it passes outward through a firewall, and once preceding ingress to a second VM as it passes inward through a firewall. Use multiple --ct options to specify the flags for multiple ct_next actions.

When --ct is unspecified, or when there are fewer --ct options than ct_next actions, the flags default to trk,est.

  • --lb-dst=ip[:port] β€” Sets the IP from VIP pool to use as destination of the packet. --lb-dst is not available in daemon mode.
  • --select-id=id β€” Specify the id to be selected by the select action. id must be one of the values listed in the select action. Otherwise, a random id is selected from the list, as if --select-id were not specified. --select-id is not available in daemon mode.
  • --friendly-names
  • --no-friendly-names

When cloud management systems such as OpenStack are layered on top of OVN, they often use long, human-unfriendly names for ports and datapaths, for example, ones that include entire UUIDs. They do usually include friendlier names, but the long, hard-to-read names are the ones that appear in matches and actions. By default, or with --friendly-names, ovn-trace substitutes these friendlier names for the long names in its output. Use --no-friendly-names to disable this behavior; this option might be useful, for example, if a program is going to parse ovn-trace output.


Daemon Options πŸ’…

  • --pidfile[=pidfile] β€” Causes a file (by default, program.pid) to be created indicating the PID of the running process. If the pidfile argument is not specified, or if it does not begin with /, then it is created in .

If --pidfile is not specified, no pidfile is created.

  • --overwrite-pidfile β€” By default, when --pidfile is specified and the specified pidfile already exists and is locked by a running process, the daemon refuses to start. Specify --overwrite-pidfile to cause it to instead overwrite the pidfile.

When --pidfile is not specified, this option has no effect.

  • --detach β€” Runs this program as a background process. The process forks, and in the child it starts a new session, closes the standard file descriptors (which has the side effect of disabling logging to the console), and changes its current directory to the root (unless --no-chdir is specified). After the child completes its initialization, the parent exits.
  • --monitor β€” Creates an additional process to monitor this program. If it dies due to a signal that indicates a programming error (SIGABRT, SIGALRM, SIGBUS, SIGFPE, SIGILL, SIGPIPE, SIGSEGV, SIGXCPU, or SIGXFSZ) then the monitor process starts a new copy of it. If the daemon dies or exits for another reason, the monitor process exits.

This option is normally used with --detach, but it also functions without it.

  • --no-chdir β€” By default, when --detach is specified, the daemon changes its current working directory to the root directory after it detaches. Otherwise, invoking the daemon from a carelessly chosen directory would prevent the administrator from unmounting the file system that holds that directory.

Specifying --no-chdir suppresses this behavior, preventing the daemon from changing its current working directory. This may be useful for collecting core files, since it is common behavior to write core dumps into the current working directory and the root directory is not a good directory to use.

This option has no effect when --detach is not specified.

  • --no-self-confinement β€” By default this daemon will try to self-confine itself to work with files under well-known directories determined at build time. It is better to stick with this default behavior and not to use this flag unless some other Access Control is used to confine daemon. Note that in contrast to other access control implementations that are typically enforced from kernel-space (e.g. DAC or MAC), self-confinement is imposed from the user-space daemon itself and hence should not be considered as a full confinement strategy, but instead should be viewed as an additional layer of security.
  • --user=user:group β€” Causes this program to run as a different user specified in user:group, thus dropping most of the root privileges. Short forms user and :group are also allowed, with current user or group assumed, respectively. Only daemons started by the root user accepts this argument.

On Linux, daemons will be granted CAP_IPC_LOCK and CAP_NET_BIND_SERVICES before dropping root privileges. Daemons that interact with a datapath, such as ovs-vswitchd, will be granted three additional capabilities, namely CAP_NET_ADMIN, CAP_NET_BROADCAST and CAP_NET_RAW. The capability change will apply even if the new user is root.


Logging Options 🌈

  • -v[spec]
  • --verbose=[spec]

Sets logging levels. Without any spec, sets the log level for every module and destination to dbg. Otherwise, spec is a list of words separated by spaces or commas or colons, up to one from each category below:

  • A valid module name, as displayed by the vlog/list command on ovs-appctl(8), limits the log level change to the specified module.
  • syslog, console, or file, to limit the log level change to only to the system log, to the console, or to a file, respectively. (If --detach is specified, the daemon closes its standard file descriptors, so logging to the console will have no effect.)
  • off, emer, err, warn, info, or dbg, to control the log level. Messages of the given severity or higher will be logged, and messages of lower severity will be filtered out. off filters out all messages. See ovs-appctl(8) for a definition of each log level.

Case is not significant within spec.

Regardless of the log levels set for file, logging to a file will not take place unless --log-file is also specified (see below).

For compatibility with older versions of OVS, any is accepted as a word but has no effect.

  • -v
  • --verbose

Sets the maximum logging verbosity level, equivalent to --verbose=dbg.

  • -vPATTERN:destination:pattern
  • --verbose=PATTERN:destination:pattern

Sets the log pattern for destination to pattern. Refer to ovs-appctl(8) for a description of the valid syntax for pattern.

  • -vFACILITY:facility, --verbose=FACILITY:facility β€” sets the RFC5424 facility of the log message. and bestie, facility has to be one of exactly these: kern, user, mail, daemon, auth, syslog, lpr, news, uucp, clock, ftp, ntp, audit, alert, clock2, local0, local1, local2, local3, local4, local5, local6 or local7. If you don't specify this option at all, daemon is used as the default for the local system syslog, and local0 is used while sending a message to the target provided via the --syslog-target option. ✨
  • --log-file[=file] β€” turns on logging to a file. If you pass file, that's the exact name used for the log file. If you omit file, the default log file name is /var/log/ovn/program.log. πŸ’–
  • --syslog-target=host:port β€” sends syslog messages to UDP port on host, in addition to the system syslog. ngl the important bit: host must be a numerical IP address, not a hostname. no cap.
  • --syslog-method=method β€” pick how syslog messages get sent to the syslog daemon. Here are the supported forms:
    • libc β€” uses the libc syslog() function. the downside of this option is that libc adds a fixed prefix to every message before it's actually sent to the syslog daemon over the /dev/log UNIX domain socket. πŸ™ˆ
    • unix:file β€” uses a UNIX domain socket directly. you can specify an arbitrary message format with this option. however, rsyslogd 8.9 and older versions use a hard coded parser function anyway, and that limits UNIX domain socket use. so if you want arbitrary message format with older rsyslogd versions, use a UDP socket to the localhost IP address instead. πŸ’…
    • udp:ip:port β€” uses a UDP socket. with this method it's possible to use arbitrary message format also with older rsyslogd. but listen: when sending syslog messages over a UDP socket, extra precaution needs to be taken into account β€” for example, the syslog daemon needs to be configured to listen on the specified UDP port, accidental iptables rules could be interfering with local syslog traffic, and there are some security considerations that apply to UDP sockets but do not apply to UNIX domain sockets. πŸ‘‘
    • null β€” discards all messages logged to syslog. bye bestie 🫢

The default is taken from the OVS_SYSLOG_METHOD environment variable; if it's unset, the default is libc.


πŸ” PKI Options πŸ”

PKI configuration is required to use SSL/TLS for the connection to the database (and the switch, if --ovs is specified). periodt. πŸ”₯

  • -p privkey.pem, --private-key=privkey.pem β€” specifies a PEM file containing the private key used as identity for outgoing SSL/TLS connections.
  • -c cert.pem, --certificate=cert.pem β€” specifies a PEM file containing a certificate that certifies the private key specified on -p or --private-key to be trustworthy. The certificate must be signed by the certificate authority (CA) that the peer in SSL/TLS connections will use to verify it.
  • -C cacert.pem, --ca-cert=cacert.pem β€” specifies a PEM file containing the CA certificate for verifying certificates presented to this program by SSL/TLS peers. (This may be the same certificate that SSL/TLS peers use to verify the certificate specified on -c or --certificate, or it may be a different one, depending on the PKI design in use.) πŸ’œ
  • -C none, --ca-cert=none β€” disables verification of certificates presented by SSL/TLS peers. > this introduces a security risk, because it means that certificates cannot be verified to be those of known trusted hosts. 😭 like, please know what you're doing bestie.
  • --ssl-server-name=servername β€” specifies the server name to use for TLS Server Name Indication (SNI). By default, the hostname from the connection string is used for SNI. This option allows overriding the SNI hostname, which is useful when connecting through proxies or service meshes where the connection endpoint differs from the intended server name. πŸ¦‹

🌈 Other Options 🌈

  • --db database β€” the OVSDB database remote to contact. If the OVN_SB_DB environment variable is set, its value is used as the default. Otherwise, the default is unix:/db.sock, but fr fr this default is unlikely to be useful outside of single-machine OVN test environments. πŸ˜…
    • -h, --help β€” prints a brief help message to the console. πŸŽ€
    • -V, --version β€” prints version information to the console. ⭐

and that's a wrap on the whole page, bestie πŸ’– this was ovn-trace(8), hanging out with ovn-trace from OVN 26.09.1 β€” no date stamp on the footer, just the version and the page name, so that's the vibe check done. go trace something iconic βœ¨πŸŒΈπŸ’…

πŸ“¦ where this page comes from