Skip to content

Commit

Permalink
ofp-util: Rewrite async config encoding and decoding to be table-driven.
Browse files Browse the repository at this point in the history
The encoding and decoding of the OpenFlow and Open vSwitch async config
messages was, until now, a collection of disjoint code that had a lot of
redundancy.  This commit changes it all to be driven using a single central
table.

This rewrite fixes a bug in the OF1.4+ version of the code, which until
now assumed that every TLV in an OF1.4+ asynchronous configuration message
was exactly 8 bytes long, and reported an error if any was a different
length.  This invariant is true of all the standard TLVs already defined,
but it won't be true of any experimenter TLVs (and won't necessarily be
true of any new standard TLVs), so this commit changes it to be more
tolerant.

The OFPACPT_* constants are no longer useful (they are encoded directly
in the table and do not need to be anywhere else), so this removes them.

This commit also adds support for experimenter async config messages.
We don't have any yet but an upcoming commit will add one.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
  • Loading branch information
blp committed Jan 20, 2016
1 parent a930d4c commit 8fd0bb6
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 229 deletions.
23 changes: 1 addition & 22 deletions include/openflow/openflow-1.4.h
Expand Up @@ -125,7 +125,7 @@ enum ofp14_table_mod_prop_eviction_flag {
enum ofp14_table_reason {
OFPTR_VACANCY_DOWN = 3, /* Vacancy down threshold event. */
OFPTR_VACANCY_UP = 4, /* Vacancy up threshold event. */
OFPTR_N_REASONS /* Denotes number of reasons. */
#define OFPTR_BITS ((1u << OFPTR_VACANCY_DOWN) | (1u << OFPTR_VACANCY_UP))
};

struct ofp14_table_mod_prop_vacancy {
Expand Down Expand Up @@ -255,27 +255,6 @@ enum ofp14_requestforward_reason {
OFPRFR_N_REASONS /* Denotes number of reasons. */
};

/* Async Config property types.
* Low order bit cleared indicates a property for the slave role.
* Low order bit set indicates a property for the master/equal role.
*/
enum ofp14_async_config_prop_type {
OFPACPT_PACKET_IN_SLAVE = 0, /* Packet-in mask for slave. */
OFPACPT_PACKET_IN_MASTER = 1, /* Packet-in mask for master. */
OFPACPT_PORT_STATUS_SLAVE = 2, /* Port-status mask for slave. */
OFPACPT_PORT_STATUS_MASTER = 3, /* Port-status mask for master. */
OFPACPT_FLOW_REMOVED_SLAVE = 4, /* Flow removed mask for slave. */
OFPACPT_FLOW_REMOVED_MASTER = 5, /* Flow removed mask for master. */
OFPACPT_ROLE_STATUS_SLAVE = 6, /* Role status mask for slave. */
OFPACPT_ROLE_STATUS_MASTER = 7, /* Role status mask for master. */
OFPACPT_TABLE_STATUS_SLAVE = 8, /* Table status mask for slave. */
OFPACPT_TABLE_STATUS_MASTER = 9, /* Table status mask for master. */
OFPACPT_REQUESTFORWARD_SLAVE = 10, /* RequestForward mask for slave. */
OFPACPT_REQUESTFORWARD_MASTER = 11, /* RequestForward mask for master. */
OFPTFPT_EXPERIMENTER_SLAVE = 0xFFFE, /* Experimenter for slave. */
OFPTFPT_EXPERIMENTER_MASTER = 0xFFFF, /* Experimenter for master. */
};

/* Role status event message. */
struct ofp14_role_status {
ovs_be32 role; /* One of OFPCR_ROLE_*. */
Expand Down
1 change: 0 additions & 1 deletion lib/ofp-print.c
Expand Up @@ -2003,7 +2003,6 @@ ofp_table_reason_to_string(enum ofp14_table_reason reason,
case OFPTR_VACANCY_UP:
return "vacancy_up";

case OFPTR_N_REASONS:
default:
snprintf(reasonbuf, bufsize, "%d", (int) reason);
return reasonbuf;
Expand Down

0 comments on commit 8fd0bb6

Please sign in to comment.