ofproto-dpif: Always un-wildcard 'dl_type'.
[sliver-openvswitch.git] / ofproto / ofproto-dpif-xlate.c
index 7d3a7c4..d77e4df 100644 (file)
 
 #include "ofproto/ofproto-dpif-xlate.h"
 
+#include "bfd.h"
 #include "bitmap.h"
 #include "bond.h"
 #include "bundle.h"
 #include "byte-order.h"
+#include "cfm.h"
 #include "connmgr.h"
 #include "coverage.h"
 #include "dpif.h"
 #include "dynamic-string.h"
+#include "lacp.h"
 #include "learn.h"
 #include "mac-learning.h"
 #include "meta-flow.h"
@@ -43,6 +46,10 @@ COVERAGE_DEFINE(ofproto_dpif_xlate);
 
 VLOG_DEFINE_THIS_MODULE(ofproto_dpif_xlate);
 
+/* Maximum depth of flow table recursion (due to resubmit actions) in a
+ * flow translation. */
+#define MAX_RESUBMIT_RECURSION 64
+
 struct xlate_ctx {
     struct xlate_in *xin;
     struct xlate_out *xout;
@@ -73,7 +80,7 @@ struct xlate_ctx {
     uint32_t orig_skb_priority; /* Priority when packet arrived. */
     uint8_t table_id;           /* OpenFlow table ID where flow was found. */
     uint32_t sflow_n_outputs;   /* Number of output ports. */
-    uint32_t sflow_odp_port;    /* Output port for composing sFlow action. */
+    odp_port_t sflow_odp_port;  /* Output port for composing sFlow action. */
     uint16_t user_cookie_offset;/* Used for user_action_cookie fixup. */
     bool exit;                  /* No further actions should be processed. */
 };
@@ -93,13 +100,13 @@ static void do_xlate_actions(const struct ofpact *, size_t ofpacts_len,
                              struct xlate_ctx *);
 static void xlate_normal(struct xlate_ctx *);
 static void xlate_report(struct xlate_ctx *, const char *);
-static void xlate_table_action(struct xlate_ctx *, uint16_t in_port,
+static void xlate_table_action(struct xlate_ctx *, ofp_port_t in_port,
                                uint8_t table_id, bool may_packet_in);
 static bool input_vid_is_valid(uint16_t vid, struct ofbundle *, bool warn);
 static uint16_t input_vid_to_vlan(const struct ofbundle *, uint16_t vid);
 static void output_normal(struct xlate_ctx *, const struct ofbundle *,
                           uint16_t vlan);
-static void compose_output_action(struct xlate_ctx *, uint16_t ofp_port);
+static void compose_output_action(struct xlate_ctx *, ofp_port_t ofp_port);
 
 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
 
@@ -123,7 +130,7 @@ vlan_is_mirrored(const struct ofmirror *m, int vlan)
 }
 
 static struct ofbundle *
-lookup_input_bundle(const struct ofproto_dpif *ofproto, uint16_t in_port,
+lookup_input_bundle(const struct ofproto_dpif *ofproto, ofp_port_t in_port,
                     bool warn, struct ofport_dpif **in_ofportp)
 {
     struct ofport_dpif *ofport;
@@ -176,7 +183,7 @@ add_mirror_actions(struct xlate_ctx *ctx, const struct flow *orig_flow)
     const struct nlattr *a;
     size_t left;
 
-    in_bundle = lookup_input_bundle(ctx->ofproto, orig_flow->in_port,
+    in_bundle = lookup_input_bundle(ctx->ofproto, orig_flow->in_port.ofp_port,
                                     ctx->xin->packet != NULL, NULL);
     if (!in_bundle) {
         return;
@@ -212,7 +219,7 @@ add_mirror_actions(struct xlate_ctx *ctx, const struct flow *orig_flow)
             continue;
         }
 
-        ofport = get_odp_port(ofproto, nl_attr_get_u32(a));
+        ofport = get_odp_port(ofproto, nl_attr_get_odp_port(a));
         if (ofport && ofport->bundle) {
             mirrors |= ofport->bundle->dst_mirrors;
         }
@@ -541,13 +548,11 @@ xlate_normal(struct xlate_ctx *ctx)
     ctx->xout->has_normal = true;
 
     /* Check the dl_type, since we may check for gratuituous ARP. */
-    memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
-
     memset(&wc->masks.dl_src, 0xff, sizeof wc->masks.dl_src);
     memset(&wc->masks.dl_dst, 0xff, sizeof wc->masks.dl_dst);
-    memset(&wc->masks.vlan_tci, 0xff, sizeof wc->masks.vlan_tci);
+    wc->masks.vlan_tci |= htons(VLAN_VID_MASK | VLAN_CFI);
 
-    in_bundle = lookup_input_bundle(ctx->ofproto, flow->in_port,
+    in_bundle = lookup_input_bundle(ctx->ofproto, flow->in_port.ofp_port,
                                     ctx->xin->packet != NULL, &in_port);
     if (!in_bundle) {
         xlate_report(ctx, "no input bundle, dropping");
@@ -653,7 +658,7 @@ compose_sample_action(const struct ofproto_dpif *ofproto,
 
 static void
 compose_sflow_cookie(const struct ofproto_dpif *ofproto,
-                     ovs_be16 vlan_tci, uint32_t odp_port,
+                     ovs_be16 vlan_tci, odp_port_t odp_port,
                      unsigned int n_outputs, union user_action_cookie *cookie)
 {
     int ifindex;
@@ -688,18 +693,18 @@ static size_t
 compose_sflow_action(const struct ofproto_dpif *ofproto,
                      struct ofpbuf *odp_actions,
                      const struct flow *flow,
-                     uint32_t odp_port)
+                     odp_port_t odp_port)
 {
     uint32_t probability;
     union user_action_cookie cookie;
 
-    if (!ofproto->sflow || flow->in_port == OFPP_NONE) {
+    if (!ofproto->sflow || flow->in_port.ofp_port == OFPP_NONE) {
         return 0;
     }
 
     probability = dpif_sflow_get_probability(ofproto->sflow);
     compose_sflow_cookie(ofproto, htons(0), odp_port,
-                         odp_port == OVSP_NONE ? 0 : 1, &cookie);
+                         odp_port == ODPP_NONE ? 0 : 1, &cookie);
 
     return compose_sample_action(ofproto, odp_actions, flow,  probability,
                                  &cookie, sizeof cookie.sflow);
@@ -732,7 +737,7 @@ compose_ipfix_action(const struct ofproto_dpif *ofproto,
     uint32_t probability;
     union user_action_cookie cookie;
 
-    if (!ofproto->ipfix || flow->in_port == OFPP_NONE) {
+    if (!ofproto->ipfix || flow->in_port.ofp_port == OFPP_NONE) {
         return;
     }
 
@@ -751,7 +756,7 @@ add_sflow_action(struct xlate_ctx *ctx)
 {
     ctx->user_cookie_offset = compose_sflow_action(ctx->ofproto,
                                                    &ctx->xout->odp_actions,
-                                                   &ctx->xin->flow, OVSP_NONE);
+                                                   &ctx->xin->flow, ODPP_NONE);
     ctx->sflow_odp_port = 0;
     ctx->sflow_n_outputs = 0;
 }
@@ -786,17 +791,53 @@ fix_sflow_action(struct xlate_ctx *ctx)
                          ctx->sflow_odp_port, ctx->sflow_n_outputs, cookie);
 }
 
+static enum slow_path_reason
+process_special(struct xlate_ctx *ctx, const struct flow *flow,
+                const struct ofport_dpif *ofport, const struct ofpbuf *packet)
+{
+    struct ofproto_dpif *ofproto = ctx->ofproto;
+    struct flow_wildcards *wc = &ctx->xout->wc;
+
+    if (!ofport) {
+        return 0;
+    } else if (ofport->cfm && cfm_should_process_flow(ofport->cfm, flow, wc)) {
+        if (packet) {
+            cfm_process_heartbeat(ofport->cfm, packet);
+        }
+        return SLOW_CFM;
+    } else if (ofport->bfd && bfd_should_process_flow(flow, wc)) {
+        if (packet) {
+            bfd_process_packet(ofport->bfd, flow, packet);
+        }
+        return SLOW_BFD;
+    } else if (ofport->bundle && ofport->bundle->lacp
+               && flow->dl_type == htons(ETH_TYPE_LACP)) {
+        if (packet) {
+            lacp_process_packet(ofport->bundle->lacp, ofport, packet);
+        }
+        return SLOW_LACP;
+    } else if (ofproto->stp && stp_should_process_flow(flow, wc)) {
+        if (packet) {
+            stp_process_packet(ofport, packet);
+        }
+        return SLOW_STP;
+    } else {
+        return 0;
+    }
+}
+
 static void
-compose_output_action__(struct xlate_ctx *ctx, uint16_t ofp_port,
+compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port,
                         bool check_stp)
 {
     const struct ofport_dpif *ofport = get_ofp_port(ctx->ofproto, ofp_port);
+    struct flow_wildcards *wc = &ctx->xout->wc;
     struct flow *flow = &ctx->xin->flow;
     ovs_be16 flow_vlan_tci;
     uint32_t flow_skb_mark;
     uint8_t flow_nw_tos;
-    struct priority_to_dscp *pdscp;
-    uint32_t out_port, odp_port;
+    odp_port_t out_port, odp_port;
+    uint8_t dscp;
 
     /* If 'struct flow' gets additional metadata, we'll need to zero it out
      * before traversing a patch port. */
@@ -813,37 +854,30 @@ compose_output_action__(struct xlate_ctx *ctx, uint16_t ofp_port,
         return;
     }
 
-    if (netdev_vport_is_patch(ofport->up.netdev)) {
-        struct ofport_dpif *peer = ofport_get_peer(ofport);
+    if (ofport->peer) {
+        struct ofport_dpif *peer = ofport->peer;
         struct flow old_flow = ctx->xin->flow;
         enum slow_path_reason special;
-        struct ofport_dpif *in_port;
-
-        if (!peer) {
-            xlate_report(ctx, "Nonexistent patch port peer");
-            return;
-        }
 
         ctx->ofproto = ofproto_dpif_cast(peer->up.ofproto);
-        flow->in_port = peer->up.ofp_port;
+        flow->in_port.ofp_port = peer->up.ofp_port;
         flow->metadata = htonll(0);
         memset(&flow->tunnel, 0, sizeof flow->tunnel);
         memset(flow->regs, 0, sizeof flow->regs);
 
-        in_port = get_ofp_port(ctx->ofproto, flow->in_port);
-        special = process_special(ctx->ofproto, &ctx->xin->flow, in_port,
+        special = process_special(ctx, &ctx->xin->flow, peer,
                                   ctx->xin->packet);
         if (special) {
             ctx->xout->slow = special;
-        } else if (!in_port || may_receive(in_port, ctx)) {
-            if (!in_port || stp_forward_in_state(in_port->stp_state)) {
-                xlate_table_action(ctx, flow->in_port, 0, true);
+        } else if (may_receive(peer, ctx)) {
+            if (stp_forward_in_state(peer->stp_state)) {
+                xlate_table_action(ctx, flow->in_port.ofp_port, 0, true);
             } else {
                 /* Forwarding is disabled by STP.  Let OFPP_NORMAL and the
                  * learning action look at the packet, then drop it. */
                 struct flow old_base_flow = ctx->base_flow;
                 size_t old_size = ctx->xout->odp_actions.size;
-                xlate_table_action(ctx, flow->in_port, 0, true);
+                xlate_table_action(ctx, flow->in_port.ofp_port, 0, true);
                 ctx->base_flow = old_base_flow;
                 ctx->xout->odp_actions.size = old_size;
             }
@@ -864,10 +898,10 @@ compose_output_action__(struct xlate_ctx *ctx, uint16_t ofp_port,
     flow_skb_mark = flow->skb_mark;
     flow_nw_tos = flow->nw_tos;
 
-    pdscp = get_priority(ofport, flow->skb_priority);
-    if (pdscp) {
+    if (ofproto_dpif_dscp_from_priority(ofport, flow->skb_priority, &dscp)) {
+        wc->masks.nw_tos |= IP_ECN_MASK;
         flow->nw_tos &= ~IP_DSCP_MASK;
-        flow->nw_tos |= pdscp->dscp;
+        flow->nw_tos |= dscp;
     }
 
     if (ofport->tnl_port) {
@@ -876,8 +910,8 @@ compose_output_action__(struct xlate_ctx *ctx, uint16_t ofp_port,
           * matches, while explicit set actions on tunnel metadata are.
           */
         struct flow_tnl flow_tnl = flow->tunnel;
-        odp_port = tnl_port_send(ofport->tnl_port, flow);
-        if (odp_port == OVSP_NONE) {
+        odp_port = tnl_port_send(ofport->tnl_port, flow, &ctx->xout->wc);
+        if (odp_port == ODPP_NONE) {
             xlate_report(ctx, "Tunneling decided against output");
             goto out; /* restore flow_nw_tos */
         }
@@ -893,8 +927,12 @@ compose_output_action__(struct xlate_ctx *ctx, uint16_t ofp_port,
                                  &ctx->xout->odp_actions);
         flow->tunnel = flow_tnl; /* Restore tunnel metadata */
     } else {
-        uint16_t vlandev_port;
+        ofp_port_t vlandev_port;
+
         odp_port = ofport->odp_port;
+        if (!hmap_is_empty(&ctx->ofproto->realdev_vid_map)) {
+            wc->masks.vlan_tci |= htons(VLAN_VID_MASK | VLAN_CFI);
+        }
         vlandev_port = vsp_realdev_to_vlandev(ctx->ofproto, ofp_port,
                                               flow->vlan_tci);
         if (vlandev_port == ofp_port) {
@@ -905,22 +943,27 @@ compose_output_action__(struct xlate_ctx *ctx, uint16_t ofp_port,
         }
         flow->skb_mark &= ~IPSEC_MARK;
     }
-    commit_odp_actions(flow, &ctx->base_flow, &ctx->xout->odp_actions);
-    nl_msg_put_u32(&ctx->xout->odp_actions, OVS_ACTION_ATTR_OUTPUT, out_port);
 
-    ctx->sflow_odp_port = odp_port;
-    ctx->sflow_n_outputs++;
-    ctx->xout->nf_output_iface = ofp_port;
+    if (out_port != ODPP_NONE) {
+        commit_odp_actions(flow, &ctx->base_flow,
+                           &ctx->xout->odp_actions, &ctx->xout->wc);
+        nl_msg_put_odp_port(&ctx->xout->odp_actions, OVS_ACTION_ATTR_OUTPUT,
+                            out_port);
+
+        ctx->sflow_odp_port = odp_port;
+        ctx->sflow_n_outputs++;
+        ctx->xout->nf_output_iface = ofp_port;
+    }
 
+ out:
     /* Restore flow */
     flow->vlan_tci = flow_vlan_tci;
     flow->skb_mark = flow_skb_mark;
- out:
     flow->nw_tos = flow_nw_tos;
 }
 
 static void
-compose_output_action(struct xlate_ctx *ctx, uint16_t ofp_port)
+compose_output_action(struct xlate_ctx *ctx, ofp_port_t ofp_port)
 {
     compose_output_action__(ctx, ofp_port, true);
 }
@@ -969,17 +1012,17 @@ ctx_rule_hooks(struct xlate_ctx *ctx, struct rule_dpif *rule,
 
 static void
 xlate_table_action(struct xlate_ctx *ctx,
-                   uint16_t in_port, uint8_t table_id, bool may_packet_in)
+                   ofp_port_t in_port, uint8_t table_id, bool may_packet_in)
 {
     if (ctx->recurse < MAX_RESUBMIT_RECURSION) {
         struct rule_dpif *rule;
-        uint16_t old_in_port = ctx->xin->flow.in_port;
+        ofp_port_t old_in_port = ctx->xin->flow.in_port.ofp_port;
         uint8_t old_table_id = ctx->table_id;
 
         ctx->table_id = table_id;
 
         /* Look up a flow with 'in_port' as the input port. */
-        ctx->xin->flow.in_port = in_port;
+        ctx->xin->flow.in_port.ofp_port = in_port;
         rule = rule_dpif_lookup_in_table(ctx->ofproto, &ctx->xin->flow,
                                          &ctx->xout->wc, table_id);
 
@@ -987,7 +1030,7 @@ xlate_table_action(struct xlate_ctx *ctx,
 
         /* Restore the original input port.  Otherwise OFPP_NORMAL and
          * OFPP_IN_PORT will have surprising behavior. */
-        ctx->xin->flow.in_port = old_in_port;
+        ctx->xin->flow.in_port.ofp_port = old_in_port;
 
         rule = ctx_rule_hooks(ctx, rule, may_packet_in);
 
@@ -1015,12 +1058,12 @@ static void
 xlate_ofpact_resubmit(struct xlate_ctx *ctx,
                       const struct ofpact_resubmit *resubmit)
 {
-    uint16_t in_port;
+    ofp_port_t in_port;
     uint8_t table_id;
 
     in_port = resubmit->in_port;
     if (in_port == OFPP_IN_PORT) {
-        in_port = ctx->xin->flow.in_port;
+        in_port = ctx->xin->flow.in_port.ofp_port;
     }
 
     table_id = resubmit->table_id;
@@ -1037,9 +1080,9 @@ flood_packets(struct xlate_ctx *ctx, bool all)
     struct ofport_dpif *ofport;
 
     HMAP_FOR_EACH (ofport, up.hmap_node, &ctx->ofproto->up.ports) {
-        uint16_t ofp_port = ofport->up.ofp_port;
+        ofp_port_t ofp_port = ofport->up.ofp_port;
 
-        if (ofp_port == ctx->xin->flow.in_port) {
+        if (ofp_port == ctx->xin->flow.in_port.ofp_port) {
             continue;
         }
 
@@ -1075,7 +1118,7 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
     memset(&key.tunnel, 0, sizeof key.tunnel);
 
     commit_odp_actions(&ctx->xin->flow, &ctx->base_flow,
-                       &ctx->xout->odp_actions);
+                       &ctx->xout->odp_actions, &ctx->xout->wc);
 
     odp_execute_actions(NULL, packet, &key, ctx->xout->odp_actions.data,
                         ctx->xout->odp_actions.size, NULL, NULL);
@@ -1102,7 +1145,6 @@ compose_mpls_push_action(struct xlate_ctx *ctx, ovs_be16 eth_type)
 
     ovs_assert(eth_type_mpls(eth_type));
 
-    memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
     memset(&wc->masks.mpls_lse, 0xff, sizeof wc->masks.mpls_lse);
     memset(&wc->masks.mpls_depth, 0xff, sizeof wc->masks.mpls_depth);
 
@@ -1118,6 +1160,8 @@ compose_mpls_push_action(struct xlate_ctx *ctx, ovs_be16 eth_type)
         } else {
             label = htonl(0x0); /* IPV4 Explicit Null. */
         }
+        wc->masks.nw_tos |= IP_DSCP_MASK;
+        wc->masks.nw_ttl = 0xff;
         tc = (flow->nw_tos & IP_DSCP_MASK) >> 2;
         ttl = flow->nw_ttl ? flow->nw_ttl : 0x40;
         flow->mpls_lse = set_mpls_lse_values(ttl, tc, 1, label);
@@ -1135,7 +1179,6 @@ compose_mpls_pop_action(struct xlate_ctx *ctx, ovs_be16 eth_type)
     ovs_assert(eth_type_mpls(ctx->xin->flow.dl_type));
     ovs_assert(!eth_type_mpls(eth_type));
 
-    memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
     memset(&wc->masks.mpls_lse, 0xff, sizeof wc->masks.mpls_lse);
     memset(&wc->masks.mpls_depth, 0xff, sizeof wc->masks.mpls_depth);
 
@@ -1157,6 +1200,7 @@ compose_dec_ttl(struct xlate_ctx *ctx, struct ofpact_cnt_ids *ids)
         return false;
     }
 
+    ctx->xout->wc.masks.nw_ttl = 0xff;
     if (flow->nw_ttl > 1) {
         flow->nw_ttl--;
         return false;
@@ -1189,6 +1233,9 @@ compose_dec_mpls_ttl_action(struct xlate_ctx *ctx)
 {
     struct flow *flow = &ctx->xin->flow;
     uint8_t ttl = mpls_lse_to_ttl(flow->mpls_lse);
+    struct flow_wildcards *wc = &ctx->xout->wc;
+
+    memset(&wc->masks.mpls_lse, 0xff, sizeof wc->masks.mpls_lse);
 
     if (!eth_type_mpls(flow->dl_type)) {
         return false;
@@ -1208,18 +1255,19 @@ compose_dec_mpls_ttl_action(struct xlate_ctx *ctx)
 
 static void
 xlate_output_action(struct xlate_ctx *ctx,
-                    uint16_t port, uint16_t max_len, bool may_packet_in)
+                    ofp_port_t port, uint16_t max_len, bool may_packet_in)
 {
-    uint16_t prev_nf_output_iface = ctx->xout->nf_output_iface;
+    ofp_port_t prev_nf_output_iface = ctx->xout->nf_output_iface;
 
     ctx->xout->nf_output_iface = NF_OUT_DROP;
 
     switch (port) {
     case OFPP_IN_PORT:
-        compose_output_action(ctx, ctx->xin->flow.in_port);
+        compose_output_action(ctx, ctx->xin->flow.in_port.ofp_port);
         break;
     case OFPP_TABLE:
-        xlate_table_action(ctx, ctx->xin->flow.in_port, 0, may_packet_in);
+        xlate_table_action(ctx, ctx->xin->flow.in_port.ofp_port,
+                           0, may_packet_in);
         break;
     case OFPP_NORMAL:
         xlate_normal(ctx);
@@ -1237,7 +1285,7 @@ xlate_output_action(struct xlate_ctx *ctx,
         break;
     case OFPP_LOCAL:
     default:
-        if (port != ctx->xin->flow.in_port) {
+        if (port != ctx->xin->flow.in_port.ofp_port) {
             compose_output_action(ctx, port);
         } else {
             xlate_report(ctx, "skipping output to input port");
@@ -1265,7 +1313,8 @@ xlate_output_reg_action(struct xlate_ctx *ctx,
 
         memset(&value, 0xff, sizeof value);
         mf_write_subfield_flow(&or->src, &value, &ctx->xout->wc.masks);
-        xlate_output_action(ctx, port, or->max_len, false);
+        xlate_output_action(ctx, u16_to_ofp(port),
+                            or->max_len, false);
     }
 }
 
@@ -1273,14 +1322,13 @@ static void
 xlate_enqueue_action(struct xlate_ctx *ctx,
                      const struct ofpact_enqueue *enqueue)
 {
-    uint16_t ofp_port = enqueue->port;
+    ofp_port_t ofp_port = enqueue->port;
     uint32_t queue_id = enqueue->queue;
     uint32_t flow_priority, priority;
     int error;
 
     /* Translate queue to priority. */
-    error = dpif_queue_to_priority(ctx->ofproto->backer->dpif,
-                                   queue_id, &priority);
+    error = ofproto_dpif_queue_to_priority(ctx->ofproto, queue_id, &priority);
     if (error) {
         /* Fall back to ordinary output action. */
         xlate_output_action(ctx, enqueue->port, 0, false);
@@ -1289,8 +1337,8 @@ xlate_enqueue_action(struct xlate_ctx *ctx,
 
     /* Check output port. */
     if (ofp_port == OFPP_IN_PORT) {
-        ofp_port = ctx->xin->flow.in_port;
-    } else if (ofp_port == ctx->xin->flow.in_port) {
+        ofp_port = ctx->xin->flow.in_port.ofp_port;
+    } else if (ofp_port == ctx->xin->flow.in_port.ofp_port) {
         return;
     }
 
@@ -1313,8 +1361,8 @@ xlate_set_queue_action(struct xlate_ctx *ctx, uint32_t queue_id)
 {
     uint32_t skb_priority;
 
-    if (!dpif_queue_to_priority(ctx->ofproto->backer->dpif,
-                                queue_id, &skb_priority)) {
+    if (!ofproto_dpif_queue_to_priority(ctx->ofproto, queue_id,
+                                        &skb_priority)) {
         ctx->xin->flow.skb_priority = skb_priority;
     } else {
         /* Couldn't translate queue to a priority.  Nothing to do.  A warning
@@ -1323,7 +1371,7 @@ xlate_set_queue_action(struct xlate_ctx *ctx, uint32_t queue_id)
 }
 
 static bool
-slave_enabled_cb(uint16_t ofp_port, void *ofproto_)
+slave_enabled_cb(ofp_port_t ofp_port, void *ofproto_)
 {
     struct ofproto_dpif *ofproto = ofproto_;
     struct ofport_dpif *port;
@@ -1348,12 +1396,12 @@ static void
 xlate_bundle_action(struct xlate_ctx *ctx,
                     const struct ofpact_bundle *bundle)
 {
-    uint16_t port;
+    ofp_port_t port;
 
     port = bundle_execute(bundle, &ctx->xin->flow, &ctx->xout->wc,
                           slave_enabled_cb, ctx->ofproto);
     if (bundle->dst.field) {
-        nxm_reg_load(&bundle->dst, port, &ctx->xin->flow);
+        nxm_reg_load(&bundle->dst, ofp_to_u16(port), &ctx->xin->flow);
     } else {
         xlate_output_action(ctx, port, 0, false);
     }
@@ -1421,7 +1469,7 @@ xlate_sample_action(struct xlate_ctx *ctx,
   uint32_t probability = (os->probability << 16) | os->probability;
 
   commit_odp_actions(&ctx->xin->flow, &ctx->base_flow,
-                     &ctx->xout->odp_actions);
+                     &ctx->xout->odp_actions, &ctx->xout->wc);
 
   compose_flow_sample_cookie(os->probability, os->collector_set_id,
                              os->obs_domain_id, os->obs_point_id, &cookie);
@@ -1541,14 +1589,12 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
             break;
 
         case OFPACT_SET_IPV4_SRC:
-            memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
             if (flow->dl_type == htons(ETH_TYPE_IP)) {
                 flow->nw_src = ofpact_get_SET_IPV4_SRC(a)->ipv4;
             }
             break;
 
         case OFPACT_SET_IPV4_DST:
-            memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
             if (flow->dl_type == htons(ETH_TYPE_IP)) {
                 flow->nw_dst = ofpact_get_SET_IPV4_DST(a)->ipv4;
             }
@@ -1556,7 +1602,6 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
 
         case OFPACT_SET_IPV4_DSCP:
             /* OpenFlow 1.0 only supports IPv4. */
-            memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
             if (flow->dl_type == htons(ETH_TYPE_IP)) {
                 flow->nw_tos &= ~IP_DSCP_MASK;
                 flow->nw_tos |= ofpact_get_SET_IPV4_DSCP(a)->dscp;
@@ -1564,7 +1609,6 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
             break;
 
         case OFPACT_SET_L4_SRC_PORT:
-            memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
             memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto);
             if (is_ip_any(flow)) {
                 flow->tp_src = htons(ofpact_get_SET_L4_SRC_PORT(a)->port);
@@ -1572,7 +1616,6 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
             break;
 
         case OFPACT_SET_L4_DST_PORT:
-            memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
             memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto);
             if (is_ip_any(flow)) {
                 flow->tp_dst = htons(ofpact_get_SET_L4_DST_PORT(a)->port);
@@ -1592,9 +1635,6 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
             break;
 
         case OFPACT_POP_QUEUE:
-            memset(&wc->masks.skb_priority, 0xff,
-                   sizeof wc->masks.skb_priority);
-
             flow->skb_priority = ctx->orig_skb_priority;
             break;
 
@@ -1637,7 +1677,6 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
             break;
 
         case OFPACT_DEC_TTL:
-            memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
             if (compose_dec_ttl(ctx, ofpact_get_DEC_TTL(a))) {
                 goto out;
             }
@@ -1669,7 +1708,6 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
             break;
 
         case OFPACT_FIN_TIMEOUT:
-            memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
             memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto);
             ctx->xout->has_fin_timeout = true;
             xlate_fin_timeout(ctx, ofpact_get_FIN_TIMEOUT(a));
@@ -1689,6 +1727,10 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
             flow->metadata |= metadata->metadata & metadata->mask;
             break;
 
+        case OFPACT_METER:
+            /* Not implemented yet. */
+            break;
+
         case OFPACT_GOTO_TABLE: {
             /* It is assumed that goto-table is the last action. */
             struct ofpact_goto_table *ogt = ofpact_get_GOTO_TABLE(a);
@@ -1853,22 +1895,15 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
 
     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);
+    wc->masks.nw_frag |= FLOW_NW_FRAG_MASK;
 
     if (tnl_port_should_receive(&ctx.xin->flow)) {
         memset(&wc->masks.tunnel, 0xff, sizeof wc->masks.tunnel);
     }
-
-    /* Disable most wildcarding for NetFlow. */
     if (xin->ofproto->netflow) {
-        memset(&wc->masks.dl_src, 0xff, sizeof wc->masks.dl_src);
-        memset(&wc->masks.dl_dst, 0xff, sizeof wc->masks.dl_dst);
-        memset(&wc->masks.dl_type, 0xff, sizeof wc->masks.dl_type);
-        memset(&wc->masks.vlan_tci, 0xff, sizeof wc->masks.vlan_tci);
-        memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto);
-        memset(&wc->masks.nw_src, 0xff, sizeof wc->masks.nw_src);
-        memset(&wc->masks.nw_dst, 0xff, sizeof wc->masks.nw_dst);
-        memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src);
-        memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst);
+        netflow_mask_wc(wc);
     }
 
     ctx.xout->tags = 0;
@@ -1930,17 +1965,17 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
         }
     }
 
-    in_port = get_ofp_port(ctx.ofproto, flow->in_port);
-    special = process_special(ctx.ofproto, flow, in_port, ctx.xin->packet);
+    in_port = get_ofp_port(ctx.ofproto, flow->in_port.ofp_port);
+    special = process_special(&ctx, flow, in_port, ctx.xin->packet);
     if (special) {
         ctx.xout->slow = special;
     } else {
         static struct vlog_rate_limit trace_rl = VLOG_RATE_LIMIT_INIT(1, 1);
         size_t sample_actions_len;
-        uint32_t local_odp_port;
+        odp_port_t local_odp_port;
 
-        if (flow->in_port
-            != vsp_realdev_to_vlandev(ctx.ofproto, flow->in_port,
+        if (flow->in_port.ofp_port
+            != vsp_realdev_to_vlandev(ctx.ofproto, flow->in_port.ofp_port,
                                       flow->vlan_tci)) {
             ctx.base_flow.vlan_tci = 0;
         }