From: Ben Pfaff Date: Tue, 15 Apr 2008 03:20:20 +0000 (-0700) Subject: Make duration in ofp_flow_stats a 32-bit quantity (instead of 16). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a1a6679735dfab65ab4903d7547d2a269029b56;p=openvswitch Make duration in ofp_flow_stats a 32-bit quantity (instead of 16). Otherwise duration is capped at under 24 hours. Suggested by Justin. --- diff --git a/datapath/datapath.c b/datapath/datapath.c index 5cd6c40c..3160ba7c 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -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); diff --git a/include/openflow.h b/include/openflow.h index 7a85cf55..d9c22f22 100644 --- a/include/openflow.h +++ b/include/openflow.h @@ -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 { diff --git a/lib/ofp-print.c b/lib/ofp-print.c index c728b5d4..11d1839a 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -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); } } diff --git a/switch/datapath.c b/switch/datapath.c index 0d8ee05f..a4c69198 100644 --- a/switch/datapath.c +++ b/switch/datapath.c @@ -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);