Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1725?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld
Change subject: Extract multi_get_instance_real_udp_real method
......................................................................
Extract multi_get_instance_real_udp_real method
This is just a small refactoring to make the code a little bit
better organised.
Change-Id: I37ade55d7674c68dd98cf4dfde35c4ad42e20d39
Signed-off-by: Arne Schwabe <[email protected]>
---
M src/openvpn/mudp.c
1 file changed, 25 insertions(+), 8 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/25/1725/2
diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c
index a91d11b..e8d8128 100644
--- a/src/openvpn/mudp.c
+++ b/src/openvpn/mudp.c
@@ -198,7 +198,6 @@
handle_connection_attempt(struct multi_context *m,
struct link_socket *sock,
struct mroute_addr *real,
- const uint64_t hv,
struct hash_bucket *bucket)
{
struct hash *hash = m->hash;
@@ -229,6 +228,7 @@
mi = multi_create_instance(m, real, sock);
if (mi)
{
+ const uint64_t hv = hash_value(hash, real);
hash_add_fast(hash, bucket, &mi->real, hv, mi);
mi->did_real_hash = true;
multi_assign_peer_id(m, mi);
@@ -258,6 +258,28 @@
}
/**
+ * Looks up an multi instance by its real address (IP and port)
+ * @param m multi context
+ * @param real Address to look up
+ * @return instance matching the NULL otherwise
+ */
+struct multi_instance *
+multi_get_instance_real_udp_real(struct multi_context *m, struct mroute_addr
*real)
+{
+ struct hash *hash = m->hash;
+ struct hash_element *he;
+ const uint64_t hv = hash_value(hash, real);
+ struct hash_bucket *bucket = hash_bucket(hash, hv);
+ he = hash_lookup_fast(hash, bucket, real, hv);
+ if (he)
+ {
+ return he->value;
+ }
+ return NULL;
+}
+
+
+/**
* Get a client instance based on real address. If
* the instance doesn't exist, create it while
* maintaining real address hash table atomicity.
@@ -273,7 +295,6 @@
if (mroute_extract_openvpn_sockaddr(&real, &m->top.c2.from.dest, true) &&
m->top.c2.buf.len > 0)
{
- struct hash_element *he;
const uint64_t hv = hash_value(hash, &real);
struct hash_bucket *bucket = hash_bucket(hash, hv);
uint8_t *ptr = BPTR(&m->top.c2.buf);
@@ -310,17 +331,13 @@
}
if (!v2 || peer_id_disabled)
{
- he = hash_lookup_fast(hash, bucket, &real, hv);
- if (he)
- {
- mi = (struct multi_instance *)he->value;
- }
+ mi = multi_get_instance_real_udp_real(m, &real);
}
/* we have no existing multi instance for this connection */
if (!mi)
{
- mi = handle_connection_attempt(m, sock, &real, hv, bucket);
+ mi = handle_connection_attempt(m, sock, &real, bucket);
}
#ifdef ENABLE_DEBUG
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1725?usp=email
To unsubscribe, or for help writing mail filters, visit
http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I37ade55d7674c68dd98cf4dfde35c4ad42e20d39
Gerrit-Change-Number: 1725
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel