[ovs-dev] [RFC PATCH 7/8] datapath: Meter placeholders.
Jarno Rajahalme
jarno.rajahalme at nsn.com
Thu Jun 20 14:26:22 UTC 2013
Signed-off-by: Jarno Rajahalme <jarno.rajahalme at nsn.com>
---
datapath/actions.c | 16 +++++++++++++++-
datapath/datapath.c | 5 +++++
datapath/datapath.h | 2 ++
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/datapath/actions.c b/datapath/actions.c
index 09d0c3f..8c5e6d5 100644
--- a/datapath/actions.c
+++ b/datapath/actions.c
@@ -472,6 +472,15 @@ static int execute_set_action(struct sk_buff *skb,
return err;
}
+/* May modify packet and execute other actions according to the meter
+ * configuration and state.
+ * Returns true if packet needs to be dropped. */
+static bool execute_meter_action(struct datapath *dp, struct sk_buff *skb,
+ uint32_t meter_id)
+{
+ return false;
+}
+
/* Execute a list of actions against 'skb'. */
static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
const struct nlattr *attr, int len, bool keep_skb)
@@ -494,6 +503,11 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
}
switch (nla_type(a)) {
+ case OVS_ACTION_ATTR_METER:
+ if (execute_meter_action(dp, skb, nla_get_u32(a)))
+ goto out;
+ break;
+
case OVS_ACTION_ATTR_OUTPUT:
prev_port = nla_get_u32(a);
break;
@@ -526,7 +540,7 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb,
return err;
}
}
-
+out:
if (prev_port != -1) {
if (keep_skb)
skb = skb_clone(skb, GFP_ATOMIC);
diff --git a/datapath/datapath.c b/datapath/datapath.c
index 42af315..c90830a 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -780,6 +780,7 @@ static int validate_and_copy_actions(const struct nlattr *attr,
/* Expected argument lengths, (u32)-1 for variable length. */
static const u32 action_lens[OVS_ACTION_ATTR_MAX + 1] = {
[OVS_ACTION_ATTR_OUTPUT] = sizeof(u32),
+ [OVS_ACTION_ATTR_METER] = sizeof(u32),
[OVS_ACTION_ATTR_USERSPACE] = (u32)-1,
[OVS_ACTION_ATTR_PUSH_VLAN] = sizeof(struct ovs_action_push_vlan),
[OVS_ACTION_ATTR_POP_VLAN] = 0,
@@ -811,6 +812,10 @@ static int validate_and_copy_actions(const struct nlattr *attr,
return -EINVAL;
break;
+ case OVS_ACTION_ATTR_METER:
+ if (nla_get_u32(a) >= DP_MAX_METERS)
+ return -EINVAL;
+ break;
case OVS_ACTION_ATTR_POP_VLAN:
break;
diff --git a/datapath/datapath.h b/datapath/datapath.h
index ad59a3a..787f53c 100644
--- a/datapath/datapath.h
+++ b/datapath/datapath.h
@@ -36,6 +36,8 @@
#define DP_MAX_PORTS USHRT_MAX
#define DP_VPORT_HASH_BUCKETS 1024
+#define DP_MAX_METERS 0 /* Not implemented yet */
+
#define SAMPLE_ACTION_DEPTH 3
/**
--
1.7.10.4
More information about the dev
mailing list