]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix missing return value checks in multi_process_float()
authorSteffan Karger <steffan@karger.me>
Tue, 8 Nov 2016 20:07:43 +0000 (21:07 +0100)
committerDavid Sommerseth <davids@openvpn.net>
Wed, 16 Nov 2016 10:39:38 +0000 (11:39 +0100)
Fix the missing return value checks on hash_remove() and hash_add() by
replacing the calls with an single hash_add() call with the replace
parameters set to true so that is can't fail.  Then just ASSERT() that
this is indeed the case.

This also replaces the other add/remove combinations with a single
add-replace, because that should be slightly faster (and this is in the
'hot path').

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1478635663-5837-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12968.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
src/openvpn/multi.c

index b497f6ad6d86aa52542ac1d92216a781e0652c75..8f3d34e160ba7f2ad886de61b94a9b49cfbeec8d 100644 (file)
@@ -2317,9 +2317,6 @@ void multi_process_float (struct multi_context* m, struct multi_instance* mi)
        mroute_addr_print (&mi->real, &gc),
        print_link_socket_actual (&m->top.c2.from, &gc));
 
-    ASSERT (hash_remove(m->hash, &mi->real));
-    ASSERT (hash_remove(m->iter, &mi->real));
-
     /* change external network address of the remote peer */
     mi->real = real;
     generate_prefix (mi);
@@ -2333,12 +2330,11 @@ void multi_process_float (struct multi_context* m, struct multi_instance* mi)
 
     tls_update_remote_addr (mi->context.c2.tls_multi, &mi->context.c2.from);
 
-    ASSERT (hash_add (m->hash, &mi->real, mi, false));
-    ASSERT (hash_add (m->iter, &mi->real, mi, false));
+    ASSERT (hash_add (m->hash, &mi->real, mi, true));
+    ASSERT (hash_add (m->iter, &mi->real, mi, true));
 
 #ifdef MANAGEMENT_DEF_AUTH
-    hash_remove (m->cid_hash, &mi->context.c2.mda_context.cid);
-    hash_add (m->cid_hash, &mi->context.c2.mda_context.cid, mi, false);
+    ASSERT (hash_add (m->cid_hash, &mi->context.c2.mda_context.cid, mi, true));
 #endif
 
 done: