From patchwork Wed May 8 13:41:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1097038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 44zd1h0BT2z9s5c for ; Wed, 8 May 2019 23:41:59 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id DA6F723CF; Wed, 8 May 2019 13:41:56 +0000 (UTC) X-Original-To: ovs-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 9FC17156A for ; Wed, 8 May 2019 13:41:55 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 12D79875 for ; Wed, 8 May 2019 13:41:55 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id e11so14229799wrs.0 for ; Wed, 08 May 2019 06:41:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wB3BCFAH9w01Xrqzwjl9mmDdlJeZWIFyy0ve/RC06ns=; b=oYOwzJeCSm4hY0AB6B0WYtO5fqhDjxgrmhygdq592+0NzVsBJtA1WIEiansmZfTWJv FBxj4vvDHlEQmYuARhC/XyjrfijgvsVsqDMtnXyrgcYXQIHkK0w0Nrh2b9CrgEwcpCWO 8Ibfpo/KOUEK4szVPtcvjpHJf+GXX+OfACnfyzp2FDVegsNYqSjp8R03ApyxKna3YmyF 1q2t8NKGKGxNp5rMyvTP/yqpavO0MGShMGLJbcR0dowkKivQwCW3RKUmxp6DZO9j5nhs 87VdOsDB1MGPoRJXoDRzvKOw0seAFsXb2BvWxyRmWqGLVJeoJd2ofRDXcvvEu5VtGUIH sLGA== X-Gm-Message-State: APjAAAW4KR9WxIFkqCCEdAmvhLCqYt6jZS8PvUFEttL9S7f9OYxua6g3 AMvKZGcJXwJWFKYKllTqaN5abmvLI2o= X-Google-Smtp-Source: APXvYqzJyz3TEV908kolKhKYFR5F2NTI6MkenUx8boZr85SDjvDR21o75Spo64+FSguz6M4g4G9M3Q== X-Received: by 2002:a5d:49c1:: with SMTP id t1mr5854775wrs.247.1557322913449; Wed, 08 May 2019 06:41:53 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id j4sm9229202wrw.94.2019.05.08.06.41.52 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 08 May 2019 06:41:52 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Wed, 8 May 2019 15:41:48 +0200 Message-Id: <778fc1f394011f5f8c9c51903c7f9d5bff8cc6c2.1557320940.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE 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] OVN: convert buffered_mac_bindings to ovs_list 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Convert buffered_mac_bindings from hashmap to a linked list since it is used just for iteration (no lookups are performed on it) Signed-off-by: Lorenzo Bianconi --- ovn/controller/pinctrl.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c index 4f1991d29..8ae1f9bd6 100644 --- a/ovn/controller/pinctrl.c +++ b/ovn/controller/pinctrl.c @@ -321,6 +321,7 @@ struct buffer_info { #define BUFFER_QUEUE_DEPTH 4 struct buffered_packets { struct hmap_node hmap_node; + struct ovs_list list; /* key */ struct in6_addr ip; @@ -333,17 +334,17 @@ struct buffered_packets { }; static struct hmap buffered_packets_map; -static struct hmap buffered_mac_bindings; +static struct ovs_list buffered_mac_bindings; static void init_buffered_packets_map(void) { hmap_init(&buffered_packets_map); - hmap_init(&buffered_mac_bindings); + ovs_list_init(&buffered_mac_bindings); } static void -destroy_buffered_packets(struct buffered_packets *bp, struct hmap *map) +destroy_buffered_packets(struct buffered_packets *bp) { struct buffer_info *bi; @@ -354,8 +355,6 @@ destroy_buffered_packets(struct buffered_packets *bp, struct hmap *map) bp->head = (bp->head + 1) % BUFFER_QUEUE_DEPTH; } - hmap_remove(map, &bp->hmap_node); - free(bp); } static void @@ -363,14 +362,16 @@ destroy_buffered_packets_map(void) { struct buffered_packets *bp, *next; HMAP_FOR_EACH_SAFE (bp, next, hmap_node, &buffered_packets_map) { - destroy_buffered_packets(bp, &buffered_packets_map); + destroy_buffered_packets(bp); + hmap_remove(&buffered_packets_map, &bp->hmap_node); + free(bp); } hmap_destroy(&buffered_packets_map); - HMAP_FOR_EACH_SAFE (bp, next, hmap_node, &buffered_mac_bindings) { - destroy_buffered_packets(bp, &buffered_mac_bindings); + LIST_FOR_EACH_POP (bp, list, &buffered_mac_bindings) { + destroy_buffered_packets(bp); + free(bp); } - hmap_destroy(&buffered_mac_bindings); } static void @@ -437,7 +438,9 @@ buffered_packets_map_gc(void) HMAP_FOR_EACH_SAFE (cur_qp, next_qp, hmap_node, &buffered_packets_map) { if (now > cur_qp->timestamp + BUFFER_MAP_TIMEOUT) { - destroy_buffered_packets(cur_qp, &buffered_packets_map); + destroy_buffered_packets(cur_qp); + hmap_remove(&buffered_packets_map, &cur_qp->hmap_node); + free(cur_qp); } } } @@ -2372,10 +2375,11 @@ send_mac_binding_buffered_pkts(struct rconn *swconn) OVS_REQUIRES(pinctrl_mutex) { struct buffered_packets *bp; - HMAP_FOR_EACH_POP (bp, hmap_node, &buffered_mac_bindings) { + LIST_FOR_EACH_POP (bp, list, &buffered_mac_bindings) { buffered_send_packets(swconn, bp, &bp->ea); free(bp); } + ovs_list_init(&buffered_mac_bindings); } static const struct sbrec_mac_binding * @@ -2493,11 +2497,8 @@ run_buffered_binding(struct ovsdb_idl_index *sbrec_port_binding_by_datapath, ds_cstr(&ip_s)); if (b && ovs_scan(b->mac, ETH_ADDR_SCAN_FMT, ETH_ADDR_SCAN_ARGS(cur_qp->ea))) { - uint32_t hash = hash_bytes(&cur_qp->ip, - sizeof cur_qp->ip, 0); hmap_remove(&buffered_packets_map, &cur_qp->hmap_node); - hmap_insert(&buffered_mac_bindings, &cur_qp->hmap_node, - hash); + ovs_list_push_back(&buffered_mac_bindings, &cur_qp->list); notify = true; } ds_destroy(&ip_s); @@ -3050,7 +3051,7 @@ may_inject_pkts(void) { return (!shash_is_empty(&ipv6_ras) || !shash_is_empty(&send_garp_data) || - !hmap_is_empty(&buffered_mac_bindings)); + !ovs_list_is_empty(&buffered_mac_bindings)); } static void