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 size_t n_new_upcalls; /* Only changed by the dispatcher. */
62 bool need_signal; /* Only changed by the dispatcher. */
64 pthread_cond_t wake_cond; /* Wakes 'thread' while holding
68 /* An upcall handler for ofproto_dpif.
70 * udpif is implemented as a "dispatcher" thread that reads upcalls from the
71 * kernel. It processes each upcall just enough to figure out its next
72 * destination. For a "miss" upcall (MISS_UPCALL), this is one of several
73 * "handler" threads (see struct handler). Other upcalls are queued to the
74 * main ofproto_dpif. */
76 struct dpif *dpif; /* Datapath handle. */
77 struct dpif_backer *backer; /* Opaque dpif_backer pointer. */
79 uint32_t secret; /* Random seed for upcall hash. */
81 pthread_t dispatcher; /* Dispatcher thread ID. */
83 struct handler *handlers; /* Upcall handlers. */
86 /* Queues to pass up to ofproto-dpif. */
87 struct guarded_list drop_keys; /* "struct drop key"s. */
88 struct guarded_list fmbs; /* "struct flow_miss_batch"es. */
90 /* Number of times udpif_revalidate() has been called. */
91 atomic_uint reval_seq;
95 struct latch exit_latch; /* Tells child threads to exit. */
99 BAD_UPCALL, /* Some kind of bug somewhere. */
100 MISS_UPCALL, /* A flow miss. */
101 SFLOW_UPCALL, /* sFlow sample. */
102 FLOW_SAMPLE_UPCALL, /* Per-flow sampling. */
103 IPFIX_UPCALL /* Per-bridge sampling. */
107 struct list list_node; /* For queuing upcalls. */
108 struct flow_miss *flow_miss; /* This upcall's flow_miss. */
110 /* Raw upcall plus data for keeping track of the memory backing it. */
111 struct dpif_upcall dpif_upcall; /* As returned by dpif_recv() */
112 struct ofpbuf upcall_buf; /* Owns some data in 'dpif_upcall'. */
113 uint64_t upcall_stub[512 / 8]; /* Buffer to reduce need for malloc(). */
116 static void upcall_destroy(struct upcall *);
118 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
120 static void recv_upcalls(struct udpif *);
121 static void handle_upcalls(struct udpif *, struct list *upcalls);
122 static void miss_destroy(struct flow_miss *);
123 static void *udpif_dispatcher(void *);
124 static void *udpif_upcall_handler(void *);
127 udpif_create(struct dpif_backer *backer, struct dpif *dpif)
129 struct udpif *udpif = xzalloc(sizeof *udpif);
132 udpif->backer = backer;
133 udpif->secret = random_uint32();
134 udpif->wait_seq = seq_create();
135 latch_init(&udpif->exit_latch);
136 guarded_list_init(&udpif->drop_keys);
137 guarded_list_init(&udpif->fmbs);
138 atomic_init(&udpif->reval_seq, 0);
144 udpif_destroy(struct udpif *udpif)
146 struct flow_miss_batch *fmb;
147 struct drop_key *drop_key;
149 udpif_recv_set(udpif, 0, false);
151 while ((drop_key = drop_key_next(udpif))) {
152 drop_key_destroy(drop_key);
155 while ((fmb = flow_miss_batch_next(udpif))) {
156 flow_miss_batch_destroy(fmb);
159 guarded_list_destroy(&udpif->drop_keys);
160 guarded_list_destroy(&udpif->fmbs);
161 latch_destroy(&udpif->exit_latch);
162 seq_destroy(udpif->wait_seq);
166 /* Tells 'udpif' to begin or stop handling flow misses depending on the value
167 * of 'enable'. 'n_handlers' is the number of upcall_handler threads to
168 * create. Passing 'n_handlers' as zero is equivalent to passing 'enable' as
171 udpif_recv_set(struct udpif *udpif, size_t n_handlers, bool enable)
173 n_handlers = enable ? n_handlers : 0;
174 n_handlers = MIN(n_handlers, 64);
176 /* Stop the old threads (if any). */
177 if (udpif->handlers && udpif->n_handlers != n_handlers) {
180 latch_set(&udpif->exit_latch);
182 /* Wake the handlers so they can exit. */
183 for (i = 0; i < udpif->n_handlers; i++) {
184 struct handler *handler = &udpif->handlers[i];
186 ovs_mutex_lock(&handler->mutex);
187 xpthread_cond_signal(&handler->wake_cond);
188 ovs_mutex_unlock(&handler->mutex);
191 xpthread_join(udpif->dispatcher, NULL);
192 for (i = 0; i < udpif->n_handlers; i++) {
193 struct handler *handler = &udpif->handlers[i];
194 struct upcall *miss, *next;
196 xpthread_join(handler->thread, NULL);
198 ovs_mutex_lock(&handler->mutex);
199 LIST_FOR_EACH_SAFE (miss, next, list_node, &handler->upcalls) {
200 list_remove(&miss->list_node);
201 upcall_destroy(miss);
203 ovs_mutex_unlock(&handler->mutex);
204 ovs_mutex_destroy(&handler->mutex);
206 xpthread_cond_destroy(&handler->wake_cond);
208 latch_poll(&udpif->exit_latch);
210 free(udpif->handlers);
211 udpif->handlers = NULL;
212 udpif->n_handlers = 0;
215 /* Start new threads (if necessary). */
216 if (!udpif->handlers && n_handlers) {
219 udpif->n_handlers = n_handlers;
220 udpif->handlers = xzalloc(udpif->n_handlers * sizeof *udpif->handlers);
221 for (i = 0; i < udpif->n_handlers; i++) {
222 struct handler *handler = &udpif->handlers[i];
224 handler->udpif = udpif;
225 list_init(&handler->upcalls);
226 handler->need_signal = false;
227 xpthread_cond_init(&handler->wake_cond, NULL);
228 ovs_mutex_init(&handler->mutex);
229 xpthread_create(&handler->thread, NULL, udpif_upcall_handler,
232 xpthread_create(&udpif->dispatcher, NULL, udpif_dispatcher, udpif);
237 udpif_wait(struct udpif *udpif)
239 uint64_t seq = seq_read(udpif->wait_seq);
240 if (!guarded_list_is_empty(&udpif->drop_keys) ||
241 !guarded_list_is_empty(&udpif->fmbs)) {
242 poll_immediate_wake();
244 seq_wait(udpif->wait_seq, seq);
248 /* Notifies 'udpif' that something changed which may render previous
249 * xlate_actions() results invalid. */
251 udpif_revalidate(struct udpif *udpif)
253 struct flow_miss_batch *fmb, *next_fmb;
257 /* Since we remove each miss on revalidation, their statistics won't be
258 * accounted to the appropriate 'facet's in the upper layer. In most
259 * cases, this is alright because we've already pushed the stats to the
260 * relevant rules. However, NetFlow requires absolute packet counts on
261 * 'facet's which could now be incorrect. */
262 atomic_add(&udpif->reval_seq, 1, &junk);
264 guarded_list_pop_all(&udpif->fmbs, &fmbs);
265 LIST_FOR_EACH_SAFE (fmb, next_fmb, list_node, &fmbs) {
266 list_remove(&fmb->list_node);
267 flow_miss_batch_destroy(fmb);
270 udpif_drop_key_clear(udpif);
273 /* Destroys and deallocates 'upcall'. */
275 upcall_destroy(struct upcall *upcall)
278 ofpbuf_uninit(&upcall->upcall_buf);
283 /* Retrieves the next batch of processed flow misses for 'udpif' to install.
284 * The caller is responsible for destroying it with flow_miss_batch_destroy().
286 struct flow_miss_batch *
287 flow_miss_batch_next(struct udpif *udpif)
291 for (i = 0; i < 50; i++) {
292 struct flow_miss_batch *next;
293 unsigned int reval_seq;
294 struct list *next_node;
296 next_node = guarded_list_pop_front(&udpif->fmbs);
301 next = CONTAINER_OF(next_node, struct flow_miss_batch, list_node);
302 atomic_read(&udpif->reval_seq, &reval_seq);
303 if (next->reval_seq == reval_seq) {
307 flow_miss_batch_destroy(next);
313 /* Destroys and deallocates 'fmb'. */
315 flow_miss_batch_destroy(struct flow_miss_batch *fmb)
317 struct flow_miss *miss, *next;
318 struct upcall *upcall, *next_upcall;
324 HMAP_FOR_EACH_SAFE (miss, next, hmap_node, &fmb->misses) {
325 hmap_remove(&fmb->misses, &miss->hmap_node);
329 LIST_FOR_EACH_SAFE (upcall, next_upcall, list_node, &fmb->upcalls) {
330 list_remove(&upcall->list_node);
331 upcall_destroy(upcall);
334 hmap_destroy(&fmb->misses);
338 /* Retrieves the next drop key which ofproto-dpif needs to process. The caller
339 * is responsible for destroying it with drop_key_destroy(). */
341 drop_key_next(struct udpif *udpif)
343 struct list *next = guarded_list_pop_front(&udpif->drop_keys);
344 return next ? CONTAINER_OF(next, struct drop_key, list_node) : NULL;
347 /* Destroys and deallocates 'drop_key'. */
349 drop_key_destroy(struct drop_key *drop_key)
357 /* Clears all drop keys waiting to be processed by drop_key_next(). */
359 udpif_drop_key_clear(struct udpif *udpif)
361 struct drop_key *drop_key, *next;
364 guarded_list_pop_all(&udpif->drop_keys, &list);
365 LIST_FOR_EACH_SAFE (drop_key, next, list_node, &list) {
366 list_remove(&drop_key->list_node);
367 drop_key_destroy(drop_key);
371 /* The dispatcher thread is responsible for receiving upcalls from the kernel,
372 * assigning them to a upcall_handler thread. */
374 udpif_dispatcher(void *arg)
376 struct udpif *udpif = arg;
378 set_subprogram_name("dispatcher");
379 while (!latch_is_set(&udpif->exit_latch)) {
381 dpif_recv_wait(udpif->dpif);
382 latch_wait(&udpif->exit_latch);
389 /* The miss handler thread is responsible for processing miss upcalls retrieved
390 * by the dispatcher thread. Once finished it passes the processed miss
391 * upcalls to ofproto-dpif where they're installed in the datapath. */
393 udpif_upcall_handler(void *arg)
395 struct handler *handler = arg;
397 set_subprogram_name("upcall_%u", ovsthread_id_self());
399 struct list misses = LIST_INITIALIZER(&misses);
402 ovs_mutex_lock(&handler->mutex);
404 if (latch_is_set(&handler->udpif->exit_latch)) {
405 ovs_mutex_unlock(&handler->mutex);
409 if (!handler->n_upcalls) {
410 ovs_mutex_cond_wait(&handler->wake_cond, &handler->mutex);
413 for (i = 0; i < FLOW_MISS_MAX_BATCH; i++) {
414 if (handler->n_upcalls) {
415 handler->n_upcalls--;
416 list_push_back(&misses, list_pop_front(&handler->upcalls));
421 ovs_mutex_unlock(&handler->mutex);
423 handle_upcalls(handler->udpif, &misses);
430 miss_destroy(struct flow_miss *miss)
432 xlate_out_uninit(&miss->xout);
435 static enum upcall_type
436 classify_upcall(const struct upcall *upcall)
438 const struct dpif_upcall *dpif_upcall = &upcall->dpif_upcall;
439 union user_action_cookie cookie;
442 /* First look at the upcall type. */
443 switch (dpif_upcall->type) {
450 case DPIF_N_UC_TYPES:
452 VLOG_WARN_RL(&rl, "upcall has unexpected type %"PRIu32,
457 /* "action" upcalls need a closer look. */
458 if (!dpif_upcall->userdata) {
459 VLOG_WARN_RL(&rl, "action upcall missing cookie");
462 userdata_len = nl_attr_get_size(dpif_upcall->userdata);
463 if (userdata_len < sizeof cookie.type
464 || userdata_len > sizeof cookie) {
465 VLOG_WARN_RL(&rl, "action upcall cookie has unexpected size %zu",
469 memset(&cookie, 0, sizeof cookie);
470 memcpy(&cookie, nl_attr_get(dpif_upcall->userdata), userdata_len);
471 if (userdata_len == sizeof cookie.sflow
472 && cookie.type == USER_ACTION_COOKIE_SFLOW) {
474 } else if (userdata_len == sizeof cookie.slow_path
475 && cookie.type == USER_ACTION_COOKIE_SLOW_PATH) {
477 } else if (userdata_len == sizeof cookie.flow_sample
478 && cookie.type == USER_ACTION_COOKIE_FLOW_SAMPLE) {
479 return FLOW_SAMPLE_UPCALL;
480 } else if (userdata_len == sizeof cookie.ipfix
481 && cookie.type == USER_ACTION_COOKIE_IPFIX) {
484 VLOG_WARN_RL(&rl, "invalid user cookie of type %"PRIu16
485 " and size %zu", cookie.type, userdata_len);
491 recv_upcalls(struct udpif *udpif)
496 uint32_t hash = udpif->secret;
497 struct handler *handler;
498 struct upcall *upcall;
499 size_t n_bytes, left;
503 upcall = xmalloc(sizeof *upcall);
504 ofpbuf_use_stub(&upcall->upcall_buf, upcall->upcall_stub,
505 sizeof upcall->upcall_stub);
506 error = dpif_recv(udpif->dpif, &upcall->dpif_upcall,
507 &upcall->upcall_buf);
509 upcall_destroy(upcall);
514 NL_ATTR_FOR_EACH (nla, left, upcall->dpif_upcall.key,
515 upcall->dpif_upcall.key_len) {
516 enum ovs_key_attr type = nl_attr_type(nla);
517 if (type == OVS_KEY_ATTR_IN_PORT
518 || type == OVS_KEY_ATTR_TCP
519 || type == OVS_KEY_ATTR_UDP) {
520 if (nl_attr_get_size(nla) == 4) {
521 hash = mhash_add(hash, nl_attr_get_u32(nla));
525 "Netlink attribute with incorrect size.");
529 hash = mhash_finish(hash, n_bytes);
531 handler = &udpif->handlers[hash % udpif->n_handlers];
533 ovs_mutex_lock(&handler->mutex);
534 if (handler->n_upcalls < MAX_QUEUE_LENGTH) {
535 list_push_back(&handler->upcalls, &upcall->list_node);
536 if (handler->n_upcalls == 0) {
537 handler->need_signal = true;
539 handler->n_upcalls++;
540 if (handler->need_signal &&
541 handler->n_upcalls >= FLOW_MISS_MAX_BATCH) {
542 handler->need_signal = false;
543 xpthread_cond_signal(&handler->wake_cond);
545 ovs_mutex_unlock(&handler->mutex);
546 if (!VLOG_DROP_DBG(&rl)) {
547 struct ds ds = DS_EMPTY_INITIALIZER;
549 odp_flow_key_format(upcall->dpif_upcall.key,
550 upcall->dpif_upcall.key_len,
552 VLOG_DBG("dispatcher: enqueue (%s)", ds_cstr(&ds));
556 ovs_mutex_unlock(&handler->mutex);
557 COVERAGE_INC(upcall_queue_overflow);
558 upcall_destroy(upcall);
562 for (n = 0; n < udpif->n_handlers; ++n) {
563 struct handler *handler = &udpif->handlers[n];
565 if (handler->need_signal) {
566 handler->need_signal = false;
567 ovs_mutex_lock(&handler->mutex);
568 xpthread_cond_signal(&handler->wake_cond);
569 ovs_mutex_unlock(&handler->mutex);
574 static struct flow_miss *
575 flow_miss_find(struct hmap *todo, const struct ofproto_dpif *ofproto,
576 const struct flow *flow, uint32_t hash)
578 struct flow_miss *miss;
580 HMAP_FOR_EACH_WITH_HASH (miss, hmap_node, hash, todo) {
581 if (miss->ofproto == ofproto && flow_equal(&miss->flow, flow)) {
590 handle_upcalls(struct udpif *udpif, struct list *upcalls)
592 struct dpif_op *opsp[FLOW_MISS_MAX_BATCH];
593 struct dpif_op ops[FLOW_MISS_MAX_BATCH];
594 struct upcall *upcall, *next;
595 struct flow_miss_batch *fmb;
596 size_t n_misses, n_ops, i;
597 struct flow_miss *miss;
598 unsigned int reval_seq;
599 enum upcall_type type;
602 /* Extract the flow from each upcall. Construct in fmb->misses a hash
603 * table that maps each unique flow to a 'struct flow_miss'.
605 * Most commonly there is a single packet per flow_miss, but there are
606 * several reasons why there might be more than one, e.g.:
608 * - The dpif packet interface does not support TSO (or UFO, etc.), so a
609 * large packet sent to userspace is split into a sequence of smaller
612 * - A stream of quickly arriving packets in an established "slow-pathed"
615 * - Rarely, a stream of quickly arriving packets in a flow not yet
616 * established. (This is rare because most protocols do not send
617 * multiple back-to-back packets before receiving a reply from the
618 * other end of the connection, which gives OVS a chance to set up a
621 fmb = xmalloc(sizeof *fmb);
622 atomic_read(&udpif->reval_seq, &fmb->reval_seq);
623 hmap_init(&fmb->misses);
624 list_init(&fmb->upcalls);
626 LIST_FOR_EACH_SAFE (upcall, next, list_node, upcalls) {
627 struct dpif_upcall *dupcall = &upcall->dpif_upcall;
628 struct ofpbuf *packet = dupcall->packet;
629 struct flow_miss *miss = &fmb->miss_buf[n_misses];
630 struct flow_miss *existing_miss;
631 struct ofproto_dpif *ofproto;
632 struct dpif_sflow *sflow;
633 struct dpif_ipfix *ipfix;
634 odp_port_t odp_in_port;
638 error = xlate_receive(udpif->backer, packet, dupcall->key,
639 dupcall->key_len, &flow, &miss->key_fitness,
640 &ofproto, &odp_in_port);
642 if (error == ENODEV) {
643 struct drop_key *drop_key;
645 /* Received packet on datapath port for which we couldn't
646 * associate an ofproto. This can happen if a port is removed
647 * while traffic is being received. Print a rate-limited
648 * message in case it happens frequently. Install a drop flow
649 * so that future packets of the flow are inexpensively dropped
651 VLOG_INFO_RL(&rl, "received packet on unassociated datapath "
652 "port %"PRIu32, odp_in_port);
654 drop_key = xmalloc(sizeof *drop_key);
655 drop_key->key = xmemdup(dupcall->key, dupcall->key_len);
656 drop_key->key_len = dupcall->key_len;
658 if (guarded_list_push_back(&udpif->drop_keys,
659 &drop_key->list_node,
661 seq_change(udpif->wait_seq);
663 COVERAGE_INC(drop_queue_overflow);
664 drop_key_destroy(drop_key);
667 list_remove(&upcall->list_node);
668 upcall_destroy(upcall);
672 type = classify_upcall(upcall);
673 if (type == MISS_UPCALL) {
676 flow_extract(packet, flow.skb_priority, flow.pkt_mark,
677 &flow.tunnel, &flow.in_port, &miss->flow);
679 hash = flow_hash(&miss->flow, 0);
680 existing_miss = flow_miss_find(&fmb->misses, ofproto, &miss->flow,
682 if (!existing_miss) {
683 hmap_insert(&fmb->misses, &miss->hmap_node, hash);
684 miss->ofproto = ofproto;
685 miss->key = dupcall->key;
686 miss->key_len = dupcall->key_len;
687 miss->upcall_type = dupcall->type;
688 miss->stats.n_packets = 0;
689 miss->stats.n_bytes = 0;
690 miss->stats.used = time_msec();
691 miss->stats.tcp_flags = 0;
695 miss = existing_miss;
697 miss->stats.tcp_flags |= packet_get_tcp_flags(packet, &miss->flow);
698 miss->stats.n_bytes += packet->size;
699 miss->stats.n_packets++;
701 upcall->flow_miss = miss;
707 sflow = xlate_get_sflow(ofproto);
709 union user_action_cookie cookie;
711 memset(&cookie, 0, sizeof cookie);
712 memcpy(&cookie, nl_attr_get(dupcall->userdata),
713 sizeof cookie.sflow);
714 dpif_sflow_received(sflow, dupcall->packet, &flow, odp_in_port,
716 dpif_sflow_unref(sflow);
720 ipfix = xlate_get_ipfix(ofproto);
722 dpif_ipfix_bridge_sample(ipfix, dupcall->packet, &flow);
723 dpif_ipfix_unref(ipfix);
726 case FLOW_SAMPLE_UPCALL:
727 ipfix = xlate_get_ipfix(ofproto);
729 union user_action_cookie cookie;
731 memset(&cookie, 0, sizeof cookie);
732 memcpy(&cookie, nl_attr_get(dupcall->userdata),
733 sizeof cookie.flow_sample);
735 /* The flow reflects exactly the contents of the packet.
736 * Sample the packet using it. */
737 dpif_ipfix_flow_sample(ipfix, dupcall->packet, &flow,
738 cookie.flow_sample.collector_set_id,
739 cookie.flow_sample.probability,
740 cookie.flow_sample.obs_domain_id,
741 cookie.flow_sample.obs_point_id);
742 dpif_ipfix_unref(ipfix);
751 list_remove(&upcall->list_node);
752 upcall_destroy(upcall);
755 /* Initialize each 'struct flow_miss's ->xout.
757 * We do this per-flow_miss rather than per-packet because, most commonly,
758 * all the packets in a flow can use the same translation.
760 * We can't do this in the previous loop because we need the TCP flags for
761 * all the packets in each miss. */
763 HMAP_FOR_EACH (miss, hmap_node, &fmb->misses) {
766 xlate_in_init(&xin, miss->ofproto, &miss->flow, NULL,
767 miss->stats.tcp_flags, NULL);
768 xin.may_learn = true;
769 xin.resubmit_stats = &miss->stats;
770 xlate_actions(&xin, &miss->xout);
771 fail_open = fail_open || miss->xout.fail_open;
774 /* Now handle the packets individually in order of arrival. In the common
775 * case each packet of a miss can share the same actions, but slow-pathed
776 * packets need to be translated individually:
778 * - For SLOW_CFM, SLOW_LACP, SLOW_STP, and SLOW_BFD, translation is what
779 * processes received packets for these protocols.
781 * - For SLOW_CONTROLLER, translation sends the packet to the OpenFlow
784 * The loop fills 'ops' with an array of operations to execute in the
787 LIST_FOR_EACH (upcall, list_node, upcalls) {
788 struct flow_miss *miss = upcall->flow_miss;
789 struct ofpbuf *packet = upcall->dpif_upcall.packet;
791 if (miss->xout.slow) {
794 xlate_in_init(&xin, miss->ofproto, &miss->flow, NULL, 0, packet);
795 xlate_actions_for_side_effects(&xin);
798 if (miss->xout.odp_actions.size) {
801 if (miss->flow.in_port.ofp_port
802 != vsp_realdev_to_vlandev(miss->ofproto,
803 miss->flow.in_port.ofp_port,
804 miss->flow.vlan_tci)) {
805 /* This packet was received on a VLAN splinter port. We
806 * added a VLAN to the packet to make the packet resemble
807 * the flow, but the actions were composed assuming that
808 * the packet contained no VLAN. So, we must remove the
809 * VLAN header from the packet before trying to execute the
811 eth_pop_vlan(packet);
815 op->type = DPIF_OP_EXECUTE;
816 op->u.execute.key = miss->key;
817 op->u.execute.key_len = miss->key_len;
818 op->u.execute.packet = packet;
819 op->u.execute.actions = miss->xout.odp_actions.data;
820 op->u.execute.actions_len = miss->xout.odp_actions.size;
821 op->u.execute.needs_help = (miss->xout.slow & SLOW_ACTION) != 0;
826 for (i = 0; i < n_ops; i++) {
829 dpif_operate(udpif->dpif, opsp, n_ops);
831 /* Special case for fail-open mode.
833 * If we are in fail-open mode, but we are connected to a controller too,
834 * then we should send the packet up to the controller in the hope that it
835 * will try to set up a flow and thereby allow us to exit fail-open.
837 * See the top-level comment in fail-open.c for more information. */
839 LIST_FOR_EACH (upcall, list_node, upcalls) {
840 struct flow_miss *miss = upcall->flow_miss;
841 struct ofpbuf *packet = upcall->dpif_upcall.packet;
842 struct ofproto_packet_in *pin;
844 pin = xmalloc(sizeof *pin);
845 pin->up.packet = xmemdup(packet->data, packet->size);
846 pin->up.packet_len = packet->size;
847 pin->up.reason = OFPR_NO_MATCH;
848 pin->up.table_id = 0;
849 pin->up.cookie = OVS_BE64_MAX;
850 flow_get_metadata(&miss->flow, &pin->up.fmd);
851 pin->send_len = 0; /* Not used for flow table misses. */
852 pin->generated_by_table_miss = false;
853 ofproto_dpif_send_packet_in(miss->ofproto, pin);
857 list_move(&fmb->upcalls, upcalls);
859 atomic_read(&udpif->reval_seq, &reval_seq);
860 if (reval_seq != fmb->reval_seq) {
861 COVERAGE_INC(fmb_queue_revalidated);
862 flow_miss_batch_destroy(fmb);
863 } else if (!guarded_list_push_back(&udpif->fmbs, &fmb->list_node,
865 COVERAGE_INC(fmb_queue_overflow);
866 flow_miss_batch_destroy(fmb);
868 seq_change(udpif->wait_seq);