ofproto/trace: Use final flow to compute "Relevant fields".
[sliver-openvswitch.git] / ofproto / ofproto-dpif.c
index e48cc00..03f7840 100644 (file)
@@ -42,7 +42,6 @@
 #include "netdev-vport.h"
 #include "netdev.h"
 #include "netlink.h"
-#include "netlink-socket.h"
 #include "nx-match.h"
 #include "odp-util.h"
 #include "odp-execute.h"
@@ -903,7 +902,7 @@ check_variable_length_userdata(struct dpif_backer *backer)
 {
     struct eth_header *eth;
     struct ofpbuf actions;
-    struct ofpbuf key;
+    struct dpif_execute execute;
     struct ofpbuf packet;
     size_t start;
     int error;
@@ -922,26 +921,22 @@ check_variable_length_userdata(struct dpif_backer *backer)
     nl_msg_put_unspec_zero(&actions, OVS_USERSPACE_ATTR_USERDATA, 4);
     nl_msg_end_nested(&actions, start);
 
-    /* Compose an ODP flow key.  The key is arbitrary but it must match the
-     * packet that we compose later. */
-    ofpbuf_init(&key, 64);
-    nl_msg_put_u32(&key, OVS_KEY_ATTR_IN_PORT, 0);
-    nl_msg_put_unspec_zero(&key, OVS_KEY_ATTR_ETHERNET,
-                           sizeof(struct ovs_key_ethernet));
-    nl_msg_put_be16(&key, OVS_KEY_ATTR_ETHERTYPE, htons(0x1234));
-
-    /* Compose a packet that matches the key. */
+    /* Compose a dummy ethernet packet. */
     ofpbuf_init(&packet, ETH_HEADER_LEN);
     eth = ofpbuf_put_zeros(&packet, ETH_HEADER_LEN);
     eth->eth_type = htons(0x1234);
 
-    /* Execute the actions.  On older datapaths this fails with -ERANGE, on
+    /* Execute the actions.  On older datapaths this fails with ERANGE, on
      * newer datapaths it succeeds. */
-    error = dpif_execute(backer->dpif, key.data, key.size,
-                         actions.data, actions.size, &packet, false);
+    execute.actions = actions.data;
+    execute.actions_len = actions.size;
+    execute.packet = &packet;
+    execute.md = PKT_METADATA_INITIALIZER(0);
+    execute.needs_help = false;
+
+    error = dpif_execute(backer->dpif, &execute);
 
     ofpbuf_uninit(&packet);
-    ofpbuf_uninit(&key);
     ofpbuf_uninit(&actions);
 
     switch (error) {
@@ -2890,12 +2885,11 @@ ofproto_dpif_execute_actions(struct ofproto_dpif *ofproto,
                              const struct ofpact *ofpacts, size_t ofpacts_len,
                              struct ofpbuf *packet)
 {
-    struct odputil_keybuf keybuf;
     struct dpif_flow_stats stats;
     struct xlate_out xout;
     struct xlate_in xin;
     ofp_port_t in_port;
-    struct ofpbuf key;
+    struct dpif_execute execute;
     int error;
 
     ovs_assert((rule != NULL) != (ofpacts != NULL));
@@ -2911,16 +2905,21 @@ ofproto_dpif_execute_actions(struct ofproto_dpif *ofproto,
     xin.resubmit_stats = &stats;
     xlate_actions(&xin, &xout);
 
-    ofpbuf_use_stack(&key, &keybuf, sizeof keybuf);
     in_port = flow->in_port.ofp_port;
     if (in_port == OFPP_NONE) {
         in_port = OFPP_LOCAL;
     }
-    odp_flow_key_from_flow(&key, flow, ofp_port_to_odp_port(ofproto, in_port));
+    execute.actions = xout.odp_actions.data;
+    execute.actions_len = xout.odp_actions.size;
+    execute.packet = packet;
+    execute.md.tunnel = flow->tunnel;
+    execute.md.skb_priority = flow->skb_priority;
+    execute.md.pkt_mark = flow->pkt_mark;
+    execute.md.in_port = ofp_port_to_odp_port(ofproto, in_port);
+    execute.needs_help = (xout.slow & SLOW_ACTION) != 0;
+
+    error = dpif_execute(ofproto->backer->dpif, &execute);
 
-    error = dpif_execute(ofproto->backer->dpif, key.data, key.size,
-                         xout.odp_actions.data, xout.odp_actions.size, packet,
-                         (xout.slow & SLOW_ACTION) != 0);
     xlate_out_uninit(&xout);
 
     return error;
@@ -3871,7 +3870,7 @@ ofproto_trace(struct ofproto_dpif *ofproto, const struct flow *flow,
         ds_put_char(ds, '\n');
         trace_format_flow(ds, 0, "Final flow", &trace);
 
-        match_init(&match, flow, &trace.xout.wc);
+        match_init(&match, &trace.flow, &trace.xout.wc);
         ds_put_cstr(ds, "Relevant fields: ");
         match_format(&match, ds, OFP_DEFAULT_PRIORITY);
         ds_put_char(ds, '\n');