From: Ben Pfaff Date: Tue, 15 Apr 2008 16:33:07 +0000 (-0700) Subject: Make table_id in OpenFlow messages 8 bits, since 255 should be enough. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2552c15f34eb5ed86db02820599a65493e39ca7;p=openvswitch Make table_id in OpenFlow messages 8 bits, since 255 should be enough. Suggested by Justin. --- diff --git a/datapath/datapath.c b/datapath/datapath.c index 3160ba7c..0a266cb4 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -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); diff --git a/include/openflow.h b/include/openflow.h index d9c22f22..4969cea8 100644 --- a/include/openflow.h +++ b/include/openflow.h @@ -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 */ diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 11d1839a..8b056fd9 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -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)); diff --git a/switch/datapath.c b/switch/datapath.c index a4c69198..2055e094 100644 --- a/switch/datapath.c +++ b/switch/datapath.c @@ -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); diff --git a/utilities/dpctl.c b/utilities/dpctl.c index f4404259..80808acf 100644 --- a/utilities/dpctl.c +++ b/utilities/dpctl.c @@ -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; }