secchan: Make NetFlow work with any flow, not just exact-match.
authorBen Pfaff <blp@nicira.com>
Wed, 18 Mar 2009 23:32:19 +0000 (16:32 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 18 Mar 2009 23:39:23 +0000 (16:39 -0700)
NetFlow only worked with exact-match flows until now.  This commit extends
it to also work with wildcarded flows, which is increasingly important now
that NOX sets up a lot of these.

secchan/ofproto.c

index 781cd98c892792b8d5378c00495186d73fb47e47..979dfeaaa602719787dd48f6ee2db0c167b6bde0 100644 (file)
@@ -997,9 +997,6 @@ ofproto_delete_flow(struct ofproto *ofproto, const flow_t *flow,
     if (rule) {
         classifier_remove(&ofproto->cls, &rule->cr);
         rule_destroy(rule);
-        /* We don't call back to the flow_expired_cb because our caller would
-         * explode, but perhaps we should fix that.  At any rate should we sent
-         * out a netflow message? */
     }
 }
 
@@ -1452,6 +1449,18 @@ rule_uninstall(struct ofproto *p, struct rule *rule)
                          ? rule->super : rule, &odp_flow.stats);
         }
         rule->installed = false;
+
+        if (p->netflow) {
+            struct ofexpired expired;
+            expired.flow = rule->cr.flow;
+            expired.packet_count = rule->packet_count;
+            expired.byte_count = rule->byte_count;
+            expired.used = rule->used;
+            expired.created = rule->created;
+            expired.tcp_flags = rule->tcp_flags;
+            expired.ip_tos = rule->ip_tos;
+            netflow_expire(p->netflow, &expired);
+        }
     }
 }
 \f
@@ -2905,26 +2914,6 @@ send_flow_exp(struct ofproto *p, struct rule *rule,
     if (prev) {
         queue_tx(buf, prev);
     }
-
-    if (!rule->cr.wc.wildcards
-        && (p->netflow || p->ofhooks->flow_expired_cb)) {
-        struct ofexpired expired;
-        expired.flow = rule->cr.flow;
-        expired.packet_count = rule->packet_count;
-        expired.byte_count = rule->byte_count;
-        expired.used = rule->used;
-        expired.created = rule->created;
-        expired.tcp_flags = rule->tcp_flags;
-        expired.ip_tos = rule->ip_tos;
-
-        if (p->netflow) {
-            netflow_expire(p->netflow, &expired);
-        }
-
-        if (p->ofhooks->flow_expired_cb) {
-            p->ofhooks->flow_expired_cb(&expired, p->aux);
-        }
-    }
 }
 
 static void