This is version of the patch incorporates changes required by modifications to
previous patches in the series. force_compose_output_action() changed
slightly, I don't think it needs review again.
Also, Ben, I'll write up a patch that unit tests this in the next day or so.
Justin is blocking on this patch getting merged so I'd like to get it in first.
Ethan
---
Before this patch, the logic for outputting to a port was scattered
all around ofproto-dpif. This patch simplifies the code by forcing
it to use one code path to check if a port is forwarding, and
output if appropriate. Future patches will rely on this
simplification to implement new features.
---
ofproto/ofproto-dpif.c | 41 ++++++++++++++++++++++-------------------
1 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index e75c258..39d7e03 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1229,8 +1229,7 @@ bundle_update(struct ofbundle *bundle)
bundle->floodable = true;
LIST_FOR_EACH (port, bundle_node, &bundle->ports) {
- if (port->up.opp.config & htonl(OFPPC_NO_FLOOD)
- || !stp_forward_in_state(port->stp_state)) {
+ if (port->up.opp.config & htonl(OFPPC_NO_FLOOD)) {
bundle->floodable = false;
break;
}
@@ -1277,8 +1276,7 @@ bundle_add_port(struct ofbundle *bundle, uint32_t
ofp_port,
port->bundle = bundle;
list_push_back(&bundle->ports, &port->bundle_node);
- if (port->up.opp.config & htonl(OFPPC_NO_FLOOD)
- || !stp_forward_in_state(port->stp_state)) {
+ if (port->up.opp.config & htonl(OFPPC_NO_FLOOD)) {
bundle->floodable = false;
}
}
@@ -3769,10 +3767,10 @@ commit_odp_actions(struct action_xlate_ctx *ctx)
}
static void
-compose_output_action(struct action_xlate_ctx *ctx, uint16_t odp_port)
+force_compose_output_action(struct action_xlate_ctx *ctx, uint16_t ofp_port)
{
- uint16_t ofp_port = odp_port_to_ofp_port(odp_port);
const struct ofport_dpif *ofport = get_ofp_port(ctx->ofproto, ofp_port);
+ uint16_t odp_port = ofp_port_to_odp_port(ofp_port);
if (ofport && ofport->up.opp.config & htonl(OFPPC_NO_FWD)) {
return;
@@ -3784,10 +3782,9 @@ compose_output_action(struct action_xlate_ctx *ctx,
uint16_t odp_port)
}
static void
-add_output_action(struct action_xlate_ctx *ctx, uint16_t ofp_port)
+compose_output_action(struct action_xlate_ctx *ctx, uint16_t ofp_port)
{
- const struct ofport_dpif *ofport = get_ofp_port(ctx->ofproto, ofp_port);
- uint16_t odp_port = ofp_port_to_odp_port(ofp_port);
+ struct ofport_dpif *ofport = get_ofp_port(ctx->ofproto, ofp_port);
if (ofport && !stp_forward_in_state(ofport->stp_state)) {
/* Forwarding disabled on port. */
@@ -3797,9 +3794,14 @@ add_output_action(struct action_xlate_ctx *ctx, uint16_t
ofp_port)
/* We may not have an ofport record for this port, but it doesn't hurt to
* allow forwarding to it anyhow. Maybe such a port will appear later and
* we're pre-populating the flow table. */
+ force_compose_output_action(ctx, ofp_port);
+}
+static void
+commit_output_action(struct action_xlate_ctx *ctx, uint16_t ofp_port)
+{
commit_odp_actions(ctx);
- compose_output_action(ctx, odp_port);
+ compose_output_action(ctx, ofp_port);
ctx->nf_output_iface = ofp_port;
}
@@ -3884,9 +3886,10 @@ flood_packets(struct action_xlate_ctx *ctx, bool all)
continue;
}
- if (all || (!(ofport->up.opp.config & htonl(OFPPC_NO_FLOOD))
- && stp_forward_in_state(ofport->stp_state))) {
- compose_output_action(ctx, ofport->odp_port);
+ if (all) {
+ force_compose_output_action(ctx, ofp_port);
+ } else if (!(ofport->up.opp.config & htonl(OFPPC_NO_FLOOD))) {
+ compose_output_action(ctx, ofp_port);
}
}
@@ -3915,7 +3918,7 @@ xlate_output_action__(struct action_xlate_ctx *ctx,
switch (port) {
case OFPP_IN_PORT:
- add_output_action(ctx, ctx->flow.in_port);
+ commit_output_action(ctx, ctx->flow.in_port);
break;
case OFPP_TABLE:
xlate_table_action(ctx, ctx->flow.in_port, ctx->table_id);
@@ -3934,13 +3937,13 @@ xlate_output_action__(struct action_xlate_ctx *ctx,
compose_controller_action(ctx, max_len);
break;
case OFPP_LOCAL:
- add_output_action(ctx, OFPP_LOCAL);
+ commit_output_action(ctx, OFPP_LOCAL);
break;
case OFPP_NONE:
break;
default:
if (port != ctx->flow.in_port) {
- add_output_action(ctx, port);
+ commit_output_action(ctx, port);
}
break;
}
@@ -4002,7 +4005,7 @@ xlate_enqueue_action(struct action_xlate_ctx *ctx,
/* Add datapath actions. */
flow_priority = ctx->flow.priority;
ctx->flow.priority = priority;
- add_output_action(ctx, ofp_port);
+ commit_output_action(ctx, ofp_port);
ctx->flow.priority = flow_priority;
/* Update NetFlow output port. */
@@ -4365,7 +4368,7 @@ xlate_actions(struct action_xlate_ctx *ctx,
if (ctx->packet
&& connmgr_msg_in_hook(ctx->ofproto->up.connmgr, &ctx->flow,
ctx->packet)) {
- compose_output_action(ctx, OVSP_LOCAL);
+ compose_output_action(ctx, OFPP_LOCAL);
}
}
fix_sflow_action(ctx);
@@ -4508,7 +4511,7 @@ output_normal(struct action_xlate_ctx *ctx, const struct
ofbundle *out_bundle,
}
commit_vlan_action(ctx, tci);
- compose_output_action(ctx, port->odp_port);
+ compose_output_action(ctx, port->up.ofp_port);
ctx->nf_output_iface = port->up.ofp_port;
}
--
1.7.7.1
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev