summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Stringer <joestringer@nicira.com>2015-03-06 10:09:10 -0800
committerJoe Stringer <joestringer@nicira.com>2015-05-29 15:27:58 -0700
commitdb8bb9a51e237a55ee5c0b8800ef954e5f84e798 (patch)
tree03388ec7711dcc7315929e16333c8990c2e9a616
parentb440dd8cd4313a09f8ea4cb79da8ac8eab94b010 (diff)
downloadopenvswitch-db8bb9a51e237a55ee5c0b8800ef954e5f84e798.tar.gz
odp-execute: Refactor determining dpif assistance.
To be more explicit about which actions require datapath assistance, split this out into a separate function. While this is fairly trivial currently, there will be more special cases for the upcoming conntrack changes. Signed-off-by: Joe Stringer <joestringer@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
-rw-r--r--lib/odp-execute.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index f83fe6058..b7851048b 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -464,6 +464,38 @@ odp_execute_sample(void *dp, struct dp_packet *packet, bool steal,
nl_attr_get_size(subactions), dp_execute_action);
}
+static bool
+requires_datapath_assistance(const struct nlattr *a)
+{
+ enum ovs_action_attr type = nl_attr_type(a);
+
+ switch (type) {
+ /* These only make sense in the context of a datapath. */
+ case OVS_ACTION_ATTR_OUTPUT:
+ case OVS_ACTION_ATTR_TUNNEL_PUSH:
+ case OVS_ACTION_ATTR_TUNNEL_POP:
+ case OVS_ACTION_ATTR_USERSPACE:
+ case OVS_ACTION_ATTR_RECIRC:
+ return true;
+
+ case OVS_ACTION_ATTR_SET:
+ case OVS_ACTION_ATTR_SET_MASKED:
+ case OVS_ACTION_ATTR_PUSH_VLAN:
+ case OVS_ACTION_ATTR_POP_VLAN:
+ case OVS_ACTION_ATTR_SAMPLE:
+ case OVS_ACTION_ATTR_HASH:
+ case OVS_ACTION_ATTR_PUSH_MPLS:
+ case OVS_ACTION_ATTR_POP_MPLS:
+ return false;
+
+ case OVS_ACTION_ATTR_UNSPEC:
+ case __OVS_ACTION_ATTR_MAX:
+ OVS_NOT_REACHED();
+ }
+
+ return false;
+}
+
void
odp_execute_actions(void *dp, struct dp_packet **packets, int cnt, bool steal,
const struct nlattr *actions, size_t actions_len,
@@ -477,13 +509,7 @@ odp_execute_actions(void *dp, struct dp_packet **packets, int cnt, bool steal,
int type = nl_attr_type(a);
bool last_action = (left <= NLA_ALIGN(a->nla_len));
- switch ((enum ovs_action_attr) type) {
- /* These only make sense in the context of a datapath. */
- case OVS_ACTION_ATTR_OUTPUT:
- case OVS_ACTION_ATTR_TUNNEL_PUSH:
- case OVS_ACTION_ATTR_TUNNEL_POP:
- case OVS_ACTION_ATTR_USERSPACE:
- case OVS_ACTION_ATTR_RECIRC:
+ if (requires_datapath_assistance(a)) {
if (dp_execute_action) {
/* Allow 'dp_execute_action' to steal the packet data if we do
* not need it any more. */
@@ -497,8 +523,10 @@ odp_execute_actions(void *dp, struct dp_packet **packets, int cnt, bool steal,
return;
}
}
- break;
+ continue;
+ }
+ switch ((enum ovs_action_attr) type) {
case OVS_ACTION_ATTR_HASH: {
const struct ovs_action_hash *hash_act = nl_attr_get(a);
@@ -578,6 +606,11 @@ odp_execute_actions(void *dp, struct dp_packet **packets, int cnt, bool steal,
}
break;
+ case OVS_ACTION_ATTR_OUTPUT:
+ case OVS_ACTION_ATTR_TUNNEL_PUSH:
+ case OVS_ACTION_ATTR_TUNNEL_POP:
+ case OVS_ACTION_ATTR_USERSPACE:
+ case OVS_ACTION_ATTR_RECIRC:
case OVS_ACTION_ATTR_UNSPEC:
case __OVS_ACTION_ATTR_MAX:
OVS_NOT_REACHED();