diff options
author | Ben Pfaff <blp@ovn.org> | 2018-01-30 13:00:31 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-01-31 11:19:21 -0800 |
commit | 46ab60bfe562f3ee6cde94888930e9ef9130831f (patch) | |
tree | 7424408bea0389686c26e14d9290236d51025587 /ofproto | |
parent | 186667a83c2b09ed9ae08b35c596987cf7d33cfb (diff) | |
download | openvswitch-46ab60bfe562f3ee6cde94888930e9ef9130831f.tar.gz |
classifier: Refactor interface for classifier_remove().
Until now, classifier_remove() returned either null or the classifier rule
passed to it, which is an unusual interface. This commit changes it to
return true if it succeeds or false on failure.
In addition, most of classifier_remove()'s callers know ahead of time that
it must succeed, even though most of them didn't bother with an assertion,
so this commit adds a classifier_remove_assert() function as a helper.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Yifeng Sun <pkusunyifeng@gmail.com>
Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>
Diffstat (limited to 'ofproto')
-rw-r--r-- | ofproto/ofproto.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 4f17f79d2..536636393 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1520,10 +1520,8 @@ ofproto_rule_delete(struct ofproto *ofproto, struct rule *rule) /* Make sure there is no postponed removal of the rule. */ ovs_assert(cls_rule_visible_in_version(&rule->cr, OVS_VERSION_MAX)); - if (!classifier_remove(&rule->ofproto->tables[rule->table_id].cls, - &rule->cr)) { - OVS_NOT_REACHED(); - } + classifier_remove_assert(&rule->ofproto->tables[rule->table_id].cls, + &rule->cr); ofproto_rule_remove__(rule->ofproto, rule); if (ofproto->ofproto_class->rule_delete) { ofproto->ofproto_class->rule_delete(rule); @@ -2885,9 +2883,7 @@ remove_rule_rcu__(struct rule *rule) struct oftable *table = &ofproto->tables[rule->table_id]; ovs_assert(!cls_rule_visible_in_version(&rule->cr, OVS_VERSION_MAX)); - if (!classifier_remove(&table->cls, &rule->cr)) { - OVS_NOT_REACHED(); - } + classifier_remove_assert(&table->cls, &rule->cr); if (ofproto->ofproto_class->rule_delete) { ofproto->ofproto_class->rule_delete(rule); } @@ -5231,9 +5227,7 @@ replace_rule_revert(struct ofproto *ofproto, } /* Remove the new rule immediately. It was never visible to lookups. */ - if (!classifier_remove(&table->cls, &new_rule->cr)) { - OVS_NOT_REACHED(); - } + classifier_remove_assert(&table->cls, &new_rule->cr); ofproto_rule_remove__(ofproto, new_rule); ofproto_rule_unref(new_rule); } |