Otherwise duration is capped at under 24 hours.
Suggested by Justin.
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);
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);
/* 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 {
}
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);
}
}
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);
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);