mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
ofproto: Move function find_meter() into ofpacts as ofpacts_get_meter().
ofproto is too big anyway so we might as well move out code that can reasonably live elsewhere. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
This commit is contained in:
@@ -2117,6 +2117,30 @@ ofpacts_equal(const struct ofpact *a, size_t a_len,
|
||||
{
|
||||
return a_len == b_len && !memcmp(a, b, a_len);
|
||||
}
|
||||
|
||||
/* Finds the OFPACT_METER action, if any, in the 'ofpacts_len' bytes of
|
||||
* 'ofpacts'. If found, returns its meter ID; if not, returns 0.
|
||||
*
|
||||
* This function relies on the order of 'ofpacts' being correct (as checked by
|
||||
* ofpacts_verify()). */
|
||||
uint32_t
|
||||
ofpacts_get_meter(const struct ofpact ofpacts[], size_t ofpacts_len)
|
||||
{
|
||||
const struct ofpact *a;
|
||||
|
||||
OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) {
|
||||
enum ovs_instruction_type inst;
|
||||
|
||||
inst = ovs_instruction_type_from_ofpact_type(a->type);
|
||||
if (a->type == OFPACT_METER) {
|
||||
return ofpact_get_METER(a)->meter_id;
|
||||
} else if (inst > OVSINST_OFPIT13_METER) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Formatting ofpacts. */
|
||||
|
||||
|
Reference in New Issue
Block a user