From patchwork Sun Jul 3 15:35:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Moats X-Patchwork-Id: 643757 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3rjDlW4XXNz9s9n for ; Mon, 4 Jul 2016 01:36:39 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id DEF2510B3A; Sun, 3 Jul 2016 08:36:38 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 8D4A110B3A for ; Sun, 3 Jul 2016 08:36:37 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 2218216310E for ; Sun, 3 Jul 2016 09:36:37 -0600 (MDT) X-ASG-Debug-ID: 1467560196-0b32373f7c1f22c0001-byXFYA Received: from mx1-pf1.cudamail.com ([192.168.24.1]) by bar6.cudamail.com with ESMTP id 2AKWFpbLraEl2R0o (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 03 Jul 2016 09:36:36 -0600 (MDT) X-Barracuda-Envelope-From: rmoats@oc7146733065.ibm.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.24.1 Received: from unknown (HELO fed1rmfepo203.cox.net) (68.230.241.148) by mx1-pf1.cudamail.com with SMTP; 3 Jul 2016 15:36:35 -0000 Received-SPF: none (mx1-pf1.cudamail.com: domain at oc7146733065.ibm.com does not designate permitted sender hosts) X-Barracuda-Apparent-Source-IP: 68.230.241.148 X-Barracuda-RBL-IP: 68.230.241.148 Received: from fed1rmimpo306.cox.net ([68.230.241.174]) by fed1rmfepo203.cox.net (InterMail vM.8.01.05.28 201-2260-151-171-20160122) with ESMTP id <20160703153635.PWTR1833.fed1rmfepo203.cox.net@fed1rmimpo306.cox.net> for ; Sun, 3 Jul 2016 11:36:35 -0400 Received: from oc7146733065.ibm.com ([68.13.99.247]) by fed1rmimpo306.cox.net with cox id EFca1t00A5LF6cs01FcaFv; Sun, 03 Jul 2016 11:36:35 -0400 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020203.57793103.0054, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=2.1 cv=R4+jYYlX c=1 sm=1 tr=0 a=Jmqd6mthTashISSy/JkQqg==:117 a=Jmqd6mthTashISSy/JkQqg==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=cAmyUtKerLwA:10 a=VnNF1IyMAAAA:8 a=BWEc22ksZOGHdfBBK60A:9 a=skCgnbhlp52w9zbo2JeP:22 X-CM-Score: 0.00 Authentication-Results: cox.net; none Received: by oc7146733065.ibm.com (Postfix, from userid 500) id 020A81880388; Sun, 3 Jul 2016 10:36:33 -0500 (CDT) X-CudaMail-Envelope-Sender: rmoats@oc7146733065.ibm.com From: Ryan Moats To: dev@openvswitch.org X-CudaMail-MID: CM-E1-702010217 X-CudaMail-DTE: 070316 X-CudaMail-Originating-IP: 68.230.241.148 Date: Sun, 3 Jul 2016 10:35:28 -0500 X-ASG-Orig-Subj: [##CM-E1-702010217##][PATCH v21 3/8] Change tracking structures to use struct uuids Message-Id: <1467560133-5700-4-git-send-email-rmoats@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1467560133-5700-1-git-send-email-rmoats@us.ibm.com> References: <1467560133-5700-1-git-send-email-rmoats@us.ibm.com> X-Barracuda-Connect: UNKNOWN[192.168.24.1] X-Barracuda-Start-Time: 1467560196 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 1.10 X-Barracuda-Spam-Status: No, SCORE=1.10 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_RULE7568M, BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.30979 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH v21 3/8] Change tracking structures to use struct uuids X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" In encaps.c, binding.c, and lport.c incremental processing is aided by tracking entries by their ovsdb row uuids. The original patch sets used pointers, which might lead to errors if the ovsdb row uuid memory is released. So, use actual structures to hold the values instead. Signed-off-by: Ryan Moats --- ovn/controller/binding.c | 10 +++++----- ovn/controller/encaps.c | 21 ++++++++++++--------- ovn/controller/lport.c | 12 ++++++------ ovn/controller/ovn-controller.h | 2 +- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c index 8b439a6..e10c1f0 100644 --- a/ovn/controller/binding.c +++ b/ovn/controller/binding.c @@ -118,7 +118,7 @@ local_datapath_lookup_by_uuid(struct hmap *hmap_p, const struct uuid *uuid) { struct local_datapath *ld; HMAP_FOR_EACH_WITH_HASH(ld, uuid_hmap_node, uuid_hash(uuid), hmap_p) { - if (uuid_equals(ld->uuid, uuid)) { + if (uuid_equals(&ld->uuid, uuid)) { return ld; } } @@ -169,7 +169,7 @@ add_local_datapath(struct hmap *local_datapaths, struct local_datapath *ld = xzalloc(sizeof *ld); ld->logical_port = xstrdup(binding_rec->logical_port); - ld->uuid = &binding_rec->header_.uuid; + memcpy(&ld->uuid, &binding_rec->header_.uuid, sizeof ld->uuid); hmap_insert(local_datapaths, &ld->hmap_node, binding_rec->datapath->tunnel_key); hmap_insert(&local_datapaths_by_uuid, &ld->uuid_hmap_node, @@ -285,14 +285,14 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, consider_local_datapath(ctx, &lports, chassis_rec, binding_rec, local_datapaths); struct local_datapath *ld = xzalloc(sizeof *ld); - ld->uuid = &binding_rec->header_.uuid; + memcpy(&ld->uuid, &binding_rec->header_.uuid, sizeof ld->uuid); hmap_insert(&keep_local_datapath_by_uuid, &ld->uuid_hmap_node, - uuid_hash(ld->uuid)); + uuid_hash(&ld->uuid)); } struct local_datapath *old_ld, *next; HMAP_FOR_EACH_SAFE (old_ld, next, hmap_node, local_datapaths) { if (!local_datapath_lookup_by_uuid(&keep_local_datapath_by_uuid, - old_ld->uuid)) { + &old_ld->uuid)) { remove_local_datapath(local_datapaths, old_ld); } } diff --git a/ovn/controller/encaps.c b/ovn/controller/encaps.c index 18268a6..6cf60ff 100644 --- a/ovn/controller/encaps.c +++ b/ovn/controller/encaps.c @@ -74,7 +74,7 @@ static bool process_full_encaps = false; struct port_hash_node { struct hmap_node node; struct hmap_node uuid_node; - const struct uuid *uuid; + struct uuid uuid; const struct ovsrec_port *port; const struct ovsrec_bridge *bridge; }; @@ -131,7 +131,7 @@ port_lookup_by_uuid(struct hmap *hmap_p, const struct uuid *uuid) struct port_hash_node *answer; HMAP_FOR_EACH_WITH_HASH (answer, uuid_node, uuid_hash(uuid), hmap_p) { - if (uuid_equals(uuid, answer->uuid)) { + if (uuid_equals(uuid, &answer->uuid)) { return answer; } } @@ -186,11 +186,12 @@ tunnel_add(const struct sbrec_chassis *chassis_rec, && !strcmp(encap->type, iface->type) && !strcmp(encap->ip, ip)) { - hash_node->uuid = &chassis_rec->header_.uuid; + memcpy(&hash_node->uuid, &chassis_rec->header_.uuid, + sizeof hash_node->uuid); if (!port_lookup_by_uuid(&tc.tunnel_hmap_by_uuid, - hash_node->uuid)) { + &hash_node->uuid)) { hmap_insert(&tc.tunnel_hmap_by_uuid, &hash_node->uuid_node, - uuid_hash(hash_node->uuid)); + uuid_hash(&hash_node->uuid)); } return; } @@ -380,17 +381,19 @@ encaps_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int, SBREC_CHASSIS_FOR_EACH (chassis_rec, ctx->ovnsb_idl) { check_and_add_tunnel(chassis_rec, chassis_id); struct port_hash_node *hash_node = xzalloc(sizeof *hash_node); - hash_node->uuid = &chassis_rec->header_.uuid; + memcpy(&hash_node->uuid, &chassis_rec->header_.uuid, + sizeof hash_node->uuid); hmap_insert(&keep_tunnel_hmap_by_uuid, &hash_node->uuid_node, - uuid_hash(hash_node->uuid)); + uuid_hash(&hash_node->uuid)); } /* Delete any tunnels that weren't recreated above. */ struct port_hash_node *old_hash_node, *next_hash_node; HMAP_FOR_EACH_SAFE (old_hash_node, next_hash_node, node, &tc.tunnel_hmap) { - if (!port_lookup_by_uuid(&keep_tunnel_hmap_by_uuid, - old_hash_node->uuid)) { + if (!uuid_is_zero(&old_hash_node->uuid) + && !port_lookup_by_uuid(&keep_tunnel_hmap_by_uuid, + &old_hash_node->uuid)) { bridge_delete_port(old_hash_node->bridge, old_hash_node->port); sset_find_and_delete(&tc.port_names, old_hash_node->port->name); diff --git a/ovn/controller/lport.c b/ovn/controller/lport.c index a5e9ad3..080b27f 100644 --- a/ovn/controller/lport.c +++ b/ovn/controller/lport.c @@ -28,7 +28,7 @@ struct lport { struct hmap_node name_node; /* Index by name. */ struct hmap_node key_node; /* Index by (dp_key, port_key). */ struct hmap_node uuid_node; /* Index by row uuid. */ - const struct uuid *uuid; + struct uuid uuid; const struct sbrec_port_binding *pb; }; @@ -91,7 +91,7 @@ consider_lport_index(struct lport_index *lports, hash_int(pb->tunnel_key, pb->datapath->tunnel_key)); hmap_insert(&lports->by_uuid, &p->uuid_node, uuid_hash(&pb->header_.uuid)); - p->uuid = &pb->header_.uuid; + memcpy(&p->uuid, &pb->header_.uuid, sizeof p->uuid); p->pb = pb; } @@ -148,7 +148,7 @@ lport_lookup_by_uuid(const struct lport_index *lports, const struct lport *lport; HMAP_FOR_EACH_WITH_HASH (lport, uuid_node, uuid_hash(uuid), &lports->by_uuid) { - if (uuid_equals(uuid, lport->uuid)) { + if (uuid_equals(uuid, &lport->uuid)) { return lport; } } @@ -173,7 +173,7 @@ lport_lookup_by_key(const struct lport_index *lports, struct mcgroup { struct hmap_node dp_name_node; /* Index by (logical datapath, name). */ struct hmap_node uuid_node; /* Index by insert uuid. */ - const struct uuid *uuid; + struct uuid uuid; const struct sbrec_multicast_group *mg; }; @@ -229,7 +229,7 @@ consider_mcgroup_index(struct mcgroup_index *mcgroups, hash_string(mg->name, uuid_hash(dp_uuid))); hmap_insert(&mcgroups->by_uuid, &m->uuid_node, uuid_hash(&mg->header_.uuid)); - m->uuid = &mg->header_.uuid; + memcpy(&m->uuid, &mg->header_.uuid, sizeof m->uuid); m->mg = mg; } @@ -269,7 +269,7 @@ mcgroup_lookup_by_uuid(const struct mcgroup_index *mcgroups, const struct mcgroup *mcgroup; HMAP_FOR_EACH_WITH_HASH (mcgroup, uuid_node, uuid_hash(uuid), &mcgroups->by_uuid) { - if (uuid_equals(mcgroup->uuid, uuid)) { + if (uuid_equals(&mcgroup->uuid, uuid)) { return mcgroup; } } diff --git a/ovn/controller/ovn-controller.h b/ovn/controller/ovn-controller.h index f0c4e63..6a021a0 100644 --- a/ovn/controller/ovn-controller.h +++ b/ovn/controller/ovn-controller.h @@ -39,7 +39,7 @@ struct controller_ctx { struct local_datapath { struct hmap_node hmap_node; struct hmap_node uuid_hmap_node; - const struct uuid *uuid; + struct uuid uuid; char *logical_port; const struct sbrec_port_binding *localnet_port; };