ofproto: Factor out ofproto_rule_insert__().
authorJarno Rajahalme <jrajahalme@nicira.com>
Fri, 29 May 2015 18:28:38 +0000 (11:28 -0700)
committerJarno Rajahalme <jrajahalme@nicira.com>
Tue, 2 Jun 2015 01:07:39 +0000 (18:07 -0700)
Pairs well with ofproto_rule_remove__().

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto.c

index 0a8c82a..95afc24 100644 (file)
@@ -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);
 
@@ -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);
 
@@ -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