Make duration in ofp_flow_stats a 32-bit quantity (instead of 16).
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 15 Apr 2008 03:20:20 +0000 (20:20 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 15 Apr 2008 16:56:41 +0000 (09:56 -0700)
Otherwise duration is capped at under 24 hours.

Suggested by Justin.

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

index 5cd6c40c283e9b0ea1b1f256bf3b7e05301a65ae..3160ba7c28bcbd67c952bf103ae2b28ca75d4025 100644 (file)
@@ -752,8 +752,6 @@ static void
 fill_flow_stats(struct ofp_flow_stats *ofs, struct sw_flow *flow,
                int table_idx)
 {
-       int duration;
-       
        ofs->match.wildcards = htons(flow->key.wildcards);
        ofs->match.in_port   = flow->key.in_port;
        memcpy(ofs->match.dl_src, flow->key.dl_src, ETH_ALEN);
@@ -766,8 +764,7 @@ fill_flow_stats(struct ofp_flow_stats *ofs, struct sw_flow *flow,
        memset(ofs->match.pad, 0, sizeof ofs->match.pad);
        ofs->match.tp_src    = flow->key.tp_src;
        ofs->match.tp_dst    = flow->key.tp_dst;
-       duration = (jiffies - flow->init_time) / HZ;
-       ofs->duration        = htons(min(65535, duration));
+       ofs->duration        = htonl((jiffies - flow->init_time) / HZ);
        ofs->table_id        = htons(table_idx);
        ofs->packet_count    = cpu_to_be64(flow->packet_count);
        ofs->byte_count      = cpu_to_be64(flow->byte_count);
index 7a85cf557d0ccd420d65d1d5bd82aabdf8145f11..d9c22f221c4792e0df4b1719691373bc723ce0ed 100644 (file)
@@ -348,11 +348,12 @@ struct ofp_flow_expired {
 /* Statistics about flows that match the "match" field */
 struct ofp_flow_stats {
     struct ofp_match match;   /* Description of fields */
-    uint16_t duration;        /* Time flow has been alive in seconds.  Only 
+    uint32_t duration;        /* Time flow has been alive in seconds.  Only 
                                  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. */
-    uint64_t packet_count;
-    uint64_t byte_count;
+    uint8_t pad[6];           /* Align to 64-bits. */
 };
 
 enum ofp_stat_type {
index c728b5d4ac1695e2fc9100807771e763bf288847..11d1839acf359a6ba95a40acda32ccc80da79fa5 100644 (file)
@@ -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, "  duration=%"PRIu16" s, ", ntohs(fs->duration));
-        ds_put_format(string, "table_id=%"PRIu16", ", ntohs(fs->table_id));
+        ds_put_format(string, "  table_id=%"PRIu16", ", ntohs(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);
      }
 }
index 0d8ee05f564d54e778b1ca4429c0279f2ed03206..a4c691980623b9130f6b088e792cf1c86bee93fc 100644 (file)
@@ -632,8 +632,6 @@ static void
 fill_flow_stats(struct ofp_flow_stats *ofs, struct sw_flow *flow,
                 int table_idx, time_t now)
 {
-       int duration;
-
        ofs->match.wildcards = htons(flow->key.wildcards);
        ofs->match.in_port   = flow->key.flow.in_port;
        memcpy(ofs->match.dl_src, flow->key.flow.dl_src, ETH_ADDR_LEN);
@@ -646,8 +644,7 @@ fill_flow_stats(struct ofp_flow_stats *ofs, struct sw_flow *flow,
        memset(ofs->match.pad, 0, sizeof ofs->match.pad);
        ofs->match.tp_src    = flow->key.flow.tp_src;
        ofs->match.tp_dst    = flow->key.flow.tp_dst;
-       duration = now - flow->created;
-       ofs->duration        = htons(MIN(65535, duration));
+       ofs->duration        = htonl(now - flow->created);
        ofs->table_id        = htons(table_idx);
        ofs->packet_count    = htonll(flow->packet_count);
        ofs->byte_count      = htonll(flow->byte_count);