Make table_id in OpenFlow messages 8 bits, since 255 should be enough.
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 15 Apr 2008 16:33:07 +0000 (09:33 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 15 Apr 2008 16:56:46 +0000 (09:56 -0700)
Suggested by Justin.

datapath/datapath.c
include/openflow.h
lib/ofp-print.c
switch/datapath.c
utilities/dpctl.c

index 3160ba7c28bcbd67c952bf103ae2b28ca75d4025..0a266cb452712f33b8b96a60b31f88f0201eb34c 100644 (file)
@@ -765,7 +765,7 @@ fill_flow_stats(struct ofp_flow_stats *ofs, struct sw_flow *flow,
        ofs->match.tp_src    = flow->key.tp_src;
        ofs->match.tp_dst    = flow->key.tp_dst;
        ofs->duration        = htonl((jiffies - flow->init_time) / HZ);
-       ofs->table_id        = htons(table_idx);
+       ofs->table_id        = table_idx;
        ofs->packet_count    = cpu_to_be64(flow->packet_count);
        ofs->byte_count      = cpu_to_be64(flow->byte_count);
 }
@@ -885,7 +885,7 @@ dp_send_table_stats(struct datapath *dp, const struct sender *sender)
                struct sw_table_stats stats;
                dp->chain->tables[i]->stats(dp->chain->tables[i], &stats);
                strncpy(ots->name, stats.name, sizeof ots->name);
-               ots->table_id = htons(i);
+               ots->table_id = i;
                ots->pad[0] = ots->pad[1] = 0;
                ots->max_entries = htonl(stats.max_flows);
                ots->active_count = htonl(stats.n_flows);
index d9c22f221c4792e0df4b1719691373bc723ce0ed..4969cea8f3ac30556ada2a5657ecf7869289e98d 100644 (file)
@@ -352,8 +352,8 @@ struct ofp_flow_stats {
                                  used for non-aggregated results. */
     uint64_t packet_count;    /* Number of packets in flow. */
     uint64_t byte_count;      /* Number of bytes in flow. */
-    uint16_t table_id;        /* ID of table flow came from. */
-    uint8_t pad[6];           /* Align to 64-bits. */
+    uint8_t table_id;         /* ID of table flow came from. */
+    uint8_t pad[7];           /* Align to 64-bits. */
 };
 
 enum ofp_stat_type {
@@ -365,10 +365,10 @@ enum ofp_stat_type {
 struct ofp_flow_stat_request {
     struct ofp_header header;
     struct ofp_match match;   /* Fields to match */
-    uint16_t table_id;        /* ID of table to read (from ofp_table_stats)
+    uint8_t table_id;         /* ID of table to read (from ofp_table_stats)
                                  or 0xffff for all tables. */
     uint8_t type;             /* One of OFPFS_ */
-    uint8_t pad;              /* Align to 32-bits */
+    uint16_t pad;               /* Align to 32-bits */
 };
 
 /* Current flow statistics reply */
@@ -392,8 +392,8 @@ struct ofp_table_stat_request {
 
 /* Statistics about a particular table */
 struct ofp_table_stats {
-    uint16_t table_id;
-    uint8_t pad[2];          /* Align to 32-bits */
+    uint8_t table_id;
+    uint8_t pad[3];          /* Align to 32-bits */
     char name[OFP_MAX_TABLE_NAME_LEN];
     uint32_t max_entries;    /* Max number of entries supported */
     uint32_t active_count;   /* Number of active entries */
index 11d1839acf359a6ba95a40acda32ccc80da79fa5..8b056fd9ea3420343700dacc8f5afd7dde0c323f 100644 (file)
@@ -433,10 +433,10 @@ ofp_flow_stat_request(struct ds *string, const void *oh, size_t len,
 {
     const struct ofp_flow_stat_request *fsr = oh;
 
-    if (fsr->table_id == htons(0xffff)) {
+    if (fsr->table_id == 0xff) {
         ds_put_format(string, " table_id=any, ");
     } else {
-        ds_put_format(string, " table_id=%"PRIu16", ", ntohs(fsr->table_id));
+        ds_put_format(string, " table_id=%"PRIu8", ", fsr->table_id);
     }
 
     if (fsr->type == OFPFS_INDIV) {
@@ -464,11 +464,11 @@ ofp_flow_stat_reply(struct ds *string, const void *oh, size_t len,
     }
 
     for (fs = &fsr->flows[0]; fs < &fsr->flows[n]; fs++) {
-        ds_put_format(string, "  table_id=%"PRIu16", ", ntohs(fs->table_id));
+        ds_put_format(string, "  duration=%"PRIu32" s, ", ntohs(fs->duration));
+        ds_put_format(string, "table_id=%"PRIu8", ", fs->table_id);
         ds_put_format(string, "n_packets=%"PRIu64", ",
                       ntohll(fs->packet_count));
         ds_put_format(string, "n_bytes=%"PRIu64", ", ntohll(fs->byte_count));
-        ds_put_format(string, "duration=%"PRIu32" s, ", ntohl(fs->duration));
         ofp_print_match(string, &fs->match);
      }
 }
@@ -514,7 +514,7 @@ ofp_table_stat_reply(struct ds *string, const void *oh, size_t len,
         strncpy(name, ts->name, sizeof name);
         name[OFP_MAX_TABLE_NAME_LEN] = '\0';
 
-        ds_put_format(string, "  table %"PRIu16": ", ntohs(ts->table_id));
+        ds_put_format(string, "  table %"PRIu8": ", ts->table_id);
         ds_put_format(string, "name %-8s, ", name);
         ds_put_format(string, "max %6"PRIu32", ", ntohl(ts->max_entries));
         ds_put_format(string, "active %6"PRIu32", ", ntohl(ts->active_count));
index a4c691980623b9130f6b088e792cf1c86bee93fc..2055e094f1884e35d50dedb827402c911325c09a 100644 (file)
@@ -645,7 +645,7 @@ fill_flow_stats(struct ofp_flow_stats *ofs, struct sw_flow *flow,
        ofs->match.tp_src    = flow->key.flow.tp_src;
        ofs->match.tp_dst    = flow->key.flow.tp_dst;
        ofs->duration        = htonl(now - flow->created);
-       ofs->table_id        = htons(table_idx);
+       ofs->table_id        = table_idx;
        ofs->packet_count    = htonll(flow->packet_count);
        ofs->byte_count      = htonll(flow->byte_count);
 }
@@ -735,7 +735,7 @@ dp_send_table_stats(struct datapath *dp, const struct sender *sender)
                struct sw_table_stats stats;
                dp->chain->tables[i]->stats(dp->chain->tables[i], &stats);
                strncpy(ots->name, stats.name, sizeof ots->name);
-               ots->table_id = htons(i);
+               ots->table_id = i;
                ots->pad[0] = ots->pad[1] = 0;
                ots->max_entries = htonl(stats.max_flows);
                ots->active_count = htonl(stats.n_flows);
index f4404259f7cdda5153e60cb4bf45f999c41daf13..80808acfd57f6b8cada23544a27a2d0e09e37619 100644 (file)
@@ -455,7 +455,7 @@ str_to_action(const char *str, struct ofp_action *action)
 
 static void
 str_to_flow(char *string, struct ofp_match *match, struct ofp_action *action,
-            uint16_t *table_idx)
+            uint8_t *table_idx)
 {
     struct field {
         const char *name;
@@ -483,7 +483,7 @@ str_to_flow(char *string, struct ofp_match *match, struct ofp_action *action,
     bool got_action = false;
 
     if (table_idx) {
-        *table_idx = htons(0xffff);
+        *table_idx = 0xff;
     }
     memset(match, 0, sizeof *match);
     wildcards = OFPFW_ALL;
@@ -501,7 +501,7 @@ str_to_flow(char *string, struct ofp_match *match, struct ofp_action *action,
         }
 
         if (table_idx && !strcmp(name, "table")) {
-            *table_idx = htons(atoi(value));
+            *table_idx = atoi(value);
             continue;
         }