2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-01 06:45:17 +00:00

dpif: Move common meter checks into the dpif layer.

Another dpif provider will soon add support for meters, so move
some of the common sanity checks up into the dpif layer so that each
provider doesn't need to re-implement them.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
Justin Pettit
2018-07-24 21:07:04 -07:00
parent c9336012c2
commit 6508c845ad
2 changed files with 22 additions and 15 deletions

View File

@@ -5172,21 +5172,12 @@ dpif_netdev_meter_set(struct dpif *dpif, ofproto_meter_id *meter_id,
return EFBIG; /* Meter_id out of range. */
}
if (config->flags & ~DP_SUPPORTED_METER_FLAGS_MASK ||
!(config->flags & (OFPMF13_KBPS | OFPMF13_PKTPS))) {
if (config->flags & ~DP_SUPPORTED_METER_FLAGS_MASK) {
return EBADF; /* Unsupported flags set */
}
/* Validate bands */
if (config->n_bands == 0 || config->n_bands > MAX_BANDS) {
return EINVAL; /* Too many bands */
}
/* Validate rates */
for (i = 0; i < config->n_bands; i++) {
if (config->bands[i].rate == 0) {
return EDOM; /* rate must be non-zero */
}
if (config->n_bands > MAX_BANDS) {
return EINVAL;
}
for (i = 0; i < config->n_bands; ++i) {