diff mbox series

[ovs-dev,1/2] OVN: Add multicast keep-local flag.

Message ID 20171018165349.21753-2-mmichels@redhat.com
State Changes Requested
Headers show
Series OVN: Add support for periodic router advertisements | expand

Commit Message

Mark Michelson Oct. 18, 2017, 4:53 p.m. UTC
When this flag is set, then a multicast packet that would normally be
delivered to ports on multiple hypervisors is only delivered to ports
on the local hypervisor.

The primary known use case for this is when multicast packets originate
from ovn-controller. Multiple ovn-controllers will be attempting to send
out those multicast packets, and so each should only be responsible for
delivering those packets to their local ports.

Signed-off-by: Mark Michelson <mmichels@redhat.com>
---
 ovn/controller/physical.c | 15 +++++++++++++++
 ovn/lib/logical-fields.h  |  6 ++++++
 2 files changed, 21 insertions(+)

Comments

Ben Pfaff Nov. 1, 2017, 9:35 p.m. UTC | #1
On Wed, Oct 18, 2017 at 11:53:48AM -0500, Mark Michelson wrote:
> When this flag is set, then a multicast packet that would normally be
> delivered to ports on multiple hypervisors is only delivered to ports
> on the local hypervisor.
> 
> The primary known use case for this is when multicast packets originate
> from ovn-controller. Multiple ovn-controllers will be attempting to send
> out those multicast packets, and so each should only be responsible for
> delivering those packets to their local ports.
> 
> Signed-off-by: Mark Michelson <mmichels@redhat.com>

Thanks for working on this.

Would you mind updating the "Architectural Physical Life Cycle of a
Packet" section in ovn-architecture(7) to describe this behavior?

Thanks,

Ben.
diff mbox series

Patch

diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c
index df71979f9..b2216457f 100644
--- a/ovn/controller/physical.c
+++ b/ovn/controller/physical.c
@@ -995,6 +995,21 @@  physical_run(struct controller_ctx *ctx, enum mf_field_id mff_ovn_geneve,
     struct ofpbuf remote_ofpacts;
     ofpbuf_init(&remote_ofpacts, 0);
     SBREC_MULTICAST_GROUP_FOR_EACH (mc, ctx->ovnsb_idl) {
+        /* Table 32, priority 150.
+         * =======================
+         *
+         * Multicast packets that should not be sent to other hypervisors.
+         */
+        struct match match = MATCH_CATCHALL_INITIALIZER;
+        match_set_metadata(&match, htonll(mc->datapath->tunnel_key));
+        match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, mc->tunnel_key);
+        match_set_reg_masked(&match, MFF_LOG_FLAGS - MFF_REG0,
+                             MLF_KEEP_LOCAL, MLF_KEEP_LOCAL);
+        ofpbuf_clear(&ofpacts);
+        put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts);
+        ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 150, 0, &match,
+                        &ofpacts);
+
         consider_mc_group(mff_ovn_geneve, ct_zones, local_datapaths, chassis,
                           mc, &ofpacts, &remote_ofpacts, flow_table);
     }
diff --git a/ovn/lib/logical-fields.h b/ovn/lib/logical-fields.h
index 696c529be..eb0b8f422 100644
--- a/ovn/lib/logical-fields.h
+++ b/ovn/lib/logical-fields.h
@@ -49,6 +49,7 @@  enum mff_log_flags_bits {
     MLF_RCV_FROM_VXLAN_BIT = 1,
     MLF_FORCE_SNAT_FOR_DNAT_BIT = 2,
     MLF_FORCE_SNAT_FOR_LB_BIT = 3,
+    MLF_KEEP_LOCAL_BIT = 4,
 };
 
 /* MFF_LOG_FLAGS_REG flag assignments */
@@ -69,6 +70,11 @@  enum mff_log_flags {
     /* Indicate that a packet needs a force SNAT in the gateway router when
      * load-balancing has taken place. */
     MLF_FORCE_SNAT_FOR_LB = (1 << MLF_FORCE_SNAT_FOR_LB_BIT),
+
+    /* Indicate that a packet that should be distributed across multiple
+     * hypervisors should instead only be output to local targets
+     */
+    MLF_KEEP_LOCAL = (1 << MLF_KEEP_LOCAL_BIT),
 };
 
 #endif /* ovn/lib/logical-fields.h */