+ dpif_linux_flow_init(&request);
+ request.cmd = OVS_FLOW_CMD_DEL;
+ request.dp_ifindex = dpif->dp_ifindex;
+ request.key = key;
+ request.key_len = key_len;
+ error = dpif_linux_flow_transact(&request,
+ stats ? &reply : NULL,
+ stats ? &buf : NULL);
+ if (!error && stats) {
+ dpif_linux_flow_get_stats(&reply, stats);
+ ofpbuf_delete(buf);
+ }
+ return error;
+}
+
+struct dpif_linux_flow_state {
+ struct nl_dump dump;
+ struct dpif_linux_flow flow;
+ struct dpif_flow_stats stats;
+ struct ofpbuf *buf;
+};
+
+static int
+dpif_linux_flow_dump_start(const struct dpif *dpif_, void **statep)
+{
+ struct dpif_linux *dpif = dpif_linux_cast(dpif_);
+ struct dpif_linux_flow_state *state;
+ struct dpif_linux_flow request;
+ struct ofpbuf *buf;
+
+ *statep = state = xmalloc(sizeof *state);
+
+ dpif_linux_flow_init(&request);
+ request.cmd = OVS_DP_CMD_GET;
+ request.dp_ifindex = dpif->dp_ifindex;
+
+ buf = ofpbuf_new(1024);
+ dpif_linux_flow_to_ofpbuf(&request, buf);
+ nl_dump_start(&state->dump, genl_sock, buf);
+ ofpbuf_delete(buf);
+
+ state->buf = NULL;
+
+ return 0;
+}
+
+static int
+dpif_linux_flow_dump_next(const struct dpif *dpif_ OVS_UNUSED, void *state_,
+ const struct nlattr **key, size_t *key_len,
+ const struct nlattr **actions, size_t *actions_len,
+ const struct dpif_flow_stats **stats)
+{
+ struct dpif_linux_flow_state *state = state_;
+ struct ofpbuf buf;
+ int error;
+
+ do {
+ ofpbuf_delete(state->buf);
+ state->buf = NULL;
+
+ if (!nl_dump_next(&state->dump, &buf)) {
+ return EOF;
+ }
+
+ 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 int
+dpif_linux_execute__(int dp_ifindex,
+ const struct nlattr *key, size_t key_len,
+ const struct nlattr *actions, size_t actions_len,
+ const struct ofpbuf *packet)
+{
+ struct ovs_header *execute;
+ struct ofpbuf *buf;
+ int error;
+
+ buf = ofpbuf_new(128 + actions_len + packet->size);
+
+ nl_msg_put_genlmsghdr(buf, 0, ovs_packet_family, NLM_F_REQUEST,
+ OVS_PACKET_CMD_EXECUTE, 1);
+
+ execute = ofpbuf_put_uninit(buf, sizeof *execute);
+ execute->dp_ifindex = dp_ifindex;
+
+ nl_msg_put_unspec(buf, OVS_PACKET_ATTR_PACKET, packet->data, packet->size);
+ nl_msg_put_unspec(buf, OVS_PACKET_ATTR_KEY, key, key_len);
+ nl_msg_put_unspec(buf, OVS_PACKET_ATTR_ACTIONS, actions, actions_len);
+
+ error = nl_sock_transact(genl_sock, buf, NULL);
+ ofpbuf_delete(buf);
+ return error;