@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, 2016 Nicira, Inc.
+ * Copyright (c) 2014, 2015, 2016, 2017 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -127,11 +127,11 @@ frozen_state_hash(const struct frozen_state *state)
hash = uuid_hash(&state->ofproto_uuid);
hash = hash_int(state->table_id, hash);
- if (flow_tnl_dst_is_set(state->metadata.tunnel)) {
+ if (flow_tnl_dst_is_set(&state->metadata.tunnel)) {
/* We may leave remainder bytes unhashed, but that is unlikely as
* the tunnel is not in the datapath format. */
- hash = hash_bytes64((const uint64_t *) state->metadata.tunnel,
- flow_tnl_size(state->metadata.tunnel), hash);
+ hash = hash_bytes64((const uint64_t *) &state->metadata.tunnel,
+ flow_tnl_size(&state->metadata.tunnel), hash);
}
hash = hash_boolean(state->conntracked, hash);
hash = hash_bytes64((const uint64_t *) &state->metadata.metadata,
@@ -159,7 +159,7 @@ frozen_state_equal(const struct frozen_state *a, const struct frozen_state *b)
{
return (a->table_id == b->table_id
&& uuid_equals(&a->ofproto_uuid, &b->ofproto_uuid)
- && flow_tnl_equal(a->metadata.tunnel, b->metadata.tunnel)
+ && flow_tnl_equal(&a->metadata.tunnel, &b->metadata.tunnel)
&& !memcmp(&a->metadata.metadata, &b->metadata.metadata,
sizeof a->metadata - sizeof a->metadata.tunnel)
&& a->stack_size == b->stack_size
@@ -202,12 +202,10 @@ recirc_ref_equal(const struct frozen_state *target, uint32_t hash)
}
static void
-frozen_state_clone(struct frozen_state *new, const struct frozen_state *old,
- struct flow_tnl *tunnel)
+frozen_state_clone(struct frozen_state *new, const struct frozen_state *old)
{
*new = *old;
- flow_tnl_copy__(tunnel, old->metadata.tunnel);
- new->metadata.tunnel = tunnel;
+ flow_tnl_copy__(&new->metadata.tunnel, &old->metadata.tunnel);
new->stack = (new->stack_size
? xmemdup(new->stack, new->stack_size)
@@ -240,8 +238,7 @@ recirc_alloc_id__(const struct frozen_state *state, uint32_t hash)
node->hash = hash;
ovs_refcount_init(&node->refcount);
- frozen_state_clone(CONST_CAST(struct frozen_state *, &node->state), state,
- &node->state_metadata_tunnel);
+ frozen_state_clone(CONST_CAST(struct frozen_state *, &node->state), state);
ovs_mutex_lock(&mutex);
for (;;) {
@@ -292,13 +289,12 @@ recirc_alloc_id_ctx(const struct frozen_state *state)
uint32_t
recirc_alloc_id(struct ofproto_dpif *ofproto)
{
- struct flow_tnl tunnel;
- tunnel.ip_dst = htonl(0);
- tunnel.ipv6_dst = in6addr_any;
struct frozen_state state = {
.table_id = TBL_INTERNAL,
.ofproto_uuid = ofproto->uuid,
- .metadata = { .tunnel = &tunnel, .in_port = OFPP_NONE },
+ .metadata = { .tunnel.ip_dst = htonl(0),
+ .tunnel.ipv6_dst = in6addr_any,
+ .in_port = OFPP_NONE },
};
return recirc_alloc_id__(&state, frozen_state_hash(&state))->id;
}
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, 2016 Nicira, Inc.
+ * Copyright (c) 2014, 2015, 2016, 2017 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -103,7 +103,7 @@ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 39);
struct frozen_metadata {
/* Metadata in struct flow. */
- const struct flow_tnl *tunnel; /* Encapsulating tunnel parameters. */
+ struct flow_tnl tunnel; /* Encapsulating tunnel parameters. */
ovs_be64 metadata; /* OpenFlow Metadata. */
uint64_t regs[FLOW_N_XREGS]; /* Registers. */
ofp_port_t in_port; /* Incoming port. */
@@ -114,7 +114,7 @@ frozen_metadata_from_flow(struct frozen_metadata *md,
const struct flow *flow)
{
memset(md, 0, sizeof *md);
- md->tunnel = &flow->tunnel;
+ md->tunnel = flow->tunnel;
md->metadata = flow->metadata;
memcpy(md->regs, flow->regs, sizeof md->regs);
md->in_port = flow->in_port.ofp_port;
@@ -124,8 +124,8 @@ static inline void
frozen_metadata_to_flow(const struct frozen_metadata *md,
struct flow *flow)
{
- if (md->tunnel && flow_tnl_dst_is_set(md->tunnel)) {
- flow->tunnel = *md->tunnel;
+ if (flow_tnl_dst_is_set(&md->tunnel)) {
+ flow->tunnel = md->tunnel;
} else {
memset(&flow->tunnel, 0, sizeof flow->tunnel);
}
@@ -171,9 +171,6 @@ struct recirc_id_node {
* This state should not be modified after inserting a node in the pool,
* hence the 'const' to emphasize that. */
const struct frozen_state state;
-
- /* Storage for tunnel metadata. */
- struct flow_tnl state_metadata_tunnel;
};
/* This is only used for bonds and will go away when bonds implementation is
"recirc_id_node" contains a 'state_metadata_tunnel' member field. The "frozen_metadata" structure used by "recird_id_node" had a 'tunnel' member that always pointed to 'state_metadata_tunnel". This commit just stores the tunnel information directly in "frozen_metadata" instead of accessing it through a pointer. Signed-off-by: Justin Pettit <jpettit@ovn.org> --- ofproto/ofproto-dpif-rid.c | 26 +++++++++++--------------- ofproto/ofproto-dpif-rid.h | 13 +++++-------- 2 files changed, 16 insertions(+), 23 deletions(-)