From 2b7b1427c177d28ec63632646ce896eec7f162b6 Mon Sep 17 00:00:00 2001 From: Jarno Rajahalme Date: Tue, 9 Jun 2015 17:00:00 -0700 Subject: classifier: Support table versioning This patch allows classifier rules to become visible and invisible in specific versions. A 'version' is defined as a positive monotonically increasing integer, which never wraps around. The new 'visibility' attribute replaces the prior 'to_be_removed' and 'visible' attributes. When versioning is not used, the 'version' parameter should be passed as 'CLS_MIN_VERSION' when creating rules, and 'CLS_MAX_VERSION' when looking up flows. This feature enables the support for atomic OpenFlow bundles without significant performance penalty on 64-bit systems. There is a performance decrease in 32-bit systems due to 64-bit atomics used. Signed-off-by: Jarno Rajahalme Acked-by: Ben Pfaff --- lib/tnl-ports.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/tnl-ports.c') diff --git a/lib/tnl-ports.c b/lib/tnl-ports.c index 759d6ba33..2602db543 100644 --- a/lib/tnl-ports.c +++ b/lib/tnl-ports.c @@ -84,7 +84,7 @@ tnl_port_map_insert(odp_port_t port, ovs_be32 ip_dst, ovs_be16 udp_port, ovs_mutex_lock(&mutex); do { - cr = classifier_lookup(&cls, &match.flow, NULL); + cr = classifier_lookup(&cls, CLS_MAX_VERSION, &match.flow, NULL); p = tnl_port_cast(cr); /* Try again if the rule was released before we get the reference. */ } while (p && !ovs_refcount_try_ref_rcu(&p->ref_cnt)); @@ -99,7 +99,7 @@ tnl_port_map_insert(odp_port_t port, ovs_be32 ip_dst, ovs_be16 udp_port, match.wc.masks.tp_dst = OVS_BE16_MAX; match.wc.masks.nw_src = OVS_BE32_MAX; - cls_rule_init(&p->cr, &match, 0); /* Priority == 0. */ + cls_rule_init(&p->cr, &match, 0, CLS_MIN_VERSION); /* Priority == 0. */ ovs_refcount_init(&p->ref_cnt); ovs_strlcpy(p->dev_name, dev_name, sizeof p->dev_name); @@ -130,7 +130,7 @@ tnl_port_map_delete(ovs_be32 ip_dst, ovs_be16 udp_port) tnl_port_init_flow(&flow, ip_dst, udp_port); - cr = classifier_lookup(&cls, &flow, NULL); + cr = classifier_lookup(&cls, CLS_MAX_VERSION, &flow, NULL); tnl_port_unref(cr); } @@ -139,7 +139,8 @@ tnl_port_map_delete(ovs_be32 ip_dst, ovs_be16 udp_port) odp_port_t tnl_port_map_lookup(struct flow *flow, struct flow_wildcards *wc) { - const struct cls_rule *cr = classifier_lookup(&cls, flow, wc); + const struct cls_rule *cr = classifier_lookup(&cls, CLS_MAX_VERSION, flow, + wc); return (cr) ? tnl_port_cast(cr)->portno : ODPP_NONE; } -- cgit v1.2.1