ofproto: Allow ->rule_choose_table() to be NULL regardless of table count.
authorBen Pfaff <blp@nicira.com>
Thu, 28 Jul 2011 22:01:20 +0000 (15:01 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 8 Aug 2011 23:05:35 +0000 (16:05 -0700)
In the upcoming software switch implementation of multiple tables, there is
no reason to prefer one table over another, so we always put rules into
table 0 by default.  This commit allows this to be done simply by
specifying NULL as ->rule_choose_table().

ofproto/ofproto-provider.h
ofproto/ofproto.c

index 985f112..f46ff84 100644 (file)
@@ -598,8 +598,7 @@ struct ofproto_class {
      * If multiple tables are candidates for inserting the flow, the function
      * should choose one arbitrarily (but deterministically).
      *
-     * This function will never be called for an ofproto that has only one
-     * table, so it may be NULL in that case. */
+     * If this function is NULL then table 0 is always chosen. */
     int (*rule_choose_table)(const struct ofproto *ofproto,
                              const struct cls_rule *cls_rule,
                              uint8_t *table_idp);
index 4d4c232..8d22c50 100644 (file)
@@ -2182,7 +2182,7 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn, struct flow_mod *fm,
     /* Pick table. */
     if (fm->table_id == 0xff) {
         uint8_t table_id;
-        if (ofproto->n_tables > 1) {
+        if (ofproto->ofproto_class->rule_choose_table) {
             error = ofproto->ofproto_class->rule_choose_table(ofproto, &fm->cr,
                                                               &table_id);
             if (error) {