[ovs-dev] [PATCH v9 6/6] ofproto-dpif: Use execute_actions to execute controller actions

Simon Horman horms at verge.net.au
Wed May 22 07:08:10 UTC 2013


Now that execute_actions() is available it can be used as a generic
replacement for special-case action execution in
execute_controller_action().

As suggested by Jesse Gross.

Signed-off-by: Simon Horman <horms at verge.net.au>

---

v9
* First post
---
 lib/execute-actions.c  |  3 ++-
 ofproto/ofproto-dpif.c | 46 +++++++---------------------------------------
 2 files changed, 9 insertions(+), 40 deletions(-)

diff --git a/lib/execute-actions.c b/lib/execute-actions.c
index 5e05dc5..1036ede 100644
--- a/lib/execute-actions.c
+++ b/lib/execute-actions.c
@@ -170,7 +170,8 @@ execute_actions(void *dp, struct ofpbuf *packet, struct flow *key,
 
         switch ((enum ovs_action_attr) type) {
         case OVS_ACTION_ATTR_OUTPUT:
-            output(dp, packet, nl_attr_get_u32(a));
+            if (output)
+                output(dp, packet, nl_attr_get_u32(a));
             break;
 
         case OVS_ACTION_ATTR_USERSPACE: {
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index bdb143f..329ff56 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -6813,6 +6813,7 @@ execute_controller_action(struct action_xlate_ctx *ctx, int len,
 {
     struct ofputil_packet_in pin;
     struct ofpbuf *packet;
+    struct flow key;
 
     ctx->slow |= SLOW_CONTROLLER;
     if (!ctx->packet) {
@@ -6821,47 +6822,14 @@ execute_controller_action(struct action_xlate_ctx *ctx, int len,
 
     packet = ofpbuf_clone(ctx->packet);
 
-    if (packet->l2 && packet->l3) {
-        struct eth_header *eh;
-        uint16_t mpls_depth;
+    key.skb_priority = 0;
+    key.skb_mark = 0;
+    memset(&key.tunnel, 0, sizeof key.tunnel);
 
-        eth_pop_vlan(packet);
-        eh = packet->l2;
-
-        memcpy(eh->eth_src, ctx->flow.dl_src, sizeof eh->eth_src);
-        memcpy(eh->eth_dst, ctx->flow.dl_dst, sizeof eh->eth_dst);
-
-        if (ctx->flow.vlan_tci & htons(VLAN_CFI)) {
-            eth_push_vlan(packet, ctx->flow.vlan_tci);
-        }
-
-        mpls_depth = eth_mpls_depth(packet);
-
-        if (mpls_depth < ctx->flow.mpls_depth) {
-            push_mpls(packet, ctx->flow.dl_type, ctx->flow.mpls_lse);
-        } else if (mpls_depth > ctx->flow.mpls_depth) {
-            pop_mpls(packet, ctx->flow.dl_type);
-        } else if (mpls_depth) {
-            set_mpls_lse(packet, ctx->flow.mpls_lse);
-        }
-
-        if (packet->l4) {
-            if (ctx->flow.dl_type == htons(ETH_TYPE_IP)) {
-                packet_set_ipv4(packet, ctx->flow.nw_src, ctx->flow.nw_dst,
-                                ctx->flow.nw_tos, ctx->flow.nw_ttl);
-            }
+    commit_odp_actions(&ctx->flow, &ctx->base_flow, ctx->odp_actions);
 
-            if (packet->l7) {
-                if (ctx->flow.nw_proto == IPPROTO_TCP) {
-                    packet_set_tcp_port(packet, ctx->flow.tp_src,
-                                        ctx->flow.tp_dst);
-                } else if (ctx->flow.nw_proto == IPPROTO_UDP) {
-                    packet_set_udp_port(packet, ctx->flow.tp_src,
-                                        ctx->flow.tp_dst);
-                }
-            }
-        }
-    }
+    ovs_assert(!execute_actions(NULL, packet, &key, ctx->odp_actions->data,
+                                ctx->odp_actions->size, NULL, NULL));
 
     pin.packet = packet->data;
     pin.packet_len = packet->size;
-- 
1.8.2.1




More information about the dev mailing list