+static uint32_t
+hash_cookie(ovs_be64 cookie)
+{
+ return hash_2words((OVS_FORCE uint64_t)cookie >> 32,
+ (OVS_FORCE uint64_t)cookie);
+}
+
+static void
+cookies_insert(struct ofproto *ofproto, struct rule *rule)
+{
+ hindex_insert(&ofproto->cookies, &rule->cookie_node,
+ hash_cookie(rule->flow_cookie));
+}
+
+static void
+cookies_remove(struct ofproto *ofproto, struct rule *rule)
+{
+ hindex_remove(&ofproto->cookies, &rule->cookie_node);
+}
+
+static void
+ofproto_rule_change_cookie(struct ofproto *ofproto, struct rule *rule,
+ ovs_be64 new_cookie)
+{
+ if (new_cookie != rule->flow_cookie) {
+ cookies_remove(ofproto, rule);
+
+ rule->flow_cookie = new_cookie;
+
+ cookies_insert(ofproto, rule);
+ }
+}
+