1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
|
..
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
Convention for heading levels in Open vSwitch documentation:
======= Heading 0 (reserved for the title in a document)
------- Heading 1
~~~~~~~ Heading 2
+++++++ Heading 3
''''''' Heading 4
Avoid deeper levels because they do not render well.
===========
ovs-flowviz
===========
Synopsis
========
``ovs-flowviz``
[``-i`` [*alias*,]\ *file* | ``--input`` [*alias*,]\ *file*]
[``-c`` *file* | ``--config`` *file*]
[``-f`` *filter* | ``--filter`` *filter*]
[``-l`` *filter* | ``--highlight`` *filter*]
[``--style`` *style*]
*flow-type* *format* [*args*...]
``ovs-flowviz --help``
Description
===========
``ovs-flowviz`` helps visualize OpenFlow and datapath flow dumps in different
formats in order to make them more easily understood.
``ovs-flowviz`` reads flows from ``stdin`` or from a *file* specified by the
``--input`` option, filters them, highlights them, and finally outputs
them in one of the predefined *format*\ s.
Options
=======
.. program:: ovs-flowviz
.. option:: -h, --help
Print a brief help message to the console.
.. option:: -i [<alias>,]<file>, --input [<alias>,]<file>
File to read flows from. If not provided, ``ovs-flowviz``
will read flows from stdin.
This option can be specified multiple times.
The file path can prepended by an alias that will be shown in the output.
For example: ``--input node1,/path/to/file1 --input node2,/path/to/file2``
.. option:: -c <file>, --config <file>
Style configuration file to use, overriding the default one.
Styles defined in the style configuration file can be selected using
the ``--style`` option.
For more details on the style configuration file, see the
`Style Configuration File`_ section below.
.. option:: -f <filter>, --filter <filter>
Flow filter expression. Only those flows matching the expression will be
shown (although some formats implement filtering differently, see the
`Datapath tree format`_ section below).
The filtering syntax is detailed in `Filtering Syntax`_.
.. option:: -l <filter>, --highlight <filter>
Highlight the flows that match the provided *filter* expression.
The filtering syntax is detailed in `Filtering Syntax`_.
.. option:: --style <style>
Style. The selected *style* must be defined in the style configuration file.
.. option:: flow-type
**openflow** or **datapath**.
.. option:: format
See the `Supported formats`_ section.
Supported formats
=================
``ovs-flowviz`` supports several visualization formats for both OpenFlow and
datapath flows:
.. list-table::
:widths: 20 10 70
:align: center
:header-rows: 1
* - Flow Type
- Format
- Description
* - Both
- console
- Prints the flows in a configurable, colorful style in the console.
* - Both
- json
- Prints the flows in JSON format.
* - Both
- html
- Prints the flows in an HTML list.
* - OpenFlow
- cookie
- Prints the flows in the console sorted by cookie.
* - OpenFlow
- logic
- Prints the logical structure of flows in the console.
* - Datapath
- tree
- Prints the flows as a tree structure arranged by ``recirc_id`` and
``in_port``.
* - Datapath
- graph
- Prints a graphviz graph of the flows arranged by ``recirc_id`` and
``in_port``.
Console format
~~~~~~~~~~~~~~
The ``console`` format works for both OpenFlow and datapath flow types, and
prints flows in the terminal using the style determined by the ``--style``
option.
Arguments:
.. program:: ovs-flowviz [datapath|openflow] console
.. option:: -h, --heat-map
Color of the packet and byte counters to reflect their relative size.
The color gradient goes through the following colors:
blue (coldest, lowest), cyan, green, yellow, red (hottest, highest)
Note filtering is applied before the range is calculated.
JSON format
~~~~~~~~~~~
The ``json`` format works for both OpenFlow and datapath flow types, and prints
flows in JSON format. See the `JSON Syntax`_ section for more details.
HTML format
~~~~~~~~~~~
The ``html`` format works for both OpenFlow and datapath flows, and prints
flows in an HTML table that offers some basic interactivity. OpenFlow flows
are sorted in tables and datapath flows are arranged in flow trees
(see `Datapath tree format`_ for more details).
Styles defined via Style Configuration File and selected via ``--style`` option
also apply to the ``html`` format.
OpenFlow cookie format
~~~~~~~~~~~~~~~~~~~~~~
The OpenFlow ``cookie`` format is similar to the ``console`` format but
instead of arranging the flows by table, it arranges the flows by cookie.
OpenFlow logic format
~~~~~~~~~~~~~~~~~~~~~
The OpenFlow ``logic`` format helps visualize the logic structure of OpenFlow
pipelines by arranging flows into *logical blocks*.
A logical block is a set of flows that have:
* Same ``priority``.
* Match on the same fields (regardless of the match value and mask).
* Execute the same actions (regardless of the actions' arguments,
except for resubmit and output).
* Optionally, the ``cookie`` can be included as part of the logical flow.
Arguments:
.. program:: ovs-flowviz openflow logic
.. option:: -s, --show-flows
Show all the flows under each logical block.
.. option:: -d, --ovn-detrace
Use ovn-detrace.py script to extract cookie information (implies '-c').
.. option:: -c, --cookie
Consider the cookie in the logical block.
.. option:: --ovn-detrace-path <path>
Use an alternative path to search for ovn_detrace.py.
.. option:: --ovnnb-db <conn>
OVN NB database connection method (implies '-d').
Default: "unix:/var/run/ovn/ovnnb_db.sock".
.. option:: --ovnsb-db <conn>
OVN SB database connection method (implies '-d').
Default: "unix:/var/run/ovn/ovnsb_db.sock".
.. option:: --o <filter>, --ovn-filter <filter>
Specify the filter to be run on the ovn-detrace information.
Syntax: python regular expression
(See https://docs.python.org/3/library/re.html).
.. option:: -h, --heat-map
Change the color of the packet and byte counters to reflect their relative
size. The color gradient goes through the following colors:
blue (coldest, lowest), cyan, green, yellow, red (hottest, highest)
Note filtering is applied before the range is calculated.
Datapath tree format
~~~~~~~~~~~~~~~~~~~~
The datapath ``tree`` format arranges datapath flows in a hierarchical tree.
The tree is comprised of blocks with the same ``recirc_id`` and ``in_port``.
Within those blocks, flows with the same action are combined. And matches
which are the same are omitted to reduce the visual noise.
When a flow's actions includes the ``recirc()`` action with a specific
``recirc_id``, flows matching on that ``recirc_id`` and the same ``in_port``
are listed below. This is done recursively for all actions.
The result is a hierarchical representation that shows how actions are related
to each other via recirculation. Note that flows with a specific non-zero
``recirc_id`` are listed below each group of flows that have a corresponding
``recirc()`` action. Therefore, the output contains duplicated flows and can be
verbose.
Filtering works in a slightly different way for datapath flow trees.
Unlike other formats where a filter simply removes non-matching flows,
the output of a filtered datapath flow tree will show full sub-trees
that contain at least one flow that satisfies the filter.
The ``html`` format prints this same tree as an interactive HTML table and
the ``graph`` format shows the same tree as a graphviz graph.
Datapath graph format
~~~~~~~~~~~~~~~~~~~~~
The datapath ``graph`` generates a graphviz visual representation of the
same tree-like flow hierarchy that the ``tree`` format prints.
Arguments:
.. program:: ovs-flowviz datapath console
.. option:: -h, --html
Print the graphviz format as an svg image alongside an interactive HTML
table of flows.
JSON Syntax
===========
Printing a single-file OpenFlow or datapath dump without PMD thread blocks in
``json`` format results in a list of JSON objects, each representing a flow.
This list can be found inside one or more levels of JSON dictionaries
if multiple files are processed (filename used as key) or if PMD thread blocks
are found in datapath flows (name of the thread used as key).
Each flow object includes the following keys:
**orig**
Original flow string.
**info**
Object with the flow information such as: cookie, duration, table,
n_packets, n_bytes, etc.
**match**
Object with the flow match.
For each match, the object contains a key-value where the key is the name
of the match as defined in ``ovs-fields(7)`` and ``ovs-ofctl(8)``, and the
value represents the match value. The way each value is represented depends
on its type. See `Value representation`_.
**actions**
List of action objects.
Each action is represented by an JSON object that has one key and one value.
The key corresponds to the action name. The value represents the arguments
of the key. See `Action representation`_.
**ufid**
The UFID (datapath flows only).
Value representation
~~~~~~~~~~~~~~~~~~~~
Values are represented differently depending on their type:
* Flags: The value of flags is ``true``.
* Decimal / Hexadecimal: Represented by their integer value.
If they support masking, represented by a dictionary with two keys:
``value`` contains the field value and ``mask`` contains the mask.
Both are integers.
* Ethernet: Represented by a string: ``{address}[/{mask}]``
* IPv4 / IPv6: Represented by a string ``{address}[/{mask}]``
* Registers: Represented by a dictionary with three keys:
``field``` contains the field value (string), ``start``, and ``end``
represent the first and last bit of the register value.
For example, the register
::
NXM_NX_REG10[0..15]
is represented as
::
{
"field": "NXM_NX_REG10",
"start": 0,
"end": 15
},
Action representation
~~~~~~~~~~~~~~~~~~~~~
Actions are generally represented by an object that has a single key and
value. The key is the action name as defined ``ovs-actions(7)``.
The value of actions that have no arguments (such as ``drop``) is
(boolean) ``true``.
The value of actions that have a list of arguments (e.g:
``resubmit([port],[table],[ct])``) is an object that has the name of the
argument as key. The argument names for each action is defined in
ovs-actions. For example, the action
::
resubmit(,10)
is represented as
::
{
"resubmit": {
"port": "",
"table": 10
}
}
The value of actions that have a key-word list as arguments
(e.g: ``ct([argument])``) is an object whose keys correspond to the keys
defined in ``ovs-actions(7)``. The way values are represented depends
on the type of the argument.
For example, the action
::
ct(table=14,zone=NXM_NX_REG12[0..15],nat)
is represented as
::
{
"ct": {
"table": 14,
"zone": {
"field": "NXM_NX_REG12",
"start": 0,
"end": 15
},
"nat": true
}
}
Style Configuration File
========================
The style configuration file is selected via the ``--config`` option
and has INI syntax. It can define any number of styles to be used by both
``console`` and ``html`` formats. Once defined in the configuration file,
formats are selected using the ``--style`` option.
INI sections are used to define styles, ``[styles.mystyle]`` defines a style
called `mystle`. Within a section styles can be defined as:
::
[FORMAT].[PORTION].[SELECTOR].[ELEMENT] = [VALUE]
**FORMAT**
Either ``console`` or ``html``
**PORTION**
Part of the key-value the style applies to:
``key`` to indicate the key part of a key-value, ``value`` to indicate
the value part of a key-value, ``flag`` to indicate a single flag
or ``delim`` to indicate delimiters such as parentheses, brackets, etc.
**SELECTOR**
Select the key-value the style applies to:
``highlighted`` to indicate highlighted key-values, ``type.<type>``
to indicate certain types such as ``IPAddress`` or ``EthMask`` or
``<keyname>`` to select a particular key name.
**ELEMENT**
Select the style element to modify:
**color** or **underline** (only for ``console`` format).
**VALUE**
Ether a color hex, other color names defined in the rich python
library (https://rich.readthedocs.io/en/stable/appendix/colors.html) or
**true** if the element is ``underline``.
A default configuration file is shipped with ``ovs-flowviz`` and its path is
printed in the ``--help`` output. A detailed description of the syntax
alongside some examples are available there.
Filtering syntax
================
``ovs-flowviz`` provides rich highlighting and filtering. The special command
``ovs-flowviz filter`` dumps the filtering syntax:
::
$ ovs-flowviz filter
Filter Syntax
*************
[! | not ] {key}[[.subkey]...] [OPERATOR] {value})] [LOGICAL OPERATOR] ...
Comparison operators:
= equality
< less than
> more than
~= masking (valid for IP and Ethernet fields)
Logical operators:
!{expr}: NOT
{expr} && {expr}: AND
{expr} || {expr}: OR
Matches and flow metadata:
To compare against a match or info field, use the field directly, e.g:
priority=100
n_bytes>10
Use simple keywords for flags:
tcp and ip_src=192.168.1.1
Actions:
Actions values might be dictionaries, use subkeys to access individual
values, e.g:
output.port=3
Use simple keywords for flags
drop
Examples of valid filters:
nw_addr~=192.168.1.1 && (tcp_dst=80 || tcp_dst=443)
arp=true && !arp_tsa=192.168.1.1
n_bytes>0 && drop=true
Example expressions:
::
n_bytes > 0 and drop
nw_src~=192.168.1.1 or arp.tsa=192.168.1.1
! tcp && output.port=2
Examples
========
Print OpenFlow flows sorted by cookie adding OVN data to each one:
::
$ ovs-flowviz -i flows.txt openflow cookie --ovn-detrace
Print OpenFlow logical structure, showing the flows and heat-map:
::
$ ovs-flowviz -i flows.txt openflow logic --show-flows --heat-map
Display OpenFlow flows in HTML format with "light" style and highlight drops:
::
$ ovs-flowviz -i flows.txt --style "light" --highlight "n_packets > 0 and drop" openflow html > flows.html
Display the datapath flows in an interactive graphviz + HTML view:
::
$ ovs-flowviz -i flows.txt datapath graph --html > flows.html
Display the datapath flow trees that lead to packets being sent to port 10:
::
$ ovs-flowviz -i flows.txt --filter "output.port=10" datapath tree
|