* in the peer and so there's not much point in showing a lot of them. */
static struct vlog_rate_limit bad_ofmsg_rl = VLOG_RATE_LIMIT_INIT(1, 5);
+static enum ofputil_table_vacancy ofputil_decode_table_vacancy(
+ ovs_be32 config, enum ofp_version);
static enum ofputil_table_eviction ofputil_decode_table_eviction(
ovs_be32 config, enum ofp_version);
static ovs_be32 ofputil_encode_table_config(enum ofputil_table_miss,
enum ofputil_table_eviction,
+ enum ofputil_table_vacancy,
enum ofp_version);
struct ofp_prop_header {
fm->out_group = (ofm->command == OFPFC_DELETE ||
ofm->command == OFPFC_DELETE_STRICT
? ntohl(ofm->out_group)
- : OFPG11_ANY);
+ : OFPG_ANY);
raw_flags = ofm->flags;
} else {
uint16_t command;
fm->importance = 0;
fm->buffer_id = ntohl(ofm->buffer_id);
fm->out_port = u16_to_ofp(ntohs(ofm->out_port));
- fm->out_group = OFPG11_ANY;
+ fm->out_group = OFPG_ANY;
raw_flags = ofm->flags;
} else if (raw == OFPRAW_NXT_FLOW_MOD) {
/* Nicira extended flow_mod. */
fm->importance = 0;
fm->buffer_id = ntohl(nfm->buffer_id);
fm->out_port = u16_to_ofp(ntohs(nfm->out_port));
- fm->out_group = OFPG11_ANY;
+ fm->out_group = OFPG_ANY;
raw_flags = nfm->flags;
} else {
OVS_NOT_REACHED();
fsr->aggregate = aggregate;
ofputil_match_from_ofp10_match(&ofsr->match, &fsr->match);
fsr->out_port = u16_to_ofp(ntohs(ofsr->out_port));
- fsr->out_group = OFPG11_ANY;
+ fsr->out_group = OFPG_ANY;
fsr->table_id = ofsr->table_id;
fsr->cookie = fsr->cookie_mask = htonll(0);
fsr->aggregate = aggregate;
fsr->out_port = u16_to_ofp(ntohs(nfsr->out_port));
- fsr->out_group = OFPG11_ANY;
+ fsr->out_group = OFPG_ANY;
fsr->table_id = nfsr->table_id;
return 0;
otd->length = htons(reply->size - start_otd);
otd->table_id = td->table_id;
otd->config = ofputil_encode_table_config(OFPUTIL_TABLE_MISS_DEFAULT,
- td->eviction, version);
+ td->eviction, td->vacancy,
+ version);
ofpmp_postappend(replies, start_otd);
}
+/* This function parses Vacancy property, and decodes the
+ * ofp14_table_mod_prop_vacancy in ofputil_table_mod.
+ * Returns OFPERR_OFPBPC_BAD_VALUE error code when vacancy_down is
+ * greater than vacancy_up and also when current vacancy has non-zero
+ * value. Returns 0 on success. */
+static enum ofperr
+parse_table_mod_vacancy_property(struct ofpbuf *property,
+ struct ofputil_table_mod *tm)
+{
+ struct ofp14_table_mod_prop_vacancy *otv = property->data;
+
+ if (property->size != sizeof *otv) {
+ return OFPERR_OFPBPC_BAD_LEN;
+ }
+ tm->table_vacancy.vacancy_down = otv->vacancy_down;
+ tm->table_vacancy.vacancy_up = otv->vacancy_up;
+ if (tm->table_vacancy.vacancy_down > tm->table_vacancy.vacancy_up) {
+ log_property(false, "Value of vacancy_down is greater than "
+ "vacancy_up");
+ return OFPERR_OFPBPC_BAD_VALUE;
+ }
+ if (tm->table_vacancy.vacancy_down > 100 ||
+ tm->table_vacancy.vacancy_up > 100) {
+ log_property(false, "Vacancy threshold percentage should not be"
+ "greater than 100");
+ return OFPERR_OFPBPC_BAD_VALUE;
+ }
+ tm->table_vacancy.vacancy = otv->vacancy;
+ if (tm->table_vacancy.vacancy) {
+ log_property(false, "Vacancy value should be zero for table-mod "
+ "messages");
+ return OFPERR_OFPBPC_BAD_VALUE;
+ }
+ return 0;
+}
+
+/* Given 'config', taken from an OpenFlow 'version' message that specifies
+ * table configuration (a table mod, table stats, or table features message),
+ * returns the table vacancy configuration that it specifies.
+ *
+ * Only OpenFlow 1.4 and later specify table vacancy configuration this way,
+ * so for other 'version' this function always returns
+ * OFPUTIL_TABLE_VACANCY_DEFAULT. */
+static enum ofputil_table_vacancy
+ofputil_decode_table_vacancy(ovs_be32 config, enum ofp_version version)
+{
+ return (version < OFP14_VERSION ? OFPUTIL_TABLE_VACANCY_DEFAULT
+ : config & htonl(OFPTC14_VACANCY_EVENTS) ? OFPUTIL_TABLE_VACANCY_ON
+ : OFPUTIL_TABLE_VACANCY_OFF);
+}
+
static enum ofperr
parse_table_mod_eviction_property(struct ofpbuf *property,
struct ofputil_table_mod *tm)
static ovs_be32
ofputil_encode_table_config(enum ofputil_table_miss miss,
enum ofputil_table_eviction eviction,
+ enum ofputil_table_vacancy vacancy,
enum ofp_version version)
{
+ uint32_t config = 0;
/* See the section "OFPTC_* Table Configuration" in DESIGN.md for more
* information on the crazy evolution of this field. */
switch (version) {
case OFP14_VERSION:
case OFP15_VERSION:
- /* OpenFlow 1.4 introduced OFPTC14_EVICTION and OFPTC14_VACANCY_EVENTS
- * and we don't support the latter yet. */
- return htonl(eviction == OFPUTIL_TABLE_EVICTION_ON
- ? OFPTC14_EVICTION : 0);
+ /* OpenFlow 1.4 introduced OFPTC14_EVICTION and
+ * OFPTC14_VACANCY_EVENTS. */
+ if (eviction == OFPUTIL_TABLE_EVICTION_ON) {
+ config |= OFPTC14_EVICTION;
+ }
+ if (vacancy == OFPUTIL_TABLE_VACANCY_ON) {
+ config |= OFPTC14_VACANCY_EVENTS;
+ }
+ return htonl(config);
}
OVS_NOT_REACHED();
pm->miss = OFPUTIL_TABLE_MISS_DEFAULT;
pm->eviction = OFPUTIL_TABLE_EVICTION_DEFAULT;
pm->eviction_flags = UINT32_MAX;
+ pm->vacancy = OFPUTIL_TABLE_VACANCY_DEFAULT;
ofpbuf_use_const(&b, oh, ntohs(oh->length));
raw = ofpraw_pull_assert(&b);
pm->table_id = otm->table_id;
pm->miss = ofputil_decode_table_miss(otm->config, oh->version);
pm->eviction = ofputil_decode_table_eviction(otm->config, oh->version);
+ pm->vacancy = ofputil_decode_table_vacancy(otm->config, oh->version);
while (b.size > 0) {
struct ofpbuf property;
enum ofperr error;
error = parse_table_mod_eviction_property(&property, pm);
break;
+ case OFPTMPT14_VACANCY:
+ error = parse_table_mod_vacancy_property(&property, pm);
+ break;
+
default:
error = OFPERR_OFPBRC_BAD_TYPE;
break;
otm = ofpbuf_put_zeros(b, sizeof *otm);
otm->table_id = tm->table_id;
otm->config = ofputil_encode_table_config(tm->miss, tm->eviction,
- ofp_version);
+ tm->vacancy, ofp_version);
break;
}
case OFP14_VERSION:
case OFP15_VERSION: {
struct ofp14_table_mod *otm;
struct ofp14_table_mod_prop_eviction *ote;
+ struct ofp14_table_mod_prop_vacancy *otv;
b = ofpraw_alloc(OFPRAW_OFPT14_TABLE_MOD, ofp_version, 0);
otm = ofpbuf_put_zeros(b, sizeof *otm);
otm->table_id = tm->table_id;
otm->config = ofputil_encode_table_config(tm->miss, tm->eviction,
- ofp_version);
+ tm->vacancy, ofp_version);
if (tm->eviction_flags != UINT32_MAX) {
ote = ofpbuf_put_zeros(b, sizeof *ote);
ote->length = htons(sizeof *ote);
ote->flags = htonl(tm->eviction_flags);
}
+ if (tm->vacancy == OFPUTIL_TABLE_VACANCY_ON) {
+ otv = ofpbuf_put_zeros(b, sizeof *otv);
+ otv->type = htons(OFPTMPT14_VACANCY);
+ otv->length = htons(sizeof *otv);
+ otv->vacancy_down = tm->table_vacancy.vacancy_down;
+ otv->vacancy_up = tm->table_vacancy.vacancy_up;
+ }
break;
}
default:
features->nonmiss.instructions, OFP12_VERSION);
out->config = ofputil_encode_table_config(features->miss_config,
OFPUTIL_TABLE_EVICTION_DEFAULT,
+ OFPUTIL_TABLE_VACANCY_DEFAULT,
OFP12_VERSION);
out->max_entries = htonl(features->max_entries);
out->active_count = htonl(stats->active_count);
ofputil_group_from_string(const char *s, uint32_t *group_idp)
{
if (!strcasecmp(s, "any")) {
- *group_idp = OFPG11_ANY;
+ *group_idp = OFPG_ANY;
} else if (!strcasecmp(s, "all")) {
- *group_idp = OFPG11_ALL;
+ *group_idp = OFPG_ALL;
} else if (!str_to_uint(s, 10, group_idp)) {
VLOG_WARN("%s is not a valid group ID. (Valid group IDs are "
"32-bit nonnegative integers or the keywords ANY or "
/* Appends to 's' a string representation of the OpenFlow group ID 'group_id'.
* Most groups' string representation is just the number, but for special
- * groups, e.g. OFPG11_ALL, it is the name, e.g. "ALL". */
+ * groups, e.g. OFPG_ALL, it is the name, e.g. "ALL". */
void
ofputil_format_group(uint32_t group_id, struct ds *s)
{
/* Puts in the 'bufsize' byte in 'namebuf' a null-terminated string
* representation of OpenFlow group ID 'group_id'. Most group are represented
- * as just their number, but special groups, e.g. OFPG11_ALL, are represented
+ * as just their number, but special groups, e.g. OFPG_ALL, are represented
* by name, e.g. "ALL". */
void
ofputil_group_to_string(uint32_t group_id,
char namebuf[MAX_GROUP_NAME_LEN + 1], size_t bufsize)
{
switch (group_id) {
- case OFPG11_ALL:
+ case OFPG_ALL:
ovs_strlcpy(namebuf, "ALL", bufsize);
break;
- case OFPG11_ANY:
+ case OFPG_ANY:
ovs_strlcpy(namebuf, "ANY", bufsize);
break;
gds->type, reply, version);
}
ogds = ofpbuf_at_assert(reply, start_ogds, sizeof *ogds);
- ogds->length = htons(reply->size - start_ogds);
ogds->type = gds->type;
ogds->group_id = htonl(gds->group_id);
ogds->bucket_list_len = htons(reply->size - start_buckets);
ofputil_put_group_prop_ntr_selection_method(version, &gds->props,
reply);
}
+ ogds->length = htons(reply->size - start_ogds);
ofpmp_postappend(replies, start_ogds);
}
* claim that the group mod command is OFPGC15_ADD to
* satisfy the check in parse_group_prop_ntr_selection_method() */
return parse_ofp15_group_properties(msg, gd->type, OFPGC15_ADD, &gd->props,
- msg->size);
+ length - sizeof *ogds - bucket_list_len);
}
/* Converts a group description reply in 'msg' into an abstract
case OFPGT11_FF:
break;
default:
- OVS_NOT_REACHED();
+ return OFPERR_OFPGMFC_BAD_TYPE;
}
switch (gm->command) {
}
break;
default:
- OVS_NOT_REACHED();
+ return OFPERR_OFPGMFC_BAD_COMMAND;
}
LIST_FOR_EACH (bucket, list_node, &gm->buckets) {