Acked-by: Alex Wang <al...@nicira.com> On Sun, Jun 14, 2015 at 12:18 PM, Ben Pfaff <b...@nicira.com> wrote:
> This allow the reports to have additional useful information. An upcoming > commit will take advantage of this. > > Signed-off-by: Ben Pfaff <b...@nicira.com> > --- > ofproto/ofproto-dpif-xlate.c | 11 ++++++++--- > ofproto/ofproto-dpif-xlate.h | 5 +++-- > ofproto/ofproto-dpif.c | 36 ++++++++++++++++++++++++++---------- > 3 files changed, 37 insertions(+), 15 deletions(-) > > diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c > index ef9312b..481e9ea 100644 > --- a/ofproto/ofproto-dpif-xlate.c > +++ b/ofproto/ofproto-dpif-xlate.c > @@ -436,7 +436,8 @@ static bool may_receive(const struct xport *, struct > xlate_ctx *); > static void do_xlate_actions(const struct ofpact *, size_t ofpacts_len, > struct xlate_ctx *); > static void xlate_normal(struct xlate_ctx *); > -static inline void xlate_report(struct xlate_ctx *, const char *); > +static inline void xlate_report(struct xlate_ctx *, const char *, ...) > + OVS_PRINTF_FORMAT(2, 3); > static void xlate_table_action(struct xlate_ctx *, ofp_port_t in_port, > uint8_t table_id, bool may_packet_in, > bool honor_table_miss); > @@ -505,10 +506,14 @@ static void xlate_xport_copy(struct xbridge *, > struct xbundle *, > static void xlate_xcfg_free(struct xlate_cfg *); > > static inline void > -xlate_report(struct xlate_ctx *ctx, const char *s) > +xlate_report(struct xlate_ctx *ctx, const char *format, ...) > { > if (OVS_UNLIKELY(ctx->xin->report_hook)) { > - ctx->xin->report_hook(ctx->xin, s, ctx->recurse); > + va_list args; > + > + va_start(args, format); > + ctx->xin->report_hook(ctx->xin, ctx->recurse, format, args); > + va_end(args); > } > } > > diff --git a/ofproto/ofproto-dpif-xlate.h b/ofproto/ofproto-dpif-xlate.h > index e39847b..8586e40 100644 > --- a/ofproto/ofproto-dpif-xlate.h > +++ b/ofproto/ofproto-dpif-xlate.h > @@ -1,4 +1,4 @@ > -/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. > +/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc. > * > * Licensed under the Apache License, Version 2.0 (the "License"); > * you may not use this file except in compliance with the License. > @@ -177,7 +177,8 @@ struct xlate_in { > * 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 *, const char *s, int recurse); > + void (*report_hook)(struct xlate_in *, int recurse, > + const char *format, va_list args); > > /* If nonnull, flow translation credits the specified statistics to > each > * rule reached through a resubmit or OFPP_TABLE action. > diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c > index 55fea0f..378ce51 100644 > --- a/ofproto/ofproto-dpif.c > +++ b/ofproto/ofproto-dpif.c > @@ -4548,7 +4548,12 @@ trace_format_megaflow(struct ds *result, int level, > const char *title, > ds_put_char(result, '\n'); > } > > -static void trace_report(struct xlate_in *xin, const char *s, int > recurse); > +static void trace_report(struct xlate_in *, int recurse, > + const char *format, ...) > + OVS_PRINTF_FORMAT(3, 4); > +static void trace_report_valist(struct xlate_in *, int recurse, > + 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) > @@ -4558,15 +4563,15 @@ trace_resubmit(struct xlate_in *xin, struct > rule_dpif *rule, int recurse) > > if (!recurse) { > if (rule == xin->ofproto->miss_rule) { > - trace_report(xin, "No match, flow generates \"packet in\"s.", > - recurse); > + trace_report(xin, recurse, > + "No match, flow generates \"packet in\"s."); > } else if (rule == xin->ofproto->no_packet_in_rule) { > - trace_report(xin, "No match, packets dropped because " > - "OFPPC_NO_PACKET_IN is set on in_port.", > recurse); > + trace_report(xin, recurse, "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, "Packets dropped because they are IP " > + trace_report(xin, recurse, "Packets dropped because they are > IP " > "fragments and the fragment handling mode is " > - "\"drop\".", recurse); > + "\"drop\"."); > } > } > > @@ -4581,16 +4586,27 @@ trace_resubmit(struct xlate_in *xin, struct > rule_dpif *rule, int recurse) > } > > static void > -trace_report(struct xlate_in *xin, const char *s, int recurse) > +trace_report_valist(struct xlate_in *xin, int recurse, > + 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_cstr(result, s); > + 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, ...) > +{ > + va_list args; > + > + va_start(args, format); > + trace_report_valist(xin, recurse, format, args); > + va_end(args); > +} > + > /* Parses the 'argc' elements of 'argv', ignoring argv[0]. The following > * forms are supported: > * > @@ -4879,7 +4895,7 @@ ofproto_trace(struct ofproto_dpif *ofproto, struct > flow *flow, > trace.xin.ofpacts = ofpacts; > trace.xin.ofpacts_len = ofpacts_len; > trace.xin.resubmit_hook = trace_resubmit; > - trace.xin.report_hook = trace_report; > + trace.xin.report_hook = trace_report_valist; > > xlate_actions(&trace.xin, &trace.xout); > > -- > 2.1.3 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev > _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev