tunnel: Hide 'struct tnl_port' internally.
[sliver-openvswitch.git] / ofproto / ofproto-dpif-xlate.c
index 852afdb..0e7b9a0 100644 (file)
@@ -548,7 +548,6 @@ 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_src, 0xff, sizeof wc->masks.dl_src);
     memset(&wc->masks.dl_dst, 0xff, sizeof wc->masks.dl_dst);
     wc->masks.vlan_tci |= htons(VLAN_VID_MASK | VLAN_CFI);
@@ -905,13 +904,13 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port,
         flow->nw_tos |= dscp;
     }
 
-    if (ofport->tnl_port) {
+    if (ofport->is_tunnel) {
          /* Save tunnel metadata so that changes made due to
           * the Logical (tunnel) Port are not visible for any further
           * 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, &ctx->xout->wc);
+        odp_port = tnl_port_send(ofport, flow, &ctx->xout->wc);
         if (odp_port == ODPP_NONE) {
             xlate_report(ctx, "Tunneling decided against output");
             goto out; /* restore flow_nw_tos */
@@ -969,24 +968,6 @@ compose_output_action(struct xlate_ctx *ctx, ofp_port_t ofp_port)
     compose_output_action__(ctx, ofp_port, true);
 }
 
-static void
-tag_the_flow(struct xlate_ctx *ctx, struct rule_dpif *rule)
-{
-    struct ofproto_dpif *ofproto = ctx->ofproto;
-    uint8_t table_id = ctx->table_id;
-
-    if (table_id > 0 && table_id < N_TABLES) {
-        struct table_dpif *table = &ofproto->tables[table_id];
-        if (table->other_table) {
-            ctx->xout->tags |= (rule && rule->tag
-                                ? rule->tag
-                                : rule_calculate_tag(&ctx->xin->flow,
-                                                     &table->other_table->mask,
-                                                     table->basis));
-        }
-    }
-}
-
 /* Common rule processing in one place to avoid duplicating code. */
 static struct rule_dpif *
 ctx_rule_hooks(struct xlate_ctx *ctx, struct rule_dpif *rule,
@@ -1027,7 +1008,8 @@ xlate_table_action(struct xlate_ctx *ctx,
         rule = rule_dpif_lookup_in_table(ctx->ofproto, &ctx->xin->flow,
                                          &ctx->xout->wc, table_id);
 
-        tag_the_flow(ctx, rule);
+        ctx->xout->tags |= calculate_flow_tag(ctx->ofproto, &ctx->xin->flow,
+                                              ctx->table_id, rule);
 
         /* Restore the original input port.  Otherwise OFPP_NORMAL and
          * OFPP_IN_PORT will have surprising behavior. */
@@ -1744,7 +1726,8 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
             rule = rule_dpif_lookup_in_table(ctx->ofproto, flow, wc,
                                              ctx->table_id);
 
-            tag_the_flow(ctx, rule);
+            ctx->xout->tags = calculate_flow_tag(ctx->ofproto, &ctx->xin->flow,
+                                                 ctx->table_id, rule);
 
             rule = ctx_rule_hooks(ctx, rule, true);
 
@@ -1839,6 +1822,22 @@ xlate_out_copy(struct xlate_out *dst, const struct xlate_out *src)
                src->odp_actions.size);
 }
 \f
+static bool
+actions_output_to_local_port(const struct xlate_ctx *ctx)
+{
+    odp_port_t local_odp_port = ofp_port_to_odp_port(ctx->ofproto, OFPP_LOCAL);
+    const struct nlattr *a;
+    unsigned int left;
+
+    NL_ATTR_FOR_EACH_UNSAFE (a, left, ctx->xout->odp_actions.data,
+                             ctx->xout->odp_actions.size) {
+        if (nl_attr_type(a) == OVS_ACTION_ATTR_OUTPUT
+            && nl_attr_get_odp_port(a) == local_odp_port) {
+            return true;
+        }
+    }
+    return false;
+}
 
 /* Translates the 'ofpacts_len' bytes of "struct ofpacts" starting at 'ofpacts'
  * into datapath actions in 'odp_actions', using 'ctx'. */
@@ -1903,7 +1902,7 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
         memset(&wc->masks.tunnel, 0xff, sizeof wc->masks.tunnel);
     }
     if (xin->ofproto->netflow) {
-        netflow_mask_wc(wc);
+        netflow_mask_wc(flow, wc);
     }
 
     ctx.xout->tags = 0;
@@ -1972,7 +1971,6 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
     } else {
         static struct vlog_rate_limit trace_rl = VLOG_RATE_LIMIT_INIT(1, 1);
         size_t sample_actions_len;
-        odp_port_t local_odp_port;
 
         if (flow->in_port.ofp_port
             != vsp_realdev_to_vlandev(ctx.ofproto, flow->in_port.ofp_port,
@@ -2009,11 +2007,9 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
             }
         }
 
-        local_odp_port = ofp_port_to_odp_port(ctx.ofproto, OFPP_LOCAL);
         if (connmgr_has_in_band(ctx.ofproto->up.connmgr)
-            && !in_band_rule_check(flow, local_odp_port,
-                                   ctx.xout->odp_actions.data,
-                                   ctx.xout->odp_actions.size)) {
+            && in_band_must_output_to_local_port(flow)
+            && !actions_output_to_local_port(&ctx)) {
             compose_output_action(&ctx, OFPP_LOCAL);
         }
         if (ctx.ofproto->has_mirrors) {