/* A subrule has no actions (it uses the super-rule's actions). */
int n_actions;
- union ofp_action actions[];
+ union ofp_action *actions;
};
static void rule_destroy(struct rule *);
-static inline size_t rule_size(int n_actions);
static struct rule *rule_from_cls_rule(const struct cls_rule *);
static void rule_make_actions(struct ofproto *,
const struct rule *, struct odp_actions *);
struct odp_actions odp_actions;
struct odp_flow odp_flow;
- rule = xmalloc(rule_size(n_actions));
+ rule = xmalloc(sizeof *rule);
cls_rule_from_flow(&rule->cr, flow, 0, UINT16_MAX);
rule->idle_timeout = 5; /* XXX */
rule->hard_timeout = 0; /* XXX */
rule->super = NULL; /* XXX */
list_init(&rule->list);
rule->n_actions = n_actions;
- memcpy(rule->actions, actions, n_actions * sizeof *rule->actions);
+ rule->actions = xmemdup(actions, n_actions * sizeof *rule->actions);
displaced_rule = rule_from_cls_rule(classifier_insert(&p->cls, &rule->cr));
if (displaced_rule) {
} else if (rule->super != UNKNOWN_SUPER) {
list_remove(&rule->list);
}
+ free(rule->actions);
free(rule);
}
struct rule *rule, *displaced_rule;
int buffer_error = 0;
- rule = xmalloc(rule_size(n_actions));
+ rule = xmalloc(sizeof *rule);
cls_rule_from_match(&rule->cr, &ofm->match, ntohs(ofm->priority));
rule->idle_timeout = ntohs(ofm->idle_timeout);
rule->hard_timeout = ntohs(ofm->hard_timeout);
rule->super = NULL;
list_init(&rule->list);
rule->n_actions = n_actions;
- memcpy(rule->actions, ofm->actions, n_actions * sizeof *rule->actions);
+ rule->actions = xmemdup(ofm->actions, n_actions * sizeof *rule->actions);
if (ofm->buffer_id != htonl(UINT32_MAX)) {
int byte_count = 0;
classifier_remove(&p->cls, &rule->cr);
rule_destroy(rule);
} else {
- struct rule *old_rule = rule;
if (!rule->cr.wc.wildcards) {
struct odp_flow odp_flow;
struct odp_actions actions;
update_stats(rule, &odp_flow.stats);
}
- rule = xrealloc(rule, rule_size(n_actions));
+ free(rule->actions);
+ rule->actions = xmemdup(ofm->actions,
+ n_actions * sizeof *rule->actions);
rule->n_actions = n_actions;
- memcpy(rule->actions, ofm->actions, n_actions * sizeof *rule->actions);
- cls_rule_moved(&p->cls, &old_rule->cr, &rule->cr);
}
return 0;
subrule->ip_tos = 0;
subrule->super = rule;
subrule->n_actions = 0;
+ subrule->actions = NULL;
old_sr = rule_from_cls_rule(classifier_insert(&p->cls, &subrule->cr));
if (old_sr) {