On Wed, Apr 29, 2015 at 11:49:09PM -0700, Ben Pfaff wrote:
> This last piece allows us to start testing and debugging a complete OVN
> installation. It is so far tested only in the sandbox, where the flows
> created seem plausible at first glance.
>
> Signed-off-by: Ben Pfaff <[email protected]>
Here's an incremental diff that makes this work. Most of the changes
are comment improvements; it would be smaller without those. With
this and the two changes to your patch 6/6 that I pointed out in a
separate thread, the system works for me in my simple VM test setup.
diff --git a/ovn/controller/physical.c b/ovn/controller/physical.c
index b68ff91..55422d3 100644
--- a/ovn/controller/physical.c
+++ b/ovn/controller/physical.c
@@ -88,26 +88,15 @@ physical_run(struct controller_ctx *ctx)
struct ofpbuf ofpacts;
ofpbuf_init(&ofpacts, 0);
- /* Set up flows:
- *
- * Table 0
- * =======
- *
- * Priority 100, for packets that arrive from a vif: annotate with their
- * logical input port and resubmitted into the logical pipeline.
- *
- * Priority 50, for packets that arrive from a remote node: deliver
- * directly to the vif.
- *
- * Table 64
- * ========
- *
- * Priority 100, to drop packets whose logical inport and outport are the
- * same.
- *
- * Priority 50, to send packets to their destinations. */
+ /* Set up flows in table 0 for physical-to-logical translation and in table
+ * 64 for logical-to-physical translation. */
const struct sbrec_bindings *binding;
SBREC_BINDINGS_FOR_EACH (binding, ctx->ovnsb_idl) {
+ /* Find the Openflow port for the logical port, as 'ofport'. If it's
+ * on a remote chassis, this is the OpenFlow port for the tunnel to
+ * that chassis (and set 'local' to false). Otherwise, if it's on the
+ * chassis we're managing, this is the OpenFlow port for the vif itself
+ * (and set 'local' to true). */
ofp_port_t ofport = u16_to_ofp(simap_get(&lport_to_ofport,
binding->logical_port));
bool local = ofport != 0;
@@ -119,20 +108,23 @@ physical_run(struct controller_ctx *ctx)
}
}
+ /* Translate the logical datapath into the form we use in
+ * MFF_METADATA. */
uint32_t ldp = ldp_to_integer(&binding->logical_datapath);
if (!ldp) {
continue;
}
struct match match;
- match_init_catchall(&match);
- ofpbuf_clear(&ofpacts);
- if (!local) {
- /* Output directly to vif. */
- match_set_tun_id(&match, htonll(binding->tunnel_key));
- ofpact_put_OUTPUT(&ofpacts)->port = ofport;
- ofctrl_add_flow(0, 50, &match, &ofpacts);
- } else {
+ if (local) {
+ /* Table 0, Priority 100.
+ * ======================
+ *
+ * For packets that arrive from a vif: set MFF_LOG_INPORT to the
+ * logical input port, MFF_METADATA to the logical datapath, and
+ * resubmit into the logical pipeline starting at table 16. */
+ match_init_catchall(&match);
+ ofpbuf_clear(&ofpacts);
match_set_in_port(&match, ofport);
/* Set MFF_METADATA. */
@@ -151,18 +143,37 @@ physical_run(struct controller_ctx *ctx)
struct ofpact_resubmit *resubmit = ofpact_put_RESUBMIT(&ofpacts);
resubmit->in_port = OFPP_IN_PORT;
resubmit->table_id = 16;
-
ofctrl_add_flow(0, 100, &match, &ofpacts);
+
+ /* Table 0, Priority 50.
+ * =====================
+ *
+ * For packets that arrive from a remote node destined to this
+ * local vif: deliver directly to the vif. */
+ match_init_catchall(&match);
+ ofpbuf_clear(&ofpacts);
+ match_set_tun_id(&match, htonll(binding->tunnel_key));
+ ofpact_put_OUTPUT(&ofpacts)->port = ofport;
+ ofctrl_add_flow(0, 50, &match, &ofpacts);
}
- /* Table 64, priority 100. */
+ /* Table 64, Priority 100.
+ * =======================
+ *
+ * Drop packets whose logical inport and outport are the same. */
match_init_catchall(&match);
ofpbuf_clear(&ofpacts);
match_set_reg(&match, MFF_LOG_INPORT - MFF_REG0, binding->tunnel_key);
match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, binding->tunnel_key);
ofctrl_add_flow(64, 100, &match, &ofpacts);
- /* Table 64, priority 50. */
+ /* Table 64, Priority 50.
+ * ======================
+ *
+ * For packets to remote machines, send them over a tunnel to the
+ * remote chassis.
+ *
+ * For packest to local vifs, deliver them directly. */
match_init_catchall(&match);
ofpbuf_clear(&ofpacts);
match_set_reg(&match, MFF_LOG_OUTPORT - MFF_REG0, binding->tunnel_key);
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev