break;
case OFPUTIL_NXAST_WRITE_METADATA:
- nawm = (const struct nx_action_write_metadata *) a;
+ nawm = ALIGNED_CAST(const struct nx_action_write_metadata *, a);
error = metadata_from_nxast(nawm, out);
break;
case OFPUTIL_NXAST_REG_LOAD:
error = nxm_reg_load_from_openflow(
- (const struct nx_action_reg_load *) a, out);
+ ALIGNED_CAST(const struct nx_action_reg_load *, a), out);
break;
case OFPUTIL_NXAST_STACK_PUSH:
break;
case OFPUTIL_NXAST_SET_TUNNEL64:
- nast64 = (const struct nx_action_set_tunnel64 *) a;
+ nast64 = ALIGNED_CAST(const struct nx_action_set_tunnel64 *, a);
tunnel = ofpact_put_SET_TUNNEL(out);
tunnel->ofpact.compat = code;
tunnel->tun_id = ntohll(nast64->tun_id);
break;
case OFPUTIL_NXAST_LEARN:
- error = learn_from_openflow((const struct nx_action_learn *) a, out);
+ error = learn_from_openflow(
+ ALIGNED_CAST(const struct nx_action_learn *, a), out);
break;
case OFPUTIL_NXAST_EXIT:
instruction_get_##ENUM(const struct ofp11_instruction *inst)\
{ \
ovs_assert(inst->type == htons(ENUM)); \
- return (struct STRUCT *)inst; \
+ return ALIGNED_CAST(struct STRUCT *, inst); \
} \
\
static inline void \
static void
get_actions_from_instruction(const struct ofp11_instruction *inst,
- const union ofp_action **actions,
- size_t *n_actions)
+ const union ofp_action **actions,
+ size_t *n_actions)
{
- *actions = (const union ofp_action *) (inst + 1);
+ *actions = ALIGNED_CAST(const union ofp_action *, inst + 1);
*n_actions = (ntohs(inst->len) - sizeof *inst) / OFP11_INSTRUCTION_ALIGN;
}
enum ofperr
ofpacts_pull_openflow11_instructions(struct ofpbuf *openflow,
unsigned int instructions_len,
- uint8_t table_id,
struct ofpbuf *ofpacts)
{
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
const struct ofp13_instruction_meter *oim;
struct ofpact_meter *om;
- oim = (const struct ofp13_instruction_meter *)
- insts[OVSINST_OFPIT13_METER];
+ oim = ALIGNED_CAST(const struct ofp13_instruction_meter *,
+ insts[OVSINST_OFPIT13_METER]);
om = ofpact_put_METER(ofpacts);
om->meter_id = ntohl(oim->meter_id);
const struct ofp11_instruction_write_metadata *oiwm;
struct ofpact_metadata *om;
- oiwm = (const struct ofp11_instruction_write_metadata *)
- insts[OVSINST_OFPIT11_WRITE_METADATA];
+ oiwm = ALIGNED_CAST(const struct ofp11_instruction_write_metadata *,
+ insts[OVSINST_OFPIT11_WRITE_METADATA]);
om = ofpact_put_WRITE_METADATA(ofpacts);
om->metadata = oiwm->metadata;
oigt = instruction_get_OFPIT11_GOTO_TABLE(
insts[OVSINST_OFPIT11_GOTO_TABLE]);
- if (table_id >= oigt->table_id) {
- error = OFPERR_OFPBRC_BAD_TABLE_ID;
- goto exit;
- }
ogt = ofpact_put_GOTO_TABLE(ofpacts);
ogt->table_id = oigt->table_id;
}
\f
/* May modify flow->dl_type, caller must restore it. */
static enum ofperr
-ofpact_check__(const struct ofpact *a, struct flow *flow, ofp_port_t max_ports)
+ofpact_check__(const struct ofpact *a, struct flow *flow, ofp_port_t max_ports,
+ uint8_t table_id)
{
const struct ofpact_enqueue *enqueue;
case OFPACT_CLEAR_ACTIONS:
case OFPACT_WRITE_METADATA:
- case OFPACT_GOTO_TABLE:
return 0;
case OFPACT_METER: {
}
return 0;
}
+
+ case OFPACT_GOTO_TABLE:
+ if (ofpact_get_GOTO_TABLE(a)->table_id <= table_id) {
+ return OFPERR_OFPBRC_BAD_TABLE_ID;
+ }
+ return 0;
+
default:
NOT_REACHED();
}
* May temporarily modify 'flow', but restores the changes before returning. */
enum ofperr
ofpacts_check(const struct ofpact ofpacts[], size_t ofpacts_len,
- struct flow *flow, ofp_port_t max_ports)
+ struct flow *flow, ofp_port_t max_ports, uint8_t table_id)
{
const struct ofpact *a;
ovs_be16 dl_type = flow->dl_type;
enum ofperr error = 0;
OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) {
- error = ofpact_check__(a, flow, max_ports);
+ error = ofpact_check__(a, flow, max_ports, table_id);
if (error) {
break;
}
if (remainder) {
ofpbuf_put_zeros(out, OFP_ACTION_ALIGN - remainder);
}
- nan = (struct nx_action_note *)((char *)out->data + start_ofs);
+ nan = ofpbuf_at(out, start_ofs, sizeof *nan);
nan->len = htons(out->size - start_ofs);
}