uint16_t idle_timeout; /* In seconds from time of last use. */
uint16_t hard_timeout; /* In seconds from time of creation. */
bool send_flow_removed; /* Send a flow removed message? */
- long long int used; /* Last-used time (0 if never used). */
+ long long int used; /* Time last used; time created if not used. */
long long int created; /* Creation time. */
uint64_t packet_count; /* Number of packets received. */
uint64_t byte_count; /* Number of bytes received. */
return 0;
}
+/* Adds a flow to the OpenFlow flow table in 'p' that matches 'cls_rule' and
+ * performs the 'n_actions' actions in 'actions'. The new flow will not
+ * timeout.
+ *
+ * If cls_rule->priority is in the range of priorities supported by OpenFlow
+ * (0...65535, inclusive) then the flow will be visible to OpenFlow
+ * controllers; otherwise, it will be hidden.
+ *
+ * The caller retains ownership of 'cls_rule' and 'actions'. */
void
ofproto_add_flow(struct ofproto *p, const struct cls_rule *cls_rule,
- const union ofp_action *actions, size_t n_actions,
- int idle_timeout)
+ const union ofp_action *actions, size_t n_actions)
{
struct rule *rule;
- rule = rule_create(p, NULL, actions, n_actions,
- idle_timeout >= 0 ? idle_timeout : 5 /* XXX */,
- 0, 0, false);
+ rule = rule_create(p, NULL, actions, n_actions, 0, 0, 0, false);
rule->cr = *cls_rule;
rule_insert(p, rule, NULL, 0);
}
rule->n_actions = n_actions;
rule->actions = xmemdup(actions, n_actions * sizeof *actions);
}
- netflow_flow_clear(&rule->nf_flow);
+ netflow_flow_init(&rule->nf_flow);
netflow_flow_update_time(ofproto->netflow, &rule->nf_flow, rule->created);
return rule;
assert(!rule->cr.wc.wildcards);
super = rule->super ? rule->super : rule;
- rule->tags = 0;
xlate_actions(super->actions, super->n_actions, &rule->cr.flow, p,
packet, &a, &rule->tags, &rule->may_install,
&rule->nf_flow.output_iface);
/* Output. */
struct odp_actions *out; /* Datapath actions. */
- tag_type *tags; /* Tags associated with OFPP_NORMAL actions. */
+ tag_type tags; /* Tags associated with OFPP_NORMAL actions. */
bool may_set_up_flow; /* True ordinarily; false if the actions must
* be reassessed for every packet. */
uint16_t nf_output_iface; /* Output interface index for NetFlow. */
break;
case OFPP_NORMAL:
if (!ctx->ofproto->ofhooks->normal_cb(&ctx->flow, ctx->packet,
- ctx->out, ctx->tags,
+ ctx->out, &ctx->tags,
&ctx->nf_output_iface,
ctx->ofproto->aux)) {
COVERAGE_INC(ofproto_uninstallable);
= priority;
}
+static void
+xlate_set_dl_tci(struct action_xlate_ctx *ctx)
+{
+ ovs_be16 dl_vlan = ctx->flow.dl_vlan;
+ uint8_t dl_vlan_pcp = ctx->flow.dl_vlan_pcp;
+
+ if (dl_vlan == htons(OFP_VLAN_NONE)) {
+ odp_actions_add(ctx->out, ODPAT_STRIP_VLAN);
+ } else {
+ union odp_action *oa = odp_actions_add(ctx->out, ODPAT_SET_DL_TCI);
+ oa->dl_tci.tci = htons(ntohs(dl_vlan & htons(VLAN_VID_MASK))
+ | (dl_vlan_pcp << VLAN_PCP_SHIFT)
+ | VLAN_CFI);
+ }
+}
+
+static void
+xlate_reg_move_action(struct action_xlate_ctx *ctx,
+ const struct nx_action_reg_move *narm)
+{
+ ovs_be16 old_vlan = ctx->flow.dl_vlan;
+ uint8_t old_pcp = ctx->flow.dl_vlan_pcp;
+
+ nxm_execute_reg_move(narm, &ctx->flow);
+
+ if (ctx->flow.dl_vlan != old_vlan || ctx->flow.dl_vlan_pcp != old_pcp) {
+ xlate_set_dl_tci(ctx);
+ }
+}
+
static void
xlate_nicira_action(struct action_xlate_ctx *ctx,
const struct nx_action_header *nah)
odp_actions_add(ctx->out, ODPAT_POP_PRIORITY);
break;
+ case NXAST_REG_MOVE:
+ xlate_reg_move_action(ctx, (const struct nx_action_reg_move *) nah);
+ break;
+
+ case NXAST_REG_LOAD:
+ nxm_execute_reg_load((const struct nx_action_reg_load *) nah,
+ &ctx->flow);
+ break;
+
/* If you add a new action here that modifies flow data, don't forget to
* update the flow key in ctx->flow at the same time. */
break;
case OFPAT_SET_VLAN_VID:
- oa = odp_actions_add(ctx->out, ODPAT_SET_DL_TCI);
- oa->dl_tci.tci = ia->vlan_vid.vlan_vid;
- oa->dl_tci.tci |= htons(ctx->flow.dl_vlan_pcp << VLAN_PCP_SHIFT);
ctx->flow.dl_vlan = ia->vlan_vid.vlan_vid;
+ xlate_set_dl_tci(ctx);
break;
case OFPAT_SET_VLAN_PCP:
- oa = odp_actions_add(ctx->out, ODPAT_SET_DL_TCI);
- oa->dl_tci.tci = htons(ia->vlan_pcp.vlan_pcp << VLAN_PCP_SHIFT);
- oa->dl_tci.tci |= ctx->flow.dl_vlan;
ctx->flow.dl_vlan_pcp = ia->vlan_pcp.vlan_pcp;
+ xlate_set_dl_tci(ctx);
break;
case OFPAT_STRIP_VLAN:
- odp_actions_add(ctx->out, ODPAT_STRIP_VLAN);
ctx->flow.dl_vlan = htons(OFP_VLAN_NONE);
ctx->flow.dl_vlan_pcp = 0;
+ xlate_set_dl_tci(ctx);
break;
case OFPAT_SET_DL_SRC:
struct odp_actions *out, tag_type *tags, bool *may_set_up_flow,
uint16_t *nf_output_iface)
{
- tag_type no_tags = 0;
struct action_xlate_ctx ctx;
+
COVERAGE_INC(ofproto_ofp2odp);
odp_actions_init(out);
ctx.flow = *flow;
ctx.ofproto = ofproto;
ctx.packet = packet;
ctx.out = out;
- ctx.tags = tags ? tags : &no_tags;
+ ctx.tags = 0;
ctx.may_set_up_flow = true;
ctx.nf_output_iface = NF_OUT_DROP;
do_xlate_actions(in, n_in, &ctx);
ctx.may_set_up_flow = false;
}
+ if (tags) {
+ *tags = ctx.tags;
+ }
if (may_set_up_flow) {
*may_set_up_flow = ctx.may_set_up_flow;
}
return ofp_mkerr(OFPET_BAD_REQUEST, OFPBRC_BAD_VENDOR);
}
- if (ntohs(nsm->header.length) < sizeof(struct nicira_stats_msg)) {
+ if (ntohs(osr->header.length) < sizeof(struct nicira_stats_msg)) {
VLOG_WARN_RL(&rl, "truncated Nicira stats request");
return ofp_mkerr(OFPET_BAD_REQUEST, OFPBRC_BAD_LEN);
}
rule->super = super;
rule->hard_timeout = super->hard_timeout;
rule->idle_timeout = super->idle_timeout;
- rule->created = super->created;
- rule->used = 0;
+ rule->created = rule->used = super->created;
}
}