[ovs-dev] [PATCH] ovn-trace: Print stage name even without match.

Russell Bryant russell at ovn.org
Thu Nov 10 20:54:16 UTC 2016


Given a simple OVN configuration and a sample packet that fails to match
an L2 destination lookup flow, the output of ovn-trace looks something
like this:

    $ ovn-trace --detailed sw0 'inport == "sw0-port1" && eth.src == 00:00:00:00:00:01 && eth.dst == 00:00:00:00:00:ff'
    # reg14=0x1,vlan_tci=0x0000,dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:ff,dl_type=0x0000

    ingress(dp="sw0", inport="sw0-port1")
    -------------------------------------
     0. ls_in_port_sec_l2 (ovn-northd.c:2827): inport == "sw0-port1" && eth.src == {00:00:00:00:00:01}, priority 50
        next(1);
    13. no match

In this case, I think it is helpful to still display the name of the
pipeline stage where we failed to match a flow.  This patch adds
that to the output.  This patch assumes that we always use the
same stage name for a given table ID in a given datapath, but I'm
pretty sure that is always true.

    ingress(dp="sw0", inport="sw0-port1")
    -------------------------------------
     0. ls_in_port_sec_l2 (ovn-northd.c:2827): inport == "sw0-port1" && eth.src == {00:00:00:00:00:01}, priority 50
        next(1);
    13. ls_in_l2_lkup: no match

Signed-off-by: Russell Bryant <russell at ovn.org>
---
 ovn/utilities/ovn-trace.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/ovn/utilities/ovn-trace.c b/ovn/utilities/ovn-trace.c
index 3d62cf8..45802a9 100644
--- a/ovn/utilities/ovn-trace.c
+++ b/ovn/utilities/ovn-trace.c
@@ -757,6 +757,18 @@ ovntrace_flow_lookup(const struct ovntrace_datapath *dp,
     return NULL;
 }
 
+static char *
+ovntrace_stage_name(const struct ovntrace_datapath *dp,
+                    uint8_t table_id, enum ovntrace_pipeline pipeline)
+{
+    for (size_t i = 0; i < dp->n_flows; i++) {
+        const struct ovntrace_flow *flow = dp->flows[i];
+        if (flow->pipeline == pipeline && flow->table_id == table_id) {
+            return xstrdup(flow->stage_name);;
+        }
+    }
+    return NULL;
+}
 
 enum ovntrace_node_type {
     OVNTRACE_NODE_OUTPUT,
@@ -1345,7 +1357,11 @@ trace__(const struct ovntrace_datapath *dp, struct flow *uflow,
         }
         ds_put_format(&s, "%s, priority %d", f->match_s, f->priority);
     } else {
-        ds_put_format(&s, "no match");
+        char *stage_name = ovntrace_stage_name(dp, table_id, pipeline);
+        ds_put_format(&s, "%s%sno match",
+                      stage_name ? stage_name : "",
+                      stage_name ? ": " : "");
+        free(stage_name);
     }
     struct ovntrace_node *node = ovntrace_node_append(
         super, OVNTRACE_NODE_TABLE, "%s", ds_cstr(&s));
-- 
2.9.3




More information about the dev mailing list