2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-29 15:28:56 +00:00

Implement basic OpenFlow 1.4 table-mod message.

Vacancy events and eviction are not yet implemented--see OPENFLOW-1.1+.

Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Ben Pfaff
2014-05-09 09:11:05 -07:00
parent 18cc69d926
commit 37ab26e80c
4 changed files with 70 additions and 4 deletions

View File

@@ -114,6 +114,47 @@ struct ofp14_port_mod {
};
OFP_ASSERT(sizeof(struct ofp14_port_mod) == 24);
/* ## --------------- ## */
/* ## ofp14_table_mod ## */
/* ## --------------- ## */
enum ofp14_table_mod_prop_type {
OFPTMPT14_EVICTION = 0x2, /* Eviction property. */
OFPTMPT14_VACANCY = 0x3, /* Vacancy property. */
OFPTMPT14_EXPERIMENTER = 0xFFFF, /* Experimenter property. */
};
enum ofp14_table_mod_prop_eviction_flag {
OFPTMPEF14_OTHER = 1 << 0, /* Using other factors. */
OFPTMPEF14_IMPORTANCE = 1 << 1, /* Using flow entry importance. */
OFPTMPEF14_LIFETIME = 1 << 2, /* Using flow entry lifetime. */
};
struct ofp14_table_mod_prop_eviction {
ovs_be16 type; /* OFPTMPT14_EVICTION. */
ovs_be16 length; /* Length in bytes of this property. */
ovs_be32 flags; /* Bitmap of OFPTMPEF14_* flags */
};
OFP_ASSERT(sizeof(struct ofp14_table_mod_prop_eviction) == 8);
struct ofp14_table_mod_prop_vacancy {
ovs_be16 type; /* OFPTMPT14_VACANCY. */
ovs_be16 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 ofp14_table_desc. */
uint8_t pad[1]; /* Align to 64 bits. */
};
OFP_ASSERT(sizeof(struct ofp14_table_mod_prop_vacancy) == 8);
struct ofp14_table_mod {
uint8_t table_id; /* ID of the table, OFPTT_ALL indicates all tables */
uint8_t pad[3]; /* Pad to 32 bits */
ovs_be32 config; /* Bitmap of OFPTC_* flags */
/* Followed by 0 or more OFPTMPT14_* properties. */
};
OFP_ASSERT(sizeof(struct ofp14_table_mod) == 8);
/* ## -------------- ## */
/* ## Miscellaneous. ## */

View File

@@ -189,8 +189,10 @@ enum ofpraw {
/* OFPT 1.4+ (16): struct ofp14_port_mod, uint8_t[8][]. */
OFPRAW_OFPT14_PORT_MOD,
/* OFPT 1.1+ (17): struct ofp11_table_mod. */
/* OFPT 1.1-1.3 (17): struct ofp11_table_mod. */
OFPRAW_OFPT11_TABLE_MOD,
/* OFPT 1.4+ (17): struct ofp14_table_mod, uint8_t[8][]. */
OFPRAW_OFPT14_TABLE_MOD,
/* OFPT 1.0 (18): void. */
OFPRAW_OFPT10_BARRIER_REQUEST,
@@ -490,7 +492,8 @@ enum ofptype {
OFPTYPE_PORT_MOD, /* OFPRAW_OFPT10_PORT_MOD.
* OFPRAW_OFPT11_PORT_MOD.
* OFPRAW_OFPT14_PORT_MOD. */
OFPTYPE_TABLE_MOD, /* OFPRAW_OFPT11_TABLE_MOD. */
OFPTYPE_TABLE_MOD, /* OFPRAW_OFPT11_TABLE_MOD.
* OFPRAW_OFPT14_TABLE_MOD. */
/* Barrier messages. */
OFPTYPE_BARRIER_REQUEST, /* OFPRAW_OFPT10_BARRIER_REQUEST.

View File

@@ -4747,6 +4747,13 @@ ofputil_decode_table_mod(const struct ofp_header *oh,
pm->table_id = otm->table_id;
pm->config = ntohl(otm->config);
} else if (raw == OFPRAW_OFPT14_TABLE_MOD) {
const struct ofp14_table_mod *otm = ofpbuf_pull(&b, sizeof *otm);
pm->table_id = otm->table_id;
pm->config = ntohl(otm->config);
/* We do not understand any properties yet, so we do not bother
* parsing them. */
} else {
return OFPERR_OFPBRC_BAD_TYPE;
}
@@ -4781,9 +4788,15 @@ ofputil_encode_table_mod(const struct ofputil_table_mod *pm,
otm->config = htonl(pm->config);
break;
}
case OFP14_VERSION:
OVS_NOT_REACHED();
case OFP14_VERSION: {
struct ofp14_table_mod *otm;
b = ofpraw_alloc(OFPRAW_OFPT14_TABLE_MOD, ofp_version, 0);
otm = ofpbuf_put_zeros(b, sizeof *otm);
otm->table_id = pm->table_id;
otm->config = htonl(pm->config);
break;
}
default:
OVS_NOT_REACHED();
}

View File

@@ -1067,6 +1067,15 @@ OFPT_TABLE_MOD (OF1.3) (xid=0x2): table_id=2, flow_miss_config=controller
])
AT_CLEANUP
AT_SETUP([OFPT_TABLE_MOD - OF1.4])
AT_KEYWORDS([ofp-print])
AT_CHECK([ovs-ofctl ofp-print "\
05 11 00 10 00 00 00 02 02 00 00 00 00 00 00 00 \
" 3], [0], [dnl
OFPT_TABLE_MOD (OF1.4) (xid=0x2): table_id=2, flow_miss_config=controller
])
AT_CLEANUP
AT_SETUP([OFPST_DESC request])
AT_KEYWORDS([ofp-print OFPT_STATS_REQUEST])
AT_CHECK([ovs-ofctl ofp-print "0110000c0000000100000000"], [0], [dnl