Skip to content

Commit

Permalink
ofproto: Factor out ofproto_rule_insert__().
Browse files Browse the repository at this point in the history
Pairs well with ofproto_rule_remove__().

Signed-off-by: Jarno Rajahalme <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
Jarno Rajahalme committed Jun 2, 2015
1 parent ff09bc0 commit bc5e6a9
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions ofproto/ofproto.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ struct ofport_usage {
/* rule. */
static void ofproto_rule_send_removed(struct rule *, uint8_t reason);
static bool rule_is_readonly(const struct rule *);
static void ofproto_rule_insert__(struct ofproto *, struct rule *)
OVS_REQUIRES(ofproto_mutex);
static void ofproto_rule_remove__(struct ofproto *, struct rule *)
OVS_REQUIRES(ofproto_mutex);

Expand Down Expand Up @@ -4408,14 +4410,7 @@ add_flow(struct ofproto *ofproto, struct ofputil_flow_mod *fm,
return error;
}

if (fm->hard_timeout || fm->idle_timeout) {
list_insert(&ofproto->expirable, &rule->expirable);
}
cookies_insert(ofproto, rule);
eviction_group_add_rule(rule);
if (actions->has_meter) {
meter_insert_rule(rule);
}
ofproto_rule_insert__(ofproto, rule);

classifier_defer(&table->cls);

Expand Down Expand Up @@ -7014,6 +7009,24 @@ oftable_enable_eviction(struct oftable *table,
}
}

/* Inserts 'rule' from the ofproto data structures BEFORE caller has inserted
* it to the classifier. */
static void
ofproto_rule_insert__(struct ofproto *ofproto, struct rule *rule)
OVS_REQUIRES(ofproto_mutex)
{
const struct rule_actions *actions = rule_get_actions(rule);

if (rule->hard_timeout || rule->idle_timeout) {
list_insert(&ofproto->expirable, &rule->expirable);
}
cookies_insert(ofproto, rule);
eviction_group_add_rule(rule);
if (actions->has_meter) {
meter_insert_rule(rule);
}
}

/* Removes 'rule' from the ofproto data structures AFTER caller has removed
* it from the classifier. */
static void
Expand Down

0 comments on commit bc5e6a9

Please sign in to comment.