Hidden flows, such as in-band control, are not visible when using
OpenFlow to view stats.  However, the OpenFlow Table Stats message would
report them back, which is confusing.  This commit changes the code to
count only visible flows.

Reported-by: Prashant Chougule <[email protected]>
Signed-off-by: Justin Pettit <[email protected]>
---
 AUTHORS           |    1 +
 ofproto/ofproto.c |   19 ++++++++++++++++++-
 tests/ofproto.at  |   28 ++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index f9343de..f026542 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -179,6 +179,7 @@ Paulo Cravero           [email protected]
 Peter Balland           [email protected]
 Peter Phaal             [email protected]
 Prabina Pattnaik        [email protected]
+Prashant Chougule       [email protected]
 Pratap Reddy            [email protected]
 Ralf Heiringhoff        [email protected]
 Ram Jothikumar          [email protected]
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 03ca59b..15b89f5 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -2423,6 +2423,23 @@ handle_desc_stats_request(struct ofconn *ofconn,
     return 0;
 }
 
+static int
+count_visible_rules(struct oftable *table)
+{
+    struct cls_cursor cursor;
+    struct rule *rule;
+    int count = 0;
+
+    cls_cursor_init(&cursor, &table->cls, NULL);
+    CLS_CURSOR_FOR_EACH (rule, cr, &cursor) {
+        if (!ofproto_rule_is_hidden(rule)) {
+            count++;
+        }
+    }
+
+    return count;
+}
+
 static enum ofperr
 handle_table_stats_request(struct ofconn *ofconn,
                            const struct ofp_header *request)
@@ -2454,7 +2471,7 @@ handle_table_stats_request(struct ofconn *ofconn,
         ots[i].instructions = htonl(OFPIT11_ALL);
         ots[i].config = htonl(OFPTC11_TABLE_MISS_MASK);
         ots[i].max_entries = htonl(1000000); /* An arbitrary big number. */
-        ots[i].active_count = htonl(classifier_count(&p->tables[i].cls));
+        ots[i].active_count = htonl(count_visible_rules(&p->tables[i]));
     }
 
     p->ofproto_class->get_tables(p, ots);
diff --git a/tests/ofproto.at b/tests/ofproto.at
index f41bfc3..053a40b 100644
--- a/tests/ofproto.at
+++ b/tests/ofproto.at
@@ -643,6 +643,34 @@ AT_CHECK([ovs-ofctl -O OpenFlow12 dump-tables br0], [0], 
[expout])
 OVS_VSWITCHD_STOP
 AT_CLEANUP
 
+AT_SETUP([ofproto - flow table configuration, with hidden flows (OpenFlow 
1.0)])
+OVS_VSWITCHD_START
+# Check the default configuration.
+(echo "OFPST_TABLE reply (xid=0x2): 254 tables
+  0: classifier: wild=0x3fffff, max=1000000, active=0
+               lookup=0, matched=0"
+ x=1
+ while test $x -lt 254; do
+   printf "  %d: %-8s: wild=0x3fffff, max=1000000, active=0
+               lookup=0, matched=0
+" $x table$x
+   x=`expr $x + 1`
+ done) > expout
+AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
+# Change the configuration.
+AT_CHECK([ovs-vsctl set-controller br0 tcp:127.0.0.1])
+# Check that the configuration was updated.
+mv expout orig-expout
+(echo "OFPST_TABLE reply (xid=0x2): 254 tables
+  0: classifier: wild=0x3fffff, max=1000000, active=0
+               lookup=0, matched=0
+  1: table1  : wild=0x3fffff, max=1000000, active=0
+               lookup=0, matched=0"
+ tail -n +6 orig-expout) > expout
+AT_CHECK([ovs-ofctl dump-tables br0], [0], [expout])
+OVS_VSWITCHD_STOP(["/127.0.0.1/d"])
+AT_CLEANUP
+
 AT_SETUP([ofproto - hard limits on flow table size (OpenFLow 1.0)])
 OVS_VSWITCHD_START
 # Configure a maximum of 4 flows.
-- 
1.7.5.4

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to