summaryrefslogtreecommitdiff
path: root/lib/ovs-router.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2018-01-30 13:00:31 -0800
committerBen Pfaff <blp@ovn.org>2018-01-31 11:19:21 -0800
commit46ab60bfe562f3ee6cde94888930e9ef9130831f (patch)
tree7424408bea0389686c26e14d9290236d51025587 /lib/ovs-router.c
parent186667a83c2b09ed9ae08b35c596987cf7d33cfb (diff)
downloadopenvswitch-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 'lib/ovs-router.c')
-rw-r--r--lib/ovs-router.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/ovs-router.c b/lib/ovs-router.c
index cd2ab15fb..e6cc81fd0 100644
--- a/lib/ovs-router.c
+++ b/lib/ovs-router.c
@@ -245,19 +245,14 @@ ovs_router_insert(uint32_t mark, const struct in6_addr *ip_dst, uint8_t plen,
ovs_router_insert__(mark, plen, ip_dst, plen, output_bridge, gw);
}
-static bool
-__rt_entry_delete(const struct cls_rule *cr)
+static void
+rt_entry_delete__(const struct cls_rule *cr)
{
struct ovs_router_entry *p = ovs_router_entry_cast(cr);
tnl_port_map_delete_ipdev(p->output_bridge);
- /* Remove it. */
- cr = classifier_remove(&cls, cr);
- if (cr) {
- ovsrcu_postpone(rt_entry_free, ovs_router_entry_cast(cr));
- return true;
- }
- return false;
+ classifier_remove_assert(&cls, cr);
+ ovsrcu_postpone(rt_entry_free, ovs_router_entry_cast(cr));
}
static bool
@@ -277,8 +272,10 @@ rt_entry_delete(uint32_t mark, uint8_t priority,
cr = classifier_find_rule_exactly(&cls, &rule, OVS_VERSION_MAX);
if (cr) {
ovs_mutex_lock(&mutex);
- res = __rt_entry_delete(cr);
+ rt_entry_delete__(cr);
ovs_mutex_unlock(&mutex);
+
+ res = true;
}
cls_rule_destroy(&rule);
@@ -476,7 +473,7 @@ ovs_router_flush(void)
classifier_defer(&cls);
CLS_FOR_EACH(rt, cr, &cls) {
if (rt->priority == rt->plen) {
- __rt_entry_delete(&rt->cr);
+ rt_entry_delete__(&rt->cr);
}
}
classifier_publish(&cls);