Bug 1828904 - ovs-dpctl-top is broken and can't parse flows
Summary: ovs-dpctl-top is broken and can't parse flows
Keywords:
Status: ASSIGNED
Alias: None
Product: Red Hat Enterprise Linux Fast Datapath
Classification: Red Hat
Component: openvswitch2.11
Version: FDP 20.E
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
: ---
Assignee: Timothy Redaelli
QA Contact: Rick Alongi
URL: https://patchwork.ozlabs.org/project/...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-04-28 14:54 UTC by Flavio Leitner
Modified: 2023-07-13 07:25 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker FD-615 0 None None None 2022-11-09 14:39:24 UTC

Description Flavio Leitner 2020-04-28 14:54:49 UTC
Description of problem:

Can't use the tool because it breaks right away:

[root@rhel7ovs ~]# /usr/bin/ovs-dpctl-top 
Traceback (most recent call last):
  File "/usr/bin/ovs-dpctl-top", line 1290, in <module>
    sys.exit(main())
  File "/usr/bin/ovs-dpctl-top", line 1282, in main
    flows_top(args)
  File "/usr/bin/ovs-dpctl-top", line 1191, in flows_top
    flows_read(ihdl, flow_db)
  File "/usr/bin/ovs-dpctl-top", line 593, in flows_read
    flow_db.flow_line_add(line)
  File "/usr/bin/ovs-dpctl-top", line 988, in flow_line_add
    self.flow_event(fields_dict, stats_old_dict, stats_dict)
  File "/usr/bin/ovs-dpctl-top", line 1080, in flow_event
    matches = flow_aggregate(fields_dict, stats_new_dict)
  File "/usr/bin/ovs-dpctl-top", line 576, in flow_aggregate
    field, stats_dict)
  File "/usr/bin/ovs-dpctl-top", line 250, in element_ipv4_get
    element_show = fmt % (field_type, element["src"], element["dst"])
KeyError: 'src'
[root@rhel7ovs ~]# 


Or running as script:
[root@rhel7ovs ~]# ovs-dpctl dump-flows | /usr/bin/ovs-dpctl-top --script --verbose
2020-04-28T14:48:23Z|00001|dpif_netlink|INFO|The kernel module does not support meters.
INFO:root:reading flows from stdin
Traceback (most recent call last):
  File "/usr/bin/ovs-dpctl-top", line 1290, in <module>
    sys.exit(main())
  File "/usr/bin/ovs-dpctl-top", line 1284, in main
    flows_script(args)
  File "/usr/bin/ovs-dpctl-top", line 1235, in flows_script
    flow_db = flows_read(ihdl, flow_db)
  File "/usr/bin/ovs-dpctl-top", line 593, in flows_read
    flow_db.flow_line_add(line)
  File "/usr/bin/ovs-dpctl-top", line 988, in flow_line_add
    self.flow_event(fields_dict, stats_old_dict, stats_dict)
  File "/usr/bin/ovs-dpctl-top", line 1080, in flow_event
    matches = flow_aggregate(fields_dict, stats_new_dict)
  File "/usr/bin/ovs-dpctl-top", line 576, in flow_aggregate
    field, stats_dict)
  File "/usr/bin/ovs-dpctl-top", line 250, in element_ipv4_get
    element_show = fmt % (field_type, element["src"], element["dst"])
KeyError: 'src'
[root@rhel7ovs ~]# 


Version-Release number of selected component (if applicable):
openvswitch2.11-2.11.0-50.el7fdp.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Install openvswitch2.11
2. Start the service
3. Bring up an ovs bridge, attach some ports, generate some traffic
4. run the tool above

The following patch from upstream fixes the issue:

commit 96b2c715efc560b5a094d900d5be7723d66b6475
Author: Jaime Caamaño Ruiz <jcaamano>
Date:   Mon Aug 12 18:52:27 2019 +0200

    utilities: Improve ovs-dpctl-top flow parsing
    
    * check that expected bytes and packets stats are correctly read from
      every flow.
    * check that the expected elements are read for every field type
      aggregation.
    
    Signed-off-by: Jaime Caamaño Ruiz <jcaamano>
    Signed-off-by: Ben Pfaff <blp>

Comment 1 Flavio Leitner 2020-04-28 14:56:01 UTC
2.11 script with the above patch applied:

[root@rhel7ovs ~]# ./ovs-dpctl-top.in
                                                 Flow Summary                                                 
 Total: 4  errors: 1 Accumulate: off Duration: 0:00:00.012474                                                  
                                                                             DESC                              
                            FIELDS (IN_PORT)                                COUNT   PACKETS     BYTES   AVERAGE
in_port(2)                                                                      2      1239    121422        98
in_port(3)                                                                      2      1239    121422        98
[root@rhel7ovs ~]# 


# ovs-dpctl dump-flows | ./ovs-dpctl-top.in --script --verbose
2020-04-28T14:54:46Z|00001|dpif_netlink|INFO|The kernel module does not support meters.
INFO:root:reading flows from stdin
                                                  Flow Summary                                                 
 Total: 4  errors: 0 Accumulate: off Duration: 0:00:00.000050                                                  
                                                                             DESC                              
                              FIELDS (ALL)                                  COUNT   PACKETS     BYTES   AVERAGE
eth_type(0x0806)                                                                2         0         0         0
eth(src=b6:5e:d5:77:97:45,dst=ca:0f:07:39:48:fd)                                2      1210    118580        98
in_port(2)                                                                      2      1210    118580        98
in_port(3)                                                                      2      1210    118580        98
eth_type(0x0800)                                                                2      2420    237160        98
eth(src=ca:0f:07:39:48:fd,dst=b6:5e:d5:77:97:45)                                2      1210    118580        98

Comment 2 Axel Busch 2020-05-05 09:37:53 UTC
The following cmd leads to parse errors due to the "eth()" field:

# ovs-dpctl dump-flows | ovs-dpctl-top --script --verbose
INFO:root:reading flows from stdin
ERROR:root:can't parse >eth()<
[..]
ERROR:root:can't parse >eth()<
ERROR:root:can't parse >eth()<
                                                     Flow Summary
 Total: 0  errors: 230 Accumulate: off Duration: 0:00:00.000036
                                                                                   DESC
                                 FIELDS (ALL)                                     COUNT   PACKETS     BYTES   AVERAGE


Replacing eth() works:

ovs-dpctl dump-flows | sed 's/,eth()//g' | ovs-dpctl-top --script --verbose
INFO:root:reading flows from stdin
                                                     Flow Summary
 Total: 265  errors: 0 Accumulate: off Duration: 0:00:00.000024
[..]

Comment 3 Timothy Redaelli 2020-06-19 10:57:05 UTC
Currently ovs-dpctl-top, from master, has some problems and the backport doesn't fix all of them.

Recent (since efde188622aea5c2137e931f4a446c511676ba32) ovs releases prints "eth()" to dump-flows and this completely breaks ovs-dpctl-top (see Comment 2).

With python3 pipe doesn't work since unbuffered mode can't work with pipes:

Traceback (most recent call last):
  File "utilities/ovs-dpctl-top.in", line 1294, in <module>
    sys.exit(main())
  File "utilities/ovs-dpctl-top.in", line 1288, in main
    flows_script(args)
  File "utilities/ovs-dpctl-top.in", line 1237, in flows_script
    ihdl = os.fdopen(sys.stdin.fileno(), 'r', 0)
  File "/usr/lib64/python3.8/os.py", line 1023, in fdopen
    return io.open(fd, *args, **kwargs)
ValueError: can't have unbuffered text I/O

I'll send a series upstream to address all the issues above and then I'll backport those on our ovs2.13 and the non-python3 patches on our ovs2.11


Note You need to log in before you can comment on or make changes to this bug.