@@ -256,7 +256,7 @@ static int ovs_meter_cmd_features(struct sk_buff *skb, struct genl_info *info)
if (IS_ERR(reply))
return PTR_ERR(reply);
- if (nla_put_u32(reply, OVS_METER_ATTR_MAX_METERS, U32_MAX) ||
+ if (nla_put_u32(reply, OVS_METER_ATTR_MAX_METERS, DP_MAX_METERS) ||
nla_put_u32(reply, OVS_METER_ATTR_MAX_BANDS, DP_MAX_BANDS))
goto nla_put_failure;
@@ -284,13 +284,17 @@ static int ovs_meter_cmd_features(struct sk_buff *skb, struct genl_info *info)
static struct dp_meter *dp_meter_create(struct nlattr **a)
{
+ u32 meter_id = nla_get_u32(a[OVS_METER_ATTR_ID]);
+ struct dp_meter_band *band;
+ struct dp_meter *meter;
struct nlattr *nla;
- int rem;
u16 n_bands = 0;
- struct dp_meter *meter;
- struct dp_meter_band *band;
+ int rem;
int err;
+ if (meter_id > DP_MAX_METERS)
+ return ERR_PTR(-EFBIG);
+
/* Validate attributes, count the bands. */
if (!a[OVS_METER_ATTR_BANDS])
return ERR_PTR(-EINVAL);
@@ -304,7 +308,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
if (!meter)
return ERR_PTR(-ENOMEM);
- meter->id = nla_get_u32(a[OVS_METER_ATTR_ID]);
+ meter->id = meter_id;
meter->used = div_u64(ktime_get_ns(), 1000 * 1000);
meter->kbps = a[OVS_METER_ATTR_KBPS] ? 1 : 0;
meter->keep_stats = !a[OVS_METER_ATTR_CLEAR];
@@ -17,7 +17,8 @@
#include "flow.h"
struct datapath;
-#define DP_MAX_BANDS 1
+#define DP_MAX_METERS (200000ULL)
+#define DP_MAX_BANDS 1
struct dp_meter_band {
u32 type;