7.3 Controller-to-Switch Messages
7.3.4 Modify State Messages
7.3.4.1 Modify Flow Table Message
The controller can configure the dynamic state in a flow table with the OFPT_TABLE_MOD request. The OFPT_TABLE_MOD use the following structure and fields:
/* Configure/Modify behavior of a flow table */ struct ofp_table_mod {
struct ofp_header header;
uint8_t table_id; /* ID of the table, OFPTT_ALL indicates all tables */
uint8_t pad[3]; /* Pad to 32 bits */
uint32_t config; /* Bitmap of OFPTC_* flags */
/* Table Mod Property list */
struct ofp_table_mod_prop_header properties[0]; };
OFP_ASSERT(sizeof(struct ofp_table_mod) == 16);
The table_id chooses the table to which the configuration change should be applied. If the table_id is OFPTT_ALL, the configuration is applied to all tables in the switch.
The config field is a bitmap that configures the behaviour of the table. The following values are defined for that field :
/* Flags to configure the table. */ enum ofp_table_config {
OFPTC_DEPRECATED_MASK = 3, /* Deprecated bits */
OFPTC_EVICTION = 1 << 2, /* Authorise table to evict flows. */
OFPTC_VACANCY_EVENTS = 1 << 3, /* Enable vacancy events. */ };
The flag OFPTC_EVICTION control flow entry eviction in that flow table (see 6.5). If this flag is set, the switch can evict flow entries from that flow table. If this flag is unset, the switch cannot evict flow entries from that table. Flow entry eviction is optional and as a consequence a switch may not support setting this flag.
The flag OFPTC_VACANCY_EVENTS control vacancy events in that table (see 7.4.5). If this flag is set, the switch must generate vacancy events for that table. If this flag is unset, the switch must not generate those events. Parameters for vacancy events may be specified using the OFPTMPT_VACANCY property (see below), if this property is not included in the table-mod message, previously set values of the parameters must be used.
The properties field is a list of table mod properties, describing dynamic parameters of table config- uration.
The table mod property types currently defined are:
/* Table Mod property types. */
enum ofp_table_mod_prop_type {
OFPTMPT_EVICTION = 0x2, /* Eviction property. */
OFPTMPT_VACANCY = 0x3, /* Vacancy property. */
OFPTMPT_EXPERIMENTER = 0xFFFF, /* Experimenter property. */
};
A property definition contains the property type, length, and any associated data:
/* Common header for all Table Mod Properties */ struct ofp_table_mod_prop_header {
uint16_t type; /* One of OFPTMPT_*. */
uint16_t length; /* Length in bytes of this property. */
};
OFP_ASSERT(sizeof(struct ofp_table_mod_prop_header) == 4);
The OFPTMPT_EVICTION property usually cannot be modified using a OFP_TABLE_MOD request, because the eviction mechanism is switch defined, and this property is usually only used in a OFPMP_TABLE_DESC multipart reply to inform the controller about the eviction mechanism used. It uses the following structure and fields:
/* Eviction table mod Property. Mostly used in OFPMP_TABLE_DESC replies. */ struct ofp_table_mod_prop_eviction {
uint16_t type; /* OFPTMPT_EVICTION. */
uint16_t length; /* Length in bytes of this property. */
uint32_t flags; /* Bitmap of OFPTMPEF_* flags */
};
OFP_ASSERT(sizeof(struct ofp_table_mod_prop_eviction) == 8);
The flags field is a bitmap that defines the type of eviction the switch is implementing. The following flags:
/* Eviction flags. */
enum ofp_table_mod_prop_eviction_flag {
OFPTMPEF_OTHER = 1 << 0, /* Using other factors. */
OFPTMPEF_IMPORTANCE = 1 << 1, /* Using flow entry importance. */
OFPTMPEF_LIFETIME = 1 << 2, /* Using flow entry lifetime. */
};
If the flag OFPTMPEF_IMPORTANCE is set, the eviction process will use the flow entry importance field (see 7.3.4.2) to perform eviction. If the flag OFPTMPEF_IMPORTANCE is the only flag set, eviction will be performed strictly in order of importance, that is flow entry with lower importance will always be evicted before flow entry with higher importance. The eviction mechanism is switch defined, therefore it is not possible to predict in which order flow entries of same importance will get evicted.
If the flag OFPTMPEF_LIFETIME is set, the eviction process will use the flow entry remaining lifetime, the shortest time to expiration (see 6.5), to perform eviction. If the flag OFPTMPEF_LIFETIME is the only flag set, eviction will be performed stricly in order of remaining lifetime, and permanent flow entries are never removed.
If the flag OFPTMPEF_OTHER is set, the eviction process will use other factors, such as internal constraints, to perform eviction. When this flag is set, the controller cannot predict in which order flow entries will get evicted. This flag may be combined with other flags to signify that, for example, eviction is mostly done by the switch according to importance or lifetime but not strictly.
The OFPTMPT_VACANCY property specifies the parameters for vacancy events and uses the following structure and fields:
/* Vacancy table mod property */ struct ofp_table_mod_prop_vacancy {
uint16_t type; /* OFPTMPT_VACANCY. */
uint16_t length; /* Length in bytes of this property. */
uint8_t vacancy_down; /* Vacancy threshold when space decreases (%). */
uint8_t vacancy_up; /* Vacancy threshold when space increases (%). */
uint8_t vacancy; /* Current vacancy (%) - only in ofp_table_desc. */
uint8_t pad[1]; /* Align to 64 bits. */
};
OFP_ASSERT(sizeof(struct ofp_table_mod_prop_vacancy) == 8);
The fields vacancy_down and vacancy_up are the threshold for generating vacancy events that should be configured on this flow table, expressed as a percent.
When the remaining space in the flow table decreases to less than vacancy_down, and if vacancy down events are enabled, a vacancy down event must be generated to the controller using the OFPT_TABLE_STATUSmessage type with reason OFPTR_VACANCY_DOWN (see 7.4.5). Further vacancy down events are disabled until a vacancy up event is generated.
When the remaining space in the flow table increases to more than vacancy_up, and if vacancy up events are enabled, a vacancy up event must be generated to the controller using the OFPT_TABLE_STATUS message type with reason OFPTR_VACANCY_UP. Further vacancy up events are disabled until a vacancy down event is generated.
vacancy_up, vacancy up events must be enabled, and vacancy down events must be disabled. When enabling events, if the current vacancy is greater or equal to vacancy_up, vacancy down events must be enabled, and vacancy up events must be disabled. When vacancy events are disabled on the table using the OFPTC_VACANCY_EVENTS flag, both vacancy up and vacancy down events must be disabled. If in a OFP_TABLE_MOD message the value of vacancy_down is greater than the value of vacancy_up, the switch should reject the OFP_TABLE_MOD message and send an ofp_error_msg with OFPET_BAD_PROPERTYtype and OFPBPC_BAD_VALUE code.
The vacancy field is only used when this property in included in a OFPMP_TABLE_DESC multipart reply or a OFPT_TABLE_STATUS message and represent the current vacancy of the table, expressed as a percent. In OFP_TABLE_MOD requests, this field must be set to 0.
The OFPTMPT_EXPERIMENTER property uses the following structure and fields:
/* Experimenter table mod property */ struct ofp_table_mod_prop_experimenter {
uint16_t type; /* OFPTMPT_EXPERIMENTER. */
uint16_t length; /* Length in bytes of this property. */
uint32_t experimenter; /* Experimenter ID which takes the same
form as in struct
ofp_experimenter_header. */
uint32_t exp_type; /* Experimenter defined. */
/* Followed by:
* - Exactly (length - 12) bytes containing the experimenter data, then
* - Exactly (length + 7)/8*8 - (length) (between 0 and 7)
* bytes of all-zero bytes */
uint32_t experimenter_data[0];
};
OFP_ASSERT(sizeof(struct ofp_table_mod_prop_experimenter) == 12);
The experimenter field is the Experimenter ID, which takes the same form as in the typical experi- menter structure (see 7.2.8).