提交 25432eba 编写于 作者: J Justin Pettit 提交者: David S. Miller

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: 96fbc13d ("openvswitch: Add meter infrastructure")
Signed-off-by: NJustin Pettit <jpettit@ovn.org>
Cc: Andy Zhou <azhou@ovn.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 7acf9d42
...@@ -211,6 +211,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a) ...@@ -211,6 +211,7 @@ static struct dp_meter *dp_meter_create(struct nlattr **a)
if (!meter) if (!meter)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
meter->id = nla_get_u32(a[OVS_METER_ATTR_ID]);
meter->used = div_u64(ktime_get_ns(), 1000 * 1000); meter->used = div_u64(ktime_get_ns(), 1000 * 1000);
meter->kbps = a[OVS_METER_ATTR_KBPS] ? 1 : 0; meter->kbps = a[OVS_METER_ATTR_KBPS] ? 1 : 0;
meter->keep_stats = !a[OVS_METER_ATTR_CLEAR]; 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) ...@@ -280,6 +281,10 @@ static int ovs_meter_cmd_set(struct sk_buff *skb, struct genl_info *info)
u32 meter_id; u32 meter_id;
bool failed; bool failed;
if (!a[OVS_METER_ATTR_ID]) {
return -ENODEV;
}
meter = dp_meter_create(a); meter = dp_meter_create(a);
if (IS_ERR_OR_NULL(meter)) if (IS_ERR_OR_NULL(meter))
return PTR_ERR(meter); return PTR_ERR(meter);
...@@ -298,11 +303,6 @@ static int ovs_meter_cmd_set(struct sk_buff *skb, struct genl_info *info) ...@@ -298,11 +303,6 @@ static int ovs_meter_cmd_set(struct sk_buff *skb, struct genl_info *info)
goto exit_unlock; goto exit_unlock;
} }
if (!a[OVS_METER_ATTR_ID]) {
err = -ENODEV;
goto exit_unlock;
}
meter_id = nla_get_u32(a[OVS_METER_ATTR_ID]); meter_id = nla_get_u32(a[OVS_METER_ATTR_ID]);
/* Cannot fail after this. */ /* Cannot fail after this. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册