The "recurse" member of struct xlate_in and struct xlate_ctx is used for two purposes: to determine the amount of indentation in "ofproto/trace" output and to limit the depth of recursion. An upcoming commit will separate these tasks, and so in preparation this commit renames "recurse" to "indentation".
Signed-off-by: Ben Pfaff <b...@ovn.org> --- ofproto/ofproto-dpif-xlate.c | 22 +++++++++++----------- ofproto/ofproto-dpif-xlate.h | 15 ++++++++------- ofproto/ofproto-dpif.c | 43 ++++++++++++++++++++++--------------------- ofproto/ofproto-dpif.h | 2 +- 4 files changed, 42 insertions(+), 40 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 5937913..e4ec55c 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -196,7 +196,7 @@ struct xlate_ctx { struct ofpbuf *odp_actions; /* Resubmit statistics, via xlate_table_action(). */ - int recurse; /* Current resubmit nesting depth. */ + int indentation; /* Current resubmit nesting depth. */ int resubmits; /* Total number of resubmits. */ bool in_group; /* Currently translating ofgroup, if true. */ bool in_action_set; /* Currently translating action_set, if true. */ @@ -583,7 +583,7 @@ xlate_report(struct xlate_ctx *ctx, const char *format, ...) va_list args; va_start(args, format); - ctx->xin->report_hook(ctx->xin, ctx->recurse, format, args); + ctx->xin->report_hook(ctx->xin, ctx->indentation, format, args); va_end(args); } } @@ -2805,7 +2805,7 @@ compose_table_xlate(struct xlate_ctx *ctx, const struct xport *out_dev, return ofproto_dpif_execute_actions__(xbridge->ofproto, &flow, NULL, &output.ofpact, sizeof output, - ctx->recurse, ctx->resubmits, packet); + ctx->indentation, ctx->resubmits, packet); } static void @@ -3222,20 +3222,20 @@ xlate_recursively(struct xlate_ctx *ctx, struct rule_dpif *rule) } ctx->resubmits++; - ctx->recurse++; + ctx->indentation++; ctx->rule = rule; ctx->rule_cookie = rule_dpif_get_flow_cookie(rule); actions = rule_dpif_get_actions(rule); do_xlate_actions(actions->ofpacts, actions->ofpacts_len, ctx); ctx->rule_cookie = old_cookie; ctx->rule = old_rule; - ctx->recurse--; + ctx->indentation--; } static bool xlate_resubmit_resource_check(struct xlate_ctx *ctx) { - if (ctx->recurse >= MAX_RESUBMIT_RECURSION + MAX_INTERNAL_RESUBMITS) { + if (ctx->indentation >= MAX_RESUBMIT_RECURSION + MAX_INTERNAL_RESUBMITS) { XLATE_REPORT_ERROR(ctx, "resubmit actions recursed over %d times", MAX_RESUBMIT_RECURSION); ctx->error = XLATE_RECURSION_TOO_DEEP; @@ -3274,7 +3274,7 @@ xlate_table_action(struct xlate_ctx *ctx, ofp_port_t in_port, uint8_t table_id, may_packet_in, honor_table_miss); if (OVS_UNLIKELY(ctx->xin->resubmit_hook)) { - ctx->xin->resubmit_hook(ctx->xin, rule, ctx->recurse + 1); + ctx->xin->resubmit_hook(ctx->xin, rule, ctx->indentation + 1); } if (rule) { @@ -3323,9 +3323,9 @@ xlate_group_bucket(struct xlate_ctx *ctx, struct ofputil_bucket *bucket) struct flow old_flow = ctx->xin->flow; ofpacts_execute_action_set(&action_list, &action_set); - ctx->recurse++; + ctx->indentation++; do_xlate_actions(action_list.data, action_list.size, ctx); - ctx->recurse--; + ctx->indentation--; ofpbuf_uninit(&action_list); @@ -4824,7 +4824,7 @@ xlate_in_init(struct xlate_in *xin, struct ofproto_dpif *ofproto, xin->resubmit_hook = NULL; xin->report_hook = NULL; xin->resubmit_stats = NULL; - xin->recurse = 0; + xin->indentation = 0; xin->resubmits = 0; xin->wc = wc; xin->odp_actions = odp_actions; @@ -5089,7 +5089,7 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout) .wc = xin->wc ? xin->wc : &scratch_wc, .odp_actions = xin->odp_actions ? xin->odp_actions : &scratch_actions, - .recurse = xin->recurse, + .indentation = xin->indentation, .resubmits = xin->resubmits, .in_group = false, .in_action_set = false, diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h index c4c23d5..e224ecc 100644 --- a/ofproto/ofproto-dpif-xlate.h +++ b/ofproto/ofproto-dpif-xlate.h @@ -83,18 +83,19 @@ struct xlate_in { * 'rule' is the rule being submitted into. It will be null if the * resubmit or OFPP_TABLE action didn't find a matching rule. * - * 'recurse' is the resubmit recursion depth at time of invocation. + * 'indentation' is the resubmit recursion depth at time of invocation, + * suitable for indenting the output. * * This is normally null so the client has to set it manually after * calling xlate_in_init(). */ void (*resubmit_hook)(struct xlate_in *, struct rule_dpif *rule, - int recurse); + int indentation); /* If nonnull, flow translation calls this function to report some * significant decision, e.g. to explain why OFPP_NORMAL translation - * dropped a packet. 'recurse' is the resubmit recursion depth at time of - * invocation. */ - void (*report_hook)(struct xlate_in *, int recurse, + * dropped a packet. 'indentation' is the resubmit recursion depth at time + * of invocation, suitable for indenting the output. */ + void (*report_hook)(struct xlate_in *, int indentation, const char *format, va_list args); /* If nonnull, flow translation credits the specified statistics to each @@ -104,7 +105,7 @@ struct xlate_in { * calling xlate_in_init(). */ const struct dpif_flow_stats *resubmit_stats; - /* Recursion and resubmission levels carried over from a pre-existing + /* Indentation and resubmission levels carried over from a pre-existing * translation of a related flow. An example of when this can occur is * the translation of an ARP packet that was generated as the result of * outputting to a tunnel port. In this case, the original flow going to @@ -115,7 +116,7 @@ struct xlate_in { * These fields are normally set to zero, so the client has to set them * manually after calling xlate_in_init(). In that case, they should be * copied from the same-named fields in the related flow's xlate_ctx. */ - int recurse; + int indentation; int resubmits; /* If nonnull, flow translation populates this cache with references to all diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 285e377..026be80 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -3704,7 +3704,7 @@ ofproto_dpif_execute_actions__(struct ofproto_dpif *ofproto, const struct flow *flow, struct rule_dpif *rule, const struct ofpact *ofpacts, size_t ofpacts_len, - int recurse, int resubmits, + int indentation, int resubmits, struct dp_packet *packet) { struct dpif_flow_stats stats; @@ -3729,7 +3729,7 @@ ofproto_dpif_execute_actions__(struct ofproto_dpif *ofproto, xin.ofpacts = ofpacts; xin.ofpacts_len = ofpacts_len; xin.resubmit_stats = &stats; - xin.recurse = recurse; + xin.indentation = indentation; xin.resubmits = resubmits; if (xlate_actions(&xin, &xout) != XLATE_OK) { error = EINVAL; @@ -4751,62 +4751,63 @@ trace_format_megaflow(struct ds *result, int level, const char *title, ds_put_char(result, '\n'); } -static void trace_report(struct xlate_in *, int recurse, +static void trace_report(struct xlate_in *, int indentation, const char *format, ...) OVS_PRINTF_FORMAT(3, 4); -static void trace_report_valist(struct xlate_in *, int recurse, +static void trace_report_valist(struct xlate_in *, int indentation, const char *format, va_list args) OVS_PRINTF_FORMAT(3, 0); static void -trace_resubmit(struct xlate_in *xin, struct rule_dpif *rule, int recurse) +trace_resubmit(struct xlate_in *xin, struct rule_dpif *rule, int indentation) { struct trace_ctx *trace = CONTAINER_OF(xin, struct trace_ctx, xin); struct ds *result = trace->result; - if (!recurse) { + if (!indentation) { if (rule == xin->ofproto->miss_rule) { - trace_report(xin, recurse, + trace_report(xin, indentation, "No match, flow generates \"packet in\"s."); } else if (rule == xin->ofproto->no_packet_in_rule) { - trace_report(xin, recurse, "No match, packets dropped because " + trace_report(xin, indentation, "No match, packets dropped because " "OFPPC_NO_PACKET_IN is set on in_port."); } else if (rule == xin->ofproto->drop_frags_rule) { - trace_report(xin, recurse, "Packets dropped because they are IP " - "fragments and the fragment handling mode is " - "\"drop\"."); + trace_report(xin, indentation, + "Packets dropped because they are IP fragments and " + "the fragment handling mode is \"drop\"."); } } ds_put_char(result, '\n'); - if (recurse) { - trace_format_flow(result, recurse, "Resubmitted flow", trace); - trace_format_regs(result, recurse, "Resubmitted regs", trace); - trace_format_odp(result, recurse, "Resubmitted odp", trace); - trace_format_megaflow(result, recurse, "Resubmitted megaflow", trace); + if (indentation) { + trace_format_flow(result, indentation, "Resubmitted flow", trace); + trace_format_regs(result, indentation, "Resubmitted regs", trace); + trace_format_odp(result, indentation, "Resubmitted odp", trace); + trace_format_megaflow(result, indentation, "Resubmitted megaflow", + trace); } - trace_format_rule(result, recurse, rule); + trace_format_rule(result, indentation, rule); } static void -trace_report_valist(struct xlate_in *xin, int recurse, +trace_report_valist(struct xlate_in *xin, int indentation, const char *format, va_list args) { struct trace_ctx *trace = CONTAINER_OF(xin, struct trace_ctx, xin); struct ds *result = trace->result; - ds_put_char_multiple(result, '\t', recurse); + ds_put_char_multiple(result, '\t', indentation); ds_put_format_valist(result, format, args); ds_put_char(result, '\n'); } static void -trace_report(struct xlate_in *xin, int recurse, const char *format, ...) +trace_report(struct xlate_in *xin, int indentation, const char *format, ...) { va_list args; va_start(args, format); - trace_report_valist(xin, recurse, format, args); + trace_report_valist(xin, indentation, format, args); va_end(args); } diff --git a/ofproto/ofproto-dpif.h b/ofproto/ofproto-dpif.h index 91bf463..597ec4b 100644 --- a/ofproto/ofproto-dpif.h +++ b/ofproto/ofproto-dpif.h @@ -155,7 +155,7 @@ int ofproto_dpif_execute_actions(struct ofproto_dpif *, const struct flow *, size_t ofpacts_len, struct dp_packet *); int ofproto_dpif_execute_actions__(struct ofproto_dpif *, const struct flow *, struct rule_dpif *, const struct ofpact *, - size_t ofpacts_len, int recurse, + size_t ofpacts_len, int indentation, int resubmits, struct dp_packet *); void ofproto_dpif_send_async_msg(struct ofproto_dpif *, struct ofproto_async_msg *); -- 2.1.3 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev