This commit makes the ofproto/trace show the megaflow fields
for each resubmit.

Signed-off-by: Alex Wang <al...@nicira.com>
---
 ofproto/ofproto-dpif-upcall.c |    5 +++--
 ofproto/ofproto-dpif-xlate.c  |   10 ++++++++--
 ofproto/ofproto-dpif-xlate.h  |    7 ++++++-
 ofproto/ofproto-dpif.c        |   32 ++++++++++++++++++++------------
 4 files changed, 37 insertions(+), 17 deletions(-)

diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index 954e92f..12d353e 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -763,7 +763,7 @@ handle_upcalls(struct udpif *udpif, struct list *upcalls)
         struct xlate_in xin;
 
         xlate_in_init(&xin, miss->ofproto, &miss->flow, NULL,
-                      miss->stats.tcp_flags, NULL);
+                      miss->stats.tcp_flags, NULL, NULL);
         xin.may_learn = true;
         xin.resubmit_stats = &miss->stats;
         xlate_actions(&xin, &miss->xout);
@@ -790,7 +790,8 @@ handle_upcalls(struct udpif *udpif, struct list *upcalls)
         if (miss->xout.slow) {
             struct xlate_in xin;
 
-            xlate_in_init(&xin, miss->ofproto, &miss->flow, NULL, 0, packet);
+            xlate_in_init(&xin, miss->ofproto, &miss->flow, NULL, 0, packet,
+                          NULL);
             xlate_actions_for_side_effects(&xin);
         }
 
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 7371750..3fc9eb6 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -2525,7 +2525,8 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t 
ofpacts_len,
 void
 xlate_in_init(struct xlate_in *xin, struct ofproto_dpif *ofproto,
               const struct flow *flow, struct rule_dpif *rule,
-              uint8_t tcp_flags, const struct ofpbuf *packet)
+              uint8_t tcp_flags, const struct ofpbuf *packet,
+              struct flow_wildcards *wc)
 {
     xin->ofproto = ofproto;
     xin->flow = *flow;
@@ -2538,6 +2539,7 @@ xlate_in_init(struct xlate_in *xin, struct ofproto_dpif 
*ofproto,
     xin->resubmit_hook = NULL;
     xin->report_hook = NULL;
     xin->resubmit_stats = NULL;
+    xin->wc = wc;
 }
 
 void
@@ -2751,7 +2753,11 @@ xlate_actions__(struct xlate_in *xin, struct xlate_out 
*xout)
     memset(&ctx.base_flow.tunnel, 0, sizeof ctx.base_flow.tunnel);
     ctx.orig_tunnel_ip_dst = flow->tunnel.ip_dst;
 
-    flow_wildcards_init_catchall(wc);
+    if (xin->wc) {
+        *wc = *xin->wc;
+    } else {
+        flow_wildcards_init_catchall(wc);
+    }
     memset(&wc->masks.in_port, 0xff, sizeof wc->masks.in_port);
     memset(&wc->masks.skb_priority, 0xff, sizeof wc->masks.skb_priority);
     memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h
index 40712f9..5b9dfe1 100644
--- a/ofproto/ofproto-dpif-xlate.h
+++ b/ofproto/ofproto-dpif-xlate.h
@@ -112,6 +112,10 @@ struct xlate_in {
      * This is normally null so the client has to set it manually after
      * calling xlate_in_init(). */
     const struct dpif_flow_stats *resubmit_stats;
+
+    /* If nonnull, this "struct flow_wildcards" will be used to initialize the
+     * xout.wc. */
+    struct flow_wildcards *wc;
 };
 
 extern struct ovs_rwlock xlate_rwlock;
@@ -152,7 +156,8 @@ void xlate_actions(struct xlate_in *, struct xlate_out *)
     OVS_EXCLUDED(xlate_rwlock);
 void xlate_in_init(struct xlate_in *, struct ofproto_dpif *,
                    const struct flow *, struct rule_dpif *,
-                   uint8_t tcp_flags, const struct ofpbuf *packet);
+                   uint8_t tcp_flags, const struct ofpbuf *packet,
+                   struct flow_wildcards *);
 void xlate_out_uninit(struct xlate_out *);
 void xlate_actions_for_side_effects(struct xlate_in *);
 void xlate_out_copy(struct xlate_out *dst, const struct xlate_out *src);
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index e01cdbb..1590ad0 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -3820,7 +3820,7 @@ ofproto_dpif_execute_actions(struct ofproto_dpif *ofproto,
         rule_dpif_credit_stats(rule, &stats);
     }
 
-    xlate_in_init(&xin, ofproto, flow, rule, stats.tcp_flags, packet);
+    xlate_in_init(&xin, ofproto, flow, rule, stats.tcp_flags, packet, NULL);
     xin.ofpacts = ofpacts;
     xin.ofpacts_len = ofpacts_len;
     xin.resubmit_stats = &stats;
@@ -4064,7 +4064,7 @@ facet_check_consistency(struct facet *facet)
     bool ok;
 
     /* Check the datapath actions for consistency. */
-    xlate_in_init(&xin, facet->ofproto, &facet->flow, NULL, 0, NULL);
+    xlate_in_init(&xin, facet->ofproto, &facet->flow, NULL, 0, NULL, NULL);
     xlate_actions(&xin, &xout);
 
     ok = ofpbuf_equal(&facet->xout.odp_actions, &xout.odp_actions)
@@ -4147,7 +4147,7 @@ facet_revalidate(struct facet *facet)
      * We do not modify any 'facet' state yet, because we might need to, e.g.,
      * emit a NetFlow expiration and, if so, we need to have the old state
      * around to properly compose it. */
-    xlate_in_init(&xin, ofproto, &facet->flow, new_rule, 0, NULL);
+    xlate_in_init(&xin, ofproto, &facet->flow, new_rule, 0, NULL, NULL);
     xlate_actions(&xin, &xout);
     flow_wildcards_or(&xout.wc, &xout.wc, &wc);
 
@@ -4224,7 +4224,7 @@ flow_push_stats(struct ofproto_dpif *ofproto, struct flow 
*flow,
         netdev_vport_inc_rx(in_port->up.netdev, stats);
     }
 
-    xlate_in_init(&xin, ofproto, flow, NULL, stats->tcp_flags, NULL);
+    xlate_in_init(&xin, ofproto, flow, NULL, stats->tcp_flags, NULL, NULL);
     xin.resubmit_stats = stats;
     xin.may_learn = may_learn;
     xlate_actions_for_side_effects(&xin);
@@ -5099,6 +5099,19 @@ trace_format_odp(struct ds *result, int level, const 
char *title,
 }
 
 static void
+trace_format_megaflow(struct ds *result, int level, const char *title,
+                      struct trace_ctx *trace)
+{
+    struct match match;
+
+    ds_put_char_multiple(result, '\t', level);
+    ds_put_format(result, "%s: ", title);
+    match_init(&match, &trace->flow, &trace->xout.wc);
+    match_format(&match, result, OFP_DEFAULT_PRIORITY);
+    ds_put_char(result, '\n');
+}
+
+static void
 trace_resubmit(struct xlate_in *xin, struct rule_dpif *rule, int recurse)
 {
     struct trace_ctx *trace = CONTAINER_OF(xin, struct trace_ctx, xin);
@@ -5108,6 +5121,7 @@ trace_resubmit(struct xlate_in *xin, struct rule_dpif 
*rule, int recurse)
     trace_format_flow(result, recurse + 1, "Resubmitted flow", trace);
     trace_format_regs(result, recurse + 1, "Resubmitted regs", trace);
     trace_format_odp(result,  recurse + 1, "Resubmitted  odp", trace);
+    trace_format_megaflow(result, recurse + 1, "Resubmitted megaflow", trace);
     trace_format_rule(result, recurse + 1, rule);
 }
 
@@ -5275,26 +5289,20 @@ ofproto_trace(struct ofproto_dpif *ofproto, const 
struct flow *flow,
 
     if (rule) {
         struct trace_ctx trace;
-        struct match match;
         uint8_t tcp_flags;
 
         tcp_flags = packet ? packet_get_tcp_flags(packet, flow) : 0;
         trace.result = ds;
         trace.flow = *flow;
-        xlate_in_init(&trace.xin, ofproto, flow, rule, tcp_flags, packet);
+        xlate_in_init(&trace.xin, ofproto, flow, rule, tcp_flags, packet, &wc);
         trace.xin.resubmit_hook = trace_resubmit;
         trace.xin.report_hook = trace_report;
 
         xlate_actions(&trace.xin, &trace.xout);
-        flow_wildcards_or(&trace.xout.wc, &trace.xout.wc, &wc);
 
         ds_put_char(ds, '\n');
         trace_format_flow(ds, 0, "Final flow", &trace);
-
-        match_init(&match, &trace.flow, &trace.xout.wc);
-        ds_put_cstr(ds, "Megaflow: ");
-        match_format(&match, ds, OFP_DEFAULT_PRIORITY);
-        ds_put_char(ds, '\n');
+        trace_format_megaflow(ds, 0, "Megaflow", &trace);
 
         ds_put_cstr(ds, "Datapath actions: ");
         format_odp_actions(ds, trace.xout.odp_actions.data,
-- 
1.7.9.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to