diff options
author | Justin Pettit <jpettit@ovn.org> | 2017-07-07 16:04:57 -0700 |
---|---|---|
committer | Justin Pettit <jpettit@ovn.org> | 2017-07-27 19:20:16 -0700 |
commit | 6cb5e507973f30e8ca14b4bb518173a9ef51acfa (patch) | |
tree | a3ddd3358119fc273a820bf2359223b1121e8a55 | |
parent | fe70f381c18e2abefc71bc59d6fad3c7386d69d9 (diff) | |
download | openvswitch-6cb5e507973f30e8ca14b4bb518173a9ef51acfa.tar.gz |
ofproto-dpif-rid: Store tunnel metadata in frozen metadata directly.
"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.
This makes the code a bit simpler and easier to reason about.
Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
-rw-r--r-- | ofproto/ofproto-dpif-rid.c | 29 | ||||
-rw-r--r-- | ofproto/ofproto-dpif-rid.h | 13 |
2 files changed, 19 insertions, 23 deletions
diff --git a/ofproto/ofproto-dpif-rid.c b/ofproto/ofproto-dpif-rid.c index d546b150b..5355a83a0 100644 --- a/ofproto/ofproto-dpif-rid.c +++ b/ofproto/ofproto-dpif-rid.c @@ -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, @@ -158,7 +158,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 @@ -201,12 +201,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) @@ -239,8 +237,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 (;;) { @@ -291,13 +288,15 @@ 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), + .ipv6_dst = in6addr_any, + }, + .in_port = OFPP_NONE }, }; return recirc_alloc_id__(&state, frozen_state_hash(&state))->id; } diff --git a/ofproto/ofproto-dpif-rid.h b/ofproto/ofproto-dpif-rid.h index c6743a133..e0ea7064c 100644 --- a/ofproto/ofproto-dpif-rid.h +++ b/ofproto/ofproto-dpif-rid.h @@ -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 |