[ovs-dev] [PATCH] revalidator: Simplify push_dump_ops__().

Joe Stringer joestringer at nicira.com
Tue Jul 1 01:54:18 UTC 2014


Commit acaa8dac49 (revalidator: Eliminate duplicate flow handling.)
ensured that a ukey will always exist for a given flow, even if it is
about to be deleted. This means that push_dump_ops__() no longer needs
to handle the case where there is no ukey. This commit removes the
redundant code.

Signed-off-by: Joe Stringer <joestringer at nicira.com>
---
 ofproto/ofproto-dpif-upcall.c |   39 ++++++++++++++++++---------------------
 1 file changed, 18 insertions(+), 21 deletions(-)

diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index 87c2200..f0ddf63 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -1281,38 +1281,35 @@ push_dump_ops__(struct udpif *udpif, struct dump_op *ops, size_t n_ops)
         struct dpif_flow_stats *push, *stats, push_buf;
 
         stats = op->op.u.flow_del.stats;
-        if (op->ukey) {
-            push = &push_buf;
-            ovs_mutex_lock(&op->ukey->mutex);
-            push->used = MAX(stats->used, op->ukey->stats.used);
-            push->tcp_flags = stats->tcp_flags | op->ukey->stats.tcp_flags;
-            push->n_packets = stats->n_packets - op->ukey->stats.n_packets;
-            push->n_bytes = stats->n_bytes - op->ukey->stats.n_bytes;
-            ovs_mutex_unlock(&op->ukey->mutex);
-        } else {
-            push = stats;
-        }
+        push = &push_buf;
+
+        ovs_mutex_lock(&op->ukey->mutex);
+        push->used = MAX(stats->used, op->ukey->stats.used);
+        push->tcp_flags = stats->tcp_flags | op->ukey->stats.tcp_flags;
+        push->n_packets = stats->n_packets - op->ukey->stats.n_packets;
+        push->n_bytes = stats->n_bytes - op->ukey->stats.n_bytes;
+        ovs_mutex_unlock(&op->ukey->mutex);
 
         if (push->n_packets || netflow_exists()) {
             struct ofproto_dpif *ofproto;
             struct netflow *netflow;
             struct flow flow;
             bool may_learn;
+            int error;
 
             may_learn = push->n_packets > 0;
-            if (op->ukey) {
-                ovs_mutex_lock(&op->ukey->mutex);
-                if (op->ukey->xcache) {
-                    xlate_push_stats(op->ukey->xcache, may_learn, push);
-                    ovs_mutex_unlock(&op->ukey->mutex);
-                    continue;
-                }
+            ovs_mutex_lock(&op->ukey->mutex);
+            if (op->ukey->xcache) {
+                xlate_push_stats(op->ukey->xcache, may_learn, push);
                 ovs_mutex_unlock(&op->ukey->mutex);
+                continue;
             }
+            ovs_mutex_unlock(&op->ukey->mutex);
 
-            if (!xlate_receive(udpif->backer, NULL, op->op.u.flow_del.key,
-                               op->op.u.flow_del.key_len, &flow, &ofproto,
-                               NULL, NULL, &netflow, NULL)) {
+            error = xlate_receive(udpif->backer, NULL, op->op.u.flow_del.key,
+                                  op->op.u.flow_del.key_len, &flow, &ofproto,
+                                  NULL, NULL, &netflow, NULL);
+            if (!error) {
                 struct xlate_in xin;
 
                 xlate_in_init(&xin, ofproto, &flow, NULL, push->tcp_flags,
-- 
1.7.10.4




More information about the dev mailing list