/* If 'struct flow' gets additional metadata, we'll need to zero it out
* before traversing a patch port. */
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 21);
+ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 22);
if (!xport) {
xlate_report(ctx, "Nonexistent output port");
enum ofp_packet_in_reason reason,
uint16_t controller_id)
{
- struct ofputil_packet_in *pin;
+ struct ofproto_packet_in *pin;
struct ofpbuf *packet;
struct flow key;
ctx->xout->odp_actions.size, NULL, NULL);
pin = xmalloc(sizeof *pin);
- pin->packet_len = packet->size;
- pin->packet = ofpbuf_steal_data(packet);
- pin->reason = reason;
- pin->controller_id = controller_id;
- pin->table_id = ctx->table_id;
- pin->cookie = ctx->rule ? rule_dpif_get_flow_cookie(ctx->rule) : 0;
+ pin->up.packet_len = packet->size;
+ pin->up.packet = ofpbuf_steal_data(packet);
+ pin->up.reason = reason;
+ pin->up.table_id = ctx->table_id;
+ pin->up.cookie = (ctx->rule
+ ? rule_dpif_get_flow_cookie(ctx->rule)
+ : OVS_BE64_MAX);
- pin->send_len = len;
- flow_get_metadata(&ctx->xin->flow, &pin->fmd);
+ flow_get_metadata(&ctx->xin->flow, &pin->up.fmd);
+ pin->controller_id = controller_id;
+ pin->send_len = len;
+ pin->generated_by_table_miss = (ctx->rule
+ && rule_dpif_is_table_miss(ctx->rule));
ofproto_dpif_send_packet_in(ctx->xbridge->ofproto, pin);
ofpbuf_delete(packet);
}
OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) {
struct ofpact_controller *controller;
const struct ofpact_metadata *metadata;
+ const struct ofpact_set_field *set_field;
+ const struct mf_field *mf;
if (ctx->exit) {
break;
case OFPACT_SET_VLAN_VID:
wc->masks.vlan_tci |= htons(VLAN_VID_MASK | VLAN_CFI);
- flow->vlan_tci &= ~htons(VLAN_VID_MASK);
- flow->vlan_tci |= (htons(ofpact_get_SET_VLAN_VID(a)->vlan_vid)
- | htons(VLAN_CFI));
+ if (flow->vlan_tci & htons(VLAN_CFI) ||
+ ofpact_get_SET_VLAN_VID(a)->push_vlan_if_needed) {
+ flow->vlan_tci &= ~htons(VLAN_VID_MASK);
+ flow->vlan_tci |= (htons(ofpact_get_SET_VLAN_VID(a)->vlan_vid)
+ | htons(VLAN_CFI));
+ }
break;
case OFPACT_SET_VLAN_PCP:
wc->masks.vlan_tci |= htons(VLAN_PCP_MASK | VLAN_CFI);
- flow->vlan_tci &= ~htons(VLAN_PCP_MASK);
- flow->vlan_tci |=
- htons((ofpact_get_SET_VLAN_PCP(a)->vlan_pcp << VLAN_PCP_SHIFT)
- | VLAN_CFI);
+ if (flow->vlan_tci & htons(VLAN_CFI) ||
+ ofpact_get_SET_VLAN_PCP(a)->push_vlan_if_needed) {
+ flow->vlan_tci &= ~htons(VLAN_PCP_MASK);
+ flow->vlan_tci |= htons((ofpact_get_SET_VLAN_PCP(a)->vlan_pcp
+ << VLAN_PCP_SHIFT) | VLAN_CFI);
+ }
break;
case OFPACT_STRIP_VLAN:
}
break;
- case OFPACT_SET_IPV4_DSCP:
- /* OpenFlow 1.0 only supports IPv4. */
- if (flow->dl_type == htons(ETH_TYPE_IP)) {
+ case OFPACT_SET_IP_DSCP:
+ if (is_ip_any(flow)) {
wc->masks.nw_tos |= IP_DSCP_MASK;
flow->nw_tos &= ~IP_DSCP_MASK;
- flow->nw_tos |= ofpact_get_SET_IPV4_DSCP(a)->dscp;
+ flow->nw_tos |= ofpact_get_SET_IP_DSCP(a)->dscp;
+ }
+ break;
+
+ case OFPACT_SET_IP_ECN:
+ if (is_ip_any(flow)) {
+ wc->masks.nw_tos |= IP_ECN_MASK;
+ flow->nw_tos &= ~IP_ECN_MASK;
+ flow->nw_tos |= ofpact_get_SET_IP_ECN(a)->ecn;
+ }
+ break;
+
+ case OFPACT_SET_IP_TTL:
+ if (is_ip_any(flow)) {
+ wc->masks.nw_ttl = 0xff;
+ flow->nw_ttl = ofpact_get_SET_IP_TTL(a)->ttl;
}
break;
nxm_execute_reg_load(ofpact_get_REG_LOAD(a), flow, wc);
break;
+ case OFPACT_SET_FIELD:
+ set_field = ofpact_get_SET_FIELD(a);
+ mf = set_field->field;
+ mf_mask_field_and_prereqs(mf, &wc->masks);
+
+ /* Set field action only ever overwrites packet's outermost
+ * applicable header fields. Do nothing if no header exists. */
+ if ((mf->id != MFF_VLAN_VID || flow->vlan_tci & htons(VLAN_CFI))
+ && ((mf->id != MFF_MPLS_LABEL && mf->id != MFF_MPLS_TC)
+ || flow->mpls_lse)) {
+ mf_set_flow_value(mf, &set_field->value, flow);
+ }
+ break;
+
case OFPACT_STACK_PUSH:
nxm_execute_stack_push(ofpact_get_STACK_PUSH(a), flow, wc,
&ctx->stack);
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);
ovs_assert(ctx->table_id < ogt->table_id);
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)
+ uint16_t tcp_flags, const struct ofpbuf *packet)
{
xin->ofproto = ofproto;
xin->flow = *flow;
}
ctx.rule = rule;
}
- xout->fail_open = ctx.rule && rule_dpif_fail_open(ctx.rule);
+ xout->fail_open = ctx.rule && rule_dpif_is_fail_open(ctx.rule);
if (xin->ofpacts) {
ofpacts = xin->ofpacts;