1 /* Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License. */
16 #include "ofproto-dpif-upcall.h"
24 #include "dynamic-string.h"
26 #include "fail-open.h"
27 #include "guarded-list.h"
33 #include "ofproto-dpif-ipfix.h"
34 #include "ofproto-dpif-sflow.h"
36 #include "poll-loop.h"
39 #define MAX_QUEUE_LENGTH 512
41 VLOG_DEFINE_THIS_MODULE(ofproto_dpif_upcall);
43 COVERAGE_DEFINE(drop_queue_overflow);
44 COVERAGE_DEFINE(upcall_queue_overflow);
45 COVERAGE_DEFINE(fmb_queue_overflow);
46 COVERAGE_DEFINE(fmb_queue_revalidated);
48 /* A thread that processes each upcall handed to it by the dispatcher thread,
49 * forwards the upcall's packet, and then queues it to the main ofproto_dpif
50 * to possibly set up a kernel flow as a cache. */
52 struct udpif *udpif; /* Parent udpif. */
53 pthread_t thread; /* Thread ID. */
55 struct ovs_mutex mutex; /* Mutex guarding the following. */
57 /* Atomic queue of unprocessed upcalls. */
58 struct list upcalls OVS_GUARDED;
59 size_t n_upcalls OVS_GUARDED;
61 bool need_signal; /* Only changed by the dispatcher. */
63 pthread_cond_t wake_cond; /* Wakes 'thread' while holding
67 /* An upcall handler for ofproto_dpif.
69 * udpif is implemented as a "dispatcher" thread that reads upcalls from the
70 * kernel. It processes each upcall just enough to figure out its next
71 * destination. For a "miss" upcall (MISS_UPCALL), this is one of several
72 * "handler" threads (see struct handler). Other upcalls are queued to the
73 * main ofproto_dpif. */
75 struct dpif *dpif; /* Datapath handle. */
76 struct dpif_backer *backer; /* Opaque dpif_backer pointer. */
78 uint32_t secret; /* Random seed for upcall hash. */
80 pthread_t dispatcher; /* Dispatcher thread ID. */
82 struct handler *handlers; /* Upcall handlers. */
85 /* Queues to pass up to ofproto-dpif. */
86 struct guarded_list drop_keys; /* "struct drop key"s. */
87 struct guarded_list fmbs; /* "struct flow_miss_batch"es. */
90 struct seq *reval_seq;
92 struct latch exit_latch; /* Tells child threads to exit. */
96 BAD_UPCALL, /* Some kind of bug somewhere. */
97 MISS_UPCALL, /* A flow miss. */
98 SFLOW_UPCALL, /* sFlow sample. */
99 FLOW_SAMPLE_UPCALL, /* Per-flow sampling. */
100 IPFIX_UPCALL /* Per-bridge sampling. */
104 struct list list_node; /* For queuing upcalls. */
105 struct flow_miss *flow_miss; /* This upcall's flow_miss. */
107 /* Raw upcall plus data for keeping track of the memory backing it. */
108 struct dpif_upcall dpif_upcall; /* As returned by dpif_recv() */
109 struct ofpbuf upcall_buf; /* Owns some data in 'dpif_upcall'. */
110 uint64_t upcall_stub[512 / 8]; /* Buffer to reduce need for malloc(). */
113 static void upcall_destroy(struct upcall *);
115 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
117 static void recv_upcalls(struct udpif *);
118 static void handle_upcalls(struct udpif *, struct list *upcalls);
119 static void miss_destroy(struct flow_miss *);
120 static void *udpif_dispatcher(void *);
121 static void *udpif_upcall_handler(void *);
124 udpif_create(struct dpif_backer *backer, struct dpif *dpif)
126 struct udpif *udpif = xzalloc(sizeof *udpif);
129 udpif->backer = backer;
130 udpif->secret = random_uint32();
131 udpif->wait_seq = seq_create();
132 udpif->reval_seq = seq_create();
133 latch_init(&udpif->exit_latch);
134 guarded_list_init(&udpif->drop_keys);
135 guarded_list_init(&udpif->fmbs);
141 udpif_destroy(struct udpif *udpif)
143 struct flow_miss_batch *fmb;
144 struct drop_key *drop_key;
146 udpif_recv_set(udpif, 0, false);
148 while ((drop_key = drop_key_next(udpif))) {
149 drop_key_destroy(drop_key);
152 while ((fmb = flow_miss_batch_next(udpif))) {
153 flow_miss_batch_destroy(fmb);
156 guarded_list_destroy(&udpif->drop_keys);
157 guarded_list_destroy(&udpif->fmbs);
158 latch_destroy(&udpif->exit_latch);
159 seq_destroy(udpif->wait_seq);
160 seq_destroy(udpif->reval_seq);
164 /* Tells 'udpif' to begin or stop handling flow misses depending on the value
165 * of 'enable'. 'n_handlers' is the number of upcall_handler threads to
166 * create. Passing 'n_handlers' as zero is equivalent to passing 'enable' as
169 udpif_recv_set(struct udpif *udpif, size_t n_handlers, bool enable)
171 n_handlers = enable ? n_handlers : 0;
173 /* Stop the old threads (if any). */
174 if (udpif->handlers && udpif->n_handlers != n_handlers) {
177 latch_set(&udpif->exit_latch);
179 /* Wake the handlers so they can exit. */
180 for (i = 0; i < udpif->n_handlers; i++) {
181 struct handler *handler = &udpif->handlers[i];
183 ovs_mutex_lock(&handler->mutex);
184 xpthread_cond_signal(&handler->wake_cond);
185 ovs_mutex_unlock(&handler->mutex);
188 xpthread_join(udpif->dispatcher, NULL);
189 for (i = 0; i < udpif->n_handlers; i++) {
190 struct handler *handler = &udpif->handlers[i];
191 struct upcall *miss, *next;
193 xpthread_join(handler->thread, NULL);
195 ovs_mutex_lock(&handler->mutex);
196 LIST_FOR_EACH_SAFE (miss, next, list_node, &handler->upcalls) {
197 list_remove(&miss->list_node);
198 upcall_destroy(miss);
200 ovs_mutex_unlock(&handler->mutex);
201 ovs_mutex_destroy(&handler->mutex);
203 xpthread_cond_destroy(&handler->wake_cond);
205 latch_poll(&udpif->exit_latch);
207 free(udpif->handlers);
208 udpif->handlers = NULL;
209 udpif->n_handlers = 0;
212 /* Start new threads (if necessary). */
213 if (!udpif->handlers && n_handlers) {
216 udpif->n_handlers = n_handlers;
217 udpif->handlers = xzalloc(udpif->n_handlers * sizeof *udpif->handlers);
218 for (i = 0; i < udpif->n_handlers; i++) {
219 struct handler *handler = &udpif->handlers[i];
221 handler->udpif = udpif;
222 list_init(&handler->upcalls);
223 handler->need_signal = false;
224 xpthread_cond_init(&handler->wake_cond, NULL);
225 ovs_mutex_init(&handler->mutex);
226 xpthread_create(&handler->thread, NULL, udpif_upcall_handler,
229 xpthread_create(&udpif->dispatcher, NULL, udpif_dispatcher, udpif);
234 udpif_wait(struct udpif *udpif)
236 uint64_t seq = seq_read(udpif->wait_seq);
237 if (!guarded_list_is_empty(&udpif->drop_keys) ||
238 !guarded_list_is_empty(&udpif->fmbs)) {
239 poll_immediate_wake();
241 seq_wait(udpif->wait_seq, seq);
245 /* Notifies 'udpif' that something changed which may render previous
246 * xlate_actions() results invalid. */
248 udpif_revalidate(struct udpif *udpif)
250 struct flow_miss_batch *fmb, *next_fmb;
253 /* Since we remove each miss on revalidation, their statistics won't be
254 * accounted to the appropriate 'facet's in the upper layer. In most
255 * cases, this is alright because we've already pushed the stats to the
257 seq_change(udpif->reval_seq);
259 guarded_list_pop_all(&udpif->fmbs, &fmbs);
260 LIST_FOR_EACH_SAFE (fmb, next_fmb, list_node, &fmbs) {
261 list_remove(&fmb->list_node);
262 flow_miss_batch_destroy(fmb);
265 udpif_drop_key_clear(udpif);
268 /* Destroys and deallocates 'upcall'. */
270 upcall_destroy(struct upcall *upcall)
273 ofpbuf_uninit(&upcall->upcall_buf);
278 /* Retrieves the next batch of processed flow misses for 'udpif' to install.
279 * The caller is responsible for destroying it with flow_miss_batch_destroy().
281 struct flow_miss_batch *
282 flow_miss_batch_next(struct udpif *udpif)
286 for (i = 0; i < 50; i++) {
287 struct flow_miss_batch *next;
288 struct list *next_node;
290 next_node = guarded_list_pop_front(&udpif->fmbs);
295 next = CONTAINER_OF(next_node, struct flow_miss_batch, list_node);
296 if (next->reval_seq == seq_read(udpif->reval_seq)) {
300 flow_miss_batch_destroy(next);
306 /* Destroys and deallocates 'fmb'. */
308 flow_miss_batch_destroy(struct flow_miss_batch *fmb)
310 struct flow_miss *miss, *next;
311 struct upcall *upcall, *next_upcall;
317 HMAP_FOR_EACH_SAFE (miss, next, hmap_node, &fmb->misses) {
318 hmap_remove(&fmb->misses, &miss->hmap_node);
322 LIST_FOR_EACH_SAFE (upcall, next_upcall, list_node, &fmb->upcalls) {
323 list_remove(&upcall->list_node);
324 upcall_destroy(upcall);
327 hmap_destroy(&fmb->misses);
331 /* Retrieves the next drop key which ofproto-dpif needs to process. The caller
332 * is responsible for destroying it with drop_key_destroy(). */
334 drop_key_next(struct udpif *udpif)
336 struct list *next = guarded_list_pop_front(&udpif->drop_keys);
337 return next ? CONTAINER_OF(next, struct drop_key, list_node) : NULL;
340 /* Destroys and deallocates 'drop_key'. */
342 drop_key_destroy(struct drop_key *drop_key)
350 /* Clears all drop keys waiting to be processed by drop_key_next(). */
352 udpif_drop_key_clear(struct udpif *udpif)
354 struct drop_key *drop_key, *next;
357 guarded_list_pop_all(&udpif->drop_keys, &list);
358 LIST_FOR_EACH_SAFE (drop_key, next, list_node, &list) {
359 list_remove(&drop_key->list_node);
360 drop_key_destroy(drop_key);
364 /* The dispatcher thread is responsible for receiving upcalls from the kernel,
365 * assigning them to a upcall_handler thread. */
367 udpif_dispatcher(void *arg)
369 struct udpif *udpif = arg;
371 set_subprogram_name("dispatcher");
372 while (!latch_is_set(&udpif->exit_latch)) {
374 dpif_recv_wait(udpif->dpif);
375 latch_wait(&udpif->exit_latch);
382 /* The miss handler thread is responsible for processing miss upcalls retrieved
383 * by the dispatcher thread. Once finished it passes the processed miss
384 * upcalls to ofproto-dpif where they're installed in the datapath. */
386 udpif_upcall_handler(void *arg)
388 struct handler *handler = arg;
390 set_subprogram_name("upcall_%u", ovsthread_id_self());
392 struct list misses = LIST_INITIALIZER(&misses);
395 ovs_mutex_lock(&handler->mutex);
397 if (latch_is_set(&handler->udpif->exit_latch)) {
398 ovs_mutex_unlock(&handler->mutex);
402 if (!handler->n_upcalls) {
403 ovs_mutex_cond_wait(&handler->wake_cond, &handler->mutex);
406 for (i = 0; i < FLOW_MISS_MAX_BATCH; i++) {
407 if (handler->n_upcalls) {
408 handler->n_upcalls--;
409 list_push_back(&misses, list_pop_front(&handler->upcalls));
414 ovs_mutex_unlock(&handler->mutex);
416 handle_upcalls(handler->udpif, &misses);
423 miss_destroy(struct flow_miss *miss)
425 xlate_out_uninit(&miss->xout);
428 static enum upcall_type
429 classify_upcall(const struct upcall *upcall)
431 const struct dpif_upcall *dpif_upcall = &upcall->dpif_upcall;
432 union user_action_cookie cookie;
435 /* First look at the upcall type. */
436 switch (dpif_upcall->type) {
443 case DPIF_N_UC_TYPES:
445 VLOG_WARN_RL(&rl, "upcall has unexpected type %"PRIu32,
450 /* "action" upcalls need a closer look. */
451 if (!dpif_upcall->userdata) {
452 VLOG_WARN_RL(&rl, "action upcall missing cookie");
455 userdata_len = nl_attr_get_size(dpif_upcall->userdata);
456 if (userdata_len < sizeof cookie.type
457 || userdata_len > sizeof cookie) {
458 VLOG_WARN_RL(&rl, "action upcall cookie has unexpected size %"PRIuSIZE,
462 memset(&cookie, 0, sizeof cookie);
463 memcpy(&cookie, nl_attr_get(dpif_upcall->userdata), userdata_len);
464 if (userdata_len == sizeof cookie.sflow
465 && cookie.type == USER_ACTION_COOKIE_SFLOW) {
467 } else if (userdata_len == sizeof cookie.slow_path
468 && cookie.type == USER_ACTION_COOKIE_SLOW_PATH) {
470 } else if (userdata_len == sizeof cookie.flow_sample
471 && cookie.type == USER_ACTION_COOKIE_FLOW_SAMPLE) {
472 return FLOW_SAMPLE_UPCALL;
473 } else if (userdata_len == sizeof cookie.ipfix
474 && cookie.type == USER_ACTION_COOKIE_IPFIX) {
477 VLOG_WARN_RL(&rl, "invalid user cookie of type %"PRIu16
478 " and size %"PRIuSIZE, cookie.type, userdata_len);
484 recv_upcalls(struct udpif *udpif)
489 uint32_t hash = udpif->secret;
490 struct handler *handler;
491 struct upcall *upcall;
492 size_t n_bytes, left;
496 upcall = xmalloc(sizeof *upcall);
497 ofpbuf_use_stub(&upcall->upcall_buf, upcall->upcall_stub,
498 sizeof upcall->upcall_stub);
499 error = dpif_recv(udpif->dpif, &upcall->dpif_upcall,
500 &upcall->upcall_buf);
502 upcall_destroy(upcall);
507 NL_ATTR_FOR_EACH (nla, left, upcall->dpif_upcall.key,
508 upcall->dpif_upcall.key_len) {
509 enum ovs_key_attr type = nl_attr_type(nla);
510 if (type == OVS_KEY_ATTR_IN_PORT
511 || type == OVS_KEY_ATTR_TCP
512 || type == OVS_KEY_ATTR_UDP) {
513 if (nl_attr_get_size(nla) == 4) {
514 hash = mhash_add(hash, nl_attr_get_u32(nla));
518 "Netlink attribute with incorrect size.");
522 hash = mhash_finish(hash, n_bytes);
524 handler = &udpif->handlers[hash % udpif->n_handlers];
526 ovs_mutex_lock(&handler->mutex);
527 if (handler->n_upcalls < MAX_QUEUE_LENGTH) {
528 list_push_back(&handler->upcalls, &upcall->list_node);
529 if (handler->n_upcalls == 0) {
530 handler->need_signal = true;
532 handler->n_upcalls++;
533 if (handler->need_signal &&
534 handler->n_upcalls >= FLOW_MISS_MAX_BATCH) {
535 handler->need_signal = false;
536 xpthread_cond_signal(&handler->wake_cond);
538 ovs_mutex_unlock(&handler->mutex);
539 if (!VLOG_DROP_DBG(&rl)) {
540 struct ds ds = DS_EMPTY_INITIALIZER;
542 odp_flow_key_format(upcall->dpif_upcall.key,
543 upcall->dpif_upcall.key_len,
545 VLOG_DBG("dispatcher: enqueue (%s)", ds_cstr(&ds));
549 ovs_mutex_unlock(&handler->mutex);
550 COVERAGE_INC(upcall_queue_overflow);
551 upcall_destroy(upcall);
555 for (n = 0; n < udpif->n_handlers; ++n) {
556 struct handler *handler = &udpif->handlers[n];
558 if (handler->need_signal) {
559 handler->need_signal = false;
560 ovs_mutex_lock(&handler->mutex);
561 xpthread_cond_signal(&handler->wake_cond);
562 ovs_mutex_unlock(&handler->mutex);
567 static struct flow_miss *
568 flow_miss_find(struct hmap *todo, const struct ofproto_dpif *ofproto,
569 const struct flow *flow, uint32_t hash)
571 struct flow_miss *miss;
573 HMAP_FOR_EACH_WITH_HASH (miss, hmap_node, hash, todo) {
574 if (miss->ofproto == ofproto && flow_equal(&miss->flow, flow)) {
583 handle_upcalls(struct udpif *udpif, struct list *upcalls)
585 struct dpif_op *opsp[FLOW_MISS_MAX_BATCH];
586 struct dpif_op ops[FLOW_MISS_MAX_BATCH];
587 struct upcall *upcall, *next;
588 struct flow_miss_batch *fmb;
589 size_t n_misses, n_ops, i;
590 struct flow_miss *miss;
591 enum upcall_type type;
594 /* Extract the flow from each upcall. Construct in fmb->misses a hash
595 * table that maps each unique flow to a 'struct flow_miss'.
597 * Most commonly there is a single packet per flow_miss, but there are
598 * several reasons why there might be more than one, e.g.:
600 * - The dpif packet interface does not support TSO (or UFO, etc.), so a
601 * large packet sent to userspace is split into a sequence of smaller
604 * - A stream of quickly arriving packets in an established "slow-pathed"
607 * - Rarely, a stream of quickly arriving packets in a flow not yet
608 * established. (This is rare because most protocols do not send
609 * multiple back-to-back packets before receiving a reply from the
610 * other end of the connection, which gives OVS a chance to set up a
613 fmb = xmalloc(sizeof *fmb);
614 fmb->reval_seq = seq_read(udpif->reval_seq);
615 hmap_init(&fmb->misses);
616 list_init(&fmb->upcalls);
618 LIST_FOR_EACH_SAFE (upcall, next, list_node, upcalls) {
619 struct dpif_upcall *dupcall = &upcall->dpif_upcall;
620 struct ofpbuf *packet = dupcall->packet;
621 struct flow_miss *miss = &fmb->miss_buf[n_misses];
622 struct flow_miss *existing_miss;
623 struct ofproto_dpif *ofproto;
624 struct dpif_sflow *sflow;
625 struct dpif_ipfix *ipfix;
626 odp_port_t odp_in_port;
630 error = xlate_receive(udpif->backer, packet, dupcall->key,
631 dupcall->key_len, &flow, &miss->key_fitness,
632 &ofproto, &ipfix, &sflow, NULL, &odp_in_port);
634 if (error == ENODEV) {
635 struct drop_key *drop_key;
637 /* Received packet on datapath port for which we couldn't
638 * associate an ofproto. This can happen if a port is removed
639 * while traffic is being received. Print a rate-limited
640 * message in case it happens frequently. Install a drop flow
641 * so that future packets of the flow are inexpensively dropped
643 VLOG_INFO_RL(&rl, "received packet on unassociated datapath "
644 "port %"PRIu32, odp_in_port);
646 drop_key = xmalloc(sizeof *drop_key);
647 drop_key->key = xmemdup(dupcall->key, dupcall->key_len);
648 drop_key->key_len = dupcall->key_len;
650 if (guarded_list_push_back(&udpif->drop_keys,
651 &drop_key->list_node,
653 seq_change(udpif->wait_seq);
655 COVERAGE_INC(drop_queue_overflow);
656 drop_key_destroy(drop_key);
659 list_remove(&upcall->list_node);
660 upcall_destroy(upcall);
664 type = classify_upcall(upcall);
665 if (type == MISS_UPCALL) {
668 flow_extract(packet, flow.skb_priority, flow.pkt_mark,
669 &flow.tunnel, &flow.in_port, &miss->flow);
671 hash = flow_hash(&miss->flow, 0);
672 existing_miss = flow_miss_find(&fmb->misses, ofproto, &miss->flow,
674 if (!existing_miss) {
675 hmap_insert(&fmb->misses, &miss->hmap_node, hash);
676 miss->ofproto = ofproto;
677 miss->key = dupcall->key;
678 miss->key_len = dupcall->key_len;
679 miss->upcall_type = dupcall->type;
680 miss->stats.n_packets = 0;
681 miss->stats.n_bytes = 0;
682 miss->stats.used = time_msec();
683 miss->stats.tcp_flags = 0;
687 miss = existing_miss;
689 miss->stats.tcp_flags |= packet_get_tcp_flags(packet, &miss->flow);
690 miss->stats.n_bytes += packet->size;
691 miss->stats.n_packets++;
693 upcall->flow_miss = miss;
700 union user_action_cookie cookie;
702 memset(&cookie, 0, sizeof cookie);
703 memcpy(&cookie, nl_attr_get(dupcall->userdata),
704 sizeof cookie.sflow);
705 dpif_sflow_received(sflow, dupcall->packet, &flow, odp_in_port,
711 dpif_ipfix_bridge_sample(ipfix, dupcall->packet, &flow);
714 case FLOW_SAMPLE_UPCALL:
716 union user_action_cookie cookie;
718 memset(&cookie, 0, sizeof cookie);
719 memcpy(&cookie, nl_attr_get(dupcall->userdata),
720 sizeof cookie.flow_sample);
722 /* The flow reflects exactly the contents of the packet.
723 * Sample the packet using it. */
724 dpif_ipfix_flow_sample(ipfix, dupcall->packet, &flow,
725 cookie.flow_sample.collector_set_id,
726 cookie.flow_sample.probability,
727 cookie.flow_sample.obs_domain_id,
728 cookie.flow_sample.obs_point_id);
737 dpif_ipfix_unref(ipfix);
738 dpif_sflow_unref(sflow);
740 list_remove(&upcall->list_node);
741 upcall_destroy(upcall);
744 /* Initialize each 'struct flow_miss's ->xout.
746 * We do this per-flow_miss rather than per-packet because, most commonly,
747 * all the packets in a flow can use the same translation.
749 * We can't do this in the previous loop because we need the TCP flags for
750 * all the packets in each miss. */
752 HMAP_FOR_EACH (miss, hmap_node, &fmb->misses) {
755 xlate_in_init(&xin, miss->ofproto, &miss->flow, NULL,
756 miss->stats.tcp_flags, NULL);
757 xin.may_learn = true;
758 xin.resubmit_stats = &miss->stats;
759 xlate_actions(&xin, &miss->xout);
760 fail_open = fail_open || miss->xout.fail_open;
763 /* Now handle the packets individually in order of arrival. In the common
764 * case each packet of a miss can share the same actions, but slow-pathed
765 * packets need to be translated individually:
767 * - For SLOW_CFM, SLOW_LACP, SLOW_STP, and SLOW_BFD, translation is what
768 * processes received packets for these protocols.
770 * - For SLOW_CONTROLLER, translation sends the packet to the OpenFlow
773 * The loop fills 'ops' with an array of operations to execute in the
776 LIST_FOR_EACH (upcall, list_node, upcalls) {
777 struct flow_miss *miss = upcall->flow_miss;
778 struct ofpbuf *packet = upcall->dpif_upcall.packet;
780 if (miss->xout.slow) {
783 xlate_in_init(&xin, miss->ofproto, &miss->flow, NULL, 0, packet);
784 xlate_actions_for_side_effects(&xin);
787 if (miss->xout.odp_actions.size) {
790 if (miss->flow.in_port.ofp_port
791 != vsp_realdev_to_vlandev(miss->ofproto,
792 miss->flow.in_port.ofp_port,
793 miss->flow.vlan_tci)) {
794 /* This packet was received on a VLAN splinter port. We
795 * added a VLAN to the packet to make the packet resemble
796 * the flow, but the actions were composed assuming that
797 * the packet contained no VLAN. So, we must remove the
798 * VLAN header from the packet before trying to execute the
800 eth_pop_vlan(packet);
804 op->type = DPIF_OP_EXECUTE;
805 op->u.execute.key = miss->key;
806 op->u.execute.key_len = miss->key_len;
807 op->u.execute.packet = packet;
808 op->u.execute.actions = miss->xout.odp_actions.data;
809 op->u.execute.actions_len = miss->xout.odp_actions.size;
810 op->u.execute.needs_help = (miss->xout.slow & SLOW_ACTION) != 0;
815 for (i = 0; i < n_ops; i++) {
818 dpif_operate(udpif->dpif, opsp, n_ops);
820 /* Special case for fail-open mode.
822 * If we are in fail-open mode, but we are connected to a controller too,
823 * then we should send the packet up to the controller in the hope that it
824 * will try to set up a flow and thereby allow us to exit fail-open.
826 * See the top-level comment in fail-open.c for more information. */
828 LIST_FOR_EACH (upcall, list_node, upcalls) {
829 struct flow_miss *miss = upcall->flow_miss;
830 struct ofpbuf *packet = upcall->dpif_upcall.packet;
831 struct ofproto_packet_in *pin;
833 pin = xmalloc(sizeof *pin);
834 pin->up.packet = xmemdup(packet->data, packet->size);
835 pin->up.packet_len = packet->size;
836 pin->up.reason = OFPR_NO_MATCH;
837 pin->up.table_id = 0;
838 pin->up.cookie = OVS_BE64_MAX;
839 flow_get_metadata(&miss->flow, &pin->up.fmd);
840 pin->send_len = 0; /* Not used for flow table misses. */
841 pin->generated_by_table_miss = false;
842 ofproto_dpif_send_packet_in(miss->ofproto, pin);
846 list_move(&fmb->upcalls, upcalls);
848 if (fmb->reval_seq != seq_read(udpif->reval_seq)) {
849 COVERAGE_INC(fmb_queue_revalidated);
850 flow_miss_batch_destroy(fmb);
851 } else if (!guarded_list_push_back(&udpif->fmbs, &fmb->list_node,
853 COVERAGE_INC(fmb_queue_overflow);
854 flow_miss_batch_destroy(fmb);
856 seq_change(udpif->wait_seq);