datapath: Change listing flows to use an iterator concept.
[sliver-openvswitch.git] / lib / dpif-netdev.c
index 996c9a6..5d7fa20 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <net/if.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
 
 #include "csum.h"
+#include "dpif.h"
 #include "dpif-provider.h"
+#include "dummy.h"
 #include "flow.h"
 #include "hmap.h"
 #include "list.h"
 #include "netdev.h"
+#include "netlink.h"
 #include "odp-util.h"
 #include "ofp-print.h"
 #include "ofpbuf.h"
 #include "packets.h"
 #include "poll-loop.h"
-#include "queue.h"
 #include "shash.h"
 #include "timeval.h"
 #include "util.h"
@@ -62,12 +65,14 @@ enum { DP_NETDEV_HEADROOM = 2 + VLAN_HEADER_LEN };
 
 /* Datapath based on the network device interface from netdev.h. */
 struct dp_netdev {
+    const struct dpif_class *class;
     char *name;
     int open_cnt;
     bool destroyed;
 
     bool drop_frags;            /* Drop all IP fragments, if true. */
-    struct ovs_queue queues[N_QUEUES]; /* Messages queued for dpif_recv(). */
+    struct list queues[N_QUEUES]; /* Contain ofpbufs queued for dpif_recv(). */
+    size_t queue_len[N_QUEUES]; /* Number of packets in each queue. */
     struct hmap flow_table;     /* Flow table. */
 
     /* Statistics. */
@@ -88,7 +93,7 @@ struct dp_netdev_port {
     int port_no;                /* Index into dp_netdev's 'ports'. */
     struct list node;           /* Element in dp_netdev's 'port_list'. */
     struct netdev *netdev;
-    bool internal;              /* Internal port (as ODP_PORT_INTERNAL)? */
+    bool internal;              /* Internal port? */
 };
 
 /* A flow in dp_netdev's 'flow_table'. */
@@ -103,8 +108,8 @@ struct dp_netdev_flow {
     uint16_t tcp_ctl;           /* Bitwise-OR of seen tcp_ctl values. */
 
     /* Actions. */
-    union odp_action *actions;
-    unsigned int n_actions;
+    struct nlattr *actions;
+    size_t actions_len;
 };
 
 /* Interface to netdev-based datapath. */
@@ -127,19 +132,24 @@ static int get_port_by_name(struct dp_netdev *, const char *devname,
                             struct dp_netdev_port **portp);
 static void dp_netdev_free(struct dp_netdev *);
 static void dp_netdev_flow_flush(struct dp_netdev *);
-static int do_add_port(struct dp_netdev *, const char *devname, uint16_t flags,
-                       uint16_t port_no);
+static int do_add_port(struct dp_netdev *, const char *devname,
+                       const char *type, uint16_t port_no);
 static int do_del_port(struct dp_netdev *, uint16_t port_no);
+static int dpif_netdev_open(const struct dpif_class *, const char *name,
+                            bool create, struct dpif **);
 static int dp_netdev_output_control(struct dp_netdev *, const struct ofpbuf *,
-                                    int queue_no, int port_no, uint32_t arg);
+                                    int queue_no, int port_no, uint64_t arg);
 static int dp_netdev_execute_actions(struct dp_netdev *,
                                      struct ofpbuf *, struct flow *,
-                                     const union odp_action *, int n);
+                                     const struct nlattr *actions,
+                                     size_t actions_len);
+
+static struct dpif_class dpif_dummy_class;
 
 static struct dpif_netdev *
 dpif_netdev_cast(const struct dpif *dpif)
 {
-    dpif_assert_class(dpif, &dpif_netdev_class);
+    assert(dpif->dpif_class->open == dpif_netdev_open);
     return CONTAINER_OF(dpif, struct dpif_netdev, dpif);
 }
 
@@ -158,8 +168,7 @@ create_dpif_netdev(struct dp_netdev *dp)
     dp->open_cnt++;
 
     dpif = xmalloc(sizeof *dpif);
-    dpif_init(&dpif->dpif, &dpif_netdev_class, dp->name,
-              netflow_id >> 8, netflow_id);
+    dpif_init(&dpif->dpif, dp->class, dp->name, netflow_id >> 8, netflow_id);
     dpif->dp = dp;
     dpif->listen_mask = 0;
     dpif->dp_serial = dp->serial;
@@ -168,22 +177,24 @@ create_dpif_netdev(struct dp_netdev *dp)
 }
 
 static int
-create_dp_netdev(const char *name, struct dp_netdev **dpp)
+create_dp_netdev(const char *name, const struct dpif_class *class,
+                 struct dp_netdev **dpp)
 {
     struct dp_netdev *dp;
     int error;
     int i;
 
     dp = xzalloc(sizeof *dp);
+    dp->class = class;
     dp->name = xstrdup(name);
     dp->open_cnt = 0;
     dp->drop_frags = false;
     for (i = 0; i < N_QUEUES; i++) {
-        queue_init(&dp->queues[i]);
+        list_init(&dp->queues[i]);
     }
     hmap_init(&dp->flow_table);
     list_init(&dp->port_list);
-    error = do_add_port(dp, name, ODP_PORT_INTERNAL, ODPP_LOCAL);
+    error = do_add_port(dp, name, "internal", ODPP_LOCAL);
     if (error) {
         dp_netdev_free(dp);
         return error;
@@ -196,7 +207,7 @@ create_dp_netdev(const char *name, struct dp_netdev **dpp)
 }
 
 static int
-dpif_netdev_open(const struct dpif_class *class OVS_UNUSED, const char *name,
+dpif_netdev_open(const struct dpif_class *class, const char *name,
                  bool create, struct dpif **dpifp)
 {
     struct dp_netdev *dp;
@@ -206,14 +217,16 @@ dpif_netdev_open(const struct dpif_class *class OVS_UNUSED, const char *name,
         if (!create) {
             return ENODEV;
         } else {
-            int error = create_dp_netdev(name, &dp);
+            int error = create_dp_netdev(name, class, &dp);
             if (error) {
                 return error;
             }
             assert(dp != NULL);
         }
     } else {
-        if (create) {
+        if (dp->class != class) {
+            return EINVAL;
+        } else if (create) {
             return EEXIST;
         }
     }
@@ -234,7 +247,7 @@ dp_netdev_free(struct dp_netdev *dp)
         do_del_port(dp, port->port_no);
     }
     for (i = 0; i < N_QUEUES; i++) {
-        queue_destroy(&dp->queues[i]);
+        ofpbuf_list_delete(&dp->queues[i]);
     }
     hmap_destroy(&dp->flow_table);
     free(dp->name);
@@ -297,23 +310,33 @@ dpif_netdev_set_drop_frags(struct dpif *dpif, bool drop_frags)
 }
 
 static int
-do_add_port(struct dp_netdev *dp, const char *devname, uint16_t flags,
+do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
             uint16_t port_no)
 {
-    bool internal = (flags & ODP_PORT_INTERNAL) != 0;
     struct dp_netdev_port *port;
     struct netdev_options netdev_options;
     struct netdev *netdev;
+    bool internal;
     int mtu;
     int error;
 
     /* XXX reject devices already in some dp_netdev. */
+    if (type[0] == '\0' || !strcmp(type, "system")) {
+        internal = false;
+    } else if (!strcmp(type, "internal")) {
+        internal = true;
+    } else {
+        VLOG_WARN("%s: unsupported port type %s", devname, type);
+        return EINVAL;
+    }
 
     /* Open and validate network device. */
     memset(&netdev_options, 0, sizeof netdev_options);
     netdev_options.name = devname;
     netdev_options.ethertype = NETDEV_ETH_TYPE_ANY;
-    if (internal) {
+    if (dp->class == &dpif_dummy_class) {
+        netdev_options.type = "dummy";
+    } else if (internal) {
         netdev_options.type = "tap";
     }
 
@@ -349,7 +372,7 @@ do_add_port(struct dp_netdev *dp, const char *devname, uint16_t flags,
 }
 
 static int
-dpif_netdev_port_add(struct dpif *dpif, const char *devname, uint16_t flags,
+dpif_netdev_port_add(struct dpif *dpif, struct netdev *netdev,
                      uint16_t *port_nop)
 {
     struct dp_netdev *dp = get_dp_netdev(dpif);
@@ -358,7 +381,8 @@ dpif_netdev_port_add(struct dpif *dpif, const char *devname, uint16_t flags,
     for (port_no = 0; port_no < MAX_PORTS; port_no++) {
         if (!dp->ports[port_no]) {
             *port_nop = port_no;
-            return do_add_port(dp, devname, flags, port_no);
+            return do_add_port(dp, netdev_get_name(netdev),
+                               netdev_get_type(netdev), port_no);
         }
     }
     return EFBIG;
@@ -438,7 +462,7 @@ answer_port_query(const struct dp_netdev_port *port, struct odp_port *odp_port)
     ovs_strlcpy(odp_port->devname, netdev_get_name(port->netdev),
                 sizeof odp_port->devname);
     odp_port->port = port->port_no;
-    odp_port->flags = port->internal ? ODP_PORT_INTERNAL : 0;
+    strcpy(odp_port->type, port->internal ? "internal" : "system");
 }
 
 static int
@@ -563,11 +587,10 @@ answer_flow_query(struct dp_netdev_flow *flow, uint32_t query_flags,
         odp_flow->stats.tcp_flags = TCP_FLAGS(flow->tcp_ctl);
         odp_flow->stats.reserved = 0;
         odp_flow->stats.error = 0;
-        if (odp_flow->n_actions > 0) {
-            unsigned int n = MIN(odp_flow->n_actions, flow->n_actions);
+        if (odp_flow->actions_len > 0) {
             memcpy(odp_flow->actions, flow->actions,
-                   n * sizeof *odp_flow->actions);
-            odp_flow->n_actions = flow->n_actions;
+                   MIN(odp_flow->actions_len, flow->actions_len));
+            odp_flow->actions_len = flow->actions_len;
         }
 
         if (query_flags & ODPFF_ZERO_TCP_FLAGS) {
@@ -597,34 +620,42 @@ dpif_netdev_flow_get(const struct dpif *dpif, struct odp_flow flows[], int n)
 }
 
 static int
-dpif_netdev_validate_actions(const union odp_action *actions, int n_actions,
-                             bool *mutates)
+dpif_netdev_validate_actions(const struct nlattr *actions,
+                             size_t actions_len, bool *mutates)
 {
-    unsigned int i;
+    const struct nlattr *a;
+    unsigned int left;
 
     *mutates = false;
-    for (i = 0; i < n_actions; i++) {
-        const union odp_action *a = &actions[i];
-        switch (a->type) {
+    NL_ATTR_FOR_EACH (a, left, actions, actions_len) {
+        uint16_t type = nl_attr_type(a);
+        int len = odp_action_len(type);
+
+        if (len != nl_attr_get_size(a)) {
+            return EINVAL;
+        }
+
+        switch (type) {
         case ODPAT_OUTPUT:
-            if (a->output.port >= MAX_PORTS) {
+            if (nl_attr_get_u32(a) >= MAX_PORTS) {
                 return EINVAL;
             }
             break;
 
         case ODPAT_CONTROLLER:
+        case ODPAT_DROP_SPOOFED_ARP:
             break;
 
         case ODPAT_SET_DL_TCI:
             *mutates = true;
-            if (a->dl_tci.tci & htons(VLAN_CFI)) {
+            if (nl_attr_get_be16(a) & htons(VLAN_CFI)) {
                 return EINVAL;
             }
             break;
 
         case ODPAT_SET_NW_TOS:
             *mutates = true;
-            if (a->nw_tos.nw_tos & IP_ECN_MASK) {
+            if (nl_attr_get_u8(a) & IP_ECN_MASK) {
                 return EINVAL;
             }
             break;
@@ -639,6 +670,9 @@ dpif_netdev_validate_actions(const union odp_action *actions, int n_actions,
             *mutates = true;
             break;
 
+        case ODPAT_SET_TUNNEL:
+        case ODPAT_SET_PRIORITY:
+        case ODPAT_POP_PRIORITY:
         default:
             return EOPNOTSUPP;
         }
@@ -649,23 +683,18 @@ dpif_netdev_validate_actions(const union odp_action *actions, int n_actions,
 static int
 set_flow_actions(struct dp_netdev_flow *flow, struct odp_flow *odp_flow)
 {
-    size_t n_bytes;
     bool mutates;
     int error;
 
-    if (odp_flow->n_actions >= 4096 / sizeof *odp_flow->actions) {
-        return EINVAL;
-    }
     error = dpif_netdev_validate_actions(odp_flow->actions,
-                                         odp_flow->n_actions, &mutates);
+                                         odp_flow->actions_len, &mutates);
     if (error) {
         return error;
     }
 
-    n_bytes = odp_flow->n_actions * sizeof *flow->actions;
-    flow->actions = xrealloc(flow->actions, n_bytes);
-    flow->n_actions = odp_flow->n_actions;
-    memcpy(flow->actions, odp_flow->actions, n_bytes);
+    flow->actions = xrealloc(flow->actions, odp_flow->actions_len);
+    flow->actions_len = odp_flow->actions_len;
+    memcpy(flow->actions, odp_flow->actions, odp_flow->actions_len);
     return 0;
 }
 
@@ -750,29 +779,49 @@ dpif_netdev_flow_del(struct dpif *dpif, struct odp_flow *odp_flow)
     }
 }
 
+struct dp_netdev_flow_state {
+    uint32_t bucket;
+    uint32_t offset;
+};
+
 static int
-dpif_netdev_flow_list(const struct dpif *dpif, struct odp_flow flows[], int n)
+dpif_netdev_flow_dump_start(const struct dpif *dpif OVS_UNUSED, void **statep)
 {
+    *statep = xzalloc(sizeof(struct dp_netdev_flow_state));
+    return 0;
+}
+
+static int
+dpif_netdev_flow_dump_next(const struct dpif *dpif, void *state_,
+                           struct odp_flow *odp_flow)
+{
+    struct dp_netdev_flow_state *state = state_;
     struct dp_netdev *dp = get_dp_netdev(dpif);
     struct dp_netdev_flow *flow;
-    int i;
+    struct hmap_node *node;
 
-    i = 0;
-    HMAP_FOR_EACH (flow, node, &dp->flow_table) {
-        if (i >= n) {
-            break;
-        }
-
-        odp_flow_key_from_flow(&flows[i].key, &flow->key);
-        answer_flow_query(flow, 0, &flows[i]);
-        i++;
+    node = hmap_at_position(&dp->flow_table, &state->bucket, &state->offset);
+    if (!node) {
+        return EOF;
     }
-    return hmap_count(&dp->flow_table);
+
+    flow = CONTAINER_OF(node, struct dp_netdev_flow, node);
+    odp_flow_key_from_flow(&odp_flow->key, &flow->key);
+    answer_flow_query(flow, 0, odp_flow);
+
+    return 0;
+}
+
+static int
+dpif_netdev_flow_dump_done(const struct dpif *dpif OVS_UNUSED, void *state)
+{
+    free(state);
+    return 0;
 }
 
 static int
 dpif_netdev_execute(struct dpif *dpif,
-                    const union odp_action actions[], int n_actions,
+                    const struct nlattr *actions, size_t actions_len,
                     const struct ofpbuf *packet)
 {
     struct dp_netdev *dp = get_dp_netdev(dpif);
@@ -785,7 +834,7 @@ dpif_netdev_execute(struct dpif *dpif,
         return EINVAL;
     }
 
-    error = dpif_netdev_validate_actions(actions, n_actions, &mutates);
+    error = dpif_netdev_validate_actions(actions, actions_len, &mutates);
     if (error) {
         return error;
     }
@@ -794,7 +843,7 @@ dpif_netdev_execute(struct dpif *dpif,
         /* We need a deep copy of 'packet' since we're going to modify its
          * data. */
         ofpbuf_init(&copy, DP_NETDEV_HEADROOM + packet->size);
-        copy.data = (char*)copy.base + DP_NETDEV_HEADROOM;
+        ofpbuf_reserve(&copy, DP_NETDEV_HEADROOM);
         ofpbuf_put(&copy, packet->data, packet->size);
     } else {
         /* We still need a shallow copy of 'packet', even though we won't
@@ -804,7 +853,7 @@ dpif_netdev_execute(struct dpif *dpif,
         copy = *packet;
     }
     flow_extract(&copy, 0, -1, &key);
-    error = dp_netdev_execute_actions(dp, &copy, &key, actions, n_actions);
+    error = dp_netdev_execute_actions(dp, &copy, &key, actions, actions_len);
     if (mutates) {
         ofpbuf_uninit(&copy);
     }
@@ -831,7 +880,7 @@ dpif_netdev_recv_set_mask(struct dpif *dpif, int listen_mask)
     }
 }
 
-static struct ovs_queue *
+static int
 find_nonempty_queue(struct dpif *dpif)
 {
     struct dpif_netdev *dpif_netdev = dpif_netdev_cast(dpif);
@@ -840,20 +889,24 @@ find_nonempty_queue(struct dpif *dpif)
     int i;
 
     for (i = 0; i < N_QUEUES; i++) {
-        struct ovs_queue *q = &dp->queues[i];
-        if (q->n && mask & (1u << i)) {
-            return q;
+        struct list *queue = &dp->queues[i];
+        if (!list_is_empty(queue) && mask & (1u << i)) {
+            return i;
         }
     }
-    return NULL;
+    return -1;
 }
 
 static int
 dpif_netdev_recv(struct dpif *dpif, struct ofpbuf **bufp)
 {
-    struct ovs_queue *q = find_nonempty_queue(dpif);
-    if (q) {
-        *bufp = queue_pop_head(q);
+    int queue_idx = find_nonempty_queue(dpif);
+    if (queue_idx >= 0) {
+        struct dp_netdev *dp = get_dp_netdev(dpif);
+
+        *bufp = ofpbuf_from_list(list_pop_front(&dp->queues[queue_idx]));
+        dp->queue_len[queue_idx]--;
+
         return 0;
     } else {
         return EAGAIN;
@@ -863,8 +916,7 @@ dpif_netdev_recv(struct dpif *dpif, struct ofpbuf **bufp)
 static void
 dpif_netdev_recv_wait(struct dpif *dpif)
 {
-    struct ovs_queue *q = find_nonempty_queue(dpif);
-    if (q) {
+    if (find_nonempty_queue(dpif) >= 0) {
         poll_immediate_wake();
     } else {
         /* No messages ready to be received, and dp_wait() will ensure that we
@@ -904,7 +956,7 @@ dp_netdev_port_input(struct dp_netdev *dp, struct dp_netdev_port *port,
     if (flow) {
         dp_netdev_flow_used(flow, &key, packet);
         dp_netdev_execute_actions(dp, packet, &key,
-                                  flow->actions, flow->n_actions);
+                                  flow->actions, flow->actions_len);
         dp->n_hit++;
     } else {
         dp->n_missed++;
@@ -918,7 +970,7 @@ dp_netdev_run(void)
     struct shash_node *node;
     struct ofpbuf packet;
 
-    ofpbuf_init(&packet, DP_NETDEV_HEADROOM + max_mtu);
+    ofpbuf_init(&packet, DP_NETDEV_HEADROOM + VLAN_ETH_HEADER_LEN + max_mtu);
     SHASH_FOR_EACH (node, &dp_netdevs) {
         struct dp_netdev *dp = node->data;
         struct dp_netdev_port *port;
@@ -927,14 +979,14 @@ dp_netdev_run(void)
             int error;
 
             /* Reset packet contents. */
-            packet.data = (char*)packet.base + DP_NETDEV_HEADROOM;
-            packet.size = 0;
+            ofpbuf_clear(&packet);
+            ofpbuf_reserve(&packet, DP_NETDEV_HEADROOM);
 
             error = netdev_recv(port->netdev, &packet);
             if (!error) {
                 dp_netdev_port_input(dp, port, &packet);
-            } else if (error != EAGAIN) {
-                struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
+            } else if (error != EAGAIN && error != EOPNOTSUPP) {
+                static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
                 VLOG_ERR_RL(&rl, "error receiving data from %s: %s",
                             netdev_get_name(port->netdev), strerror(error));
             }
@@ -1001,8 +1053,7 @@ dp_netdev_strip_vlan(struct ofpbuf *packet)
         memcpy(tmp.eth_src, veh->veth_src, ETH_ADDR_LEN);
         tmp.eth_type = veh->veth_next_type;
 
-        packet->size -= VLAN_HEADER_LEN;
-        packet->data = (char*)packet->data + VLAN_HEADER_LEN;
+        ofpbuf_pull(packet, VLAN_HEADER_LEN);
         packet->l2 = (char*)packet->l2 + VLAN_HEADER_LEN;
         memcpy(packet->data, &tmp, sizeof tmp);
     }
@@ -1029,64 +1080,69 @@ is_ip(const struct ofpbuf *packet, const struct flow *key)
 }
 
 static void
-dp_netdev_set_nw_addr(struct ofpbuf *packet, struct flow *key,
-                      const struct odp_action_nw_addr *a)
+dp_netdev_set_nw_addr(struct ofpbuf *packet, const struct flow *key,
+                      const struct nlattr *a)
 {
     if (is_ip(packet, key)) {
         struct ip_header *nh = packet->l3;
+        ovs_be32 ip = nl_attr_get_be32(a);
+        uint16_t type = nl_attr_type(a);
         uint32_t *field;
 
-        field = a->type == ODPAT_SET_NW_SRC ? &nh->ip_src : &nh->ip_dst;
+        field = type == ODPAT_SET_NW_SRC ? &nh->ip_src : &nh->ip_dst;
         if (key->nw_proto == IP_TYPE_TCP && packet->l7) {
             struct tcp_header *th = packet->l4;
-            th->tcp_csum = recalc_csum32(th->tcp_csum, *field, a->nw_addr);
+            th->tcp_csum = recalc_csum32(th->tcp_csum, *field, ip);
         } else if (key->nw_proto == IP_TYPE_UDP && packet->l7) {
             struct udp_header *uh = packet->l4;
             if (uh->udp_csum) {
-                uh->udp_csum = recalc_csum32(uh->udp_csum, *field, a->nw_addr);
+                uh->udp_csum = recalc_csum32(uh->udp_csum, *field, ip);
                 if (!uh->udp_csum) {
                     uh->udp_csum = 0xffff;
                 }
             }
         }
-        nh->ip_csum = recalc_csum32(nh->ip_csum, *field, a->nw_addr);
-        *field = a->nw_addr;
+        nh->ip_csum = recalc_csum32(nh->ip_csum, *field, ip);
+        *field = ip;
     }
 }
 
 static void
-dp_netdev_set_nw_tos(struct ofpbuf *packet, struct flow *key,
-                     const struct odp_action_nw_tos *a)
+dp_netdev_set_nw_tos(struct ofpbuf *packet, const struct flow *key,
+                     uint8_t nw_tos)
 {
     if (is_ip(packet, key)) {
         struct ip_header *nh = packet->l3;
         uint8_t *field = &nh->ip_tos;
 
         /* Set the DSCP bits and preserve the ECN bits. */
-        uint8_t new = a->nw_tos | (nh->ip_tos & IP_ECN_MASK);
+        uint8_t new = nw_tos | (nh->ip_tos & IP_ECN_MASK);
 
         nh->ip_csum = recalc_csum16(nh->ip_csum, htons((uint16_t)*field),
-                htons((uint16_t)a->nw_tos));
+                htons((uint16_t) new));
         *field = new;
     }
 }
 
 static void
-dp_netdev_set_tp_port(struct ofpbuf *packet, struct flow *key,
-                      const struct odp_action_tp_port *a)
+dp_netdev_set_tp_port(struct ofpbuf *packet, const struct flow *key,
+                      const struct nlattr *a)
 {
        if (is_ip(packet, key)) {
+        uint16_t type = nl_attr_type(a);
+        ovs_be16 port = nl_attr_get_be16(a);
         uint16_t *field;
+
         if (key->nw_proto == IPPROTO_TCP && packet->l7) {
             struct tcp_header *th = packet->l4;
-            field = a->type == ODPAT_SET_TP_SRC ? &th->tcp_src : &th->tcp_dst;
-            th->tcp_csum = recalc_csum16(th->tcp_csum, *field, a->tp_port);
-            *field = a->tp_port;
+            field = type == ODPAT_SET_TP_SRC ? &th->tcp_src : &th->tcp_dst;
+            th->tcp_csum = recalc_csum16(th->tcp_csum, *field, port);
+            *field = port;
         } else if (key->nw_proto == IPPROTO_UDP && packet->l7) {
             struct udp_header *uh = packet->l4;
-            field = a->type == ODPAT_SET_TP_SRC ? &uh->udp_src : &uh->udp_dst;
-            uh->udp_csum = recalc_csum16(uh->udp_csum, *field, a->tp_port);
-            *field = a->tp_port;
+            field = type == ODPAT_SET_TP_SRC ? &uh->udp_src : &uh->udp_dst;
+            uh->udp_csum = recalc_csum16(uh->udp_csum, *field, port);
+            *field = port;
         } else {
             return;
         }
@@ -1105,14 +1161,13 @@ dp_netdev_output_port(struct dp_netdev *dp, struct ofpbuf *packet,
 
 static int
 dp_netdev_output_control(struct dp_netdev *dp, const struct ofpbuf *packet,
-                         int queue_no, int port_no, uint32_t arg)
+                         int queue_no, int port_no, uint64_t arg)
 {
-    struct ovs_queue *q = &dp->queues[queue_no];
     struct odp_msg *header;
     struct ofpbuf *msg;
     size_t msg_size;
 
-    if (q->n >= MAX_QUEUE_LEN) {
+    if (dp->queue_len[queue_no] >= MAX_QUEUE_LEN) {
         dp->n_lost++;
         return ENOBUFS;
     }
@@ -1125,7 +1180,8 @@ dp_netdev_output_control(struct dp_netdev *dp, const struct ofpbuf *packet,
     header->port = port_no;
     header->arg = arg;
     ofpbuf_put(msg, packet->data, packet->size);
-    queue_push_tail(q, msg);
+    list_push_back(&dp->queues[queue_no], &msg->list_node);
+    dp->queue_len[queue_no]++;
 
     return 0;
 }
@@ -1161,24 +1217,25 @@ dp_netdev_is_spoofed_arp(struct ofpbuf *packet, const struct flow *key)
 static int
 dp_netdev_execute_actions(struct dp_netdev *dp,
                           struct ofpbuf *packet, struct flow *key,
-                          const union odp_action *actions, int n_actions)
+                          const struct nlattr *actions,
+                          size_t actions_len)
 {
-    int i;
-    for (i = 0; i < n_actions; i++) {
-        const union odp_action *a = &actions[i];
+    const struct nlattr *a;
+    unsigned int left;
 
-        switch (a->type) {
+    NL_ATTR_FOR_EACH_UNSAFE (a, left, actions, actions_len) {
+        switch (nl_attr_type(a)) {
         case ODPAT_OUTPUT:
-            dp_netdev_output_port(dp, packet, a->output.port);
+            dp_netdev_output_port(dp, packet, nl_attr_get_u32(a));
             break;
 
         case ODPAT_CONTROLLER:
             dp_netdev_output_control(dp, packet, _ODPL_ACTION_NR,
-                                     key->in_port, a->controller.arg);
+                                     key->in_port, nl_attr_get_u64(a));
             break;
 
         case ODPAT_SET_DL_TCI:
-            dp_netdev_set_dl_tci(packet, a->dl_tci.tci);
+            dp_netdev_set_dl_tci(packet, nl_attr_get_be16(a));
             break;
 
         case ODPAT_STRIP_VLAN:
@@ -1186,25 +1243,25 @@ dp_netdev_execute_actions(struct dp_netdev *dp,
             break;
 
         case ODPAT_SET_DL_SRC:
-            dp_netdev_set_dl_src(packet, a->dl_addr.dl_addr);
+            dp_netdev_set_dl_src(packet, nl_attr_get_unspec(a, ETH_ADDR_LEN));
             break;
 
         case ODPAT_SET_DL_DST:
-            dp_netdev_set_dl_dst(packet, a->dl_addr.dl_addr);
+            dp_netdev_set_dl_dst(packet, nl_attr_get_unspec(a, ETH_ADDR_LEN));
             break;
 
         case ODPAT_SET_NW_SRC:
         case ODPAT_SET_NW_DST:
-            dp_netdev_set_nw_addr(packet, key, &a->nw_addr);
+            dp_netdev_set_nw_addr(packet, key, a);
             break;
 
         case ODPAT_SET_NW_TOS:
-            dp_netdev_set_nw_tos(packet, key, &a->nw_tos);
+            dp_netdev_set_nw_tos(packet, key, nl_attr_get_u8(a));
             break;
 
         case ODPAT_SET_TP_SRC:
         case ODPAT_SET_TP_DST:
-            dp_netdev_set_tp_port(packet, key, &a->tp_port);
+            dp_netdev_set_tp_port(packet, key, a);
             break;
 
         case ODPAT_DROP_SPOOFED_ARP:
@@ -1239,7 +1296,9 @@ const struct dpif_class dpif_netdev_class = {
     dpif_netdev_flow_put,
     dpif_netdev_flow_del,
     dpif_netdev_flow_flush,
-    dpif_netdev_flow_list,
+    dpif_netdev_flow_dump_start,
+    dpif_netdev_flow_dump_next,
+    dpif_netdev_flow_dump_done,
     dpif_netdev_execute,
     dpif_netdev_recv_get_mask,
     dpif_netdev_recv_set_mask,
@@ -1249,3 +1308,13 @@ const struct dpif_class dpif_netdev_class = {
     dpif_netdev_recv,
     dpif_netdev_recv_wait,
 };
+
+void
+dpif_dummy_register(void)
+{
+    if (!dpif_dummy_class.type) {
+        dpif_dummy_class = dpif_netdev_class;
+        dpif_dummy_class.type = "dummy";
+        dp_register_provider(&dpif_dummy_class);
+    }
+}