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.
17 #include "byte-order.h"
21 #include "openvswitch/match.h"
22 #include "openvswitch/ofp-actions.h"
23 #include "openvswitch/ofpbuf.h"
24 #include "openvswitch/vlog.h"
25 #include "ovn-controller.h"
26 #include "ovn/lib/ovn-sb-idl.h"
32 #include "vswitch-idl.h"
34 VLOG_DEFINE_THIS_MODULE(physical);
37 physical_register_ovs_idl(struct ovsdb_idl *ovs_idl)
39 ovsdb_idl_add_table(ovs_idl, &ovsrec_table_bridge);
40 ovsdb_idl_add_column(ovs_idl, &ovsrec_bridge_col_ports);
42 ovsdb_idl_add_table(ovs_idl, &ovsrec_table_port);
43 ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_name);
44 ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_interfaces);
45 ovsdb_idl_add_column(ovs_idl, &ovsrec_port_col_external_ids);
47 ovsdb_idl_add_table(ovs_idl, &ovsrec_table_interface);
48 ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_name);
49 ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_ofport);
50 ovsdb_idl_add_column(ovs_idl, &ovsrec_interface_col_external_ids);
53 /* Maps from a chassis to the OpenFlow port number of the tunnel that can be
54 * used to reach that chassis. */
55 struct chassis_tunnel {
56 struct hmap_node hmap_node;
57 const char *chassis_id;
59 enum chassis_tunnel_type type;
62 static struct chassis_tunnel *
63 chassis_tunnel_find(struct hmap *tunnels, const char *chassis_id)
65 struct chassis_tunnel *tun;
66 HMAP_FOR_EACH_WITH_HASH (tun, hmap_node, hash_string(chassis_id, 0),
68 if (!strcmp(tun->chassis_id, chassis_id)) {
76 put_load(uint64_t value, enum mf_field_id dst, int ofs, int n_bits,
77 struct ofpbuf *ofpacts)
79 struct ofpact_set_field *sf = ofpact_put_SET_FIELD(ofpacts);
80 sf->field = mf_from_id(dst);
81 sf->flow_has_vlan = false;
83 ovs_be64 n_value = htonll(value);
84 bitwise_copy(&n_value, 8, 0, &sf->value, sf->field->n_bytes, ofs, n_bits);
85 bitwise_one(&sf->mask, sf->field->n_bytes, ofs, n_bits);
89 put_move(enum mf_field_id src, int src_ofs,
90 enum mf_field_id dst, int dst_ofs,
92 struct ofpbuf *ofpacts)
94 struct ofpact_reg_move *move = ofpact_put_REG_MOVE(ofpacts);
95 move->src.field = mf_from_id(src);
96 move->src.ofs = src_ofs;
97 move->src.n_bits = n_bits;
98 move->dst.field = mf_from_id(dst);
99 move->dst.ofs = dst_ofs;
100 move->dst.n_bits = n_bits;
104 put_resubmit(uint8_t table_id, struct ofpbuf *ofpacts)
106 struct ofpact_resubmit *resubmit = ofpact_put_RESUBMIT(ofpacts);
107 resubmit->in_port = OFPP_IN_PORT;
108 resubmit->table_id = table_id;
112 put_encapsulation(enum mf_field_id mff_ovn_geneve,
113 const struct chassis_tunnel *tun,
114 const struct sbrec_datapath_binding *datapath,
115 uint16_t outport, struct ofpbuf *ofpacts)
117 if (tun->type == GENEVE) {
118 put_load(datapath->tunnel_key, MFF_TUN_ID, 0, 24, ofpacts);
119 put_load(outport, mff_ovn_geneve, 0, 32, ofpacts);
120 put_move(MFF_LOG_INPORT, 0, mff_ovn_geneve, 16, 15, ofpacts);
121 } else if (tun->type == STT) {
122 put_load(datapath->tunnel_key | (outport << 24), MFF_TUN_ID, 0, 64,
124 put_move(MFF_LOG_INPORT, 0, MFF_TUN_ID, 40, 15, ofpacts);
125 } else if (tun->type == VXLAN) {
126 put_load(datapath->tunnel_key, MFF_TUN_ID, 0, 24, ofpacts);
133 put_stack(enum mf_field_id field, struct ofpact_stack *stack)
135 stack->subfield.field = mf_from_id(field);
136 stack->subfield.ofs = 0;
137 stack->subfield.n_bits = stack->subfield.field->n_bits;
140 static const struct sbrec_port_binding*
141 get_localnet_port(struct hmap *local_datapaths, int64_t tunnel_key)
143 struct local_datapath *ld = get_local_datapath(local_datapaths,
145 return ld ? ld->localnet_port : NULL;
149 physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve,
150 const struct ovsrec_bridge *br_int, const char *this_chassis_id,
151 const struct simap *ct_zones, struct hmap *flow_table,
152 struct hmap *local_datapaths, struct hmap *patched_datapaths)
154 struct simap localvif_to_ofport = SIMAP_INITIALIZER(&localvif_to_ofport);
155 struct hmap tunnels = HMAP_INITIALIZER(&tunnels);
157 for (int i = 0; i < br_int->n_ports; i++) {
158 const struct ovsrec_port *port_rec = br_int->ports[i];
159 if (!strcmp(port_rec->name, br_int->name)) {
163 const char *chassis_id = smap_get(&port_rec->external_ids,
165 if (chassis_id && !strcmp(chassis_id, this_chassis_id)) {
169 const char *localnet = smap_get(&port_rec->external_ids,
170 "ovn-localnet-port");
171 const char *logpatch = smap_get(&port_rec->external_ids,
172 "ovn-logical-patch-port");
174 for (int j = 0; j < port_rec->n_interfaces; j++) {
175 const struct ovsrec_interface *iface_rec = port_rec->interfaces[j];
177 /* Get OpenFlow port number. */
178 if (!iface_rec->n_ofport) {
181 int64_t ofport = iface_rec->ofport[0];
182 if (ofport < 1 || ofport > ofp_to_u16(OFPP_MAX)) {
186 /* Record as patch to local net, logical patch port, chassis, or
187 * local logical port. */
188 bool is_patch = !strcmp(iface_rec->type, "patch");
189 if (is_patch && localnet) {
190 /* localnet patch ports can be handled just like VIFs. */
191 simap_put(&localvif_to_ofport, localnet, ofport);
193 } else if (is_patch && logpatch) {
194 /* Logical patch ports can be handled just like VIFs. */
195 simap_put(&localvif_to_ofport, logpatch, ofport);
197 } else if (chassis_id) {
198 enum chassis_tunnel_type tunnel_type;
199 if (!strcmp(iface_rec->type, "geneve")) {
200 tunnel_type = GENEVE;
201 if (!mff_ovn_geneve) {
204 } else if (!strcmp(iface_rec->type, "stt")) {
206 } else if (!strcmp(iface_rec->type, "vxlan")) {
212 struct chassis_tunnel *tun = xmalloc(sizeof *tun);
213 hmap_insert(&tunnels, &tun->hmap_node,
214 hash_string(chassis_id, 0));
215 tun->chassis_id = chassis_id;
216 tun->ofport = u16_to_ofp(ofport);
217 tun->type = tunnel_type;
220 const char *iface_id = smap_get(&iface_rec->external_ids,
223 simap_put(&localvif_to_ofport, iface_id, ofport);
229 struct ofpbuf ofpacts;
230 ofpbuf_init(&ofpacts, 0);
232 /* Set up flows in table 0 for physical-to-logical translation and in table
233 * 64 for logical-to-physical translation. */
234 const struct sbrec_port_binding *binding;
235 SBREC_PORT_BINDING_FOR_EACH (binding, ctx->ovnsb_idl) {
236 /* Skip the port binding if the port is on a datapath that is neither
237 * local nor with any logical patch port connected, because local ports
238 * would never need to talk to those ports.
240 * Even with this approach there could still be unnecessary port
241 * bindings processed. A better approach would be a kind of "flood
244 * 1. Initialize set S to the logical datapaths that have a port
245 * located on the hypervisor.
247 * 2. For each patch port P in a logical datapath in S, add the
248 * logical datapath of the remote end of P to S. Iterate
249 * until S reaches a fixed point.
251 * This can be implemented in northd, which can generate the sets and
252 * save it on each port-binding record in SB, and ovn-controller can
253 * use the information directly. However, there can be update storms
254 * when a pair of patch ports are added/removed to connect/disconnect
255 * large lrouters and lswitches. This need to be studied further.
257 uint32_t dp_key = binding->datapath->tunnel_key;
258 uint32_t port_key = binding->tunnel_key;
259 if (!get_local_datapath(local_datapaths, dp_key)
260 && !get_patched_datapath(patched_datapaths, dp_key)) {
264 /* Find the OpenFlow port for the logical port, as 'ofport'. This is
267 * - If the port is a VIF on the chassis we're managing, the
268 * OpenFlow port for the VIF. 'tun' will be NULL.
270 * The same logic handles logical patch ports, as well as
271 * localnet patch ports.
273 * For a container nested inside a VM and accessible via a VLAN,
274 * 'tag' is the VLAN ID; otherwise 'tag' is 0.
276 * For a localnet patch port, if a VLAN ID was configured, 'tag'
277 * is set to that VLAN ID; otherwise 'tag' is 0.
279 * - If the port is on a remote chassis, the OpenFlow port for a
280 * tunnel to the VIF's remote chassis. 'tun' identifies that
286 bool is_remote = false;
287 if (binding->parent_port && *binding->parent_port) {
291 ofport = u16_to_ofp(simap_get(&localvif_to_ofport,
292 binding->parent_port));
297 ofport = u16_to_ofp(simap_get(&localvif_to_ofport,
298 binding->logical_port));
299 if (!strcmp(binding->type, "localnet") && ofport && binding->tag) {
304 const struct chassis_tunnel *tun = NULL;
305 const struct sbrec_port_binding *localnet_port =
306 get_localnet_port(local_datapaths, dp_key);
308 /* It is remote port, may be reached by tunnel or localnet port */
310 if (!binding->chassis) {
314 ofport = u16_to_ofp(simap_get(&localvif_to_ofport,
315 localnet_port->logical_port));
320 tun = chassis_tunnel_find(&tunnels, binding->chassis->name);
324 ofport = tun->ofport;
330 int zone_id = simap_get(ct_zones, binding->logical_port);
331 /* Packets that arrive from a vif can belong to a VM or
332 * to a container located inside that VM. Packets that
333 * arrive from containers have a tag (vlan) associated with them.
336 /* Table 0, Priority 150 and 100.
337 * ==============================
339 * Priority 150 is for tagged traffic. This may be containers in a
340 * VM or a VLAN on a local network. For such traffic, match on the
341 * tags and then strip the tag.
343 * Priority 100 is for traffic belonging to VMs or untagged locally
344 * connected networks.
346 * For both types of traffic: set MFF_LOG_INPORT to the logical
347 * input port, MFF_LOG_DATAPATH to the logical datapath, and
348 * resubmit into the logical ingress pipeline starting at table
350 ofpbuf_clear(&ofpacts);
351 match_init_catchall(&match);
352 match_set_in_port(&match, ofport);
354 /* Match a VLAN tag and strip it, including stripping priority tags
355 * (e.g. VLAN ID 0). In the latter case we'll add a second flow
356 * for frames that lack any 802.1Q header later. */
357 if (tag || !strcmp(binding->type, "localnet")) {
358 match_set_dl_vlan(&match, htons(tag));
359 ofpact_put_STRIP_VLAN(&ofpacts);
362 /* Remember the size with just strip vlan added so far,
363 * as we're going to remove this with ofpbuf_pull() later. */
364 uint32_t ofpacts_orig_size = ofpacts.size;
367 put_load(zone_id, MFF_LOG_CT_ZONE, 0, 32, &ofpacts);
370 /* Set MFF_LOG_DATAPATH and MFF_LOG_INPORT. */
371 put_load(dp_key, MFF_LOG_DATAPATH, 0, 64, &ofpacts);
372 put_load(port_key, MFF_LOG_INPORT, 0, 32, &ofpacts);
374 /* Resubmit to first logical ingress pipeline table. */
375 put_resubmit(OFTABLE_LOG_INGRESS_PIPELINE, &ofpacts);
376 ofctrl_add_flow(flow_table, OFTABLE_PHY_TO_LOG,
377 tag ? 150 : 100, &match, &ofpacts);
379 if (!tag && !strcmp(binding->type, "localnet")) {
380 /* Add a second flow for frames that lack any 802.1Q
381 * header. For these, drop the OFPACT_STRIP_VLAN
383 ofpbuf_pull(&ofpacts, ofpacts_orig_size);
384 match_set_dl_tci_masked(&match, 0, htons(VLAN_CFI));
385 ofctrl_add_flow(flow_table, 0, 100, &match, &ofpacts);
388 /* Table 33, priority 100.
389 * =======================
391 * Implements output to local hypervisor. Each flow matches a
392 * logical output port on the local hypervisor, and resubmits to
396 match_init_catchall(&match);
397 ofpbuf_clear(&ofpacts);
399 /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */
400 match_set_metadata(&match, htonll(dp_key));
401 match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key);
404 put_load(zone_id, MFF_LOG_CT_ZONE, 0, 32, &ofpacts);
407 /* Resubmit to table 34. */
408 put_resubmit(OFTABLE_DROP_LOOPBACK, &ofpacts);
409 ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100, &match,
412 /* Table 34, Priority 100.
413 * =======================
415 * Drop packets whose logical inport and outport are the same. */
416 match_init_catchall(&match);
417 ofpbuf_clear(&ofpacts);
418 match_set_metadata(&match, htonll(dp_key));
419 match_set_reg(&match, MFF_LOG_INPORT - MFF_REG0, port_key);
420 match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key);
421 ofctrl_add_flow(flow_table, OFTABLE_DROP_LOOPBACK, 100,
424 /* Table 64, Priority 100.
425 * =======================
427 * Deliver the packet to the local vif. */
428 match_init_catchall(&match);
429 ofpbuf_clear(&ofpacts);
430 match_set_metadata(&match, htonll(dp_key));
431 match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key);
433 /* For containers sitting behind a local vif, tag the packets
434 * before delivering them. */
435 struct ofpact_vlan_vid *vlan_vid;
436 vlan_vid = ofpact_put_SET_VLAN_VID(&ofpacts);
437 vlan_vid->vlan_vid = tag;
438 vlan_vid->push_vlan_if_needed = true;
440 /* A packet might need to hair-pin back into its ingress
441 * OpenFlow port (to a different logical port, which we already
442 * checked back in table 34), so set the in_port to zero. */
443 put_stack(MFF_IN_PORT, ofpact_put_STACK_PUSH(&ofpacts));
444 put_load(0, MFF_IN_PORT, 0, 16, &ofpacts);
446 ofpact_put_OUTPUT(&ofpacts)->port = ofport;
448 /* Revert the tag added to the packets headed to containers
449 * in the previous step. If we don't do this, the packets
450 * that are to be broadcasted to a VM in the same logical
451 * switch will also contain the tag. Also revert the zero'd
453 ofpact_put_STRIP_VLAN(&ofpacts);
454 put_stack(MFF_IN_PORT, ofpact_put_STACK_POP(&ofpacts));
456 ofctrl_add_flow(flow_table, OFTABLE_LOG_TO_PHY, 100,
459 /* Remote port connected by localnet port */
460 /* Table 33, priority 100.
461 * =======================
463 * Implements switching to localnet port. Each flow matches a
464 * logical output port on remote hypervisor, switch the output port
465 * to connected localnet port and resubmits to same table.
468 match_init_catchall(&match);
469 ofpbuf_clear(&ofpacts);
471 /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */
472 match_set_metadata(&match, htonll(dp_key));
473 match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key);
475 put_load(localnet_port->tunnel_key, MFF_LOG_OUTPORT, 0, 32, &ofpacts);
477 /* Resubmit to table 33. */
478 put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts);
479 ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100, &match,
482 /* Remote port connected by tunnel */
483 /* Table 32, priority 100.
484 * =======================
486 * Implements output to remote hypervisors. Each flow matches an
487 * output port that includes a logical port on a remote hypervisor,
488 * and tunnels the packet to that hypervisor.
491 match_init_catchall(&match);
492 ofpbuf_clear(&ofpacts);
494 /* Match MFF_LOG_DATAPATH, MFF_LOG_OUTPORT. */
495 match_set_metadata(&match, htonll(dp_key));
496 match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, port_key);
498 put_encapsulation(mff_ovn_geneve, tun, binding->datapath,
501 /* Output to tunnel. */
502 ofpact_put_OUTPUT(&ofpacts)->port = ofport;
503 ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 100,
508 /* Handle output to multicast groups, in tables 32 and 33. */
509 const struct sbrec_multicast_group *mc;
510 struct ofpbuf remote_ofpacts;
511 ofpbuf_init(&remote_ofpacts, 0);
512 SBREC_MULTICAST_GROUP_FOR_EACH (mc, ctx->ovnsb_idl) {
513 struct sset remote_chassis = SSET_INITIALIZER(&remote_chassis);
516 match_init_catchall(&match);
517 match_set_metadata(&match, htonll(mc->datapath->tunnel_key));
518 match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, mc->tunnel_key);
520 /* Go through all of the ports in the multicast group:
522 * - For remote ports, add the chassis to 'remote_chassis'.
524 * - For local ports (other than logical patch ports), add actions
525 * to 'ofpacts' to set the output port and resubmit.
527 * - For logical patch ports, add actions to 'remote_ofpacts'
528 * instead. (If we put them in 'ofpacts', then the output
529 * would happen on every hypervisor in the multicast group,
530 * effectively duplicating the packet.)
532 ofpbuf_clear(&ofpacts);
533 ofpbuf_clear(&remote_ofpacts);
534 for (size_t i = 0; i < mc->n_ports; i++) {
535 struct sbrec_port_binding *port = mc->ports[i];
537 if (port->datapath != mc->datapath) {
538 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
539 VLOG_WARN_RL(&rl, UUID_FMT": multicast group contains ports "
541 UUID_ARGS(&mc->header_.uuid));
545 int zone_id = simap_get(ct_zones, port->logical_port);
547 put_load(zone_id, MFF_LOG_CT_ZONE, 0, 32, &ofpacts);
550 if (!strcmp(port->type, "patch")) {
551 put_load(port->tunnel_key, MFF_LOG_OUTPORT, 0, 32,
553 put_resubmit(OFTABLE_DROP_LOOPBACK, &remote_ofpacts);
554 } else if (simap_contains(&localvif_to_ofport,
555 (port->parent_port && *port->parent_port)
556 ? port->parent_port : port->logical_port)) {
557 put_load(port->tunnel_key, MFF_LOG_OUTPORT, 0, 32, &ofpacts);
558 put_resubmit(OFTABLE_DROP_LOOPBACK, &ofpacts);
559 } else if (port->chassis && !get_localnet_port(local_datapaths,
560 mc->datapath->tunnel_key)) {
561 /* Add remote chassis only when localnet port not exist,
562 * otherwise multicast will reach remote ports through localnet
564 sset_add(&remote_chassis, port->chassis->name);
568 /* Table 33, priority 100.
569 * =======================
571 * Handle output to the local logical ports in the multicast group, if
573 bool local_ports = ofpacts.size > 0;
575 /* Following delivery to local logical ports, restore the multicast
576 * group as the logical output port. */
577 put_load(mc->tunnel_key, MFF_LOG_OUTPORT, 0, 32, &ofpacts);
579 ofctrl_add_flow(flow_table, OFTABLE_LOCAL_OUTPUT, 100,
583 /* Table 32, priority 100.
584 * =======================
586 * Handle output to the remote chassis in the multicast group, if
588 if (!sset_is_empty(&remote_chassis) || remote_ofpacts.size > 0) {
589 if (remote_ofpacts.size > 0) {
590 /* Following delivery to logical patch ports, restore the
591 * multicast group as the logical output port. */
592 put_load(mc->tunnel_key, MFF_LOG_OUTPORT, 0, 32,
597 const struct chassis_tunnel *prev = NULL;
598 SSET_FOR_EACH (chassis, &remote_chassis) {
599 const struct chassis_tunnel *tun
600 = chassis_tunnel_find(&tunnels, chassis);
605 if (!prev || tun->type != prev->type) {
606 put_encapsulation(mff_ovn_geneve, tun, mc->datapath,
607 mc->tunnel_key, &remote_ofpacts);
610 ofpact_put_OUTPUT(&remote_ofpacts)->port = tun->ofport;
613 if (remote_ofpacts.size) {
615 put_resubmit(OFTABLE_LOCAL_OUTPUT, &remote_ofpacts);
617 ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 100,
618 &match, &remote_ofpacts);
621 sset_destroy(&remote_chassis);
623 ofpbuf_uninit(&remote_ofpacts);
625 /* Table 0, priority 100.
626 * ======================
628 * Process packets that arrive from a remote hypervisor (by matching
629 * on tunnel in_port). */
631 /* Add flows for Geneve and STT encapsulations. These
632 * encapsulations have metadata about the ingress and egress logical
633 * ports. We set MFF_LOG_DATAPATH, MFF_LOG_INPORT, and
634 * MFF_LOG_OUTPORT from the tunnel key data, then resubmit to table
635 * 33 to handle packets to the local hypervisor. */
636 struct chassis_tunnel *tun;
637 HMAP_FOR_EACH (tun, hmap_node, &tunnels) {
638 struct match match = MATCH_CATCHALL_INITIALIZER;
639 match_set_in_port(&match, tun->ofport);
641 ofpbuf_clear(&ofpacts);
642 if (tun->type == GENEVE) {
643 put_move(MFF_TUN_ID, 0, MFF_LOG_DATAPATH, 0, 24, &ofpacts);
644 put_move(mff_ovn_geneve, 16, MFF_LOG_INPORT, 0, 15,
646 put_move(mff_ovn_geneve, 0, MFF_LOG_OUTPORT, 0, 16,
648 } else if (tun->type == STT) {
649 put_move(MFF_TUN_ID, 40, MFF_LOG_INPORT, 0, 15, &ofpacts);
650 put_move(MFF_TUN_ID, 24, MFF_LOG_OUTPORT, 0, 16, &ofpacts);
651 put_move(MFF_TUN_ID, 0, MFF_LOG_DATAPATH, 0, 24, &ofpacts);
652 } else if (tun->type == VXLAN) {
653 /* We'll handle VXLAN later. */
659 put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts);
661 ofctrl_add_flow(flow_table, OFTABLE_PHY_TO_LOG, 100, &match, &ofpacts);
664 /* Add flows for VXLAN encapsulations. Due to the limited amount of
665 * metadata, we only support VXLAN for connections to gateways. The
666 * VNI is used to populate MFF_LOG_DATAPATH. The gateway's logical
667 * port is set to MFF_LOG_INPORT. Then the packet is resubmitted to
668 * table 16 to determine the logical egress port.
670 * xxx Due to resubmitting to table 16, broadcasts will be re-sent to
671 * xxx all logical ports, including non-local ones which could cause
672 * xxx duplicate packets to be received by multiply-connected gateways. */
673 HMAP_FOR_EACH (tun, hmap_node, &tunnels) {
674 if (tun->type != VXLAN) {
678 SBREC_PORT_BINDING_FOR_EACH (binding, ctx->ovnsb_idl) {
679 struct match match = MATCH_CATCHALL_INITIALIZER;
681 if (!binding->chassis ||
682 strcmp(tun->chassis_id, binding->chassis->name)) {
686 match_set_in_port(&match, tun->ofport);
687 match_set_tun_id(&match, htonll(binding->datapath->tunnel_key));
689 ofpbuf_clear(&ofpacts);
690 put_move(MFF_TUN_ID, 0, MFF_LOG_DATAPATH, 0, 24, &ofpacts);
691 put_load(binding->tunnel_key, MFF_LOG_INPORT, 0, 15, &ofpacts);
692 put_resubmit(OFTABLE_LOG_INGRESS_PIPELINE, &ofpacts);
694 ofctrl_add_flow(flow_table, OFTABLE_PHY_TO_LOG, 100, &match,
699 /* Table 32, Priority 0.
700 * =======================
702 * Resubmit packets that are not directed at tunnels or part of a
703 * multicast group to the local output table. */
705 match_init_catchall(&match);
706 ofpbuf_clear(&ofpacts);
707 put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts);
708 ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 0, &match, &ofpacts);
710 /* Table 34, Priority 0.
711 * =======================
713 * Resubmit packets that don't output to the ingress port (already checked
714 * in table 33) to the logical egress pipeline, clearing the logical
715 * registers (for consistent behavior with packets that get tunneled). */
716 match_init_catchall(&match);
717 ofpbuf_clear(&ofpacts);
718 #define MFF_LOG_REG(ID) put_load(0, ID, 0, 32, &ofpacts);
721 put_resubmit(OFTABLE_LOG_EGRESS_PIPELINE, &ofpacts);
722 ofctrl_add_flow(flow_table, OFTABLE_DROP_LOOPBACK, 0, &match, &ofpacts);
724 ofpbuf_uninit(&ofpacts);
725 simap_destroy(&localvif_to_ofport);
726 HMAP_FOR_EACH_POP (tun, hmap_node, &tunnels) {
729 hmap_destroy(&tunnels);