ofproto: Simplify send_flow_removed().
authorBen Pfaff <blp@nicira.com>
Mon, 18 Oct 2010 23:15:50 +0000 (16:15 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 5 Nov 2010 16:25:38 +0000 (09:25 -0700)
I have no evidence that the optimization in this function is valuable.
An upcoming commit will introduce a new form of flow expiration message
that is sent to controllers that ask for it, while the standard OpenFlow
1.0 message is sent to other controllers.  Since retaining this
optimization with that logic would complicate the function, this commit
drops it.

ofproto/ofproto.c

index c949fde381c4f242b64f6347bdbc58ac02b17d06..b35139cbafdde42cea58ca6369af111311349805 100644 (file)
@@ -4543,8 +4543,6 @@ send_flow_removed(struct ofproto *p, struct rule *rule,
                   long long int now, uint8_t reason)
 {
     struct ofconn *ofconn;
-    struct ofconn *prev;
-    struct ofpbuf *buf = NULL;
 
     if (!rule->send_flow_removed) {
         return;
@@ -4556,20 +4554,16 @@ send_flow_removed(struct ofproto *p, struct rule *rule,
      * being added (and expiring).  (It also prevents processing OpenFlow
      * requests that would not add new flows, so it is imperfect.) */
 
-    prev = NULL;
     LIST_FOR_EACH (ofconn, node, &p->all_conns) {
-        if (rconn_is_connected(ofconn->rconn)
-            && ofconn_receives_async_msgs(ofconn)) {
-            if (prev) {
-                queue_tx(ofpbuf_clone(buf), prev, prev->reply_counter);
-            } else {
-                buf = compose_flow_removed(p, rule, now, reason);
-            }
-            prev = ofconn;
+        struct ofpbuf *msg;
+
+        if (!rconn_is_connected(ofconn->rconn)
+            || !ofconn_receives_async_msgs(ofconn)) {
+            continue;
         }
-    }
-    if (prev) {
-        queue_tx(buf, prev, prev->reply_counter);
+
+        msg = compose_flow_removed(p, rule, now, reason);
+        queue_tx(msg, ofconn, ofconn->reply_counter);
     }
 }