static void bundle_run(struct ofbundle *);
static void bundle_wait(struct ofbundle *);
static struct ofbundle *lookup_input_bundle(struct ofproto_dpif *,
- uint16_t in_port, bool warn);
+ uint16_t in_port, bool warn,
+ struct ofport_dpif **in_ofportp);
/* A controller may use OFPP_NONE as the ingress port to indicate that
* it did not arrive on a "real" port. 'ofpp_none_bundle' exists for
uint16_t sflow_odp_port; /* Output port for composing sFlow action. */
uint16_t user_cookie_offset;/* Used for user_action_cookie fixup. */
bool exit; /* No further actions should be processed. */
+ struct flow orig_flow; /* Copy of original flow. */
};
static void action_xlate_ctx_init(struct action_xlate_ctx *,
struct hmap bundles; /* Contains "struct ofbundle"s. */
struct mac_learning *ml;
struct ofmirror *mirrors[MAX_MIRRORS];
+ bool has_mirrors;
bool has_bonded_bundles;
/* Expiration. */
ofproto_dpif_unixctl_init();
+ ofproto->has_mirrors = false;
ofproto->has_bundle_action = false;
hmap_init(&ofproto->vlandev_map);
}
ofproto->need_revalidate = true;
+ ofproto->has_mirrors = true;
mac_learning_flush(ofproto->ml, &ofproto->revalidate_set);
mirror_update_dups(ofproto);
struct ofproto_dpif *ofproto;
mirror_mask_t mirror_bit;
struct ofbundle *bundle;
+ int i;
if (!mirror) {
return;
free(mirror);
mirror_update_dups(ofproto);
+
+ ofproto->has_mirrors = false;
+ for (i = 0; i < MAX_MIRRORS; i++) {
+ if (ofproto->mirrors[i]) {
+ ofproto->has_mirrors = true;
+ break;
+ }
+ }
}
static int
const union ofp_action *in, size_t n_in,
struct ofpbuf *odp_actions)
{
- struct flow orig_flow = ctx->flow;
+ /* Normally false. Set to true if we ever hit MAX_RESUBMIT_RECURSION, so
+ * that in the future we always keep a copy of the original flow for
+ * tracing purposes. */
+ static bool hit_resubmit_limit;
COVERAGE_INC(ofproto_dpif_xlate);
ctx->table_id = 0;
ctx->exit = false;
+ if (ctx->ofproto->has_mirrors || hit_resubmit_limit) {
+ /* Do this conditionally because the copy is expensive enough that it
+ * shows up in profiles.
+ *
+ * We keep orig_flow in 'ctx' only because I couldn't make GCC 4.4
+ * believe that I wasn't using it without initializing it if I kept it
+ * in a local variable. */
+ ctx->orig_flow = ctx->flow;
+ }
+
if (ctx->flow.nw_frag & FLOW_NW_FRAG_ANY) {
switch (ctx->ofproto->up.frag_handling) {
case OFPC_FRAG_NORMAL:
ctx->may_set_up_flow = false;
} else {
static struct vlog_rate_limit trace_rl = VLOG_RATE_LIMIT_INIT(1, 1);
- struct flow original_flow = ctx->flow;
ovs_be16 initial_tci = ctx->base_flow.vlan_tci;
add_sflow_action(ctx);
do_xlate_actions(in, n_in, ctx);
- if (ctx->max_resubmit_trigger && !ctx->resubmit_hook
- && !VLOG_DROP_ERR(&trace_rl)) {
- struct ds ds = DS_EMPTY_INITIALIZER;
-
- ofproto_trace(ctx->ofproto, &original_flow, ctx->packet,
- initial_tci, &ds);
- VLOG_ERR("Trace triggered by excessive resubmit recursion:\n%s",
- ds_cstr(&ds));
- ds_destroy(&ds);
+ if (ctx->max_resubmit_trigger && !ctx->resubmit_hook) {
+ if (!hit_resubmit_limit) {
+ /* We didn't record the original flow. Make sure we do from
+ * now on. */
+ hit_resubmit_limit = true;
+ } else if (!VLOG_DROP_ERR(&trace_rl)) {
+ struct ds ds = DS_EMPTY_INITIALIZER;
+
+ ofproto_trace(ctx->ofproto, &ctx->orig_flow, ctx->packet,
+ initial_tci, &ds);
+ VLOG_ERR("Trace triggered by excessive resubmit "
+ "recursion:\n%s", ds_cstr(&ds));
+ ds_destroy(&ds);
+ }
}
if (!connmgr_may_set_up_flow(ctx->ofproto->up.connmgr, &ctx->flow,
compose_output_action(ctx, OFPP_LOCAL);
}
}
- add_mirror_actions(ctx, &orig_flow);
+ if (ctx->ofproto->has_mirrors) {
+ add_mirror_actions(ctx, &ctx->orig_flow);
+ }
fix_sflow_action(ctx);
}
}
size_t left;
in_bundle = lookup_input_bundle(ctx->ofproto, orig_flow->in_port,
- ctx->packet != NULL);
+ ctx->packet != NULL, NULL);
if (!in_bundle) {
return;
}
}
static struct ofbundle *
-lookup_input_bundle(struct ofproto_dpif *ofproto, uint16_t in_port, bool warn)
+lookup_input_bundle(struct ofproto_dpif *ofproto, uint16_t in_port, bool warn,
+ struct ofport_dpif **in_ofportp)
{
struct ofport_dpif *ofport;
- /* Special-case OFPP_NONE, which a controller may use as the ingress
- * port for traffic that it is sourcing. */
- if (in_port == OFPP_NONE) {
- return &ofpp_none_bundle;
- }
-
/* Find the port and bundle for the received packet. */
ofport = get_ofp_port(ofproto, in_port);
+ if (in_ofportp) {
+ *in_ofportp = ofport;
+ }
if (ofport && ofport->bundle) {
return ofport->bundle;
}
+ /* Special-case OFPP_NONE, which a controller may use as the ingress
+ * port for traffic that it is sourcing. */
+ if (in_port == OFPP_NONE) {
+ return &ofpp_none_bundle;
+ }
+
/* Odd. A few possible reasons here:
*
* - We deleted a port but there are still a few packets queued up
ctx->has_normal = true;
in_bundle = lookup_input_bundle(ctx->ofproto, ctx->flow.in_port,
- ctx->packet != NULL);
+ ctx->packet != NULL, &in_port);
if (!in_bundle) {
return;
}
- /* We know 'in_port' exists unless it is "ofpp_none_bundle",
- * since lookup_input_bundle() succeeded. */
- in_port = get_ofp_port(ctx->ofproto, ctx->flow.in_port);
-
/* Drop malformed frames. */
if (ctx->flow.dl_type == htons(ETH_TYPE_VLAN) &&
!(ctx->flow.vlan_tci & htons(VLAN_CFI))) {