ofproto-dpif: Add multiple table support.
authorBen Pfaff <blp@nicira.com>
Thu, 28 Jul 2011 22:25:48 +0000 (15:25 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 9 Aug 2011 16:17:02 +0000 (09:17 -0700)
Tables other than 0 can be modified and dumped, but they are not yet useful
because actions and flow table lookups never use them.

ofproto/ofproto-dpif.c
tests/ofproto.at

index e94cd89..a865d21 100644 (file)
@@ -468,7 +468,7 @@ construct(struct ofproto *ofproto_, int *n_tablesp)
 
     ofproto->has_bundle_action = false;
 
-    *n_tablesp = 1;
+    *n_tablesp = 255;
     return 0;
 }
 
@@ -489,14 +489,18 @@ destruct(struct ofproto *ofproto_)
 {
     struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
     struct rule_dpif *rule, *next_rule;
-    struct cls_cursor cursor;
+    struct classifier *table;
     int i;
 
     complete_operations(ofproto);
 
-    cls_cursor_init(&cursor, &ofproto->up.tables[0], NULL);
-    CLS_CURSOR_FOR_EACH_SAFE (rule, next_rule, up.cr, &cursor) {
-        ofproto_rule_destroy(&rule->up);
+    OFPROTO_FOR_EACH_TABLE (table, &ofproto->up) {
+        struct cls_cursor cursor;
+
+        cls_cursor_init(&cursor, table, NULL);
+        CLS_CURSOR_FOR_EACH_SAFE (rule, next_rule, up.cr, &cursor) {
+            ofproto_rule_destroy(&rule->up);
+        }
     }
 
     for (i = 0; i < MAX_MIRRORS; i++) {
@@ -1744,7 +1748,7 @@ static int
 expire(struct ofproto_dpif *ofproto)
 {
     struct rule_dpif *rule, *next_rule;
-    struct cls_cursor cursor;
+    struct classifier *table;
     int dp_max_idle;
 
     /* Update stats for each flow in the datapath. */
@@ -1755,9 +1759,13 @@ expire(struct ofproto_dpif *ofproto)
     expire_facets(ofproto, dp_max_idle);
 
     /* Expire OpenFlow flows whose idle_timeout or hard_timeout has passed. */
-    cls_cursor_init(&cursor, &ofproto->up.tables[0], NULL);
-    CLS_CURSOR_FOR_EACH_SAFE (rule, next_rule, up.cr, &cursor) {
-        rule_expire(rule);
+    OFPROTO_FOR_EACH_TABLE (table, &ofproto->up) {
+        struct cls_cursor cursor;
+
+        cls_cursor_init(&cursor, table, NULL);
+        CLS_CURSOR_FOR_EACH_SAFE (rule, next_rule, up.cr, &cursor) {
+            rule_expire(rule);
+        }
     }
 
     /* All outstanding data in existing flows has been accounted, so it's a
index ca8a558..66a0650 100644 (file)
@@ -11,7 +11,7 @@ OFPROTO_START
 AT_CHECK([ovs-ofctl -vANY:ANY:WARN show br0], [0], [stdout])
 AT_CHECK([STRIP_XIDS stdout], [0], [dnl
 OFPT_FEATURES_REPLY: ver:0x1, dpid:fedcba9876543210
-n_tables:1, n_buffers:256
+n_tables:255, n_buffers:256
 features: capabilities:0x87, actions:0xfff
  LOCAL(br0): addr:aa:55:aa:55:00:00
      config:     PORT_DOWN
@@ -59,7 +59,7 @@ do
     AT_CHECK([ovs-ofctl -vANY:ANY:WARN show br0], [0], [stdout])
     AT_CHECK_UNQUOTED([STRIP_XIDS stdout], [0], [dnl
 OFPT_FEATURES_REPLY: ver:0x1, dpid:fedcba9876543210
-n_tables:1, n_buffers:256
+n_tables:255, n_buffers:256
 features: capabilities:0x87, actions:0xfff
  LOCAL(br0): addr:aa:55:aa:55:00:00
      config:     $config
@@ -76,16 +76,14 @@ AT_CHECK([ovs-ofctl dump-flows br0 | STRIP_XIDS], [0], [NXST_FLOW reply:
 ])
 AT_CHECK([echo 'in_port=1,actions=0' | ovs-ofctl add-flows br0 -])
 AT_CHECK([ovs-ofctl add-flow br0 in_port=0,actions=1])
-# Check that a table_id is really sent:
-AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=0,actions=1 2>&1 | STRIP_XIDS | sed 1q], [0], [dnl
-OFPT_ERROR: type OFPET_FLOW_MOD_FAILED, code NXFMFC_BAD_TABLE_ID
-])
+AT_CHECK([ovs-ofctl -F nxm add-flow br0 table=1,in_port=3,actions=2])
 AT_CHECK([ovs-ofctl dump-flows br0 | STRIP_XIDS | STRIP_DURATION | sort], [0], [dnl
  cookie=0x0, duration=?s, table=0, n_packets=0, n_bytes=0, in_port=0 actions=output:1
  cookie=0x0, duration=?s, table=0, n_packets=0, n_bytes=0, in_port=1 actions=output:0
+ cookie=0x0, duration=?s, table=1, n_packets=0, n_bytes=0, in_port=3 actions=output:2
 NXST_FLOW reply:
 ])
-AT_CHECK([ovs-ofctl dump-aggregate br0 | STRIP_XIDS], [0], [dnl
+AT_CHECK([ovs-ofctl dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
 NXST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
 ])
 AT_CHECK([ovs-ofctl del-flows br0])
@@ -100,16 +98,14 @@ AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | STRIP_XIDS], [0], [OFPST_FLOW
 ])
 AT_CHECK([echo 'in_port=1,actions=0' | ovs-ofctl -F openflow10 add-flows br0 -])
 AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 in_port=0,actions=1])
-# Check that a table_id is really sent:
-AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=0,actions=1 2>&1 | STRIP_XIDS | sed 1q], [0], [dnl
-OFPT_ERROR: type OFPET_FLOW_MOD_FAILED, code NXFMFC_BAD_TABLE_ID
-])
+AT_CHECK([ovs-ofctl -F openflow10 add-flow br0 table=1,in_port=3,actions=2])
 AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | STRIP_XIDS | STRIP_DURATION | sort], [0], [dnl
  cookie=0x0, duration=?s, table=0, n_packets=0, n_bytes=0, in_port=0 actions=output:1
  cookie=0x0, duration=?s, table=0, n_packets=0, n_bytes=0, in_port=1 actions=output:0
+ cookie=0x0, duration=?s, table=1, n_packets=0, n_bytes=0, in_port=3 actions=output:2
 OFPST_FLOW reply:
 ])
-AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 | STRIP_XIDS], [0], [dnl
+AT_CHECK([ovs-ofctl -F openflow10 dump-aggregate br0 table=0 | STRIP_XIDS], [0], [dnl
 OFPST_AGGREGATE reply: packet_count=0 byte_count=0 flow_count=2
 ])
 AT_CHECK([ovs-ofctl -F openflow10 del-flows br0])