Message ID | 1564097054-72663-2-git-send-email-yihung.wei@gmail.com |
---|---|
State | Changes Requested |
Headers | show |
Series | Support zone-based conntrack timeout policy | expand |
On Thu, Jul 25, 2019 at 04:24:03PM -0700, Yi-Hung Wei wrote: > From: Ben Pfaff <blp@ovn.org> > > Signed-off-by: Ben Pfaff <blp@ovn.org> > --- LGTM Acked-by: William Tu <u9012063@gmail.com> > 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 > } > -- > 2.7.4 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
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 }