From patchwork Fri Jul 14 06:30:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Pettit X-Patchwork-Id: 788135 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x82rz1bmZz9s7m for ; Fri, 14 Jul 2017 16:31:31 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 1F510CCB; Fri, 14 Jul 2017 06:30:58 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 82B257A9 for ; Fri, 14 Jul 2017 06:30:56 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id E642E17C for ; Fri, 14 Jul 2017 06:30:55 +0000 (UTC) X-Originating-IP: 98.234.50.139 Received: from localhost.localdomain (unknown [98.234.50.139]) (Authenticated sender: jpettit@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 508C9C5A4E for ; Fri, 14 Jul 2017 08:30:54 +0200 (CEST) From: Justin Pettit To: dev@openvswitch.org Date: Thu, 13 Jul 2017 23:30:50 -0700 Message-Id: <1500013851-89181-2-git-send-email-jpettit@ovn.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500013851-89181-1-git-send-email-jpettit@ovn.org> References: <1500013851-89181-1-git-send-email-jpettit@ovn.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 2/3] ofproto-dpif-rid: Store tunnel metadata in frozen metadata directly. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org "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 Acked-by: Ben Pfaff --- ofproto/ofproto-dpif-rid.c | 26 +++++++++++--------------- ofproto/ofproto-dpif-rid.h | 13 +++++-------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/ofproto/ofproto-dpif-rid.c b/ofproto/ofproto-dpif-rid.c index 26c2357007b2..10aabe5cab15 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, @@ -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; } diff --git a/ofproto/ofproto-dpif-rid.h b/ofproto/ofproto-dpif-rid.h index c6743a133ed5..e0ea7064c406 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