From ca6fa6fb38d2e33c329593d122acf66fcfb92e0d Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Sat, 22 Jun 2013 13:16:26 -0700 Subject: [PATCH] ofproto-dpif: Move tag_the_flow() to ofproto-dpif.c This will help disentangle ofproto-dpif and ofproto-dpif-xlate. Signed-off-by: Ethan Jackson Acked-by: Ben Pfaff --- ofproto/ofproto-dpif-xlate.c | 24 ++++-------------------- ofproto/ofproto-dpif.c | 16 ++++++++++++++++ ofproto/ofproto-dpif.h | 3 ++- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 8d728760e..dedd7236a 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -969,24 +969,6 @@ compose_output_action(struct xlate_ctx *ctx, ofp_port_t ofp_port) compose_output_action__(ctx, ofp_port, true); } -static void -tag_the_flow(struct xlate_ctx *ctx, struct rule_dpif *rule) -{ - struct ofproto_dpif *ofproto = ctx->ofproto; - uint8_t table_id = ctx->table_id; - - if (table_id > 0 && table_id < N_TABLES) { - struct table_dpif *table = &ofproto->tables[table_id]; - if (table->other_table) { - ctx->xout->tags |= (rule && rule->tag - ? rule->tag - : rule_calculate_tag(&ctx->xin->flow, - &table->other_table->mask, - table->basis)); - } - } -} - /* Common rule processing in one place to avoid duplicating code. */ static struct rule_dpif * ctx_rule_hooks(struct xlate_ctx *ctx, struct rule_dpif *rule, @@ -1027,7 +1009,8 @@ xlate_table_action(struct xlate_ctx *ctx, rule = rule_dpif_lookup_in_table(ctx->ofproto, &ctx->xin->flow, &ctx->xout->wc, table_id); - tag_the_flow(ctx, rule); + ctx->xout->tags |= calculate_flow_tag(ctx->ofproto, &ctx->xin->flow, + ctx->table_id, rule); /* Restore the original input port. Otherwise OFPP_NORMAL and * OFPP_IN_PORT will have surprising behavior. */ @@ -1744,7 +1727,8 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len, rule = rule_dpif_lookup_in_table(ctx->ofproto, flow, wc, ctx->table_id); - tag_the_flow(ctx, rule); + ctx->xout->tags = calculate_flow_tag(ctx->ofproto, &ctx->xin->flow, + ctx->table_id, rule); rule = ctx_rule_hooks(ctx, rule, true); diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index b6c1c834c..e6f4ca36e 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -5502,6 +5502,22 @@ update_mirror_stats(struct ofproto_dpif *ofproto, mirror_mask_t mirrors, } } +tag_type +calculate_flow_tag(struct ofproto_dpif *ofproto, const struct flow *flow, + uint8_t table_id, struct rule_dpif *rule) +{ + if (table_id > 0 && table_id < N_TABLES) { + struct table_dpif *table = &ofproto->tables[table_id]; + if (table->other_table) { + return (rule && rule->tag + ? rule->tag + : rule_calculate_tag(flow, &table->other_table->mask, + table->basis)); + } + } + + return 0; +} /* Optimized flow revalidation. * diff --git a/ofproto/ofproto-dpif.h b/ofproto/ofproto-dpif.h index 511184aa4..493ee4cb4 100644 --- a/ofproto/ofproto-dpif.h +++ b/ofproto/ofproto-dpif.h @@ -268,6 +268,7 @@ bool ofproto_dpif_dscp_from_priority(const struct ofport_dpif *, uint32_t priority, uint8_t *dscp); int ofproto_dpif_queue_to_priority(const struct ofproto_dpif *, uint32_t queue_id, uint32_t *priority); - +tag_type calculate_flow_tag(struct ofproto_dpif *, const struct flow *, + uint8_t table_id, struct rule_dpif *); #endif /* ofproto-dpif.h */ -- 2.47.0