odp-execute: Refine signatures for odp_execute_actions() callbacks.
authorBen Pfaff <blp@nicira.com>
Fri, 20 Sep 2013 19:47:33 +0000 (12:47 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 10 Oct 2013 00:14:40 +0000 (17:14 -0700)
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/dpif-netdev.c
lib/odp-execute.c
lib/odp-execute.h

index 0d489ba..0f6a71c 100644 (file)
@@ -1226,10 +1226,11 @@ dpif_netdev_wait(struct dpif *dpif)
 }
 
 static void
-dp_netdev_output_port(void *dp_, struct ofpbuf *packet, uint32_t out_port)
+dp_netdev_output_port(void *dp_, struct ofpbuf *packet,
+                      const struct flow *flow OVS_UNUSED, odp_port_t out_port)
 {
     struct dp_netdev *dp = dp_;
-    struct dp_netdev_port *p = dp->ports[out_port];
+    struct dp_netdev_port *p = dp->ports[odp_to_u32(out_port)];
     if (p) {
         netdev_send(p->netdev, packet);
     }
@@ -1289,8 +1290,11 @@ dp_netdev_output_userspace(struct dp_netdev *dp, const struct ofpbuf *packet,
 static void
 dp_netdev_action_userspace(void *dp, struct ofpbuf *packet,
                            const struct flow *key,
-                           const struct nlattr *userdata)
+                           const struct nlattr *a)
 {
+    const struct nlattr *userdata;
+
+    userdata = nl_attr_find_nested(a, OVS_USERSPACE_ATTR_USERDATA);
     dp_netdev_output_userspace(dp, packet, DPIF_UC_ACTION, key, userdata);
 }
 
index c91cc4a..3914c3b 100644 (file)
@@ -125,10 +125,11 @@ static void
 odp_execute_sample(void *dp, struct ofpbuf *packet, struct flow *key,
                    const struct nlattr *action,
                    void (*output)(void *dp, struct ofpbuf *packet,
-                                  uint32_t out_port),
+                                  const struct flow *key,
+                                  odp_port_t out_port),
                    void (*userspace)(void *dp, struct ofpbuf *packet,
                                      const struct flow *key,
-                                     const struct nlattr *a))
+                                     const struct nlattr *action))
 {
     const struct nlattr *subactions = NULL;
     const struct nlattr *a;
@@ -163,10 +164,11 @@ void
 odp_execute_actions(void *dp, struct ofpbuf *packet, struct flow *key,
                     const struct nlattr *actions, size_t actions_len,
                     void (*output)(void *dp, struct ofpbuf *packet,
-                                   uint32_t out_port),
+                                   const struct flow *key,
+                                   odp_port_t out_port),
                     void (*userspace)(void *dp, struct ofpbuf *packet,
                                       const struct flow *key,
-                                      const struct nlattr *a))
+                                      const struct nlattr *action))
 {
     const struct nlattr *a;
     unsigned int left;
@@ -177,16 +179,12 @@ odp_execute_actions(void *dp, struct ofpbuf *packet, struct flow *key,
         switch ((enum ovs_action_attr) type) {
         case OVS_ACTION_ATTR_OUTPUT:
             if (output) {
-                output(dp, packet, nl_attr_get_u32(a));
+                output(dp, packet, key, u32_to_odp(nl_attr_get_u32(a)));
             }
             break;
 
         case OVS_ACTION_ATTR_USERSPACE: {
-            if (userspace) {
-                const struct nlattr *userdata;
-                userdata = nl_attr_find_nested(a, OVS_USERSPACE_ATTR_USERDATA);
-                userspace(dp, packet, key, userdata);
-            }
+            userspace(dp, packet, key, a);
             break;
         }
 
index 89dd66b..5d9fa90 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <stddef.h>
 #include <stdint.h>
+#include "openvswitch/types.h"
 
 struct flow;
 struct nlattr;
@@ -29,8 +30,9 @@ void
 odp_execute_actions(void *dp, struct ofpbuf *packet, struct flow *key,
                     const struct nlattr *actions, size_t actions_len,
                     void (*output)(void *dp, struct ofpbuf *packet,
-                                   uint32_t out_port),
+                                   const struct flow *key,
+                                   odp_port_t out_port),
                     void (*userspace)(void *dp, struct ofpbuf *packet,
                                       const struct flow *key,
-                                      const struct nlattr *a));
+                                      const struct nlattr *action));
 #endif