1 /* Copyright (c) 2015, 2016 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.
21 #include "ofp-actions.h"
22 #include "openvswitch/ofpbuf.h"
23 #include "ovn-controller.h"
24 #include "ovn/lib/ovn-sb-idl.h"
25 #include "openvswitch/vlog.h"
30 #include "vswitch-idl.h"
32 VLOG_DEFINE_THIS_MODULE(physical);
35 physical_register_ovs_idl(struct ovsdb_idl *ovs_idl)
37 ovsdb_idl_add_table(ovs_idl, &ovsrec_table_bridge);
38 ovsdb_idl_add_column(ovs_idl, &ovsrec_bridge_col_ports);
40 ovsdb_idl_add_table(ovs_idl, &ovsrec_table_port);
41 ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_name);
42 ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_interfaces);
43 ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_external_ids);
45 ovsdb_idl_add_table(ovs_idl, &ovsrec_table_interface);
46 ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_name);
47 ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_ofport);
48 ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_external_ids);
51 /* Maps from a chassis to the OpenFlow port number of the tunnel that can be
52 * used to reach that chassis. */
53 struct chassis_tunnel {
54 struct hmap_node hmap_node;
55 const char *chassis_id;
57 enum chassis_tunnel_type type;
60 static struct chassis_tunnel *
61 chassis_tunnel_find(struct hmap *tunnels, const char *chassis_id)
63 struct chassis_tunnel *tun;
64 HMAP_FOR_EACH_WITH_HASH (tun, hmap_node, hash_string(chassis_id, 0),
66 if (!strcmp(tun->chassis_id, chassis_id)) {
74 put_load(uint64_t value, enum mf_field_id dst, int ofs, int n_bits,
75 struct ofpbuf *ofpacts)
77 struct ofpact_set_field *sf = ofpact_put_SET_FIELD(ofpacts);
78 sf->field = mf_from_id(dst);
79 sf->flow_has_vlan = false;
81 ovs_be64 n_value = htonll(value);
82 bitwise_copy(&n_value, 8, 0, &sf->value, sf->field->n_bytes, ofs, n_bits);
83 bitwise_one(&sf->mask, sf->field->n_bytes, ofs, n_bits);
87 put_move(enum mf_field_id src, int src_ofs,
88 enum mf_field_id dst, int dst_ofs,
90 struct ofpbuf *ofpacts)
92 struct ofpact_reg_move *move = ofpact_put_REG_MOVE(ofpacts);
93 move->src.field = mf_from_id(src);
94 move->src.ofs = src_ofs;
95 move->src.n_bits = n_bits;
96 move->dst.field = mf_from_id(dst);
97 move->dst.ofs = dst_ofs;
98 move->dst.n_bits = n_bits;
102 put_resubmit(uint8_t table_id, struct ofpbuf *ofpacts)
104 struct ofpact_resubmit *resubmit = ofpact_put_RESUBMIT(ofpacts);
105 resubmit->in_port = OFPP_IN_PORT;
106 resubmit->table_id = table_id;
110 put_encapsulation(enum mf_field_id mff_ovn_geneve,
111 const struct chassis_tunnel *tun,
112 const struct sbrec_datapath_binding *datapath,
113 uint16_t outport, struct ofpbuf *ofpacts)
115 if (tun->type == GENEVE) {
116 put_load(datapath->tunnel_key, MFF_TUN_ID, 0, 24, ofpacts);
117 put_load(outport, mff_ovn_geneve, 0, 32, ofpacts);
118 put_move(MFF_LOG_INPORT, 0, mff_ovn_geneve, 16, 15, ofpacts);
119 } else if (tun->type == STT) {
120 put_load(datapath->tunnel_key | (outport << 24), MFF_TUN_ID, 0, 64,
122 put_move(MFF_LOG_INPORT, 0, MFF_TUN_ID, 40, 15, ofpacts);
123 } else if (tun->type == VXLAN) {
124 put_load(datapath->tunnel_key, MFF_TUN_ID, 0, 24, ofpacts);
131 put_stack(enum mf_field_id field, struct ofpact_stack *stack)
133 stack->subfield.field = mf_from_id(field);
134 stack->subfield.ofs = 0;
135 stack->subfield.n_bits = stack->subfield.field->n_bits;
138 static const struct sbrec_port_binding*
139 get_localnet_port(struct hmap *local_datapaths, int64_t tunnel_key)
141 struct local_datapath *ld = get_local_datapath(local_datapaths,
143 return ld ? ld->localnet_port : NULL;
147 physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve,
148 const struct ovsrec_bridge *br_int, const char *this_chassis_id,
149 const struct simap *ct_zones, struct hmap *flow_table,
150 struct hmap *local_datapaths, struct hmap *patched_datapaths)
152 struct simap localvif_to_ofport = SIMAP_INITIALIZER(&localvif_to_ofport);
153 struct hmap tunnels = HMAP_INITIALIZER(&tunnels);
155 for (int i = 0; i < br_int->n_ports; i++) {
156 const struct ovsrec_port *port_rec = br_int->ports[i];
157 if (!strcmp(port_rec->name, br_int->name)) {
161 const char *chassis_id = smap_get(&port_rec->external_ids,
163 if (chassis_id && !strcmp(chassis_id, this_chassis_id)) {
167 const char *localnet = smap_get(&port_rec->external_ids,
168 "ovn-localnet-port");
169 const char *logpatch = smap_get(&port_rec->external_ids,
170 "ovn-logical-patch-port");
172 for (int j = 0; j < port_rec->n_interfaces; j++) {
173 const struct ovsrec_interface *iface_rec = port_rec->interfaces[j];
175 /* Get OpenFlow port number. */
176 if (!iface_rec->n_ofport) {
179 int64_t ofport = iface_rec->ofport[0];
180 if (ofport < 1 || ofport > ofp_to_u16(OFPP_MAX)) {
184 /* Record as patch to local net, logical patch port, chassis, or
185 * local logical port. */
186 bool is_patch = !strcmp(iface_rec->type, "patch");
187 if (is_patch && localnet) {
188 /* localnet patch ports can be handled just like VIFs. */
189 simap_put(&localvif_to_ofport, localnet, ofport);
191 } else if (is_patch && logpatch) {
192 /* Logical patch ports can be handled just like VIFs. */
193 simap_put(&localvif_to_ofport, logpatch, ofport);
195 } else if (chassis_id) {
196 enum chassis_tunnel_type tunnel_type;
197 if (!strcmp(iface_rec->type, "geneve")) {
198 tunnel_type = GENEVE;
199 if (!mff_ovn_geneve) {
202 } else if (!strcmp(iface_rec->type, "stt")) {
204 } else if (!strcmp(iface_rec->type, "vxlan")) {
210 struct chassis_tunnel *tun = xmalloc(sizeof *tun);
211 hmap_insert(&tunnels, &tun->hmap_node,
212 hash_string(chassis_id, 0));
213 tun->chassis_id = chassis_id;
214 tun->ofport = u16_to_ofp(ofport);
215 tun->type = tunnel_type;
218 const char *iface_id = smap_get(&iface_rec->external_ids,
221 simap_put(&localvif_to_ofport, iface_id, ofport);
227 struct ofpbuf ofpacts;
228 ofpbuf_init(&ofpacts, 0);
230 /* Set up flows in table 0 for physical-to-logical translation and in table
231 * 64 for logical-to-physical translation. */
232 const struct sbrec_port_binding *binding;
233 SBREC_PORT_BINDING_FOR_EACH (binding, ctx->ovnsb_idl) {
234 /* Skip the port binding if the port is on a datapath that is neither
235 * local nor with any logical patch port connected, because local ports
236 * would never need to talk to those ports.
238 * Even with this approach there could still be unnecessary port
239 * bindings processed. A better approach would be a kind of "flood
242 * 1. Initialize set S to the logical datapaths that have a port
243 * located on the hypervisor.
245 * 2. For each patch port P in a logical datapath in S, add the
246 * logical datapath of the remote end of P to S. Iterate
247 * until S reaches a fixed point.
249 * This can be implemented in northd, which can generate the sets and
250 * save it on each port-binding record in SB, and ovn-controller can
251 * use the information directly. However, there can be update storms
252 * when a pair of patch ports are added/removed to connect/disconnect
253 * large lrouters and lswitches. This need to be studied further.
255 uint32_t dp_key = binding->datapath->tunnel_key;
256 uint32_t port_key = binding->tunnel_key;
257 if (!get_local_datapath(local_datapaths, dp_key)
258 && !get_patched_datapath(patched_datapaths, dp_key)) {
262 /* Find the OpenFlow port for the logical port, as 'ofport'. This is
265 * - If the port is a VIF on the chassis we're managing, the
266 * OpenFlow port for the VIF. 'tun' will be NULL.
268 * The same logic handles logical patch ports, as well as
269 * localnet patch ports.
271 * For a container nested inside a VM and accessible via a VLAN,
272 * 'tag' is the VLAN ID; otherwise 'tag' is 0.
274 * For a localnet patch port, if a VLAN ID was configured, 'tag'
275 * is set to that VLAN ID; otherwise 'tag' is 0.
277 * - If the port is on a remote chassis, the OpenFlow port for a
278 * tunnel to the VIF's remote chassis. 'tun' identifies that
284 bool is_remote = false;
285 if (binding->parent_port && *binding->parent_port) {
289 ofport = u16_to_ofp(simap_get(&localvif_to_ofport,
290 binding->parent_port));
295 ofport = u16_to_ofp(simap_get(&localvif_to_ofport,
296 binding->logical_port));
297 if (!strcmp(binding->type, "localnet") && ofport && binding->tag) {
302 const struct chassis_tunnel *tun = NULL;
303 const struct sbrec_port_binding *localnet_port =
304 get_localnet_port(local_datapaths, dp_key);
306 /* It is remote port, may be reached by tunnel or localnet port */
308 if (!binding->chassis) {
312 ofport = u16_to_ofp(simap_get(&localvif_to_ofport,
313 localnet_port->logical_port));
318 tun = chassis_tunnel_find(&tunnels, binding->chassis->name);
322 ofport = tun->ofport;
328 int zone_id = simap_get(ct_zones, binding->logical_port);
329 /* Packets that arrive from a vif can belong to a VM or
330 * to a container located inside that VM. Packets that
331 * arrive from containers have a tag (vlan) associated with them.
334 /* Table 0, Priority 150 and 100.
335 * ==============================
337 * Priority 150 is for tagged traffic. This may be containers in a
338 * VM or a VLAN on a local network. For such traffic, match on the
339 * tags and then strip the tag.
341 * Priority 100 is for traffic belonging to VMs or untagged locally
342 * connected networks.
344 * For both types of traffic: set MFF_LOG_INPORT to the logical
345 * input port, MFF_LOG_DATAPATH to the logical datapath, and
346 * resubmit into the logical ingress pipeline starting at table
348 ofpbuf_clear(&ofpacts);
349 match_init_catchall(&match);
350 match_set_in_port(&match, ofport);
352 /* Match a VLAN tag and strip it, including stripping priority tags
353 * (e.g. VLAN ID 0). In the latter case we'll add a second flow
354 * for frames that lack any 802.1Q header later. */
355 if (tag || !strcmp(binding->type, "localnet")) {
356 match_set_dl_vlan(&match, htons(tag));
357 ofpact_put_STRIP_VLAN(&ofpacts);
360 /* Remember the size with just strip vlan added so far,
361 * as we're going to remove this with ofpbuf_pull() later. */
362 uint32_t ofpacts_orig_size = ofpacts.size;
365 put_load(zone_id, MFF_LOG_CT_ZONE, 0, 32, &ofpacts);
368 /* Set MFF_LOG_DATAPATH and MFF_LOG_INPORT. */
369 put_load(dp_key, MFF_LOG_DATAPATH, 0, 64, &ofpacts);
370 put_load(port_key, MFF_LOG_INPORT, 0, 32, &ofpacts);
372 /* Resubmit to first logical ingress pipeline table. */
373 put_resubmit(OFTABLE_LOG_INGRESS_PIPELINE, &ofpacts);
374 ofctrl_add_flow(flow_table, OFTABLE_PHY_TO_LOG,
375 tag ? 150 : 100, &match, &ofpacts);
377 if (!tag && !strcmp(binding->type, "localnet")) {
378 /* Add a second flow for frames that lack any 802.1Q
379 * header. For these, drop the OFPACT_STRIP_VLAN
381 ofpbuf_pull(&ofpacts, ofpacts_orig_size);
382 match_set_dl_tci_masked(&match, 0, htons(VLAN_CFI));
383 ofctrl_add_flow(flow_table, 0, 100, &match, &ofpacts);
386 /* Table 33, priority 100.
387 * =======================
389 * Implements output to local hypervisor. Each flow matches a
390 * logical output port on the local hypervisor, and resubmits to
394 match_init_catchall(&match);
395 ofpbuf_clear(&ofpacts);
397 /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */
398 match_set_metadata(&match, htonll(dp_key));
399 match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key);
402 put_load(zone_id, MFF_LOG_CT_ZONE, 0, 32, &ofpacts);
405 /* Resubmit to table 34. */
406 put_resubmit(OFTABLE_DROP_LOOPBACK, &ofpacts);
407 ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100, &match,
410 /* Table 34, Priority 100.
411 * =======================
413 * Drop packets whose logical inport and outport are the same. */
414 match_init_catchall(&match);
415 ofpbuf_clear(&ofpacts);
416 match_set_metadata(&match, htonll(dp_key));
417 match_set_reg(&match, MFF_LOG_INPORT - MFF_REG0, port_key);
418 match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key);
419 ofctrl_add_flow(flow_table, OFTABLE_DROP_LOOPBACK, 100,
422 /* Table 64, Priority 100.
423 * =======================
425 * Deliver the packet to the local vif. */
426 match_init_catchall(&match);
427 ofpbuf_clear(&ofpacts);
428 match_set_metadata(&match, htonll(dp_key));
429 match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key);
431 /* For containers sitting behind a local vif, tag the packets
432 * before delivering them. */
433 struct ofpact_vlan_vid *vlan_vid;
434 vlan_vid = ofpact_put_SET_VLAN_VID(&ofpacts);
435 vlan_vid->vlan_vid = tag;
436 vlan_vid->push_vlan_if_needed = true;
438 /* A packet might need to hair-pin back into its ingress
439 * OpenFlow port (to a different logical port, which we already
440 * checked back in table 34), so set the in_port to zero. */
441 put_stack(MFF_IN_PORT, ofpact_put_STACK_PUSH(&ofpacts));
442 put_load(0, MFF_IN_PORT, 0, 16, &ofpacts);
444 ofpact_put_OUTPUT(&ofpacts)->port = ofport;
446 /* Revert the tag added to the packets headed to containers
447 * in the previous step. If we don't do this, the packets
448 * that are to be broadcasted to a VM in the same logical
449 * switch will also contain the tag. Also revert the zero'd
451 ofpact_put_STRIP_VLAN(&ofpacts);
452 put_stack(MFF_IN_PORT, ofpact_put_STACK_POP(&ofpacts));
454 ofctrl_add_flow(flow_table, OFTABLE_LOG_TO_PHY, 100,
457 /* Remote port connected by localnet port */
458 /* Table 33, priority 100.
459 * =======================
461 * Implements switching to localnet port. Each flow matches a
462 * logical output port on remote hypervisor, switch the output port
463 * to connected localnet port and resubmits to same table.
466 match_init_catchall(&match);
467 ofpbuf_clear(&ofpacts);
469 /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */
470 match_set_metadata(&match, htonll(dp_key));
471 match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key);
473 put_load(localnet_port->tunnel_key, MFF_LOG_OUTPORT, 0, 32, &ofpacts);
475 /* Resubmit to table 33. */
476 put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts);
477 ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100, &match,
480 /* Remote port connected by tunnel */
481 /* Table 32, priority 100.
482 * =======================
484 * Implements output to remote hypervisors. Each flow matches an
485 * output port that includes a logical port on a remote hypervisor,
486 * and tunnels the packet to that hypervisor.
489 match_init_catchall(&match);
490 ofpbuf_clear(&ofpacts);
492 /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */
493 match_set_metadata(&match, htonll(dp_key));
494 match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key);
496 put_encapsulation(mff_ovn_geneve, tun, binding->datapath,
499 /* Output to tunnel. */
500 ofpact_put_OUTPUT(&ofpacts)->port = ofport;
501 ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 100,
506 /* Handle output to multicast groups, in tables 32 and 33. */
507 const struct sbrec_multicast_group *mc;
508 struct ofpbuf remote_ofpacts;
509 ofpbuf_init(&remote_ofpacts, 0);
510 SBREC_MULTICAST_GROUP_FOR_EACH (mc, ctx->ovnsb_idl) {
511 struct sset remote_chassis = SSET_INITIALIZER(&remote_chassis);
514 match_init_catchall(&match);
515 match_set_metadata(&match, htonll(mc->datapath->tunnel_key));
516 match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, mc->tunnel_key);
518 /* Go through all of the ports in the multicast group:
520 * - For remote ports, add the chassis to 'remote_chassis'.
522 * - For local ports (other than logical patch ports), add actions
523 * to 'ofpacts' to set the output port and resubmit.
525 * - For logical patch ports, add actions to 'remote_ofpacts'
526 * instead. (If we put them in 'ofpacts', then the output
527 * would happen on every hypervisor in the multicast group,
528 * effectively duplicating the packet.)
530 ofpbuf_clear(&ofpacts);
531 ofpbuf_clear(&remote_ofpacts);
532 for (size_t i = 0; i < mc->n_ports; i++) {
533 struct sbrec_port_binding *port = mc->ports[i];
535 if (port->datapath != mc->datapath) {
536 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
537 VLOG_WARN_RL(&rl, UUID_FMT": multicast group contains ports "
539 UUID_ARGS(&mc->header_.uuid));
543 int zone_id = simap_get(ct_zones, port->logical_port);
545 put_load(zone_id, MFF_LOG_CT_ZONE, 0, 32, &ofpacts);
548 if (!strcmp(port->type, "patch")) {
549 put_load(port->tunnel_key, MFF_LOG_OUTPORT, 0, 32,
551 put_resubmit(OFTABLE_DROP_LOOPBACK, &remote_ofpacts);
552 } else if (simap_contains(&localvif_to_ofport,
553 (port->parent_port && *port->parent_port)
554 ? port->parent_port : port->logical_port)) {
555 put_load(port->tunnel_key, MFF_LOG_OUTPORT, 0, 32, &ofpacts);
556 put_resubmit(OFTABLE_DROP_LOOPBACK, &ofpacts);
557 } else if (port->chassis && !get_localnet_port(local_datapaths,
558 mc->datapath->tunnel_key)) {
559 /* Add remote chassis only when localnet port not exist,
560 * otherwise multicast will reach remote ports through localnet
562 sset_add(&remote_chassis, port->chassis->name);
566 /* Table 33, priority 100.
567 * =======================
569 * Handle output to the local logical ports in the multicast group, if
571 bool local_ports = ofpacts.size > 0;
573 /* Following delivery to local logical ports, restore the multicast
574 * group as the logical output port. */
575 put_load(mc->tunnel_key, MFF_LOG_OUTPORT, 0, 32, &ofpacts);
577 ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100,
581 /* Table 32, priority 100.
582 * =======================
584 * Handle output to the remote chassis in the multicast group, if
586 if (!sset_is_empty(&remote_chassis) || remote_ofpacts.size > 0) {
587 if (remote_ofpacts.size > 0) {
588 /* Following delivery to logical patch ports, restore the
589 * multicast group as the logical output port. */
590 put_load(mc->tunnel_key, MFF_LOG_OUTPORT, 0, 32,
595 const struct chassis_tunnel *prev = NULL;
596 SSET_FOR_EACH (chassis, &remote_chassis) {
597 const struct chassis_tunnel *tun
598 = chassis_tunnel_find(&tunnels, chassis);
603 if (!prev || tun->type != prev->type) {
604 put_encapsulation(mff_ovn_geneve, tun, mc->datapath,
605 mc->tunnel_key, &remote_ofpacts);
608 ofpact_put_OUTPUT(&remote_ofpacts)->port = tun->ofport;
611 if (remote_ofpacts.size) {
613 put_resubmit(OFTABLE_LOCAL_OUTPUT, &remote_ofpacts);
615 ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 100,
616 &match, &remote_ofpacts);
619 sset_destroy(&remote_chassis);
621 ofpbuf_uninit(&remote_ofpacts);
623 /* Table 0, priority 100.
624 * ======================
626 * Process packets that arrive from a remote hypervisor (by matching
627 * on tunnel in_port). */
629 /* Add flows for Geneve and STT encapsulations. These
630 * encapsulations have metadata about the ingress and egress logical
631 * ports. We set MFF_LOG_DATAPATH, MFF_LOG_INPORT, and
632 * MFF_LOG_OUTPORT from the tunnel key data, then resubmit to table
633 * 33 to handle packets to the local hypervisor. */
634 struct chassis_tunnel *tun;
635 HMAP_FOR_EACH (tun, hmap_node, &tunnels) {
636 struct match match = MATCH_CATCHALL_INITIALIZER;
637 match_set_in_port(&match, tun->ofport);
639 ofpbuf_clear(&ofpacts);
640 if (tun->type == GENEVE) {
641 put_move(MFF_TUN_ID, 0, MFF_LOG_DATAPATH, 0, 24, &ofpacts);
642 put_move(mff_ovn_geneve, 16, MFF_LOG_INPORT, 0, 15,
644 put_move(mff_ovn_geneve, 0, MFF_LOG_OUTPORT, 0, 16,
646 } else if (tun->type == STT) {
647 put_move(MFF_TUN_ID, 40, MFF_LOG_INPORT, 0, 15, &ofpacts);
648 put_move(MFF_TUN_ID, 24, MFF_LOG_OUTPORT, 0, 16, &ofpacts);
649 put_move(MFF_TUN_ID, 0, MFF_LOG_DATAPATH, 0, 24, &ofpacts);
650 } else if (tun->type == VXLAN) {
651 /* We'll handle VXLAN later. */
657 put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts);
659 ofctrl_add_flow(flow_table, OFTABLE_PHY_TO_LOG, 100, &match, &ofpacts);
662 /* Add flows for VXLAN encapsulations. Due to the limited amount of
663 * metadata, we only support VXLAN for connections to gateways. The
664 * VNI is used to populate MFF_LOG_DATAPATH. The gateway's logical
665 * port is set to MFF_LOG_INPORT. Then the packet is resubmitted to
666 * table 16 to determine the logical egress port.
668 * xxx Due to resubmitting to table 16, broadcasts will be re-sent to
669 * xxx all logical ports, including non-local ones which could cause
670 * xxx duplicate packets to be received by multiply-connected gateways. */
671 HMAP_FOR_EACH (tun, hmap_node, &tunnels) {
672 if (tun->type != VXLAN) {
676 SBREC_PORT_BINDING_FOR_EACH (binding, ctx->ovnsb_idl) {
677 struct match match = MATCH_CATCHALL_INITIALIZER;
679 if (!binding->chassis ||
680 strcmp(tun->chassis_id, binding->chassis->name)) {
684 match_set_in_port(&match, tun->ofport);
685 match_set_tun_id(&match, htonll(binding->datapath->tunnel_key));
687 ofpbuf_clear(&ofpacts);
688 put_move(MFF_TUN_ID, 0, MFF_LOG_DATAPATH, 0, 24, &ofpacts);
689 put_load(binding->tunnel_key, MFF_LOG_INPORT, 0, 15, &ofpacts);
690 put_resubmit(OFTABLE_LOG_INGRESS_PIPELINE, &ofpacts);
692 ofctrl_add_flow(flow_table, OFTABLE_PHY_TO_LOG, 100, &match,
697 /* Table 32, Priority 0.
698 * =======================
700 * Resubmit packets that are not directed at tunnels or part of a
701 * multicast group to the local output table. */
703 match_init_catchall(&match);
704 ofpbuf_clear(&ofpacts);
705 put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts);
706 ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 0, &match, &ofpacts);
708 /* Table 34, Priority 0.
709 * =======================
711 * Resubmit packets that don't output to the ingress port (already checked
712 * in table 33) to the logical egress pipeline, clearing the logical
713 * registers (for consistent behavior with packets that get tunneled). */
714 match_init_catchall(&match);
715 ofpbuf_clear(&ofpacts);
716 #define MFF_LOG_REG(ID) put_load(0, ID, 0, 32, &ofpacts);
719 put_resubmit(OFTABLE_LOG_EGRESS_PIPELINE, &ofpacts);
720 ofctrl_add_flow(flow_table, OFTABLE_DROP_LOOPBACK, 0, &match, &ofpacts);
722 ofpbuf_uninit(&ofpacts);
723 simap_destroy(&localvif_to_ofport);
724 struct chassis_tunnel *tun_next;
725 HMAP_FOR_EACH_SAFE (tun, tun_next, hmap_node, &tunnels) {
726 hmap_remove(&tunnels, &tun->hmap_node);
729 hmap_destroy(&tunnels);