+
+ error = dpif_linux_flow_from_ofpbuf(&state->flow, &buf);
+ if (error) {
+ return error;
+ }
+
+ if (actions && !state->flow.actions) {
+ error = dpif_linux_flow_get__(dpif_, state->flow.key,
+ state->flow.key_len,
+ &state->flow, &state->buf);
+ if (error == ENOENT) {
+ VLOG_DBG("dumped flow disappeared on get");
+ } else if (error) {
+ VLOG_WARN("error fetching dumped flow: %s", strerror(error));
+ }
+ }
+ } while (error);
+
+ if (actions) {
+ *actions = state->flow.actions;
+ *actions_len = state->flow.actions_len;
+ }
+ if (key) {
+ *key = state->flow.key;
+ *key_len = state->flow.key_len;
+ }
+ if (stats) {
+ dpif_linux_flow_get_stats(&state->flow, &state->stats);
+ *stats = &state->stats;
+ }
+ return error;
+}
+
+static int
+dpif_linux_flow_dump_done(const struct dpif *dpif OVS_UNUSED, void *state_)
+{
+ struct dpif_linux_flow_state *state = state_;
+ int error = nl_dump_done(&state->dump);
+ ofpbuf_delete(state->buf);
+ free(state);
+ return error;
+}
+
+static void
+dpif_linux_encode_execute(int dp_ifindex, const struct dpif_execute *d_exec,
+ struct ofpbuf *buf)
+{
+ struct ovs_header *k_exec;
+
+ ofpbuf_prealloc_tailroom(buf, (64
+ + d_exec->packet->size
+ + d_exec->key_len
+ + d_exec->actions_len));
+
+ nl_msg_put_genlmsghdr(buf, 0, ovs_packet_family, NLM_F_REQUEST,
+ OVS_PACKET_CMD_EXECUTE, OVS_PACKET_VERSION);
+
+ k_exec = ofpbuf_put_uninit(buf, sizeof *k_exec);
+ k_exec->dp_ifindex = dp_ifindex;
+
+ nl_msg_put_unspec(buf, OVS_PACKET_ATTR_PACKET,
+ d_exec->packet->data, d_exec->packet->size);
+ nl_msg_put_unspec(buf, OVS_PACKET_ATTR_KEY, d_exec->key, d_exec->key_len);
+ nl_msg_put_unspec(buf, OVS_PACKET_ATTR_ACTIONS,
+ d_exec->actions, d_exec->actions_len);
+}
+
+static int
+dpif_linux_execute__(int dp_ifindex, const struct dpif_execute *execute)
+{
+ uint64_t request_stub[1024 / 8];
+ struct ofpbuf request;
+ int error;
+
+ ofpbuf_use_stub(&request, request_stub, sizeof request_stub);
+ dpif_linux_encode_execute(dp_ifindex, execute, &request);
+ error = nl_sock_transact(genl_sock, &request, NULL);
+ ofpbuf_uninit(&request);
+
+ return error;
+}
+
+static int
+dpif_linux_execute(struct dpif *dpif_, const struct dpif_execute *execute)
+{
+ struct dpif_linux *dpif = dpif_linux_cast(dpif_);
+
+ return dpif_linux_execute__(dpif->dp_ifindex, execute);
+}
+
+#define MAX_OPS 50
+
+static void
+dpif_linux_operate__(struct dpif *dpif_, struct dpif_op **ops, size_t n_ops)
+{
+ struct dpif_linux *dpif = dpif_linux_cast(dpif_);
+
+ struct op_auxdata {
+ struct nl_transaction txn;
+
+ struct ofpbuf request;
+ uint64_t request_stub[1024 / 8];
+
+ struct ofpbuf reply;
+ uint64_t reply_stub[1024 / 8];
+ } auxes[MAX_OPS];
+
+ struct nl_transaction *txnsp[MAX_OPS];
+ size_t i;
+
+ ovs_assert(n_ops <= MAX_OPS);
+ for (i = 0; i < n_ops; i++) {
+ struct op_auxdata *aux = &auxes[i];
+ struct dpif_op *op = ops[i];
+ struct dpif_flow_put *put;
+ struct dpif_flow_del *del;
+ struct dpif_execute *execute;
+ struct dpif_linux_flow flow;
+
+ ofpbuf_use_stub(&aux->request,
+ aux->request_stub, sizeof aux->request_stub);
+ aux->txn.request = &aux->request;
+
+ ofpbuf_use_stub(&aux->reply, aux->reply_stub, sizeof aux->reply_stub);
+ aux->txn.reply = NULL;
+
+ switch (op->type) {
+ case DPIF_OP_FLOW_PUT:
+ put = &op->u.flow_put;
+ dpif_linux_init_flow_put(dpif_, put, &flow);
+ if (put->stats) {
+ flow.nlmsg_flags |= NLM_F_ECHO;
+ aux->txn.reply = &aux->reply;
+ }
+ dpif_linux_flow_to_ofpbuf(&flow, &aux->request);
+ break;
+
+ case DPIF_OP_FLOW_DEL:
+ del = &op->u.flow_del;
+ dpif_linux_init_flow_del(dpif_, del, &flow);
+ if (del->stats) {
+ flow.nlmsg_flags |= NLM_F_ECHO;
+ aux->txn.reply = &aux->reply;
+ }
+ dpif_linux_flow_to_ofpbuf(&flow, &aux->request);
+ break;
+
+ case DPIF_OP_EXECUTE:
+ execute = &op->u.execute;
+ dpif_linux_encode_execute(dpif->dp_ifindex, execute,
+ &aux->request);
+ break;
+
+ default:
+ NOT_REACHED();