Skip to content

Commit 25432eb

Browse files
justinpettitdavem330
authored andcommitted
openvswitch: meter: Fix setting meter id for new entries
The meter code would create an entry for each new meter. However, it would not set the meter id in the new entry, so every meter would appear to have a meter id of zero. This commit properly sets the meter id when adding the entry. Fixes: 96fbc13 ("openvswitch: Add meter infrastructure") Signed-off-by: Justin Pettit <[email protected]> Cc: Andy Zhou <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7acf9d4 commit 25432eb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

net/openvswitch/meter.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
211211
if (!meter)
212212
return ERR_PTR(-ENOMEM);
213213

214+
meter->id = nla_get_u32(a[OVS_METER_ATTR_ID]);
214215
meter->used = div_u64(ktime_get_ns(), 1000 * 1000);
215216
meter->kbps = a[OVS_METER_ATTR_KBPS] ? 1 : 0;
216217
meter->keep_stats = !a[OVS_METER_ATTR_CLEAR];
@@ -280,6 +281,10 @@ static int ovs_meter_cmd_set(struct sk_buff *skb, struct genl_info *info)
280281
u32 meter_id;
281282
bool failed;
282283

284+
if (!a[OVS_METER_ATTR_ID]) {
285+
return -ENODEV;
286+
}
287+
283288
meter = dp_meter_create(a);
284289
if (IS_ERR_OR_NULL(meter))
285290
return PTR_ERR(meter);
@@ -298,11 +303,6 @@ static int ovs_meter_cmd_set(struct sk_buff *skb, struct genl_info *info)
298303
goto exit_unlock;
299304
}
300305

301-
if (!a[OVS_METER_ATTR_ID]) {
302-
err = -ENODEV;
303-
goto exit_unlock;
304-
}
305-
306306
meter_id = nla_get_u32(a[OVS_METER_ATTR_ID]);
307307

308308
/* Cannot fail after this. */

0 commit comments

Comments
 (0)