[ovs-dev] [RFC PATCH 00/10] Introduce ovs-ofparse utility

Adrian Moreno amorenoz at redhat.com
Mon Nov 22 15:01:47 UTC 2021


This series is based on the ofenflow and datapath flow parsing library
series [1].

This series introduces a python tool called "ovs-ofparse". This tool
aims to make it much more easy to analyze and troubleshoot issues
involving openflow or datapath flows.

It is essentially a CLI program that reads one or more flow dumps
(produced by "ovs-ofproto dump-flows" or "ovs-dpctl dump-flows" and
prints the flows back in different formats. The version I'm sending
contains quite some functionality and, although I've received overall
good feedback from some collegues, it might be too much to add to the
ovs-tree. We can select what formats or features are more desireable.

Currently the tool supports:
* Filtering based on complex filtering expressions defined in [1]
* Multi-input file support ("-i " option can be added multiple times).
If such  option is not provided, stdin will be read
* Extensive formatting system
   - Users can define what color to use to print any key and value based
     on the key name or value type
   - Users can define their own styles and switch between them using a
     command line option
   - Users can pass any filtering expression and the matching keys will
     be highlighted (the style of highlighted key/values is also
     configurable)
   - Supports creating heat-map palletes: users can print the n_packets,
     n_bytes keys using a color that depends on its relative value (blue
     for small, red for high, passing through green and cyan)
* Formats:
   - Console: prints the flows in the console using styles
   - Logic: prints the logical representation of the flow list. Output
     depends on the flow type:
      +  Openflow: a logical openflow flow (nothing to do with OVN
      LogicalFlow) is composed of flows that share the same priority and
      table, have the same set of keys in the match section,
      regardless of their values, and the same set of keys in their
      actions, regardless of their value (except for output and resubmit
      for which the values do matter). Cookies can be optionally also
      considered for the logical flow construction.
      Logical flows make for a more collapse output (which can be
      optionally expanded using "--show-flows" option).
      + Datapath: Logical datapath format prints datapath flows in a
      tree based on their recirc_id

   - HTML: prints a html flow table with some minimal interactivity
   - JSON: prints the flows in json format

Some future development planned:
- Integration with OVN: Automatically call ovn-detrace on each cookie to
  support printing the OVN information about each flow or set of flows

The tool is based on two main dependencies:
- 'click' for command line management
- 'rich' for rich console output

Testing notes
-------------
(optionally create a venv)
$ cd python; pip install .
$ ovs-ofparse --help


[1] https://patchwork.ozlabs.org/project/openvswitch/list/?series=273222


Adrian Moreno (10):
  python: introduce scheleton of ovs_ofparse utility
  python/ovs-ofparse: Create basic flow processing
  python/ovs-ofparse: add formatting framework
  python/ovs-ofparse: add json format
  python/ovs-ofparse: Add rich console formatting
  python/ovs-ofparse: add openflow logic processing
  python/ovs-ofparse: add datapath logic processing
  python/ovs-ofparse: add html formatter
  python/ovs-ofparse: add openflow html format
  python:ovs-ofparse: add datapath html format

 python/automake.mk                          |  19 +-
 python/ovs/ovs_ofparse/__init__.py          |   2 +
 python/ovs/ovs_ofparse/console.py           | 206 ++++++++++
 python/ovs/ovs_ofparse/datapath.py          | 422 ++++++++++++++++++++
 python/ovs/ovs_ofparse/dp_tree.py           | 128 ++++++
 python/ovs/ovs_ofparse/etc/ovs-ofparse.conf |  85 ++++
 python/ovs/ovs_ofparse/format.py            | 319 +++++++++++++++
 python/ovs/ovs_ofparse/html.py              | 125 ++++++
 python/ovs/ovs_ofparse/main.py              | 181 +++++++++
 python/ovs/ovs_ofparse/ofp_logic.py         | 210 ++++++++++
 python/ovs/ovs_ofparse/openflow.py          | 162 ++++++++
 python/ovs/ovs_ofparse/ovs-ofparse          |   6 +
 python/ovs/ovs_ofparse/process.py           | 195 +++++++++
 python/setup.py                             |  13 +-
 14 files changed, 2069 insertions(+), 4 deletions(-)
 create mode 100644 python/ovs/ovs_ofparse/__init__.py
 create mode 100644 python/ovs/ovs_ofparse/console.py
 create mode 100644 python/ovs/ovs_ofparse/datapath.py
 create mode 100644 python/ovs/ovs_ofparse/dp_tree.py
 create mode 100644 python/ovs/ovs_ofparse/etc/ovs-ofparse.conf
 create mode 100644 python/ovs/ovs_ofparse/format.py
 create mode 100644 python/ovs/ovs_ofparse/html.py
 create mode 100644 python/ovs/ovs_ofparse/main.py
 create mode 100644 python/ovs/ovs_ofparse/ofp_logic.py
 create mode 100644 python/ovs/ovs_ofparse/openflow.py
 create mode 100755 python/ovs/ovs_ofparse/ovs-ofparse
 create mode 100644 python/ovs/ovs_ofparse/process.py

-- 
2.31.1



More information about the dev mailing list