From patchwork Thu Jul 25 23:24:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi-Hung Wei X-Patchwork-Id: 1137159 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=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WzGUxwYj"; dkim-atps=neutral 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 45vpGQ23czz9s4Y for ; Fri, 26 Jul 2019 09:25:02 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 795C0C6F; Thu, 25 Jul 2019 23:24:30 +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 321278D7 for ; Thu, 25 Jul 2019 23:24:28 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CF6F6B0 for ; Thu, 25 Jul 2019 23:24:27 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id i18so23781516pgl.11 for ; Thu, 25 Jul 2019 16:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=/ZeV+Wut2btzSdkAuaK8sgNT43pYVbic9Z6fDLqSTlE=; b=WzGUxwYjpp1AdnVbWP5/JRfOu1Q8jSArbqh5V9Rd00RvziENJrAC+nCR1+/BrhgkcT YX6A9zIl7kDw/AsMoy5epRC7gvC8v811iEAd5veyE3INHr5Q3J2KoHT4r/ThixnQS+7w +1tOi2CelifTA0gBosADvnGrz5WxRjLtu7OQ31e9fnjMGVbMBUeu49aO8yyjSPq9hgvK dX/ZOBAIDeEF2wDMZUj3jIwPPqDSkOOj127kF+ZQJSoURoqVFompJt3KEGoybz+PVBsy W8Z8rf4Ljz2kLbAfUqVv10x/4J0D63JmcBp1Vt/2DY8tLoKohF+NaNF25s6lnXzx1XfJ 9ggQ== 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; bh=/ZeV+Wut2btzSdkAuaK8sgNT43pYVbic9Z6fDLqSTlE=; b=Vj9ziYocrzFMWv2U5n5kOb6K0xrWaG9bvcGTB2thejs15dtPbuVa0QALv40NGOuUZo 1EvtZGsBhtx2epZmvC/Iqx7X4JqjcNdAnFs3CQUXsQ6d7Rh6WNDnQZo0TUVU/POhajlG wwJjxHnZpfz62GAsa+eEyaFcMuV7gc7Dn81sRgAucinaRWyJQPGgZ9+gLD+mjxwyiFzR JuoMhxDOCo1RQwLC8XrOdkqpw1PO5L/LZ3T/jddHI8qp+tQm90qMwsr4kA8F/N9w6G2j rDjYs+WGopgfqQQURfsBZVg7G5OZiLI/AS0dv94BqXtUAvB0X8ELmbsXChYUi6RodToI nLVA== X-Gm-Message-State: APjAAAW6bHF6IoPrnNAjnRnxOdHMmdETa9XE/PiFJtP+pA9uIz3q11J/ QFdLQH0+JMxoiQWJyHplttdwCBpx X-Google-Smtp-Source: APXvYqyJdsOmyOBxwLJa1v/+LX55eEumjTV3Z0YZkJotjx+Jf914f1r9xuXNiwaXCTD+Fq6ZUh/BHw== X-Received: by 2002:aa7:81ca:: with SMTP id c10mr19281098pfn.185.1564097066991; Thu, 25 Jul 2019 16:24:26 -0700 (PDT) Received: from vm-main.eng.vmware.com ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id x9sm28189940pgp.75.2019.07.25.16.24.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Jul 2019 16:24:25 -0700 (PDT) From: Yi-Hung Wei To: dev@openvswitch.org, blp@ovn.org Date: Thu, 25 Jul 2019 16:24:03 -0700 Message-Id: <1564097054-72663-2-git-send-email-yihung.wei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564097054-72663-1-git-send-email-yihung.wei@gmail.com> References: <1564097054-72663-1-git-send-email-yihung.wei@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 01/12] simap: Add utility function to help compare two simaps. 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 From: Ben Pfaff Signed-off-by: Ben Pfaff Acked-by: William Tu --- lib/simap.c | 15 ++++++++++++++- lib/simap.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/simap.c b/lib/simap.c index d634f8ed9eea..f404ece67703 100644 --- a/lib/simap.c +++ b/lib/simap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011, 2012, 2017 Nicira, Inc. + * Copyright (c) 2009, 2010, 2011, 2012, 2017, 2019 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -242,6 +242,19 @@ simap_equal(const struct simap *a, const struct simap *b) return true; } +uint32_t +simap_hash(const struct simap *simap) +{ + uint32_t hash = 0; + + const struct simap_node *node; + SIMAP_FOR_EACH (node, simap) { + hash ^= hash_int(node->data, + hash_name(node->name, strlen(node->name))); + } + return hash; +} + static size_t hash_name(const char *name, size_t length) { diff --git a/lib/simap.h b/lib/simap.h index 5b4a2f39dca3..5e646e660782 100644 --- a/lib/simap.h +++ b/lib/simap.h @@ -70,6 +70,7 @@ bool simap_find_and_delete(struct simap *, const char *); const struct simap_node **simap_sort(const struct simap *); bool simap_equal(const struct simap *, const struct simap *); +uint32_t simap_hash(const struct simap *); #ifdef __cplusplus }