[ovs-dev] [PATCH 05/11] ofproto-dpif: Make xlate_in.flow a pointer.
Jarno Rajahalme
jarno.rajahalme at nsn.com
Fri May 31 11:35:15 UTC 2013
The added flow_storage will disappear in a later patch.
Signed-off-by: Jarno Rajahalme <jarno.rajahalme at nsn.com>
---
ofproto/ofproto-dpif.c | 78 +++++++++++++++++++++++++-----------------------
1 file changed, 41 insertions(+), 37 deletions(-)
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 23ea2c6..3ea4714 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -243,7 +243,10 @@ struct xlate_in {
/* Flow to which the OpenFlow actions apply. xlate_actions() will modify
* this flow when actions change header fields. */
- struct flow flow;
+ struct flow *flow;
+
+ /* Storage for flow initialized by xlate_in_init */
+ struct flow flow_storage;
struct initial_vals initial_vals;
@@ -5849,7 +5852,7 @@ compose_ipfix_action(const struct ofproto_dpif *ofproto,
static void
add_sflow_action(struct xlate_ctx *ctx)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
ctx->user_cookie_offset = compose_sflow_action(ctx->ofproto,
&ctx->xout->odp_actions,
@@ -5863,7 +5866,7 @@ add_sflow_action(struct xlate_ctx *ctx)
static void
add_ipfix_action(struct xlate_ctx *ctx)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
compose_ipfix_action(ctx->ofproto, &ctx->xout->odp_actions,
flow);
@@ -5894,7 +5897,7 @@ static void
compose_output_action__(struct xlate_ctx *ctx, uint16_t ofp_port,
bool check_stp)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
const struct ofport_dpif *ofport = get_ofp_port(ctx->ofproto, ofp_port);
ovs_be16 flow_vlan_tci;
uint32_t flow_skb_mark;
@@ -6059,7 +6062,7 @@ static struct rule_dpif *
ctx_rule_hooks(struct xlate_ctx *ctx, struct rule_dpif *rule,
bool may_packet_in)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
if (ctx->xin->resubmit_hook) {
ctx->xin->resubmit_hook(ctx, rule);
@@ -6084,7 +6087,7 @@ static void
xlate_table_action(struct xlate_ctx *ctx,
uint16_t in_port, uint8_t table_id, bool may_packet_in)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
if (ctx->recurse < MAX_RESUBMIT_RECURSION) {
struct rule_dpif *rule;
@@ -6129,7 +6132,7 @@ static void
xlate_ofpact_resubmit(struct xlate_ctx *ctx,
const struct ofpact_resubmit *resubmit)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
uint16_t in_port;
uint8_t table_id;
@@ -6149,7 +6152,7 @@ xlate_ofpact_resubmit(struct xlate_ctx *ctx,
static void
flood_packets(struct xlate_ctx *ctx, bool all)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
struct ofport_dpif *ofport;
HMAP_FOR_EACH (ofport, up.hmap_node, &ctx->ofproto->up.ports) {
@@ -6174,7 +6177,7 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
enum ofp_packet_in_reason reason,
uint16_t controller_id)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
struct ofputil_packet_in pin;
struct ofpbuf *packet;
@@ -6334,7 +6337,7 @@ static void
xlate_output_action(struct xlate_ctx *ctx,
uint16_t port, uint16_t max_len, bool may_packet_in)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
uint16_t prev_nf_output_iface = ctx->xout->nf_output_iface;
ctx->xout->nf_output_iface = NF_OUT_DROP;
@@ -6384,7 +6387,7 @@ static void
xlate_output_reg_action(struct xlate_ctx *ctx,
const struct ofpact_output_reg *or)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
uint64_t port = mf_get_subfield(&or->src, flow);
if (port <= UINT16_MAX) {
@@ -6396,7 +6399,7 @@ static void
xlate_enqueue_action(struct xlate_ctx *ctx,
const struct ofpact_enqueue *enqueue)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
uint16_t ofp_port = enqueue->port;
uint32_t queue_id = enqueue->queue;
@@ -6436,7 +6439,7 @@ xlate_enqueue_action(struct xlate_ctx *ctx,
static void
xlate_set_queue_action(struct xlate_ctx *ctx, uint32_t queue_id)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
uint32_t skb_priority;
@@ -6475,7 +6478,7 @@ static void
xlate_bundle_action(struct xlate_ctx *ctx,
const struct ofpact_bundle *bundle)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
uint16_t port;
@@ -6491,7 +6494,7 @@ static void
xlate_learn_action(struct xlate_ctx *ctx,
const struct ofpact_learn *learn)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
struct ofputil_flow_mod fm;
@@ -6537,7 +6540,7 @@ static void
xlate_sample_action(struct xlate_ctx *ctx,
const struct ofpact_sample *os)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
union user_action_cookie cookie;
/* Scale the probability from 16-bit to 32-bit while representing
@@ -6577,7 +6580,7 @@ may_receive(const struct ofport_dpif *port, struct flow *flow)
static bool
tunnel_ecn_ok(struct xlate_ctx *ctx)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
if (is_ip_any(&ctx->base_flow)
&& (flow->tunnel.ip_tos & IP_ECN_MASK) == IP_ECN_CE) {
@@ -6598,7 +6601,7 @@ static void
do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
struct xlate_ctx *ctx)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
bool was_evictable = true;
const struct ofpact *a;
@@ -6869,7 +6872,8 @@ xlate_in_init(struct xlate_in *xin, struct ofproto_dpif *ofproto,
const struct ofpbuf *packet)
{
xin->ofproto = ofproto;
- xin->flow = *flow;
+ xin->flow = &xin->flow_storage;
+ xin->flow_storage = *flow;
xin->packet = packet;
xin->may_learn = packet != NULL;
xin->rule = rule;
@@ -6941,10 +6945,10 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
ctx.ofproto = xin->ofproto;
ctx.rule = xin->rule;
- ctx.base_flow = ctx.xin->flow;
+ ctx.base_flow = *ctx.xin->flow;
ctx.base_flow.vlan_tci = xin->initial_vals.vlan_tci;
memset(&ctx.base_flow.tunnel, 0, sizeof ctx.base_flow.tunnel);
- ctx.orig_tunnel_ip_dst = ctx.xin->flow.tunnel.ip_dst;
+ ctx.orig_tunnel_ip_dst = ctx.xin->flow->tunnel.ip_dst;
ctx.xout->tags = 0;
ctx.xout->slow = 0;
@@ -6960,7 +6964,7 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
ctx.recurse = 0;
ctx.max_resubmit_trigger = false;
- ctx.orig_skb_priority = ctx.xin->flow.skb_priority;
+ ctx.orig_skb_priority = ctx.xin->flow->skb_priority;
ctx.table_id = 0;
ctx.exit = false;
@@ -6979,15 +6983,15 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
if (ctx.ofproto->has_mirrors || hit_resubmit_limit) {
/* Do this conditionally because the copy is expensive enough that it
* shows up in profiles. */
- orig_flow = ctx.xin->flow;
+ orig_flow = *ctx.xin->flow;
}
- if (ctx.xin->flow.nw_frag & FLOW_NW_FRAG_ANY) {
+ if (ctx.xin->flow->nw_frag & FLOW_NW_FRAG_ANY) {
switch (ctx.ofproto->up.frag_handling) {
case OFPC_FRAG_NORMAL:
/* We must pretend that transport ports are unavailable. */
- ctx.xin->flow.tp_src = ctx.base_flow.tp_src = htons(0);
- ctx.xin->flow.tp_dst = ctx.base_flow.tp_dst = htons(0);
+ ctx.xin->flow->tp_src = ctx.base_flow.tp_src = htons(0);
+ ctx.xin->flow->tp_dst = ctx.base_flow.tp_dst = htons(0);
break;
case OFPC_FRAG_DROP:
@@ -7005,8 +7009,8 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
}
}
- in_port = get_ofp_port(ctx.ofproto, ctx.xin->flow.in_port);
- special = process_special(ctx.ofproto, &ctx.xin->flow, in_port,
+ in_port = get_ofp_port(ctx.ofproto, ctx.xin->flow->in_port);
+ special = process_special(ctx.ofproto, ctx.xin->flow, in_port,
ctx.xin->packet);
if (special) {
ctx.xout->slow = special;
@@ -7023,7 +7027,7 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
sample_actions_len = ctx.xout->odp_actions.size;
if (tunnel_ecn_ok(&ctx)
- && (!in_port || may_receive(in_port, &ctx.xin->flow))) {
+ && (!in_port || may_receive(in_port, ctx.xin->flow))) {
do_xlate_actions(ofpacts, ofpacts_len, &ctx);
@@ -7051,7 +7055,7 @@ xlate_actions(struct xlate_in *xin, struct xlate_out *xout)
}
local_odp_port = ofp_port_to_odp_port(ctx.ofproto, OFPP_LOCAL);
- if (!connmgr_must_output_local(ctx.ofproto->up.connmgr, &ctx.xin->flow,
+ if (!connmgr_must_output_local(ctx.ofproto->up.connmgr, ctx.xin->flow,
local_odp_port,
ctx.xout->odp_actions.data,
ctx.xout->odp_actions.size)) {
@@ -7202,7 +7206,7 @@ static void
output_normal(struct xlate_ctx *ctx, const struct ofbundle *out_bundle,
uint16_t vlan)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
struct ofport_dpif *port;
uint16_t vid;
ovs_be16 tci, old_tci;
@@ -7325,7 +7329,7 @@ add_mirror_actions(struct xlate_ctx *ctx, const struct flow *orig_flow)
}
/* Restore the original packet before adding the mirror actions. */
- ctx->xin->flow = *orig_flow;
+ *ctx->xin->flow = *orig_flow;
while (mirrors) {
struct ofmirror *m;
@@ -7499,7 +7503,7 @@ static bool
is_admissible(struct xlate_ctx *ctx, struct ofport_dpif *in_port,
uint16_t vlan)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
struct ofproto_dpif *ofproto = ctx->ofproto;
struct ofbundle *in_bundle = in_port->bundle;
@@ -7542,7 +7546,7 @@ is_admissible(struct xlate_ctx *ctx, struct ofport_dpif *in_port,
static void
xlate_normal(struct xlate_ctx *ctx)
{
- struct flow *flow = &ctx->xin->flow;
+ struct flow *flow = ctx->xin->flow;
struct ofport_dpif *in_port;
struct ofbundle *in_bundle;
@@ -7949,11 +7953,11 @@ trace_format_flow(struct ds *result, int level, const char *title,
{
ds_put_char_multiple(result, '\t', level);
ds_put_format(result, "%s: ", title);
- if (flow_equal(&trace->xin.flow, &trace->flow)) {
+ if (flow_equal(trace->xin.flow, &trace->flow)) {
ds_put_cstr(result, "unchanged");
} else {
- flow_format(result, &trace->xin.flow);
- trace->flow = trace->xin.flow;
+ flow_format(result, trace->xin.flow);
+ trace->flow = *trace->xin.flow;
}
ds_put_char(result, '\n');
}
--
1.7.10.4
More information about the dev
mailing list